@kubb/plugin-solid-query 3.0.0-alpha.20

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 (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +53 -0
  3. package/dist/chunk-7ZYWNHQM.js +291 -0
  4. package/dist/chunk-7ZYWNHQM.js.map +1 -0
  5. package/dist/chunk-D6TNFQR6.js +285 -0
  6. package/dist/chunk-D6TNFQR6.js.map +1 -0
  7. package/dist/chunk-KBTDHYL2.cjs +298 -0
  8. package/dist/chunk-KBTDHYL2.cjs.map +1 -0
  9. package/dist/chunk-WIE2QWZT.cjs +291 -0
  10. package/dist/chunk-WIE2QWZT.cjs.map +1 -0
  11. package/dist/components.cjs +20 -0
  12. package/dist/components.cjs.map +1 -0
  13. package/dist/components.d.cts +64 -0
  14. package/dist/components.d.ts +64 -0
  15. package/dist/components.js +3 -0
  16. package/dist/components.js.map +1 -0
  17. package/dist/generators.cjs +13 -0
  18. package/dist/generators.cjs.map +1 -0
  19. package/dist/generators.d.cts +8 -0
  20. package/dist/generators.d.ts +8 -0
  21. package/dist/generators.js +4 -0
  22. package/dist/generators.js.map +1 -0
  23. package/dist/index.cjs +125 -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 +118 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/types-DlkKXn9W.d.cts +128 -0
  30. package/dist/types-DlkKXn9W.d.ts +128 -0
  31. package/package.json +102 -0
  32. package/src/components/Query.tsx +121 -0
  33. package/src/components/QueryKey.tsx +73 -0
  34. package/src/components/QueryOptions.tsx +84 -0
  35. package/src/components/index.ts +3 -0
  36. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +51 -0
  37. package/src/generators/__snapshots__/clientGetImportPath.ts +51 -0
  38. package/src/generators/__snapshots__/findByTags.ts +51 -0
  39. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +51 -0
  40. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +51 -0
  41. package/src/generators/__snapshots__/findByTagsWithZod.ts +51 -0
  42. package/src/generators/__snapshots__/postAsQuery.ts +49 -0
  43. package/src/generators/index.ts +1 -0
  44. package/src/generators/queryGenerator.tsx +121 -0
  45. package/src/index.ts +2 -0
  46. package/src/plugin.ts +137 -0
  47. package/src/types.ts +132 -0
@@ -0,0 +1,121 @@
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 { PluginSolidQuery } 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
+ pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']
22
+ dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']
23
+ }
24
+
25
+ type GetParamsProps = {
26
+ pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']
27
+ dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']
28
+ typeSchemas: OperationSchemas
29
+ }
30
+
31
+ function getParams({ pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
32
+ const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
33
+
34
+ return FunctionParams.factory({
35
+ pathParams: {
36
+ mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
37
+ children: getPathParams(typeSchemas.pathParams, { typed: true }),
38
+ },
39
+ data: typeSchemas.request?.name
40
+ ? {
41
+ type: typeSchemas.request?.name,
42
+ optional: isOptional(typeSchemas.request?.schema),
43
+ }
44
+ : undefined,
45
+ params: typeSchemas.queryParams?.name
46
+ ? {
47
+ type: typeSchemas.queryParams?.name,
48
+ optional: isOptional(typeSchemas.queryParams?.schema),
49
+ }
50
+ : undefined,
51
+ headers: typeSchemas.headerParams?.name
52
+ ? {
53
+ type: typeSchemas.headerParams?.name,
54
+ optional: isOptional(typeSchemas.headerParams?.schema),
55
+ }
56
+ : undefined,
57
+ options: {
58
+ type: `
59
+ {
60
+ query?: Partial<CreateBaseQueryOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'unknown', 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>>,
61
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'}
62
+ }
63
+ `,
64
+ default: '{}',
65
+ },
66
+ })
67
+ }
68
+
69
+ export function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, pathParamsType, dataReturnType, typeSchemas, operation }: Props): ReactNode {
70
+ const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
71
+ const returnType = `CreateQueryResult<${['TData', typeSchemas.errors?.map((item) => item.name).join(' | ') || 'unknown'].join(', ')}> & { queryKey: TQueryKey }`
72
+ const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]
73
+
74
+ const queryKeyParams = QueryKey.getParams({
75
+ pathParamsType,
76
+ typeSchemas,
77
+ })
78
+ const queryOptionsParams = QueryOptions.getParams({
79
+ pathParamsType,
80
+ typeSchemas,
81
+ })
82
+ const params = getParams({
83
+ pathParamsType,
84
+ dataReturnType,
85
+ typeSchemas,
86
+ })
87
+
88
+ const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()}) as unknown as CreateBaseQueryOptions`
89
+
90
+ return (
91
+ <File.Source name={name} isExportable isIndexable>
92
+ <Function
93
+ name={name}
94
+ export
95
+ generics={generics.join(', ')}
96
+ params={params.toConstructor()}
97
+ JSDoc={{
98
+ comments: getComments(operation),
99
+ }}
100
+ >
101
+ {`
102
+ const { query: queryOptions, client: config = {} } = options ?? {}
103
+ const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
104
+
105
+ const query = createQuery(() => ({
106
+ ...${queryOptions},
107
+ queryKey,
108
+ initialData: null,
109
+ ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
110
+ })) as ${returnType}
111
+
112
+ query.queryKey = queryKey as TQueryKey
113
+
114
+ return query
115
+ `}
116
+ </Function>
117
+ </File.Source>
118
+ )
119
+ }
120
+
121
+ Query.getParams = getParams
@@ -0,0 +1,73 @@
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 { PluginSolidQuery } from '../types'
9
+
10
+ type Props = {
11
+ name: string
12
+ typeName: string
13
+ typeSchemas: OperationSchemas
14
+ operation: Operation
15
+ pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']
16
+ keysFn: ((keys: unknown[]) => unknown[]) | undefined
17
+ }
18
+
19
+ type GetParamsProps = {
20
+ pathParamsType: PluginSolidQuery['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
+ export function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, keysFn = (name) => name }: Props): ReactNode {
46
+ const path = new URLPath(operation.path)
47
+ const params = getParams({ pathParamsType, typeSchemas })
48
+ const keys = [
49
+ path.toObject({
50
+ type: 'path',
51
+ stringify: true,
52
+ }),
53
+ typeSchemas.queryParams?.name ? '...(params ? [params] : [])' : undefined,
54
+ typeSchemas.request?.name ? '...(data ? [data] : [])' : undefined,
55
+ ].filter(Boolean)
56
+
57
+ return (
58
+ <>
59
+ <File.Source name={name} isExportable isIndexable>
60
+ <Function.Arrow name={name} export params={params.toConstructor()} singleLine>
61
+ {`[${keysFn(keys).join(', ')}] as const`}
62
+ </Function.Arrow>
63
+ </File.Source>
64
+ <File.Source name={typeName} isExportable isIndexable isTypeOnly>
65
+ <Type name={typeName} export>
66
+ {`ReturnType<typeof ${name}>`}
67
+ </Type>
68
+ </File.Source>
69
+ </>
70
+ )
71
+ }
72
+
73
+ QueryKey.getParams = getParams
@@ -0,0 +1,84 @@
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 { PluginSolidQuery } 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
+ pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']
18
+ }
19
+
20
+ type GetParamsProps = {
21
+ pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']
22
+ typeSchemas: OperationSchemas
23
+ }
24
+
25
+ function getParams({ pathParamsType, typeSchemas }: GetParamsProps) {
26
+ return FunctionParams.factory({
27
+ pathParams: {
28
+ mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
29
+ children: getPathParams(typeSchemas.pathParams, { typed: true }),
30
+ },
31
+ data: typeSchemas.request?.name
32
+ ? {
33
+ type: typeSchemas.request?.name,
34
+ optional: isOptional(typeSchemas.request?.schema),
35
+ }
36
+ : undefined,
37
+ params: typeSchemas.queryParams?.name
38
+ ? {
39
+ type: typeSchemas.queryParams?.name,
40
+ optional: isOptional(typeSchemas.queryParams?.schema),
41
+ }
42
+ : undefined,
43
+ headers: typeSchemas.headerParams?.name
44
+ ? {
45
+ type: typeSchemas.headerParams?.name,
46
+ optional: isOptional(typeSchemas.headerParams?.schema),
47
+ }
48
+ : undefined,
49
+ config: {
50
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>',
51
+ default: '{}',
52
+ },
53
+ })
54
+ }
55
+
56
+ export function QueryOptions({ name, clientName, typeSchemas, pathParamsType, queryKeyName }: Props): ReactNode {
57
+ const params = getParams({ pathParamsType, typeSchemas })
58
+ const clientParams = Client.getParams({
59
+ typeSchemas,
60
+ pathParamsType,
61
+ })
62
+ const queryKeyParams = QueryKey.getParams({
63
+ pathParamsType,
64
+ typeSchemas,
65
+ })
66
+
67
+ return (
68
+ <File.Source name={name} isExportable isIndexable>
69
+ <Function name={name} export params={params.toConstructor()}>
70
+ {`
71
+ const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
72
+ return queryOptions({
73
+ queryKey,
74
+ queryFn: async () => {
75
+ return ${clientName}(${clientParams.toCall()})
76
+ },
77
+ })
78
+ `}
79
+ </Function>
80
+ </File.Source>
81
+ )
82
+ }
83
+
84
+ QueryOptions.getParams = getParams
@@ -0,0 +1,3 @@
1
+ export { Query } from './Query.tsx'
2
+ export { QueryKey } from './QueryKey.tsx'
3
+ 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 { createQuery, queryOptions } 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 () => {
25
+ return findPetsByTags(headers, params, config);
26
+ },
27
+ });
28
+ }
29
+
30
+ /**
31
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
32
+ * @summary Finds Pets by tags
33
+ * @link /pet/findByTags
34
+ */
35
+ export function createFindPetsByTags<TData = ResponseConfig<FindPetsByTagsQueryResponse>, TQueryData = ResponseConfig<FindPetsByTagsQueryResponse>, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
36
+ query?: Partial<CreateBaseQueryOptions<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
37
+ client?: Partial<RequestConfig>;
38
+ } = {}) {
39
+ const { query: queryOptions, client: config = {} } = options ?? {};
40
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
41
+ const query = createQuery(() => ({
42
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions,
43
+ queryKey,
44
+ initialData: null,
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 { createQuery, queryOptions } 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 () => {
25
+ return findPetsByTags(headers, params, config);
26
+ },
27
+ });
28
+ }
29
+
30
+ /**
31
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
32
+ * @summary Finds Pets by tags
33
+ * @link /pet/findByTags
34
+ */
35
+ export function createFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
36
+ query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
37
+ client?: Partial<RequestConfig>;
38
+ } = {}) {
39
+ const { query: queryOptions, client: config = {} } = options ?? {};
40
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
41
+ const query = createQuery(() => ({
42
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions,
43
+ queryKey,
44
+ initialData: null,
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 "@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 { createQuery, queryOptions } 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 () => {
25
+ return findPetsByTags(headers, params, config);
26
+ },
27
+ });
28
+ }
29
+
30
+ /**
31
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
32
+ * @summary Finds Pets by tags
33
+ * @link /pet/findByTags
34
+ */
35
+ export function createFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
36
+ query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
37
+ client?: Partial<RequestConfig>;
38
+ } = {}) {
39
+ const { query: queryOptions, client: config = {} } = options ?? {};
40
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
41
+ const query = createQuery(() => ({
42
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions,
43
+ queryKey,
44
+ initialData: null,
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 "@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 { createQuery, queryOptions } 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 () => {
25
+ return findPetsByTags(headers, params, config);
26
+ },
27
+ });
28
+ }
29
+
30
+ /**
31
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
32
+ * @summary Finds Pets by tags
33
+ * @link /pet/findByTags
34
+ */
35
+ export function createFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
36
+ query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
37
+ client?: Partial<RequestConfig>;
38
+ } = {}) {
39
+ const { query: queryOptions, client: config = {} } = options ?? {};
40
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
41
+ const query = createQuery(() => ({
42
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions,
43
+ queryKey,
44
+ initialData: null,
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 "@kubb/plugin-client/client";
2
+ import type { RequestConfig } from "@kubb/plugin-client/client";
3
+ import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/react-query";
4
+ import { createQuery, queryOptions } from "@tanstack/react-query";
5
+
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [test, { 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 () => {
25
+ return findPetsByTags(headers, params, config);
26
+ },
27
+ });
28
+ }
29
+
30
+ /**
31
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
32
+ * @summary Finds Pets by tags
33
+ * @link /pet/findByTags
34
+ */
35
+ export function createFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
36
+ query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
37
+ client?: Partial<RequestConfig>;
38
+ } = {}) {
39
+ const { query: queryOptions, client: config = {} } = options ?? {};
40
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
41
+ const query = createQuery(() => ({
42
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions,
43
+ queryKey,
44
+ initialData: null,
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 "@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 { createQuery, queryOptions } 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 () => {
25
+ return findPetsByTags(headers, params, config);
26
+ },
27
+ });
28
+ }
29
+
30
+ /**
31
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
32
+ * @summary Finds Pets by tags
33
+ * @link /pet/findByTags
34
+ */
35
+ export function createFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
36
+ query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
37
+ client?: Partial<RequestConfig>;
38
+ } = {}) {
39
+ const { query: queryOptions, client: config = {} } = options ?? {};
40
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
41
+ const query = createQuery(() => ({
42
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions,
43
+ queryKey,
44
+ initialData: null,
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,49 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import type { RequestConfig } from "@kubb/plugin-client/client";
3
+ import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "custom-query";
4
+ import { createQuery, queryOptions } from "custom-query";
5
+
6
+ export const updatePetWithFormQueryKey = (petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams) => [{ url: "/pet/:petId", params: { petId: petId } }, ...(params ? [params] : []), ...(data ? [data] : [])] as const;
7
+
8
+ export type UpdatePetWithFormQueryKey = ReturnType<typeof updatePetWithFormQueryKey>;
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
+ export function updatePetWithFormQueryOptions(petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
20
+ const queryKey = updatePetWithFormQueryKey(petId, data, params);
21
+ return queryOptions({
22
+ queryKey,
23
+ queryFn: async () => {
24
+ return updatePetWithForm(petId, data, params, config);
25
+ },
26
+ });
27
+ }
28
+
29
+ /**
30
+ * @summary Updates a pet in the store with form data
31
+ * @link /pet/:petId
32
+ */
33
+ export function createUpdatePetWithForm<TData = UpdatePetWithFormMutationResponse, TQueryData = UpdatePetWithFormMutationResponse, TQueryKey extends QueryKey = UpdatePetWithFormQueryKey>(petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, options: {
34
+ query?: Partial<CreateBaseQueryOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, TData, TQueryData, TQueryKey>>;
35
+ client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>;
36
+ } = {}) {
37
+ const { query: queryOptions, client: config = {} } = options ?? {};
38
+ const queryKey = queryOptions?.queryKey ?? updatePetWithFormQueryKey(petId, data, params);
39
+ const query = createQuery(() => ({
40
+ ...updatePetWithFormQueryOptions(petId, data, params, config) as unknown as CreateBaseQueryOptions,
41
+ queryKey,
42
+ initialData: null,
43
+ ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
44
+ })) as CreateQueryResult<TData, UpdatePetWithForm405> & {
45
+ queryKey: TQueryKey;
46
+ };
47
+ query.queryKey = queryKey as TQueryKey;
48
+ return query;
49
+ }
@@ -0,0 +1 @@
1
+ export { queryGenerator } from './queryGenerator.tsx'