@kubb/plugin-swr 4.36.1 → 5.0.0-alpha.10

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.
@@ -8,7 +8,7 @@ import { Client } from "@kubb/plugin-client/components";
8
8
  import { getBanner, getFooter } from "@kubb/plugin-oas/utils";
9
9
  import { File } from "@kubb/react-fabric";
10
10
  import { Fragment, jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
11
- import { usePluginManager } from "@kubb/core/hooks";
11
+ import { usePluginDriver } from "@kubb/core/hooks";
12
12
  import { createReactGenerator } from "@kubb/plugin-oas/generators";
13
13
  import { useOas, useOperationManager } from "@kubb/plugin-oas/hooks";
14
14
  import { difference } from "remeda";
@@ -17,7 +17,7 @@ const mutationGenerator = createReactGenerator({
17
17
  name: "swr-mutation",
18
18
  Operation({ config, operation, generator, plugin }) {
19
19
  const { options, options: { output } } = plugin;
20
- const pluginManager = usePluginManager();
20
+ const driver = usePluginDriver();
21
21
  const oas = useOas();
22
22
  const { getSchemas, getName, getFile } = useOperationManager(generator);
23
23
  const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method);
@@ -32,26 +32,26 @@ const mutationGenerator = createReactGenerator({
32
32
  file: getFile(operation, { prefix: "use" })
33
33
  };
34
34
  const type = {
35
- file: getFile(operation, { pluginKey: [pluginTsName] }),
35
+ file: getFile(operation, { pluginName: pluginTsName }),
36
36
  schemas: getSchemas(operation, {
37
- pluginKey: [pluginTsName],
37
+ pluginName: pluginTsName,
38
38
  type: "type"
39
39
  })
40
40
  };
41
41
  const zod = {
42
- file: getFile(operation, { pluginKey: [pluginZodName] }),
42
+ file: getFile(operation, { pluginName: pluginZodName }),
43
43
  schemas: getSchemas(operation, {
44
- pluginKey: [pluginZodName],
44
+ pluginName: pluginZodName,
45
45
  type: "function"
46
46
  })
47
47
  };
48
- const shouldUseClientPlugin = !!pluginManager.getPluginByKey([pluginClientName]) && options.client.clientType !== "class";
48
+ const shouldUseClientPlugin = !!driver.getPluginByName(pluginClientName) && options.client.clientType !== "class";
49
49
  const client = {
50
50
  name: shouldUseClientPlugin ? getName(operation, {
51
51
  type: "function",
52
- pluginKey: [pluginClientName]
52
+ pluginName: pluginClientName
53
53
  }) : getName(operation, { type: "function" }),
54
- file: getFile(operation, { pluginKey: [pluginClientName] })
54
+ file: getFile(operation, { pluginName: pluginClientName })
55
55
  };
56
56
  const mutationKey = {
57
57
  name: getName(operation, {
@@ -71,7 +71,7 @@ const mutationGenerator = createReactGenerator({
71
71
  banner: getBanner({
72
72
  oas,
73
73
  output,
74
- config: pluginManager.config
74
+ config: driver.config
75
75
  }),
76
76
  footer: getFooter({
77
77
  oas,
@@ -202,7 +202,7 @@ const queryGenerator = createReactGenerator({
202
202
  name: "swr-query",
203
203
  Operation({ config, operation, generator, plugin }) {
204
204
  const { options, options: { output } } = plugin;
205
- const pluginManager = usePluginManager();
205
+ const driver = usePluginDriver();
206
206
  const oas = useOas();
207
207
  const { getSchemas, getName, getFile } = useOperationManager(generator);
208
208
  const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
@@ -216,13 +216,13 @@ const queryGenerator = createReactGenerator({
216
216
  typeName: getName(operation, { type: "type" }),
217
217
  file: getFile(operation, { prefix: "use" })
218
218
  };
219
- const shouldUseClientPlugin = !!pluginManager.getPluginByKey([pluginClientName]) && options.client.clientType !== "class";
219
+ const shouldUseClientPlugin = !!driver.getPluginByName(pluginClientName) && options.client.clientType !== "class";
220
220
  const client = {
221
221
  name: shouldUseClientPlugin ? getName(operation, {
222
222
  type: "function",
223
- pluginKey: [pluginClientName]
223
+ pluginName: pluginClientName
224
224
  }) : getName(operation, { type: "function" }),
225
- file: getFile(operation, { pluginKey: [pluginClientName] })
225
+ file: getFile(operation, { pluginName: pluginClientName })
226
226
  };
227
227
  const queryOptions = { name: getName(operation, {
228
228
  type: "function",
@@ -239,16 +239,16 @@ const queryGenerator = createReactGenerator({
239
239
  })
240
240
  };
241
241
  const type = {
242
- file: getFile(operation, { pluginKey: [pluginTsName] }),
242
+ file: getFile(operation, { pluginName: pluginTsName }),
243
243
  schemas: getSchemas(operation, {
244
- pluginKey: [pluginTsName],
244
+ pluginName: pluginTsName,
245
245
  type: "type"
246
246
  })
247
247
  };
248
248
  const zod = {
249
- file: getFile(operation, { pluginKey: [pluginZodName] }),
249
+ file: getFile(operation, { pluginName: pluginZodName }),
250
250
  schemas: getSchemas(operation, {
251
- pluginKey: [pluginZodName],
251
+ pluginName: pluginZodName,
252
252
  type: "function"
253
253
  })
254
254
  };
@@ -260,7 +260,7 @@ const queryGenerator = createReactGenerator({
260
260
  banner: getBanner({
261
261
  oas,
262
262
  output,
263
- config: pluginManager.config
263
+ config: driver.config
264
264
  }),
265
265
  footer: getFooter({
266
266
  oas,
@@ -396,4 +396,4 @@ const queryGenerator = createReactGenerator({
396
396
  //#endregion
397
397
  export { mutationGenerator as n, queryGenerator as t };
398
398
 
399
- //# sourceMappingURL=generators-ClWZJ-YG.js.map
399
+ //# sourceMappingURL=generators-CRSl6u2M.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generators-CRSl6u2M.js","names":[],"sources":["../src/generators/mutationGenerator.tsx","../src/generators/queryGenerator.tsx"],"sourcesContent":["import path from 'node:path'\nimport { usePluginDriver } from '@kubb/core/hooks'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File } from '@kubb/react-fabric'\nimport { difference } from 'remeda'\nimport { Mutation, MutationKey } from '../components'\nimport type { PluginSwr } from '../types'\n\nexport const mutationGenerator = createReactGenerator<PluginSwr>({\n name: 'swr-mutation',\n Operation({ config, operation, generator, plugin }) {\n const {\n options,\n options: { output },\n } = plugin\n const driver = usePluginDriver()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\n\n const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method)\n const isMutation =\n options.mutation !== false &&\n !isQuery &&\n difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method)\n\n const importPath = options.mutation ? options.mutation.importPath : 'swr'\n\n const mutation = {\n name: getName(operation, { type: 'function', prefix: 'use' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'use' }),\n }\n\n const type = {\n file: getFile(operation, { pluginName: pluginTsName }),\n //todo remove type?\n schemas: getSchemas(operation, { pluginName: pluginTsName, type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginName: pluginZodName }),\n schemas: getSchemas(operation, { pluginName: pluginZodName, type: 'function' }),\n }\n\n const hasClientPlugin = !!driver.getPluginByName(pluginClientName)\n // Class-based clients are not compatible with query hooks, so we generate inline clients\n const shouldUseClientPlugin = hasClientPlugin && options.client.clientType !== 'class'\n const client = {\n name: shouldUseClientPlugin\n ? getName(operation, {\n type: 'function',\n pluginName: pluginClientName,\n })\n : getName(operation, {\n type: 'function',\n }),\n file: getFile(operation, { pluginName: pluginClientName }),\n }\n\n const mutationKey = {\n name: getName(operation, { type: 'const', suffix: 'MutationKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'MutationKey' }),\n }\n\n if (!isMutation) {\n return null\n }\n\n return (\n <File\n baseName={mutation.file.baseName}\n path={mutation.file.path}\n meta={mutation.file.meta}\n banner={getBanner({ oas, output, config: driver.config })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={mutation.file.path} path={zod.file.path} />\n )}\n {options.client.importPath ? (\n <>\n {!shouldUseClientPlugin && <File.Import name={'fetch'} path={options.client.importPath} />}\n <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n </>\n ) : (\n <>\n {!shouldUseClientPlugin && (\n <File.Import name={['fetch']} root={mutation.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />\n )}\n <File.Import\n name={['Client', 'RequestConfig', 'ResponseErrorConfig']}\n root={mutation.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n {options.client.dataReturnType === 'full' && (\n <File.Import\n name={['ResponseConfig']}\n root={mutation.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n )}\n </>\n )}\n <File.Import name=\"useSWRMutation\" path={importPath} />\n <File.Import name={['SWRMutationConfiguration', 'SWRMutationResponse']} path={importPath} isTypeOnly />\n {shouldUseClientPlugin && <File.Import name={[client.name]} root={mutation.file.path} path={client.file.path} />}\n {!shouldUseClientPlugin && (\n <File.Import name={['buildFormData']} root={mutation.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />\n )}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={mutation.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <MutationKey\n name={mutationKey.name}\n typeName={mutationKey.typeName}\n operation={operation}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n transformer={options.mutationKey}\n />\n\n {!shouldUseClientPlugin && (\n <Client\n name={client.name}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType || 'data'}\n paramsCasing={options.client?.paramsCasing || options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n {options.mutation && (\n <Mutation\n name={mutation.name}\n clientName={client.name}\n typeName={mutation.typeName}\n typeSchemas={type.schemas}\n operation={operation}\n dataReturnType={options.client.dataReturnType || 'data'}\n paramsType={options.paramsType}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n mutationKeyName={mutationKey.name}\n mutationKeyTypeName={mutationKey.typeName}\n paramsToTrigger={options.mutation.paramsToTrigger}\n />\n )}\n </File>\n )\n },\n})\n","import path from 'node:path'\nimport { usePluginDriver } from '@kubb/core/hooks'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File } from '@kubb/react-fabric'\nimport { difference } from 'remeda'\nimport { Query, QueryKey, QueryOptions } from '../components'\nimport type { PluginSwr } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginSwr>({\n name: 'swr-query',\n Operation({ config, operation, generator, plugin }) {\n const {\n options,\n options: { output },\n } = plugin\n const driver = usePluginDriver()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(\n (method) => operation.method === method,\n )\n const importPath = options.query ? options.query.importPath : 'swr/mutation'\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'use' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'use' }),\n }\n\n const hasClientPlugin = !!driver.getPluginByName(pluginClientName)\n // Class-based clients are not compatible with query hooks, so we generate inline clients\n const shouldUseClientPlugin = hasClientPlugin && options.client.clientType !== 'class'\n const client = {\n name: shouldUseClientPlugin\n ? getName(operation, {\n type: 'function',\n pluginName: pluginClientName,\n })\n : getName(operation, {\n type: 'function',\n }),\n file: getFile(operation, { pluginName: pluginClientName }),\n }\n\n const queryOptions = {\n name: getName(operation, { type: 'function', suffix: 'QueryOptions' }),\n }\n const queryKey = {\n name: getName(operation, { type: 'const', suffix: 'QueryKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'QueryKey' }),\n }\n\n const type = {\n file: getFile(operation, { pluginName: pluginTsName }),\n //todo remove type?\n schemas: getSchemas(operation, {\n pluginName: pluginTsName,\n type: 'type',\n }),\n }\n\n const zod = {\n file: getFile(operation, { pluginName: pluginZodName }),\n schemas: getSchemas(operation, {\n pluginName: pluginZodName,\n type: 'function',\n }),\n }\n\n if (!isQuery || isMutation) {\n return null\n }\n\n return (\n <File\n baseName={query.file.baseName}\n path={query.file.path}\n meta={query.file.meta}\n banner={getBanner({ oas, output, config: driver.config })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={query.file.path} path={zod.file.path} />\n )}\n {options.client.importPath ? (\n <>\n {!shouldUseClientPlugin && <File.Import name={'fetch'} path={options.client.importPath} />}\n <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n </>\n ) : (\n <>\n {!shouldUseClientPlugin && (\n <File.Import name={['fetch']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />\n )}\n <File.Import\n name={['Client', 'RequestConfig', 'ResponseErrorConfig']}\n root={query.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n {options.client.dataReturnType === 'full' && (\n <File.Import name={['ResponseConfig']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} isTypeOnly />\n )}\n </>\n )}\n {shouldUseClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}\n {!shouldUseClientPlugin && (\n <File.Import name={['buildFormData']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />\n )}\n\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={query.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <QueryKey\n name={queryKey.name}\n typeName={queryKey.typeName}\n operation={operation}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n transformer={options.queryKey}\n />\n {!shouldUseClientPlugin && (\n <Client\n name={client.name}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType || 'data'}\n paramsCasing={options.client.paramsCasing || options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n <QueryOptions\n name={queryOptions.name}\n clientName={client.name}\n typeSchemas={type.schemas}\n paramsType={options.paramsType}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n />\n {options.query && (\n <>\n <File.Import name=\"useSWR\" path={importPath} />\n <File.Import name={['SWRResponse']} path={importPath} isTypeOnly />\n <Query\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n operation={operation}\n dataReturnType={options.client.dataReturnType || 'data'}\n queryKeyName={queryKey.name}\n paramsCasing={options.paramsCasing}\n queryKeyTypeName={queryKey.typeName}\n />\n </>\n )}\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAa,oBAAoB,qBAAgC;CAC/D,MAAM;CACN,UAAU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Q;MACpB,gBAAgB,QAAQ;MACb;MACX,gBAAgB,QAAQ,OAAO,kBAAkB;MACjD,cAAc,SAAS;MACvB,cAAc,QAAQ;MACtB,kBAAkB,SAAS;MAC3B,CAAA;KACD,EAAA,CAAA;IAEA;;;CAGZ,CAAC"}
@@ -17,7 +17,7 @@ const mutationGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)(
17
17
  name: "swr-mutation",
18
18
  Operation({ config, operation, generator, plugin }) {
19
19
  const { options, options: { output } } = plugin;
20
- const pluginManager = (0, _kubb_core_hooks.usePluginManager)();
20
+ const driver = (0, _kubb_core_hooks.usePluginDriver)();
21
21
  const oas = (0, _kubb_plugin_oas_hooks.useOas)();
22
22
  const { getSchemas, getName, getFile } = (0, _kubb_plugin_oas_hooks.useOperationManager)(generator);
23
23
  const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method);
@@ -32,26 +32,26 @@ const mutationGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)(
32
32
  file: getFile(operation, { prefix: "use" })
33
33
  };
34
34
  const type = {
35
- file: getFile(operation, { pluginKey: [_kubb_plugin_ts.pluginTsName] }),
35
+ file: getFile(operation, { pluginName: _kubb_plugin_ts.pluginTsName }),
36
36
  schemas: getSchemas(operation, {
37
- pluginKey: [_kubb_plugin_ts.pluginTsName],
37
+ pluginName: _kubb_plugin_ts.pluginTsName,
38
38
  type: "type"
39
39
  })
40
40
  };
41
41
  const zod = {
42
- file: getFile(operation, { pluginKey: [_kubb_plugin_zod.pluginZodName] }),
42
+ file: getFile(operation, { pluginName: _kubb_plugin_zod.pluginZodName }),
43
43
  schemas: getSchemas(operation, {
44
- pluginKey: [_kubb_plugin_zod.pluginZodName],
44
+ pluginName: _kubb_plugin_zod.pluginZodName,
45
45
  type: "function"
46
46
  })
47
47
  };
48
- const shouldUseClientPlugin = !!pluginManager.getPluginByKey([_kubb_plugin_client.pluginClientName]) && options.client.clientType !== "class";
48
+ const shouldUseClientPlugin = !!driver.getPluginByName(_kubb_plugin_client.pluginClientName) && options.client.clientType !== "class";
49
49
  const client = {
50
50
  name: shouldUseClientPlugin ? getName(operation, {
51
51
  type: "function",
52
- pluginKey: [_kubb_plugin_client.pluginClientName]
52
+ pluginName: _kubb_plugin_client.pluginClientName
53
53
  }) : getName(operation, { type: "function" }),
54
- file: getFile(operation, { pluginKey: [_kubb_plugin_client.pluginClientName] })
54
+ file: getFile(operation, { pluginName: _kubb_plugin_client.pluginClientName })
55
55
  };
56
56
  const mutationKey = {
57
57
  name: getName(operation, {
@@ -71,7 +71,7 @@ const mutationGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)(
71
71
  banner: (0, _kubb_plugin_oas_utils.getBanner)({
72
72
  oas,
73
73
  output,
74
- config: pluginManager.config
74
+ config: driver.config
75
75
  }),
76
76
  footer: (0, _kubb_plugin_oas_utils.getFooter)({
77
77
  oas,
@@ -202,7 +202,7 @@ const queryGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
202
202
  name: "swr-query",
203
203
  Operation({ config, operation, generator, plugin }) {
204
204
  const { options, options: { output } } = plugin;
205
- const pluginManager = (0, _kubb_core_hooks.usePluginManager)();
205
+ const driver = (0, _kubb_core_hooks.usePluginDriver)();
206
206
  const oas = (0, _kubb_plugin_oas_hooks.useOas)();
207
207
  const { getSchemas, getName, getFile } = (0, _kubb_plugin_oas_hooks.useOperationManager)(generator);
208
208
  const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
@@ -216,13 +216,13 @@ const queryGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
216
216
  typeName: getName(operation, { type: "type" }),
217
217
  file: getFile(operation, { prefix: "use" })
218
218
  };
219
- const shouldUseClientPlugin = !!pluginManager.getPluginByKey([_kubb_plugin_client.pluginClientName]) && options.client.clientType !== "class";
219
+ const shouldUseClientPlugin = !!driver.getPluginByName(_kubb_plugin_client.pluginClientName) && options.client.clientType !== "class";
220
220
  const client = {
221
221
  name: shouldUseClientPlugin ? getName(operation, {
222
222
  type: "function",
223
- pluginKey: [_kubb_plugin_client.pluginClientName]
223
+ pluginName: _kubb_plugin_client.pluginClientName
224
224
  }) : getName(operation, { type: "function" }),
225
- file: getFile(operation, { pluginKey: [_kubb_plugin_client.pluginClientName] })
225
+ file: getFile(operation, { pluginName: _kubb_plugin_client.pluginClientName })
226
226
  };
227
227
  const queryOptions = { name: getName(operation, {
228
228
  type: "function",
@@ -239,16 +239,16 @@ const queryGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
239
239
  })
240
240
  };
241
241
  const type = {
242
- file: getFile(operation, { pluginKey: [_kubb_plugin_ts.pluginTsName] }),
242
+ file: getFile(operation, { pluginName: _kubb_plugin_ts.pluginTsName }),
243
243
  schemas: getSchemas(operation, {
244
- pluginKey: [_kubb_plugin_ts.pluginTsName],
244
+ pluginName: _kubb_plugin_ts.pluginTsName,
245
245
  type: "type"
246
246
  })
247
247
  };
248
248
  const zod = {
249
- file: getFile(operation, { pluginKey: [_kubb_plugin_zod.pluginZodName] }),
249
+ file: getFile(operation, { pluginName: _kubb_plugin_zod.pluginZodName }),
250
250
  schemas: getSchemas(operation, {
251
- pluginKey: [_kubb_plugin_zod.pluginZodName],
251
+ pluginName: _kubb_plugin_zod.pluginZodName,
252
252
  type: "function"
253
253
  })
254
254
  };
@@ -260,7 +260,7 @@ const queryGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
260
260
  banner: (0, _kubb_plugin_oas_utils.getBanner)({
261
261
  oas,
262
262
  output,
263
- config: pluginManager.config
263
+ config: driver.config
264
264
  }),
265
265
  footer: (0, _kubb_plugin_oas_utils.getFooter)({
266
266
  oas,
@@ -407,4 +407,4 @@ Object.defineProperty(exports, "queryGenerator", {
407
407
  }
408
408
  });
409
409
 
410
- //# sourceMappingURL=generators-9FlcwxK4.cjs.map
410
+ //# sourceMappingURL=generators-D062obA7.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generators-D062obA7.cjs","names":["pluginTsName","pluginZodName","pluginClientName","File","path","MutationKey","Client","Mutation","pluginClientName","pluginTsName","pluginZodName","File","path","QueryKey","Client","QueryOptions","Query"],"sources":["../src/generators/mutationGenerator.tsx","../src/generators/queryGenerator.tsx"],"sourcesContent":["import path from 'node:path'\nimport { usePluginDriver } from '@kubb/core/hooks'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File } from '@kubb/react-fabric'\nimport { difference } from 'remeda'\nimport { Mutation, MutationKey } from '../components'\nimport type { PluginSwr } from '../types'\n\nexport const mutationGenerator = createReactGenerator<PluginSwr>({\n name: 'swr-mutation',\n Operation({ config, operation, generator, plugin }) {\n const {\n options,\n options: { output },\n } = plugin\n const driver = usePluginDriver()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\n\n const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method)\n const isMutation =\n options.mutation !== false &&\n !isQuery &&\n difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method)\n\n const importPath = options.mutation ? options.mutation.importPath : 'swr'\n\n const mutation = {\n name: getName(operation, { type: 'function', prefix: 'use' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'use' }),\n }\n\n const type = {\n file: getFile(operation, { pluginName: pluginTsName }),\n //todo remove type?\n schemas: getSchemas(operation, { pluginName: pluginTsName, type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginName: pluginZodName }),\n schemas: getSchemas(operation, { pluginName: pluginZodName, type: 'function' }),\n }\n\n const hasClientPlugin = !!driver.getPluginByName(pluginClientName)\n // Class-based clients are not compatible with query hooks, so we generate inline clients\n const shouldUseClientPlugin = hasClientPlugin && options.client.clientType !== 'class'\n const client = {\n name: shouldUseClientPlugin\n ? getName(operation, {\n type: 'function',\n pluginName: pluginClientName,\n })\n : getName(operation, {\n type: 'function',\n }),\n file: getFile(operation, { pluginName: pluginClientName }),\n }\n\n const mutationKey = {\n name: getName(operation, { type: 'const', suffix: 'MutationKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'MutationKey' }),\n }\n\n if (!isMutation) {\n return null\n }\n\n return (\n <File\n baseName={mutation.file.baseName}\n path={mutation.file.path}\n meta={mutation.file.meta}\n banner={getBanner({ oas, output, config: driver.config })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={mutation.file.path} path={zod.file.path} />\n )}\n {options.client.importPath ? (\n <>\n {!shouldUseClientPlugin && <File.Import name={'fetch'} path={options.client.importPath} />}\n <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n </>\n ) : (\n <>\n {!shouldUseClientPlugin && (\n <File.Import name={['fetch']} root={mutation.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />\n )}\n <File.Import\n name={['Client', 'RequestConfig', 'ResponseErrorConfig']}\n root={mutation.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n {options.client.dataReturnType === 'full' && (\n <File.Import\n name={['ResponseConfig']}\n root={mutation.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n )}\n </>\n )}\n <File.Import name=\"useSWRMutation\" path={importPath} />\n <File.Import name={['SWRMutationConfiguration', 'SWRMutationResponse']} path={importPath} isTypeOnly />\n {shouldUseClientPlugin && <File.Import name={[client.name]} root={mutation.file.path} path={client.file.path} />}\n {!shouldUseClientPlugin && (\n <File.Import name={['buildFormData']} root={mutation.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />\n )}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={mutation.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <MutationKey\n name={mutationKey.name}\n typeName={mutationKey.typeName}\n operation={operation}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n transformer={options.mutationKey}\n />\n\n {!shouldUseClientPlugin && (\n <Client\n name={client.name}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType || 'data'}\n paramsCasing={options.client?.paramsCasing || options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n {options.mutation && (\n <Mutation\n name={mutation.name}\n clientName={client.name}\n typeName={mutation.typeName}\n typeSchemas={type.schemas}\n operation={operation}\n dataReturnType={options.client.dataReturnType || 'data'}\n paramsType={options.paramsType}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n mutationKeyName={mutationKey.name}\n mutationKeyTypeName={mutationKey.typeName}\n paramsToTrigger={options.mutation.paramsToTrigger}\n />\n )}\n </File>\n )\n },\n})\n","import path from 'node:path'\nimport { usePluginDriver } from '@kubb/core/hooks'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File } from '@kubb/react-fabric'\nimport { difference } from 'remeda'\nimport { Query, QueryKey, QueryOptions } from '../components'\nimport type { PluginSwr } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginSwr>({\n name: 'swr-query',\n Operation({ config, operation, generator, plugin }) {\n const {\n options,\n options: { output },\n } = plugin\n const driver = usePluginDriver()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(\n (method) => operation.method === method,\n )\n const importPath = options.query ? options.query.importPath : 'swr/mutation'\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'use' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'use' }),\n }\n\n const hasClientPlugin = !!driver.getPluginByName(pluginClientName)\n // Class-based clients are not compatible with query hooks, so we generate inline clients\n const shouldUseClientPlugin = hasClientPlugin && options.client.clientType !== 'class'\n const client = {\n name: shouldUseClientPlugin\n ? getName(operation, {\n type: 'function',\n pluginName: pluginClientName,\n })\n : getName(operation, {\n type: 'function',\n }),\n file: getFile(operation, { pluginName: pluginClientName }),\n }\n\n const queryOptions = {\n name: getName(operation, { type: 'function', suffix: 'QueryOptions' }),\n }\n const queryKey = {\n name: getName(operation, { type: 'const', suffix: 'QueryKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'QueryKey' }),\n }\n\n const type = {\n file: getFile(operation, { pluginName: pluginTsName }),\n //todo remove type?\n schemas: getSchemas(operation, {\n pluginName: pluginTsName,\n type: 'type',\n }),\n }\n\n const zod = {\n file: getFile(operation, { pluginName: pluginZodName }),\n schemas: getSchemas(operation, {\n pluginName: pluginZodName,\n type: 'function',\n }),\n }\n\n if (!isQuery || isMutation) {\n return null\n }\n\n return (\n <File\n baseName={query.file.baseName}\n path={query.file.path}\n meta={query.file.meta}\n banner={getBanner({ oas, output, config: driver.config })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={query.file.path} path={zod.file.path} />\n )}\n {options.client.importPath ? (\n <>\n {!shouldUseClientPlugin && <File.Import name={'fetch'} path={options.client.importPath} />}\n <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n </>\n ) : (\n <>\n {!shouldUseClientPlugin && (\n <File.Import name={['fetch']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />\n )}\n <File.Import\n name={['Client', 'RequestConfig', 'ResponseErrorConfig']}\n root={query.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n {options.client.dataReturnType === 'full' && (\n <File.Import name={['ResponseConfig']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} isTypeOnly />\n )}\n </>\n )}\n {shouldUseClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}\n {!shouldUseClientPlugin && (\n <File.Import name={['buildFormData']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />\n )}\n\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={query.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <QueryKey\n name={queryKey.name}\n typeName={queryKey.typeName}\n operation={operation}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n transformer={options.queryKey}\n />\n {!shouldUseClientPlugin && (\n <Client\n name={client.name}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType || 'data'}\n paramsCasing={options.client.paramsCasing || options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n <QueryOptions\n name={queryOptions.name}\n clientName={client.name}\n typeSchemas={type.schemas}\n paramsType={options.paramsType}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n />\n {options.query && (\n <>\n <File.Import name=\"useSWR\" path={importPath} />\n <File.Import name={['SWRResponse']} path={importPath} isTypeOnly />\n <Query\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n operation={operation}\n dataReturnType={options.client.dataReturnType || 'data'}\n queryKeyName={queryKey.name}\n paramsCasing={options.paramsCasing}\n queryKeyTypeName={queryKey.typeName}\n />\n </>\n )}\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAa,qBAAA,GAAA,4BAAA,sBAAoD;CAC/D,MAAM;CACN,UAAU,EAAE,QAAQ,WAAW,WAAW,UAAU;EAClD,MAAM,EACJ,SACA,SAAS,EAAE,aACT;EACJ,MAAM,UAAA,GAAA,iBAAA,kBAA0B;EAEhC,MAAM,OAAA,GAAA,uBAAA,SAAc;EACpB,MAAM,EAAE,YAAY,SAAS,aAAA,GAAA,uBAAA,qBAAgC,UAAU;EAEvE,MAAM,UAAU,CAAC,CAAC,QAAQ,SAAS,QAAQ,OAAO,QAAQ,MAAM,WAAW,UAAU,WAAW,OAAO;EACvG,MAAM,aACJ,QAAQ,aAAa,SACrB,CAAC,YAAA,GAAA,OAAA,YACU,QAAQ,WAAW,QAAQ,SAAS,UAAU,EAAE,EAAE,QAAQ,QAAQ,QAAQ,MAAM,UAAU,EAAE,CAAC,CAAC,MAAM,WAAW,UAAU,WAAW,OAAO;EAExJ,MAAM,aAAa,QAAQ,WAAW,QAAQ,SAAS,aAAa;EAEpE,MAAM,WAAW;GACf,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,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QAAD;KACE,MAAM,OAAO;KACb,SAAS,QAAQ,OAAO;KACb;KACX,aAAa,KAAK;KAClB,YAAY,IAAI;KAChB,gBAAgB,QAAQ,OAAO,kBAAkB;KACjD,cAAc,QAAQ,OAAO,gBAAgB,QAAQ;KACrD,YAAY,QAAQ;KACpB,gBAAgB,QAAQ;KACxB,QAAQ,QAAQ;KAChB,CAAA;IAEJ,iBAAA,GAAA,+BAAA,KAACC,mBAAAA,cAAD;KACE,MAAM,aAAa;KACnB,YAAY,OAAO;KACnB,aAAa,KAAK;KAClB,YAAY,QAAQ;KACpB,cAAc,QAAQ;KACtB,gBAAgB,QAAQ;KACxB,CAAA;IACD,QAAQ,SACP,iBAAA,GAAA,+BAAA,MAAA,+BAAA,UAAA,EAAA,UAAA;KACE,iBAAA,GAAA,+BAAA,KAACJ,mBAAAA,KAAK,QAAN;MAAa,MAAK;MAAS,MAAM;MAAc,CAAA;KAC/C,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;MAAa,MAAM,CAAC,cAAc;MAAE,MAAM;MAAY,YAAA;MAAa,CAAA;KACnE,iBAAA,GAAA,+BAAA,KAACK,mBAAAA,OAAD;MACE,MAAM,MAAM;MACZ,kBAAkB,aAAa;MAC/B,aAAa,KAAK;MAClB,YAAY,QAAQ;MACpB,gBAAgB,QAAQ;MACb;MACX,gBAAgB,QAAQ,OAAO,kBAAkB;MACjD,cAAc,SAAS;MACvB,cAAc,QAAQ;MACtB,kBAAkB,SAAS;MAC3B,CAAA;KACD,EAAA,CAAA;IAEA;;;CAGZ,CAAC"}
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_generators = require("./generators-9FlcwxK4.cjs");
2
+ const require_generators = require("./generators-D062obA7.cjs");
3
3
  exports.mutationGenerator = require_generators.mutationGenerator;
4
4
  exports.queryGenerator = require_generators.queryGenerator;
@@ -1,12 +1,39 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
- import { n as PluginSwr } from "./types-D5nI1xDO.js";
3
- import { AsyncEventEmitter, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
2
+ import { n as PluginSwr } from "./types-BIaGRPjD.js";
3
+ import { Config, FileMetaBase, Generator, Group, KubbEvents, Output, Plugin, PluginDriver, PluginFactoryOptions, ResolveNameParams } from "@kubb/core";
4
4
  import { HttpMethod, Oas, Operation, SchemaObject, contentType } from "@kubb/oas";
5
- import { Fabric } from "@kubb/react-fabric";
6
5
  import { FabricReactNode } from "@kubb/react-fabric/types";
7
- import { OperationNode, SchemaNode } from "@kubb/ast/types";
8
- import { KubbFile } from "@kubb/fabric-core/types";
6
+ import { Fabric, KubbFile } from "@kubb/fabric-core/types";
9
7
 
8
+ //#region ../../internals/utils/src/asyncEventEmitter.d.ts
9
+ /** A function that can be registered as an event listener, synchronous or async. */
10
+ type AsyncListener<TArgs extends unknown[]> = (...args: TArgs) => void | Promise<void>;
11
+ /**
12
+ * A typed EventEmitter that awaits all async listeners before resolving.
13
+ * Wraps Node's `EventEmitter` with full TypeScript event-map inference.
14
+ */
15
+ declare class AsyncEventEmitter<TEvents extends { [K in keyof TEvents]: unknown[] }> {
16
+ #private;
17
+ /**
18
+ * `maxListener` controls the maximum number of listeners per event before Node emits a memory-leak warning.
19
+ * @default 10
20
+ */
21
+ constructor(maxListener?: number);
22
+ /**
23
+ * Emits an event and awaits all registered listeners in parallel.
24
+ * Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.
25
+ */
26
+ emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
27
+ /** Registers a persistent listener for the given event. */
28
+ on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void;
29
+ /** Registers a one-shot listener that removes itself after the first invocation. */
30
+ onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void;
31
+ /** Removes a previously registered listener. */
32
+ off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void;
33
+ /** Removes all listeners from every event channel. */
34
+ removeAll(): void;
35
+ }
36
+ //#endregion
10
37
  //#region ../plugin-oas/src/types.d.ts
11
38
  type GetOasOptions = {
12
39
  validate?: boolean;
@@ -26,14 +53,14 @@ declare global {
26
53
  *
27
54
  * `originalName` is the original name used(in PascalCase), only used to remove duplicates
28
55
  *
29
- * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
56
+ * `pluginName` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
30
57
  * @example import a type(plugin-ts) for a mock file(swagger-faker)
31
58
  */
32
59
  type Ref = {
33
60
  propertyName: string;
34
61
  originalName: string;
35
62
  path: KubbFile.Path;
36
- pluginKey?: Plugin['key'];
63
+ pluginName?: string;
37
64
  };
38
65
  type Refs = Record<string, Ref>;
39
66
  type OperationSchema = {
@@ -93,8 +120,8 @@ type ByContentType = {
93
120
  type: 'contentType';
94
121
  pattern: string | RegExp;
95
122
  };
96
- type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
97
- type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
123
+ type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType | BySchemaName;
124
+ type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType | BySchemaName;
98
125
  type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
99
126
  options: Partial<TOptions>;
100
127
  };
@@ -107,7 +134,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
107
134
  include: Array<Include> | undefined;
108
135
  override: Array<Override<TOptions>> | undefined;
109
136
  contentType: contentType | undefined;
110
- pluginManager: PluginManager;
137
+ driver: PluginDriver;
111
138
  events?: AsyncEventEmitter<KubbEvents>;
112
139
  /**
113
140
  * Current plugin
@@ -133,7 +160,7 @@ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = P
133
160
  method: HttpMethod;
134
161
  operation: Operation;
135
162
  }>>;
136
- build(...generators: Array<Generator<TPluginOptions, Version>>): Promise<Array<KubbFile.File<TFileMeta>>>;
163
+ build(...generators: Array<Generator$1<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
137
164
  }
138
165
  //#endregion
139
166
  //#region ../plugin-oas/src/SchemaMapper.d.ts
@@ -361,7 +388,7 @@ type Schema = {
361
388
  type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
362
389
  fabric: Fabric;
363
390
  oas: Oas;
364
- pluginManager: PluginManager;
391
+ driver: PluginDriver;
365
392
  events?: AsyncEventEmitter<KubbEvents>;
366
393
  /**
367
394
  * Current plugin
@@ -423,46 +450,33 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
423
450
  static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
424
451
  static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
425
452
  static combineObjects(tree: Schema[] | undefined): Schema[];
426
- build(...generators: Array<Generator<TPluginOptions, Version>>): Promise<Array<KubbFile.File<TFileMeta>>>;
453
+ build(...generators: Array<Generator$1<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
427
454
  }
428
455
  //#endregion
429
456
  //#region ../plugin-oas/src/generators/createGenerator.d.ts
430
- type CoreGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {
457
+ type CoreGenerator<TOptions extends PluginFactoryOptions> = {
431
458
  name: string;
432
459
  type: 'core';
433
- version: TVersion;
434
- operations: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>;
435
- operation: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>;
436
- schema: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>;
460
+ version: '1';
461
+ operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
462
+ operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
463
+ schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
437
464
  };
438
465
  //#endregion
439
466
  //#region ../plugin-oas/src/generators/types.d.ts
440
- type Version = '1' | '2';
441
- type OperationsV1Props<TOptions extends PluginFactoryOptions> = {
467
+ type OperationsProps<TOptions extends PluginFactoryOptions> = {
442
468
  config: Config;
443
469
  generator: Omit<OperationGenerator<TOptions>, 'build'>;
444
470
  plugin: Plugin<TOptions>;
445
471
  operations: Array<Operation>;
446
472
  };
447
- type OperationsV2Props<TOptions extends PluginFactoryOptions> = {
448
- config: Config;
449
- plugin: Plugin<TOptions>;
450
- nodes: Array<OperationNode>;
451
- };
452
- type OperationV1Props<TOptions extends PluginFactoryOptions> = {
473
+ type OperationProps<TOptions extends PluginFactoryOptions> = {
453
474
  config: Config;
454
475
  generator: Omit<OperationGenerator<TOptions>, 'build'>;
455
476
  plugin: Plugin<TOptions>;
456
477
  operation: Operation;
457
478
  };
458
- type OperationV2Props<TOptions extends PluginFactoryOptions> = {
459
- config: Config;
460
- plugin: Plugin<TOptions>;
461
- node: OperationNode;
462
- };
463
- type OperationsProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? OperationsV2Props<TOptions> : OperationsV1Props<TOptions>;
464
- type OperationProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? OperationV2Props<TOptions> : OperationV1Props<TOptions>;
465
- type SchemaV1Props<TOptions extends PluginFactoryOptions> = {
479
+ type SchemaProps<TOptions extends PluginFactoryOptions> = {
466
480
  config: Config;
467
481
  generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
468
482
  plugin: Plugin<TOptions>;
@@ -472,29 +486,23 @@ type SchemaV1Props<TOptions extends PluginFactoryOptions> = {
472
486
  value: SchemaObject;
473
487
  };
474
488
  };
475
- type SchemaV2Props<TOptions extends PluginFactoryOptions> = {
476
- config: Config;
477
- plugin: Plugin<TOptions>;
478
- node: SchemaNode;
479
- };
480
- type SchemaProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? SchemaV2Props<TOptions> : SchemaV1Props<TOptions>;
481
- type Generator<TOptions extends PluginFactoryOptions, TVersion extends Version = Version> = CoreGenerator<TOptions, TVersion> | ReactGenerator<TOptions, TVersion>;
489
+ type Generator$1<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions> | Generator<TOptions>;
482
490
  //#endregion
483
491
  //#region ../plugin-oas/src/generators/createReactGenerator.d.ts
484
- type ReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {
492
+ type ReactGenerator<TOptions extends PluginFactoryOptions> = {
485
493
  name: string;
486
494
  type: 'react';
487
- version: TVersion;
488
- Operations: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode;
489
- Operation: (props: OperationProps<TOptions, TVersion>) => FabricReactNode;
490
- Schema: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode;
495
+ version: '1';
496
+ Operations: (props: OperationsProps<TOptions>) => FabricReactNode;
497
+ Operation: (props: OperationProps<TOptions>) => FabricReactNode;
498
+ Schema: (props: SchemaProps<TOptions>) => FabricReactNode;
491
499
  };
492
500
  //#endregion
493
501
  //#region src/generators/mutationGenerator.d.ts
494
- declare const mutationGenerator: ReactGenerator<PluginSwr, "1">;
502
+ declare const mutationGenerator: ReactGenerator<PluginSwr>;
495
503
  //#endregion
496
504
  //#region src/generators/queryGenerator.d.ts
497
- declare const queryGenerator: ReactGenerator<PluginSwr, "1">;
505
+ declare const queryGenerator: ReactGenerator<PluginSwr>;
498
506
  //#endregion
499
507
  export { mutationGenerator, queryGenerator };
500
508
  //# sourceMappingURL=generators.d.ts.map
@@ -1,2 +1,2 @@
1
- import { n as mutationGenerator, t as queryGenerator } from "./generators-ClWZJ-YG.js";
1
+ import { n as mutationGenerator, t as queryGenerator } from "./generators-CRSl6u2M.js";
2
2
  export { mutationGenerator, queryGenerator };
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_components = require("./components-jd0l9XKn.cjs");
3
- const require_generators = require("./generators-9FlcwxK4.cjs");
3
+ const require_generators = require("./generators-D062obA7.cjs");
4
4
  let node_path = require("node:path");
5
5
  node_path = require_components.__toESM(node_path);
6
6
  let _kubb_core = require("@kubb/core");
@@ -13,7 +13,7 @@ let _kubb_plugin_ts = require("@kubb/plugin-ts");
13
13
  let _kubb_plugin_zod = require("@kubb/plugin-zod");
14
14
  //#region src/plugin.ts
15
15
  const pluginSwrName = "plugin-swr";
16
- const pluginSwr = (0, _kubb_core.definePlugin)((options) => {
16
+ const pluginSwr = (0, _kubb_core.createPlugin)((options) => {
17
17
  const { output = {
18
18
  path: "hooks",
19
19
  barrelType: "named"
@@ -91,7 +91,7 @@ const pluginSwr = (0, _kubb_core.definePlugin)((options) => {
91
91
  const oas = await this.getOas();
92
92
  const baseURL = await this.getBaseURL();
93
93
  if (baseURL) this.plugin.options.client.baseURL = baseURL;
94
- const hasClientPlugin = !!this.pluginManager.getPluginByKey([_kubb_plugin_client.pluginClientName]);
94
+ const hasClientPlugin = !!this.driver.getPluginByName(_kubb_plugin_client.pluginClientName);
95
95
  if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
96
96
  baseName: "fetch.ts",
97
97
  path: node_path.default.resolve(root, ".kubb/fetch.ts"),
@@ -119,7 +119,7 @@ const pluginSwr = (0, _kubb_core.definePlugin)((options) => {
119
119
  const files = await new _kubb_plugin_oas.OperationGenerator(this.plugin.options, {
120
120
  fabric: this.fabric,
121
121
  oas,
122
- pluginManager: this.pluginManager,
122
+ driver: this.driver,
123
123
  events: this.events,
124
124
  plugin: this.plugin,
125
125
  contentType,
@@ -133,7 +133,7 @@ const pluginSwr = (0, _kubb_core.definePlugin)((options) => {
133
133
  type: output.barrelType ?? "named",
134
134
  root,
135
135
  output,
136
- meta: { pluginKey: this.plugin.key }
136
+ meta: { pluginName: this.plugin.name }
137
137
  });
138
138
  await this.upsertFile(...barrelFiles);
139
139
  }