@kubb/plugin-svelte-query 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.
- package/dist/components-DntKBsnB.js.map +1 -1
- package/dist/components-kpjS70qO.cjs.map +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/{generators-DVAAgPhB.cjs → generators-BqBE02uG.cjs} +19 -19
- package/dist/generators-BqBE02uG.cjs.map +1 -0
- package/dist/{generators-BtTsGGrM.js → generators-TJp_N4gT.js} +20 -20
- package/dist/generators-TJp_N4gT.js.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +56 -48
- package/dist/generators.js +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/{types-DtgzW06v.d.ts → types-DV6jmiRo.d.ts} +3 -3
- package/package.json +12 -12
- package/src/generators/mutationGenerator.tsx +10 -10
- package/src/generators/queryGenerator.tsx +10 -10
- package/src/plugin.ts +5 -5
- package/dist/generators-BtTsGGrM.js.map +0 -1
- package/dist/generators-DVAAgPhB.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-BqBE02uG.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 { PluginSvelteQuery } from '../types'\n\nexport const mutationGenerator = createReactGenerator<PluginSvelteQuery>({\n name: 'svelte-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 = !!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 : '@tanstack/svelte-query'\n\n const mutation = {\n name: getName(operation, { type: 'function', prefix: 'create' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'create' }),\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 {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 paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n transformer={options.mutationKey}\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 <>\n <File.Import name={['createMutation']} path={importPath} />\n <File.Import name={['CreateMutationOptions', 'CreateMutationResult', 'QueryClient']} path={importPath} isTypeOnly />\n <Mutation\n name={mutation.name}\n clientName={client.name}\n typeName={mutation.typeName}\n typeSchemas={type.schemas}\n operation={operation}\n paramsCasing={options.paramsCasing}\n dataReturnType={options.client.dataReturnType || 'data'}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n mutationKeyName={mutationKey.name}\n />\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 { PluginSvelteQuery } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginSvelteQuery>({\n name: 'svelte-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 : '@tanstack/svelte-query'\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'create' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'create' }),\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\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 <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\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\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 <File.Import name={['queryOptions']} path={importPath} />\n <QueryOptions\n name={queryOptions.name}\n clientName={client.name}\n queryKeyName={queryKey.name}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n dataReturnType={options.client.dataReturnType || 'data'}\n />\n {options.query && (\n <>\n <File.Import name={['createQuery']} path={importPath} />\n <File.Import name={['QueryKey', 'QueryClient', 'CreateBaseQueryOptions', 'CreateQueryResult']} path={importPath} isTypeOnly />\n <Query\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n pathParamsType={options.pathParamsType}\n operation={operation}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n dataReturnType={options.client.dataReturnType || 'data'}\n queryKeyName={queryKey.name}\n queryKeyTypeName={queryKey.typeName}\n />\n </>\n )}\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAa,qBAAA,GAAA,4BAAA,sBAA4D;CACvE,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,QAAQ;IAAU,CAAC;GAChE,UAAU,QAAQ,WAAW,EAAE,MAAM,QAAQ,CAAC;GAC9C,MAAM,QAAQ,WAAW,EAAE,QAAQ,UAAU,CAAC;GAC/C;EAED,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,YAAYA,gBAAAA,cAAc,CAAC;GAEtD,SAAS,WAAW,WAAW;IAAE,YAAYA,gBAAAA;IAAc,MAAM;IAAQ,CAAC;GAC3E;EAED,MA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BAAA,GAAA,+BAAA,KAACH,mBAAAA,KAAK,QAAN;KAAa,MAAM,CAAC,eAAe;KAAE,MAAM;KAAc,CAAA;IACzD,iBAAA,GAAA,+BAAA,KAACI,mBAAAA,cAAD;KACE,MAAM,aAAa;KACnB,YAAY,OAAO;KACnB,cAAc,SAAS;KACvB,aAAa,KAAK;KAClB,cAAc,QAAQ;KACtB,YAAY,QAAQ;KACpB,gBAAgB,QAAQ;KACxB,gBAAgB,QAAQ,OAAO,kBAAkB;KACjD,CAAA;IACD,QAAQ,SACP,iBAAA,GAAA,+BAAA,MAAA,+BAAA,UAAA,EAAA,UAAA;KACE,iBAAA,GAAA,+BAAA,KAACJ,mBAAAA,KAAK,QAAN;MAAa,MAAM,CAAC,cAAc;MAAE,MAAM;MAAc,CAAA;KACxD,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;MAAa,MAAM;OAAC;OAAY;OAAe;OAA0B;OAAoB;MAAE,MAAM;MAAY,YAAA;MAAa,CAAA;KAC9H,iBAAA,GAAA,+BAAA,KAACK,mBAAAA,OAAD;MACE,MAAM,MAAM;MACZ,kBAAkB,aAAa;MAC/B,aAAa,KAAK;MAClB,gBAAgB,QAAQ;MACb;MACX,cAAc,QAAQ;MACtB,YAAY,QAAQ;MACpB,gBAAgB,QAAQ,OAAO,kBAAkB;MACjD,cAAc,SAAS;MACvB,kBAAkB,SAAS;MAC3B,CAAA;KACD,EAAA,CAAA;IAEA;;;CAGZ,CAAC"}
|
|
@@ -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 {
|
|
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: "svelte-query",
|
|
18
18
|
Operation({ config, operation, generator, plugin }) {
|
|
19
19
|
const { options, options: { output } } = plugin;
|
|
20
|
-
const
|
|
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: "create" })
|
|
33
33
|
};
|
|
34
34
|
const type = {
|
|
35
|
-
file: getFile(operation, {
|
|
35
|
+
file: getFile(operation, { pluginName: pluginTsName }),
|
|
36
36
|
schemas: getSchemas(operation, {
|
|
37
|
-
|
|
37
|
+
pluginName: pluginTsName,
|
|
38
38
|
type: "type"
|
|
39
39
|
})
|
|
40
40
|
};
|
|
41
41
|
const zod = {
|
|
42
|
-
file: getFile(operation, {
|
|
42
|
+
file: getFile(operation, { pluginName: pluginZodName }),
|
|
43
43
|
schemas: getSchemas(operation, {
|
|
44
|
-
|
|
44
|
+
pluginName: pluginZodName,
|
|
45
45
|
type: "function"
|
|
46
46
|
})
|
|
47
47
|
};
|
|
48
|
-
const shouldUseClientPlugin = !!
|
|
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
|
-
|
|
52
|
+
pluginName: pluginClientName
|
|
53
53
|
}) : getName(operation, { type: "function" }),
|
|
54
|
-
file: getFile(operation, {
|
|
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:
|
|
74
|
+
config: driver.config
|
|
75
75
|
}),
|
|
76
76
|
footer: getFooter({
|
|
77
77
|
oas,
|
|
@@ -206,7 +206,7 @@ const queryGenerator = createReactGenerator({
|
|
|
206
206
|
name: "svelte-query",
|
|
207
207
|
Operation({ config, operation, generator, plugin }) {
|
|
208
208
|
const { options, options: { output } } = plugin;
|
|
209
|
-
const
|
|
209
|
+
const driver = usePluginDriver();
|
|
210
210
|
const oas = useOas();
|
|
211
211
|
const { getSchemas, getName, getFile } = useOperationManager(generator);
|
|
212
212
|
const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
|
|
@@ -220,13 +220,13 @@ const queryGenerator = createReactGenerator({
|
|
|
220
220
|
typeName: getName(operation, { type: "type" }),
|
|
221
221
|
file: getFile(operation, { prefix: "create" })
|
|
222
222
|
};
|
|
223
|
-
const shouldUseClientPlugin = !!
|
|
223
|
+
const shouldUseClientPlugin = !!driver.getPluginByName(pluginClientName) && options.client.clientType !== "class";
|
|
224
224
|
const client = {
|
|
225
225
|
name: shouldUseClientPlugin ? getName(operation, {
|
|
226
226
|
type: "function",
|
|
227
|
-
|
|
227
|
+
pluginName: pluginClientName
|
|
228
228
|
}) : getName(operation, { type: "function" }),
|
|
229
|
-
file: getFile(operation, {
|
|
229
|
+
file: getFile(operation, { pluginName: pluginClientName })
|
|
230
230
|
};
|
|
231
231
|
const queryOptions = { name: getName(operation, {
|
|
232
232
|
type: "function",
|
|
@@ -243,16 +243,16 @@ const queryGenerator = createReactGenerator({
|
|
|
243
243
|
})
|
|
244
244
|
};
|
|
245
245
|
const type = {
|
|
246
|
-
file: getFile(operation, {
|
|
246
|
+
file: getFile(operation, { pluginName: pluginTsName }),
|
|
247
247
|
schemas: getSchemas(operation, {
|
|
248
|
-
|
|
248
|
+
pluginName: pluginTsName,
|
|
249
249
|
type: "type"
|
|
250
250
|
})
|
|
251
251
|
};
|
|
252
252
|
const zod = {
|
|
253
|
-
file: getFile(operation, {
|
|
253
|
+
file: getFile(operation, { pluginName: pluginZodName }),
|
|
254
254
|
schemas: getSchemas(operation, {
|
|
255
|
-
|
|
255
|
+
pluginName: pluginZodName,
|
|
256
256
|
type: "function"
|
|
257
257
|
})
|
|
258
258
|
};
|
|
@@ -264,7 +264,7 @@ const queryGenerator = createReactGenerator({
|
|
|
264
264
|
banner: getBanner({
|
|
265
265
|
oas,
|
|
266
266
|
output,
|
|
267
|
-
config:
|
|
267
|
+
config: driver.config
|
|
268
268
|
}),
|
|
269
269
|
footer: getFooter({
|
|
270
270
|
oas,
|
|
@@ -411,4 +411,4 @@ const queryGenerator = createReactGenerator({
|
|
|
411
411
|
//#endregion
|
|
412
412
|
export { mutationGenerator as n, queryGenerator as t };
|
|
413
413
|
|
|
414
|
-
//# sourceMappingURL=generators-
|
|
414
|
+
//# sourceMappingURL=generators-TJp_N4gT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-TJp_N4gT.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 { PluginSvelteQuery } from '../types'\n\nexport const mutationGenerator = createReactGenerator<PluginSvelteQuery>({\n name: 'svelte-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 = !!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 : '@tanstack/svelte-query'\n\n const mutation = {\n name: getName(operation, { type: 'function', prefix: 'create' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'create' }),\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 {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 paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n transformer={options.mutationKey}\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 <>\n <File.Import name={['createMutation']} path={importPath} />\n <File.Import name={['CreateMutationOptions', 'CreateMutationResult', 'QueryClient']} path={importPath} isTypeOnly />\n <Mutation\n name={mutation.name}\n clientName={client.name}\n typeName={mutation.typeName}\n typeSchemas={type.schemas}\n operation={operation}\n paramsCasing={options.paramsCasing}\n dataReturnType={options.client.dataReturnType || 'data'}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n mutationKeyName={mutationKey.name}\n />\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 { PluginSvelteQuery } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginSvelteQuery>({\n name: 'svelte-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 : '@tanstack/svelte-query'\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'create' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'create' }),\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\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 <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\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\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 <File.Import name={['queryOptions']} path={importPath} />\n <QueryOptions\n name={queryOptions.name}\n clientName={client.name}\n queryKeyName={queryKey.name}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n dataReturnType={options.client.dataReturnType || 'data'}\n />\n {options.query && (\n <>\n <File.Import name={['createQuery']} path={importPath} />\n <File.Import name={['QueryKey', 'QueryClient', 'CreateBaseQueryOptions', 'CreateQueryResult']} path={importPath} isTypeOnly />\n <Query\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n pathParamsType={options.pathParamsType}\n operation={operation}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n dataReturnType={options.client.dataReturnType || 'data'}\n queryKeyName={queryKey.name}\n queryKeyTypeName={queryKey.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AA,UAAA,EAAA,UAAA;KACE,oBAAC,KAAK,QAAN;MAAa,MAAM,CAAC,cAAc;MAAE,MAAM;MAAc,CAAA;KACxD,oBAAC,KAAK,QAAN;MAAa,MAAM;OAAC;OAAY;OAAe;OAA0B;OAAoB;MAAE,MAAM;MAAY,YAAA;MAAa,CAAA;KAC9H,oBAAC,OAAD;MACE,MAAM,MAAM;MACZ,kBAAkB,aAAa;MAC/B,aAAa,KAAK;MAClB,gBAAgB,QAAQ;MACb;MACX,cAAc,QAAQ;MACtB,YAAY,QAAQ;MACpB,gBAAgB,QAAQ,OAAO,kBAAkB;MACjD,cAAc,SAAS;MACvB,kBAAkB,SAAS;MAC3B,CAAA;KACD,EAAA,CAAA;IAEA;;;CAGZ,CAAC"}
|
package/dist/generators.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_generators = require("./generators-
|
|
2
|
+
const require_generators = require("./generators-BqBE02uG.cjs");
|
|
3
3
|
exports.mutationGenerator = require_generators.mutationGenerator;
|
|
4
4
|
exports.queryGenerator = require_generators.queryGenerator;
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { n as PluginSvelteQuery } from "./types-
|
|
3
|
-
import {
|
|
2
|
+
import { n as PluginSvelteQuery } from "./types-DV6jmiRo.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 {
|
|
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
|
-
* `
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
457
|
+
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
431
458
|
name: string;
|
|
432
459
|
type: 'core';
|
|
433
|
-
version:
|
|
434
|
-
operations: (props: OperationsProps<TOptions
|
|
435
|
-
operation: (props: OperationProps<TOptions
|
|
436
|
-
schema: (props: SchemaProps<TOptions
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
492
|
+
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
485
493
|
name: string;
|
|
486
494
|
type: 'react';
|
|
487
|
-
version:
|
|
488
|
-
Operations: (props: OperationsProps<TOptions
|
|
489
|
-
Operation: (props: OperationProps<TOptions
|
|
490
|
-
Schema: (props: SchemaProps<TOptions
|
|
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<PluginSvelteQuery
|
|
502
|
+
declare const mutationGenerator: ReactGenerator<PluginSvelteQuery>;
|
|
495
503
|
//#endregion
|
|
496
504
|
//#region src/generators/queryGenerator.d.ts
|
|
497
|
-
declare const queryGenerator: ReactGenerator<PluginSvelteQuery
|
|
505
|
+
declare const queryGenerator: ReactGenerator<PluginSvelteQuery>;
|
|
498
506
|
//#endregion
|
|
499
507
|
export { mutationGenerator, queryGenerator };
|
|
500
508
|
//# sourceMappingURL=generators.d.ts.map
|
package/dist/generators.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as mutationGenerator, t as queryGenerator } from "./generators-
|
|
1
|
+
import { n as mutationGenerator, t as queryGenerator } from "./generators-TJp_N4gT.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-kpjS70qO.cjs");
|
|
3
|
-
const require_generators = require("./generators-
|
|
3
|
+
const require_generators = require("./generators-BqBE02uG.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 pluginSvelteQueryName = "plugin-svelte-query";
|
|
16
|
-
const pluginSvelteQuery = (0, _kubb_core.
|
|
16
|
+
const pluginSvelteQuery = (0, _kubb_core.createPlugin)((options) => {
|
|
17
17
|
const { output = {
|
|
18
18
|
path: "hooks",
|
|
19
19
|
barrelType: "named"
|
|
@@ -92,7 +92,7 @@ const pluginSvelteQuery = (0, _kubb_core.definePlugin)((options) => {
|
|
|
92
92
|
const oas = await this.getOas();
|
|
93
93
|
const baseURL = await this.getBaseURL();
|
|
94
94
|
if (baseURL) this.plugin.options.client.baseURL = baseURL;
|
|
95
|
-
const hasClientPlugin = !!this.
|
|
95
|
+
const hasClientPlugin = !!this.driver.getPluginByName(_kubb_plugin_client.pluginClientName);
|
|
96
96
|
if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
|
|
97
97
|
baseName: "fetch.ts",
|
|
98
98
|
path: node_path.default.resolve(root, ".kubb/fetch.ts"),
|
|
@@ -120,7 +120,7 @@ const pluginSvelteQuery = (0, _kubb_core.definePlugin)((options) => {
|
|
|
120
120
|
const files = await new _kubb_plugin_oas.OperationGenerator(this.plugin.options, {
|
|
121
121
|
fabric: this.fabric,
|
|
122
122
|
oas,
|
|
123
|
-
|
|
123
|
+
driver: this.driver,
|
|
124
124
|
events: this.events,
|
|
125
125
|
plugin: this.plugin,
|
|
126
126
|
contentType,
|
|
@@ -134,7 +134,7 @@ const pluginSvelteQuery = (0, _kubb_core.definePlugin)((options) => {
|
|
|
134
134
|
type: output.barrelType ?? "named",
|
|
135
135
|
root,
|
|
136
136
|
output,
|
|
137
|
-
meta: {
|
|
137
|
+
meta: { pluginName: this.plugin.name }
|
|
138
138
|
});
|
|
139
139
|
await this.upsertFile(...barrelFiles);
|
|
140
140
|
}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["MutationKey","QueryKey","queryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","path","camelCase","pascalCase","pluginClientName","fetchClientSource","axiosClientSource","configSource","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { camelCase, pascalCase } from '@internals/utils'\nimport {
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["MutationKey","QueryKey","queryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","path","camelCase","pascalCase","pluginClientName","fetchClientSource","axiosClientSource","configSource","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { camelCase, pascalCase } from '@internals/utils'\nimport { createPlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { source as axiosClientSource } from '@kubb/plugin-client/templates/clients/axios.source'\nimport { source as fetchClientSource } from '@kubb/plugin-client/templates/clients/fetch.source'\nimport { source as configSource } from '@kubb/plugin-client/templates/config.source'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\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 = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n mutation = {},\n query = {},\n paramsCasing,\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n contentType,\n client,\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n return {\n name: pluginSvelteQueryName,\n options: {\n output,\n client: {\n bundle: client?.bundle,\n baseURL: client?.baseURL,\n client: clientName,\n clientType: client?.clientType ?? 'function',\n dataReturnType: client?.dataReturnType ?? 'data',\n pathParamsType,\n importPath: clientImportPath,\n paramsCasing,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/svelte-query',\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/svelte-query',\n ...mutation,\n },\n paramsType,\n pathParamsType,\n parser,\n paramsCasing,\n group,\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 ?? getMode(path.resolve(root, output.path))\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 if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\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 install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.driver.getPluginByName(pluginClientName)\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled fetch\n await this.upsertFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: this.plugin.options.client.client === 'fetch' ? fetchClientSource : axiosClientSource,\n isExportable: true,\n isIndexable: true,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n if (!hasClientPlugin) {\n await this.addFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: configSource,\n isExportable: false,\n isIndexable: false,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n driver: this.driver,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginName: this.plugin.name,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAa,wBAAwB;AAErC,MAAa,qBAAA,GAAA,WAAA,eAAqD,YAAY;CAC5E,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,SAAS,UACT,eAAe,EAAE,EACjB,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,WAAW,EAAE,EACb,QAAQ,EAAE,EACV,cACA,cAAcA,mBAAAA,YAAY,gBAC1B,WAAWC,mBAAAA,SAAS,gBACpB,aAAa,CAACC,mBAAAA,gBAAgBC,mBAAAA,kBAAkB,CAAC,OAAO,QAAQ,EAChE,aACA,WACE;CAEJ,MAAM,aAAa,QAAQ,UAAU;CACrC,MAAM,mBAAmB,QAAQ,eAAe,CAAC,QAAQ,SAAS,+BAA+B,eAAe,KAAA;AAEhH,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA,QAAQ;IACN,QAAQ,QAAQ;IAChB,SAAS,QAAQ;IACjB,QAAQ;IACR,YAAY,QAAQ,cAAc;IAClC,gBAAgB,QAAQ,kBAAkB;IAC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C,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,WAAW,GAAG,MAAM;GAE/B,MAAM,cAAc,OAAA,GAAA,WAAA,gBAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,YAAY,KAAK,OAAO,MACzB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { n as PluginSvelteQuery, t as Options } from "./types-
|
|
2
|
+
import { n as PluginSvelteQuery, t as Options } from "./types-DV6jmiRo.js";
|
|
3
3
|
import * as _kubb_core0 from "@kubb/core";
|
|
4
4
|
|
|
5
5
|
//#region src/plugin.d.ts
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
2
|
import { a as MutationKey, i as QueryKey, o as camelCase, s as pascalCase } from "./components-DntKBsnB.js";
|
|
3
|
-
import { n as mutationGenerator, t as queryGenerator } from "./generators-
|
|
3
|
+
import { n as mutationGenerator, t as queryGenerator } from "./generators-TJp_N4gT.js";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import {
|
|
5
|
+
import { createPlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
6
6
|
import { pluginClientName } from "@kubb/plugin-client";
|
|
7
7
|
import { source } from "@kubb/plugin-client/templates/clients/axios.source";
|
|
8
8
|
import { source as source$1 } from "@kubb/plugin-client/templates/clients/fetch.source";
|
|
@@ -12,7 +12,7 @@ import { pluginTsName } from "@kubb/plugin-ts";
|
|
|
12
12
|
import { pluginZodName } from "@kubb/plugin-zod";
|
|
13
13
|
//#region src/plugin.ts
|
|
14
14
|
const pluginSvelteQueryName = "plugin-svelte-query";
|
|
15
|
-
const pluginSvelteQuery =
|
|
15
|
+
const pluginSvelteQuery = createPlugin((options) => {
|
|
16
16
|
const { output = {
|
|
17
17
|
path: "hooks",
|
|
18
18
|
barrelType: "named"
|
|
@@ -91,7 +91,7 @@ const pluginSvelteQuery = 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.
|
|
94
|
+
const hasClientPlugin = !!this.driver.getPluginByName(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: path.resolve(root, ".kubb/fetch.ts"),
|
|
@@ -119,7 +119,7 @@ const pluginSvelteQuery = definePlugin((options) => {
|
|
|
119
119
|
const files = await new OperationGenerator(this.plugin.options, {
|
|
120
120
|
fabric: this.fabric,
|
|
121
121
|
oas,
|
|
122
|
-
|
|
122
|
+
driver: this.driver,
|
|
123
123
|
events: this.events,
|
|
124
124
|
plugin: this.plugin,
|
|
125
125
|
contentType,
|
|
@@ -133,7 +133,7 @@ const pluginSvelteQuery = definePlugin((options) => {
|
|
|
133
133
|
type: output.barrelType ?? "named",
|
|
134
134
|
root,
|
|
135
135
|
output,
|
|
136
|
-
meta: {
|
|
136
|
+
meta: { pluginName: this.plugin.name }
|
|
137
137
|
});
|
|
138
138
|
await this.upsertFile(...barrelFiles);
|
|
139
139
|
}
|