@kubb/plugin-svelte-query 3.2.0 → 3.3.1

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.
@@ -1,50 +1,80 @@
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";
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
3
+ import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from 'custom-query'
4
+ import { queryOptions, createQuery } from 'custom-query'
5
5
 
6
- export const updatePetWithFormQueryKey = (petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams) => [{ url: "/pet/:petId", params: { petId: petId } }, ...(params ? [params] : []), ...(data ? [data] : [])] as const;
6
+ export const updatePetWithFormQueryKey = (
7
+ petId: UpdatePetWithFormPathParams['petId'],
8
+ data?: UpdatePetWithFormMutationRequest,
9
+ params?: UpdatePetWithFormQueryParams,
10
+ ) => [{ url: '/pet/:petId', params: { petId: petId } }, ...(params ? [params] : []), ...(data ? [data] : [])] as const
7
11
 
8
- export type UpdatePetWithFormQueryKey = ReturnType<typeof updatePetWithFormQueryKey>;
12
+ export type UpdatePetWithFormQueryKey = ReturnType<typeof updatePetWithFormQueryKey>
9
13
 
10
- /**
14
+ /**
11
15
  * @summary Updates a pet in the store with form data
12
16
  * {@link /pet/:petId}
13
17
  */
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);
18
+ async function updatePetWithForm(
19
+ petId: UpdatePetWithFormPathParams['petId'],
20
+ data?: UpdatePetWithFormMutationRequest,
21
+ params?: UpdatePetWithFormQueryParams,
22
+ config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
23
+ ) {
24
+ const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({
25
+ method: 'POST',
26
+ url: `/pet/${petId}`,
27
+ params,
28
+ data,
29
+ ...config,
30
+ })
31
+ return updatePetWithFormMutationResponse.parse(res.data)
17
32
  }
18
33
 
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
- });
34
+ export function updatePetWithFormQueryOptions(
35
+ petId: UpdatePetWithFormPathParams['petId'],
36
+ data?: UpdatePetWithFormMutationRequest,
37
+ params?: UpdatePetWithFormQueryParams,
38
+ config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
39
+ ) {
40
+ const queryKey = updatePetWithFormQueryKey(petId, data, params)
41
+ return queryOptions({
42
+ enabled: !!petId,
43
+ queryKey,
44
+ queryFn: async ({ signal }) => {
45
+ config.signal = signal
46
+ return updatePetWithForm(petId, data, params, config)
47
+ },
48
+ })
29
49
  }
30
50
 
31
- /**
51
+ /**
32
52
  * @summary Updates a pet in the store with form data
33
53
  * {@link /pet/:petId}
34
54
  */
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
- ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
45
- }) as CreateQueryResult<TData, UpdatePetWithForm405> & {
46
- queryKey: TQueryKey;
47
- };
48
- query.queryKey = queryKey as TQueryKey;
49
- return query;
55
+ export function createUpdatePetWithForm<
56
+ TData = UpdatePetWithFormMutationResponse,
57
+ TQueryData = UpdatePetWithFormMutationResponse,
58
+ TQueryKey extends QueryKey = UpdatePetWithFormQueryKey,
59
+ >(
60
+ petId: UpdatePetWithFormPathParams['petId'],
61
+ data?: UpdatePetWithFormMutationRequest,
62
+ params?: UpdatePetWithFormQueryParams,
63
+ options: {
64
+ query?: Partial<CreateBaseQueryOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, TData, TQueryData, TQueryKey>>
65
+ client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>
66
+ } = {},
67
+ ) {
68
+ const { query: queryOptions, client: config = {} } = options ?? {}
69
+ const queryKey = queryOptions?.queryKey ?? updatePetWithFormQueryKey(petId, data, params)
70
+
71
+ const query = createQuery({
72
+ ...(updatePetWithFormQueryOptions(petId, data, params, config) as unknown as CreateBaseQueryOptions),
73
+ queryKey,
74
+ ...(queryOptions as unknown as Omit<CreateBaseQueryOptions, 'queryKey'>),
75
+ }) as CreateQueryResult<TData, UpdatePetWithForm405> & { queryKey: TQueryKey }
76
+
77
+ query.queryKey = queryKey as TQueryKey
78
+
79
+ return query
50
80
  }
@@ -1,44 +1,58 @@
1
- import client from "@kubb/plugin-client/client";
2
- import type { RequestConfig } from "@kubb/plugin-client/client";
3
- import type { CreateMutationOptions } from "@tanstack/svelte-query";
4
- import { createMutation } from "@tanstack/svelte-query";
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
3
+ import type { CreateMutationOptions } from '@tanstack/svelte-query'
4
+ import { createMutation } from '@tanstack/svelte-query'
5
5
 
6
- export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
6
+ export const updatePetWithFormMutationKey = () => [{ url: '/pet/{petId}' }] as const
7
7
 
8
- export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>;
8
+ export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>
9
9
 
10
- /**
10
+ /**
11
11
  * @summary Updates a pet in the store with form data
12
12
  * {@link /pet/:petId}
13
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);
14
+ async function updatePetWithForm(
15
+ petId: UpdatePetWithFormPathParams['petId'],
16
+ data?: UpdatePetWithFormMutationRequest,
17
+ params?: UpdatePetWithFormQueryParams,
18
+ config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
19
+ ) {
20
+ const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({
21
+ method: 'POST',
22
+ url: `/pet/${petId}`,
23
+ params,
24
+ data,
25
+ ...config,
26
+ })
27
+ return updatePetWithFormMutationResponse.parse(res.data)
17
28
  }
18
29
 
19
- /**
30
+ /**
20
31
  * @summary Updates a pet in the store with form data
21
32
  * {@link /pet/:petId}
22
33
  */
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
- });
34
+ export function createUpdatePetWithForm(
35
+ options: {
36
+ mutation?: CreateMutationOptions<
37
+ UpdatePetWithFormMutationResponse,
38
+ UpdatePetWithForm405,
39
+ { petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams }
40
+ >
41
+ client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>
42
+ } = {},
43
+ ) {
44
+ const { mutation: mutationOptions, client: config = {} } = options ?? {}
45
+ const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey()
46
+
47
+ return createMutation<
48
+ UpdatePetWithFormMutationResponse,
49
+ UpdatePetWithForm405,
50
+ { petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams }
51
+ >({
52
+ mutationFn: async ({ petId, data, params }) => {
53
+ return updatePetWithForm(petId, data, params, config)
54
+ },
55
+ mutationKey,
56
+ ...mutationOptions,
57
+ })
44
58
  }
@@ -1,46 +1,58 @@
1
- import client from "@kubb/plugin-client/client";
2
- import type { RequestConfig } from "@kubb/plugin-client/client";
3
- import type { CreateMutationOptions } from "@tanstack/svelte-query";
4
- import { createMutation } from "@tanstack/svelte-query";
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
3
+ import type { CreateMutationOptions } from '@tanstack/svelte-query'
4
+ import { createMutation } from '@tanstack/svelte-query'
5
5
 
6
- export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
6
+ export const updatePetWithFormMutationKey = () => [{ url: '/pet/{petId}' }] as const
7
7
 
8
- export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>;
8
+ export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>
9
9
 
10
- /**
10
+ /**
11
11
  * @summary Updates a pet in the store with form data
12
12
  * {@link /pet/:petId}
13
13
  */
14
- async function updatePetWithForm({ petId }: {
15
- petId: UpdatePetWithFormPathParams["petId"];
16
- }, data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
17
- const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({ method: "POST", url: `/pet/${petId}`, params, data, ...config });
18
- return updatePetWithFormMutationResponse.parse(res.data);
14
+ async function updatePetWithForm(
15
+ { petId }: { petId: UpdatePetWithFormPathParams['petId'] },
16
+ data?: UpdatePetWithFormMutationRequest,
17
+ params?: UpdatePetWithFormQueryParams,
18
+ config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
19
+ ) {
20
+ const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({
21
+ method: 'POST',
22
+ url: `/pet/${petId}`,
23
+ params,
24
+ data,
25
+ ...config,
26
+ })
27
+ return updatePetWithFormMutationResponse.parse(res.data)
19
28
  }
20
29
 
21
- /**
30
+ /**
22
31
  * @summary Updates a pet in the store with form data
23
32
  * {@link /pet/:petId}
24
33
  */
25
- export function createUpdatePetWithForm(options: {
26
- mutation?: CreateMutationOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
27
- petId: UpdatePetWithFormPathParams["petId"];
28
- data?: UpdatePetWithFormMutationRequest;
29
- params?: UpdatePetWithFormQueryParams;
30
- }>;
31
- client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>;
32
- } = {}) {
33
- const { mutation: mutationOptions, client: config = {} } = options ?? {};
34
- const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey();
35
- return createMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
36
- petId: UpdatePetWithFormPathParams["petId"];
37
- data?: UpdatePetWithFormMutationRequest;
38
- params?: UpdatePetWithFormQueryParams;
39
- }>({
40
- mutationFn: async ({ petId, data, params }) => {
41
- return updatePetWithForm({ petId }, data, params, config);
42
- },
43
- mutationKey,
44
- ...mutationOptions
45
- });
34
+ export function createUpdatePetWithForm(
35
+ options: {
36
+ mutation?: CreateMutationOptions<
37
+ UpdatePetWithFormMutationResponse,
38
+ UpdatePetWithForm405,
39
+ { petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams }
40
+ >
41
+ client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>
42
+ } = {},
43
+ ) {
44
+ const { mutation: mutationOptions, client: config = {} } = options ?? {}
45
+ const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey()
46
+
47
+ return createMutation<
48
+ UpdatePetWithFormMutationResponse,
49
+ UpdatePetWithForm405,
50
+ { petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams }
51
+ >({
52
+ mutationFn: async ({ petId, data, params }) => {
53
+ return updatePetWithForm({ petId }, data, params, config)
54
+ },
55
+ mutationKey,
56
+ ...mutationOptions,
57
+ })
46
58
  }
package/src/plugin.ts CHANGED
@@ -39,7 +39,7 @@ export const pluginSvelteQuery = createPlugin<PluginSvelteQuery>((options) => {
39
39
  options: {
40
40
  output,
41
41
  client: {
42
- importPath: '@kubb/plugin-client/client',
42
+ importPath: '@kubb/plugin-client/clients/axios',
43
43
  dataReturnType: 'data',
44
44
  pathParamsType: 'inline',
45
45
  ...options.client,