@kubb/plugin-svelte-query 0.0.0-canary-20241104172400

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +123 -0
  3. package/dist/chunk-CDRGJAED.cjs +452 -0
  4. package/dist/chunk-CDRGJAED.cjs.map +1 -0
  5. package/dist/chunk-JGITTOE5.js +445 -0
  6. package/dist/chunk-JGITTOE5.js.map +1 -0
  7. package/dist/chunk-KRGCKSGR.cjs +527 -0
  8. package/dist/chunk-KRGCKSGR.cjs.map +1 -0
  9. package/dist/chunk-R6ZVBNG7.js +519 -0
  10. package/dist/chunk-R6ZVBNG7.js.map +1 -0
  11. package/dist/components.cjs +28 -0
  12. package/dist/components.cjs.map +1 -0
  13. package/dist/components.d.cts +103 -0
  14. package/dist/components.d.ts +103 -0
  15. package/dist/components.js +3 -0
  16. package/dist/components.js.map +1 -0
  17. package/dist/generators.cjs +17 -0
  18. package/dist/generators.cjs.map +1 -0
  19. package/dist/generators.d.cts +10 -0
  20. package/dist/generators.d.ts +10 -0
  21. package/dist/generators.js +4 -0
  22. package/dist/generators.js.map +1 -0
  23. package/dist/index.cjs +127 -0
  24. package/dist/index.cjs.map +1 -0
  25. package/dist/index.d.cts +9 -0
  26. package/dist/index.d.ts +9 -0
  27. package/dist/index.js +120 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/types-B9W9aYra.d.cts +365 -0
  30. package/dist/types-B9W9aYra.d.ts +365 -0
  31. package/package.json +102 -0
  32. package/src/components/Mutation.tsx +158 -0
  33. package/src/components/MutationKey.tsx +54 -0
  34. package/src/components/Query.tsx +176 -0
  35. package/src/components/QueryKey.tsx +83 -0
  36. package/src/components/QueryOptions.tsx +133 -0
  37. package/src/components/index.ts +5 -0
  38. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +51 -0
  39. package/src/generators/__snapshots__/clientGetImportPath.ts +51 -0
  40. package/src/generators/__snapshots__/clientPostImportPath.ts +44 -0
  41. package/src/generators/__snapshots__/findByTags.ts +51 -0
  42. package/src/generators/__snapshots__/findByTagsObject.ts +60 -0
  43. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +51 -0
  44. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +51 -0
  45. package/src/generators/__snapshots__/findByTagsWithZod.ts +51 -0
  46. package/src/generators/__snapshots__/postAsQuery.ts +50 -0
  47. package/src/generators/__snapshots__/updatePetById.ts +44 -0
  48. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +44 -0
  49. package/src/generators/index.ts +2 -0
  50. package/src/generators/mutationGenerator.tsx +117 -0
  51. package/src/generators/queryGenerator.tsx +129 -0
  52. package/src/index.ts +2 -0
  53. package/src/plugin.ts +141 -0
  54. package/src/types.ts +135 -0
@@ -0,0 +1,176 @@
1
+ import { File, Function, FunctionParams } from '@kubb/react'
2
+
3
+ import { type Operation, isOptional } from '@kubb/oas'
4
+ import type { OperationSchemas } from '@kubb/plugin-oas'
5
+ import { getComments, getPathParams } from '@kubb/plugin-oas/utils'
6
+ import type { ReactNode } from 'react'
7
+ import type { PluginSvelteQuery } from '../types.ts'
8
+ import { QueryKey } from './QueryKey.tsx'
9
+ import { QueryOptions } from './QueryOptions.tsx'
10
+
11
+ type Props = {
12
+ /**
13
+ * Name of the function
14
+ */
15
+ name: string
16
+ queryOptionsName: string
17
+ queryKeyName: string
18
+ queryKeyTypeName: string
19
+ typeSchemas: OperationSchemas
20
+ operation: Operation
21
+ paramsType: PluginSvelteQuery['resolvedOptions']['paramsType']
22
+ pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
23
+ dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType']
24
+ }
25
+
26
+ type GetParamsProps = {
27
+ paramsType: PluginSvelteQuery['resolvedOptions']['paramsType']
28
+ pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
29
+ dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType']
30
+ typeSchemas: OperationSchemas
31
+ }
32
+
33
+ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
34
+ const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
35
+
36
+ if (paramsType === 'object') {
37
+ return FunctionParams.factory({
38
+ data: {
39
+ mode: 'object',
40
+ children: {
41
+ ...getPathParams(typeSchemas.pathParams, { typed: true }),
42
+ data: typeSchemas.request?.name
43
+ ? {
44
+ type: typeSchemas.request?.name,
45
+ optional: isOptional(typeSchemas.request?.schema),
46
+ }
47
+ : undefined,
48
+ params: typeSchemas.queryParams?.name
49
+ ? {
50
+ type: typeSchemas.queryParams?.name,
51
+ optional: isOptional(typeSchemas.queryParams?.schema),
52
+ }
53
+ : undefined,
54
+ headers: typeSchemas.headerParams?.name
55
+ ? {
56
+ type: typeSchemas.headerParams?.name,
57
+ optional: isOptional(typeSchemas.headerParams?.schema),
58
+ }
59
+ : undefined,
60
+ },
61
+ },
62
+ options: {
63
+ type: `
64
+ {
65
+ query?: Partial<CreateBaseQueryOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>>,
66
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'}
67
+ }
68
+ `,
69
+ default: '{}',
70
+ },
71
+ })
72
+ }
73
+
74
+ return FunctionParams.factory({
75
+ pathParams: typeSchemas.pathParams?.name
76
+ ? {
77
+ mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
78
+ children: getPathParams(typeSchemas.pathParams, { typed: true }),
79
+ type: typeSchemas.pathParams?.name,
80
+ optional: isOptional(typeSchemas.pathParams?.schema),
81
+ }
82
+ : undefined,
83
+ data: typeSchemas.request?.name
84
+ ? {
85
+ type: typeSchemas.request?.name,
86
+ optional: isOptional(typeSchemas.request?.schema),
87
+ }
88
+ : undefined,
89
+ params: typeSchemas.queryParams?.name
90
+ ? {
91
+ type: typeSchemas.queryParams?.name,
92
+ optional: isOptional(typeSchemas.queryParams?.schema),
93
+ }
94
+ : undefined,
95
+ headers: typeSchemas.headerParams?.name
96
+ ? {
97
+ type: typeSchemas.headerParams?.name,
98
+ optional: isOptional(typeSchemas.headerParams?.schema),
99
+ }
100
+ : undefined,
101
+ options: {
102
+ type: `
103
+ {
104
+ query?: Partial<CreateBaseQueryOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>>,
105
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'}
106
+ }
107
+ `,
108
+ default: '{}',
109
+ },
110
+ })
111
+ }
112
+
113
+ export function Query({
114
+ name,
115
+ queryKeyTypeName,
116
+ queryOptionsName,
117
+ queryKeyName,
118
+ paramsType,
119
+ pathParamsType,
120
+ dataReturnType,
121
+ typeSchemas,
122
+ operation,
123
+ }: Props): ReactNode {
124
+ const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
125
+ const returnType = `CreateQueryResult<${['TData', typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'].join(', ')}> & { queryKey: TQueryKey }`
126
+ const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]
127
+
128
+ const queryKeyParams = QueryKey.getParams({
129
+ pathParamsType,
130
+ typeSchemas,
131
+ })
132
+ const queryOptionsParams = QueryOptions.getParams({
133
+ paramsType,
134
+ pathParamsType,
135
+ typeSchemas,
136
+ })
137
+ const params = getParams({
138
+ paramsType,
139
+ pathParamsType,
140
+ dataReturnType,
141
+ typeSchemas,
142
+ })
143
+
144
+ const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()}) as unknown as CreateBaseQueryOptions`
145
+
146
+ return (
147
+ <File.Source name={name} isExportable isIndexable>
148
+ <Function
149
+ name={name}
150
+ export
151
+ generics={generics.join(', ')}
152
+ params={params.toConstructor()}
153
+ JSDoc={{
154
+ comments: getComments(operation),
155
+ }}
156
+ >
157
+ {`
158
+ const { query: queryOptions, client: config = {} } = options ?? {}
159
+ const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
160
+
161
+ const query = createQuery({
162
+ ...${queryOptions},
163
+ queryKey,
164
+ ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
165
+ }) as ${returnType}
166
+
167
+ query.queryKey = queryKey as TQueryKey
168
+
169
+ return query
170
+ `}
171
+ </Function>
172
+ </File.Source>
173
+ )
174
+ }
175
+
176
+ Query.getParams = getParams
@@ -0,0 +1,83 @@
1
+ import { URLPath } from '@kubb/core/utils'
2
+ import { getPathParams } from '@kubb/plugin-oas/utils'
3
+ import { File, Function, FunctionParams, Type } from '@kubb/react'
4
+
5
+ import { type Operation, isOptional } from '@kubb/oas'
6
+ import type { OperationSchemas } from '@kubb/plugin-oas'
7
+ import type { ReactNode } from 'react'
8
+ import type { PluginSvelteQuery, Transformer } from '../types'
9
+
10
+ type Props = {
11
+ name: string
12
+ typeName: string
13
+ typeSchemas: OperationSchemas
14
+ operation: Operation
15
+ pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
16
+ transformer: Transformer | undefined
17
+ }
18
+
19
+ type GetParamsProps = {
20
+ pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
21
+ typeSchemas: OperationSchemas
22
+ }
23
+
24
+ function getParams({ pathParamsType, typeSchemas }: GetParamsProps) {
25
+ return FunctionParams.factory({
26
+ pathParams: {
27
+ mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
28
+ children: getPathParams(typeSchemas.pathParams, { typed: true }),
29
+ },
30
+ data: typeSchemas.request?.name
31
+ ? {
32
+ type: typeSchemas.request?.name,
33
+ optional: isOptional(typeSchemas.request?.schema),
34
+ }
35
+ : undefined,
36
+ params: typeSchemas.queryParams?.name
37
+ ? {
38
+ type: typeSchemas.queryParams?.name,
39
+ optional: isOptional(typeSchemas.queryParams?.schema),
40
+ }
41
+ : undefined,
42
+ })
43
+ }
44
+
45
+ const getTransformer: Transformer = ({ operation, schemas }) => {
46
+ const path = new URLPath(operation.path)
47
+ const keys = [
48
+ path.toObject({
49
+ type: 'path',
50
+ stringify: true,
51
+ }),
52
+ schemas.queryParams?.name ? '...(params ? [params] : [])' : undefined,
53
+ schemas.request?.name ? '...(data ? [data] : [])' : undefined,
54
+ ].filter(Boolean)
55
+
56
+ return keys
57
+ }
58
+
59
+ export function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
60
+ const params = getParams({ pathParamsType, typeSchemas })
61
+ const keys = transformer({
62
+ operation,
63
+ schemas: typeSchemas,
64
+ })
65
+
66
+ return (
67
+ <>
68
+ <File.Source name={name} isExportable isIndexable>
69
+ <Function.Arrow name={name} export params={params.toConstructor()} singleLine>
70
+ {`[${keys.join(', ')}] as const`}
71
+ </Function.Arrow>
72
+ </File.Source>
73
+ <File.Source name={typeName} isExportable isIndexable isTypeOnly>
74
+ <Type name={typeName} export>
75
+ {`ReturnType<typeof ${name}>`}
76
+ </Type>
77
+ </File.Source>
78
+ </>
79
+ )
80
+ }
81
+
82
+ QueryKey.getParams = getParams
83
+ QueryKey.getTransformer = getTransformer
@@ -0,0 +1,133 @@
1
+ import { getPathParams } from '@kubb/plugin-oas/utils'
2
+ import { File, Function, FunctionParams } from '@kubb/react'
3
+
4
+ import type { ReactNode } from 'react'
5
+
6
+ import { isOptional } from '@kubb/oas'
7
+ import { Client } from '@kubb/plugin-client/components'
8
+ import type { OperationSchemas } from '@kubb/plugin-oas'
9
+ import type { PluginSvelteQuery } from '../types.ts'
10
+ import { QueryKey } from './QueryKey.tsx'
11
+
12
+ type Props = {
13
+ name: string
14
+ clientName: string
15
+ queryKeyName: string
16
+ typeSchemas: OperationSchemas
17
+ paramsType: PluginSvelteQuery['resolvedOptions']['paramsType']
18
+ pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
19
+ }
20
+
21
+ type GetParamsProps = {
22
+ paramsType: PluginSvelteQuery['resolvedOptions']['paramsType']
23
+ pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
24
+ typeSchemas: OperationSchemas
25
+ }
26
+
27
+ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) {
28
+ if (paramsType === 'object') {
29
+ return FunctionParams.factory({
30
+ data: {
31
+ mode: 'object',
32
+ children: {
33
+ ...getPathParams(typeSchemas.pathParams, { typed: true }),
34
+ data: typeSchemas.request?.name
35
+ ? {
36
+ type: typeSchemas.request?.name,
37
+ optional: isOptional(typeSchemas.request?.schema),
38
+ }
39
+ : undefined,
40
+ params: typeSchemas.queryParams?.name
41
+ ? {
42
+ type: typeSchemas.queryParams?.name,
43
+ optional: isOptional(typeSchemas.queryParams?.schema),
44
+ }
45
+ : undefined,
46
+ headers: typeSchemas.headerParams?.name
47
+ ? {
48
+ type: typeSchemas.headerParams?.name,
49
+ optional: isOptional(typeSchemas.headerParams?.schema),
50
+ }
51
+ : undefined,
52
+ },
53
+ },
54
+ config: {
55
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>',
56
+ default: '{}',
57
+ },
58
+ })
59
+ }
60
+
61
+ return FunctionParams.factory({
62
+ pathParams: typeSchemas.pathParams?.name
63
+ ? {
64
+ mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
65
+ children: getPathParams(typeSchemas.pathParams, { typed: true }),
66
+ type: typeSchemas.pathParams?.name,
67
+ optional: isOptional(typeSchemas.pathParams?.schema),
68
+ }
69
+ : undefined,
70
+ data: typeSchemas.request?.name
71
+ ? {
72
+ type: typeSchemas.request?.name,
73
+ optional: isOptional(typeSchemas.request?.schema),
74
+ }
75
+ : undefined,
76
+ params: typeSchemas.queryParams?.name
77
+ ? {
78
+ type: typeSchemas.queryParams?.name,
79
+ optional: isOptional(typeSchemas.queryParams?.schema),
80
+ }
81
+ : undefined,
82
+ headers: typeSchemas.headerParams?.name
83
+ ? {
84
+ type: typeSchemas.headerParams?.name,
85
+ optional: isOptional(typeSchemas.headerParams?.schema),
86
+ }
87
+ : undefined,
88
+ config: {
89
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>',
90
+ default: '{}',
91
+ },
92
+ })
93
+ }
94
+
95
+ export function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsType, queryKeyName }: Props): ReactNode {
96
+ const params = getParams({ paramsType, pathParamsType, typeSchemas })
97
+ const clientParams = Client.getParams({
98
+ paramsType,
99
+ typeSchemas,
100
+ pathParamsType,
101
+ })
102
+ const queryKeyParams = QueryKey.getParams({
103
+ pathParamsType,
104
+ typeSchemas,
105
+ })
106
+
107
+ const enabled = Object.entries(queryKeyParams.flatParams)
108
+ .map(([key, item]) => (item && !item.optional ? key : undefined))
109
+ .filter(Boolean)
110
+ .join('&& ')
111
+
112
+ const enabledText = enabled ? `enabled: !!(${enabled})` : ''
113
+
114
+ return (
115
+ <File.Source name={name} isExportable isIndexable>
116
+ <Function name={name} export params={params.toConstructor()}>
117
+ {`
118
+ const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
119
+ return queryOptions({
120
+ ${enabledText}
121
+ queryKey,
122
+ queryFn: async ({ signal }) => {
123
+ config.signal = signal
124
+ return ${clientName}(${clientParams.toCall()})
125
+ },
126
+ })
127
+ `}
128
+ </Function>
129
+ </File.Source>
130
+ )
131
+ }
132
+
133
+ QueryOptions.getParams = getParams
@@ -0,0 +1,5 @@
1
+ export { Mutation } from './Mutation.tsx'
2
+ export { Query } from './Query.tsx'
3
+ export { QueryKey } from './QueryKey.tsx'
4
+ export { MutationKey } from './MutationKey.tsx'
5
+ export { QueryOptions } from './QueryOptions.tsx'
@@ -0,0 +1,51 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import type { RequestConfig, ResponseConfig } from "@kubb/plugin-client/client";
3
+ import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/svelte-query";
4
+ import { queryOptions, createQuery } from "@tanstack/svelte-query";
5
+
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
7
+
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
17
+ return { ...res, data: findPetsByTagsQueryResponse.parse(res.data) };
18
+ }
19
+
20
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
+ const queryKey = findPetsByTagsQueryKey(params);
22
+ return queryOptions({
23
+ queryKey,
24
+ queryFn: async ({ signal }) => {
25
+ config.signal = signal;
26
+ return findPetsByTags(headers, params, config);
27
+ },
28
+ });
29
+ }
30
+
31
+ /**
32
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
+ * @summary Finds Pets by tags
34
+ * @link /pet/findByTags
35
+ */
36
+ export function createFindPetsByTags<TData = ResponseConfig<FindPetsByTagsQueryResponse>, TQueryData = ResponseConfig<FindPetsByTagsQueryResponse>, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
37
+ query?: Partial<CreateBaseQueryOptions<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
38
+ client?: Partial<RequestConfig>;
39
+ } = {}) {
40
+ const { query: queryOptions, client: config = {} } = options ?? {};
41
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
42
+ const query = createQuery({
43
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions,
44
+ queryKey,
45
+ ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
46
+ }) as CreateQueryResult<TData, FindPetsByTags400> & {
47
+ queryKey: TQueryKey;
48
+ };
49
+ query.queryKey = queryKey as TQueryKey;
50
+ return query;
51
+ }
@@ -0,0 +1,51 @@
1
+ import client from "axios";
2
+ import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/svelte-query";
3
+ import type { RequestConfig } from "axios";
4
+ import { queryOptions, createQuery } from "@tanstack/svelte-query";
5
+
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
7
+
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
17
+ return findPetsByTagsQueryResponse.parse(res.data);
18
+ }
19
+
20
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
+ const queryKey = findPetsByTagsQueryKey(params);
22
+ return queryOptions({
23
+ queryKey,
24
+ queryFn: async ({ signal }) => {
25
+ config.signal = signal;
26
+ return findPetsByTags(headers, params, config);
27
+ },
28
+ });
29
+ }
30
+
31
+ /**
32
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
+ * @summary Finds Pets by tags
34
+ * @link /pet/findByTags
35
+ */
36
+ export function createFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
37
+ query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
38
+ client?: Partial<RequestConfig>;
39
+ } = {}) {
40
+ const { query: queryOptions, client: config = {} } = options ?? {};
41
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
42
+ const query = createQuery({
43
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions,
44
+ queryKey,
45
+ ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
46
+ }) as CreateQueryResult<TData, FindPetsByTags400> & {
47
+ queryKey: TQueryKey;
48
+ };
49
+ query.queryKey = queryKey as TQueryKey;
50
+ return query;
51
+ }
@@ -0,0 +1,44 @@
1
+ import client from "axios";
2
+ import type { CreateMutationOptions } from "@tanstack/svelte-query";
3
+ import type { RequestConfig } from "axios";
4
+ import { createMutation } from "@tanstack/svelte-query";
5
+
6
+ export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
7
+
8
+ export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>;
9
+
10
+ /**
11
+ * @summary Updates a pet in the store with form data
12
+ * @link /pet/:petId
13
+ */
14
+ async function updatePetWithForm(petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
15
+ const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({ method: "POST", url: `/pet/${petId}`, params, data, ...config });
16
+ return updatePetWithFormMutationResponse.parse(res.data);
17
+ }
18
+
19
+ /**
20
+ * @summary Updates a pet in the store with form data
21
+ * @link /pet/:petId
22
+ */
23
+ export function createUpdatePetWithForm(options: {
24
+ mutation?: CreateMutationOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
25
+ petId: UpdatePetWithFormPathParams["petId"];
26
+ data?: UpdatePetWithFormMutationRequest;
27
+ params?: UpdatePetWithFormQueryParams;
28
+ }>;
29
+ client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>;
30
+ } = {}) {
31
+ const { mutation: mutationOptions, client: config = {} } = options ?? {};
32
+ const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey();
33
+ return createMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
34
+ petId: UpdatePetWithFormPathParams["petId"];
35
+ data?: UpdatePetWithFormMutationRequest;
36
+ params?: UpdatePetWithFormQueryParams;
37
+ }>({
38
+ mutationFn: async ({ petId, data, params }) => {
39
+ return updatePetWithForm(petId, data, params, config);
40
+ },
41
+ mutationKey,
42
+ ...mutationOptions
43
+ });
44
+ }
@@ -0,0 +1,51 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import type { RequestConfig } from "@kubb/plugin-client/client";
3
+ import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/svelte-query";
4
+ import { queryOptions, createQuery } from "@tanstack/svelte-query";
5
+
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
7
+
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
17
+ return findPetsByTagsQueryResponse.parse(res.data);
18
+ }
19
+
20
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
+ const queryKey = findPetsByTagsQueryKey(params);
22
+ return queryOptions({
23
+ queryKey,
24
+ queryFn: async ({ signal }) => {
25
+ config.signal = signal;
26
+ return findPetsByTags(headers, params, config);
27
+ },
28
+ });
29
+ }
30
+
31
+ /**
32
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
+ * @summary Finds Pets by tags
34
+ * @link /pet/findByTags
35
+ */
36
+ export function createFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
37
+ query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
38
+ client?: Partial<RequestConfig>;
39
+ } = {}) {
40
+ const { query: queryOptions, client: config = {} } = options ?? {};
41
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
42
+ const query = createQuery({
43
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions,
44
+ queryKey,
45
+ ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
46
+ }) as CreateQueryResult<TData, FindPetsByTags400> & {
47
+ queryKey: TQueryKey;
48
+ };
49
+ query.queryKey = queryKey as TQueryKey;
50
+ return query;
51
+ }
@@ -0,0 +1,60 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import type { RequestConfig } from "@kubb/plugin-client/client";
3
+ import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/svelte-query";
4
+ import { queryOptions, createQuery } from "@tanstack/svelte-query";
5
+
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
7
+
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags({ headers, params }: {
16
+ headers: FindPetsByTagsHeaderParams;
17
+ params?: FindPetsByTagsQueryParams;
18
+ }, config: Partial<RequestConfig> = {}) {
19
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
20
+ return findPetsByTagsQueryResponse.parse(res.data);
21
+ }
22
+
23
+ export function findPetsByTagsQueryOptions({ headers, params }: {
24
+ headers: FindPetsByTagsHeaderParams;
25
+ params?: FindPetsByTagsQueryParams;
26
+ }, config: Partial<RequestConfig> = {}) {
27
+ const queryKey = findPetsByTagsQueryKey(params);
28
+ return queryOptions({
29
+ queryKey,
30
+ queryFn: async ({ signal }) => {
31
+ config.signal = signal;
32
+ return findPetsByTags({ headers, params }, config);
33
+ },
34
+ });
35
+ }
36
+
37
+ /**
38
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
39
+ * @summary Finds Pets by tags
40
+ * @link /pet/findByTags
41
+ */
42
+ export function createFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>({ headers, params }: {
43
+ headers: FindPetsByTagsHeaderParams;
44
+ params?: FindPetsByTagsQueryParams;
45
+ }, options: {
46
+ query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
47
+ client?: Partial<RequestConfig>;
48
+ } = {}) {
49
+ const { query: queryOptions, client: config = {} } = options ?? {};
50
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
51
+ const query = createQuery({
52
+ ...findPetsByTagsQueryOptions({ headers, params }, config) as unknown as CreateBaseQueryOptions,
53
+ queryKey,
54
+ ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
55
+ }) as CreateQueryResult<TData, FindPetsByTags400> & {
56
+ queryKey: TQueryKey;
57
+ };
58
+ query.queryKey = queryKey as TQueryKey;
59
+ return query;
60
+ }