@kubb/plugin-solid-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 (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +53 -0
  3. package/dist/chunk-34VWVEUR.js +341 -0
  4. package/dist/chunk-34VWVEUR.js.map +1 -0
  5. package/dist/chunk-36LQSNHS.js +400 -0
  6. package/dist/chunk-36LQSNHS.js.map +1 -0
  7. package/dist/chunk-642OIIJK.cjs +347 -0
  8. package/dist/chunk-642OIIJK.cjs.map +1 -0
  9. package/dist/chunk-Y6RUU6PO.cjs +406 -0
  10. package/dist/chunk-Y6RUU6PO.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 +69 -0
  14. package/dist/components.d.ts +69 -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 +119 -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 +112 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/types-DXL9Aw6E.d.cts +339 -0
  30. package/dist/types-DXL9Aw6E.d.ts +339 -0
  31. package/package.json +102 -0
  32. package/src/components/Query.tsx +177 -0
  33. package/src/components/QueryKey.tsx +83 -0
  34. package/src/components/QueryOptions.tsx +133 -0
  35. package/src/components/index.ts +3 -0
  36. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +52 -0
  37. package/src/generators/__snapshots__/clientGetImportPath.ts +52 -0
  38. package/src/generators/__snapshots__/findByTags.ts +52 -0
  39. package/src/generators/__snapshots__/findByTagsObject.ts +61 -0
  40. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +52 -0
  41. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +52 -0
  42. package/src/generators/__snapshots__/findByTagsWithZod.ts +52 -0
  43. package/src/generators/__snapshots__/postAsQuery.ts +51 -0
  44. package/src/generators/index.ts +1 -0
  45. package/src/generators/queryGenerator.tsx +127 -0
  46. package/src/index.ts +2 -0
  47. package/src/plugin.ts +133 -0
  48. package/src/types.ts +106 -0
@@ -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 { 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
+ paramsType: PluginSolidQuery['resolvedOptions']['paramsType']
18
+ pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']
19
+ }
20
+
21
+ type GetParamsProps = {
22
+ paramsType: PluginSolidQuery['resolvedOptions']['paramsType']
23
+ pathParamsType: PluginSolidQuery['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
+ typeSchemas,
99
+ paramsType,
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,3 @@
1
+ export { Query } from './Query.tsx'
2
+ export { QueryKey } from './QueryKey.tsx'
3
+ export { QueryOptions } from './QueryOptions.tsx'
@@ -0,0 +1,52 @@
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
+ initialData: null,
46
+ ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
47
+ })) as CreateQueryResult<TData, FindPetsByTags400> & {
48
+ queryKey: TQueryKey;
49
+ };
50
+ query.queryKey = queryKey as TQueryKey;
51
+ return query;
52
+ }
@@ -0,0 +1,52 @@
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
+ initialData: null,
46
+ ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
47
+ })) as CreateQueryResult<TData, FindPetsByTags400> & {
48
+ queryKey: TQueryKey;
49
+ };
50
+ query.queryKey = queryKey as TQueryKey;
51
+ return query;
52
+ }
@@ -0,0 +1,52 @@
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
+ initialData: null,
46
+ ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
47
+ })) as CreateQueryResult<TData, FindPetsByTags400> & {
48
+ queryKey: TQueryKey;
49
+ };
50
+ query.queryKey = queryKey as TQueryKey;
51
+ return query;
52
+ }
@@ -0,0 +1,61 @@
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
+ initialData: null,
55
+ ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
56
+ })) as CreateQueryResult<TData, FindPetsByTags400> & {
57
+ queryKey: TQueryKey;
58
+ };
59
+ query.queryKey = queryKey as TQueryKey;
60
+ return query;
61
+ }
@@ -0,0 +1,52 @@
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
+ initialData: null,
46
+ ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
47
+ })) as CreateQueryResult<TData, FindPetsByTags400> & {
48
+ queryKey: TQueryKey;
49
+ };
50
+ query.queryKey = queryKey as TQueryKey;
51
+ return query;
52
+ }
@@ -0,0 +1,52 @@
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 { queryOptions, createQuery } 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 ({ 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
+ initialData: null,
46
+ ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
47
+ })) as CreateQueryResult<TData, FindPetsByTags400> & {
48
+ queryKey: TQueryKey;
49
+ };
50
+ query.queryKey = queryKey as TQueryKey;
51
+ return query;
52
+ }
@@ -0,0 +1,52 @@
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
+ initialData: null,
46
+ ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
47
+ })) as CreateQueryResult<TData, FindPetsByTags400> & {
48
+ queryKey: TQueryKey;
49
+ };
50
+ query.queryKey = queryKey as TQueryKey;
51
+ return query;
52
+ }
@@ -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 "custom-query";
4
+ import { queryOptions, createQuery } 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
+ enabled: !!(petId),
23
+ queryKey,
24
+ queryFn: async ({ signal }) => {
25
+ config.signal = signal;
26
+ return updatePetWithForm(petId, data, params, config);
27
+ },
28
+ });
29
+ }
30
+
31
+ /**
32
+ * @summary Updates a pet in the store with form data
33
+ * @link /pet/:petId
34
+ */
35
+ export function createUpdatePetWithForm<TData = UpdatePetWithFormMutationResponse, TQueryData = UpdatePetWithFormMutationResponse, TQueryKey extends QueryKey = UpdatePetWithFormQueryKey>(petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, options: {
36
+ query?: Partial<CreateBaseQueryOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, TData, TQueryData, TQueryKey>>;
37
+ client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>;
38
+ } = {}) {
39
+ const { query: queryOptions, client: config = {} } = options ?? {};
40
+ const queryKey = queryOptions?.queryKey ?? updatePetWithFormQueryKey(petId, data, params);
41
+ const query = createQuery(() => ({
42
+ ...updatePetWithFormQueryOptions(petId, data, params, config) as unknown as CreateBaseQueryOptions,
43
+ queryKey,
44
+ initialData: null,
45
+ ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
46
+ })) as CreateQueryResult<TData, UpdatePetWithForm405> & {
47
+ queryKey: TQueryKey;
48
+ };
49
+ query.queryKey = queryKey as TQueryKey;
50
+ return query;
51
+ }
@@ -0,0 +1 @@
1
+ export { queryGenerator } from './queryGenerator.tsx'