@htkimura/files-storage-backend.rest-client 0.0.19 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{src/generated/model/createUserDto.ts → dist/generated/model/createUserDto.d.ts} +2 -3
- package/dist/generated/model/createUserDto.js +8 -0
- package/{src/generated/model/index.ts → dist/generated/model/index.d.ts} +1 -2
- package/dist/generated/model/index.js +13 -0
- package/{src/generated/model/loginDto.ts → dist/generated/model/loginDto.d.ts} +2 -3
- package/dist/generated/model/loginDto.js +8 -0
- package/{src/generated/model/refreshTokenDto.ts → dist/generated/model/refreshTokenDto.d.ts} +1 -2
- package/dist/generated/model/refreshTokenDto.js +8 -0
- package/{src/generated/model/storageControllerGetPresignedUrlParams.ts → dist/generated/model/storageControllerGetPresignedUrlParams.d.ts} +3 -4
- package/dist/generated/model/storageControllerGetPresignedUrlParams.js +8 -0
- package/{src/generated/model/user.ts → dist/generated/model/user.d.ts} +4 -5
- package/dist/generated/model/user.js +8 -0
- package/{src/generated/model/userLogin.ts → dist/generated/model/userLogin.d.ts} +3 -4
- package/dist/generated/model/userLogin.js +1 -0
- package/dist/generated/storage/storage.d.ts +19 -0
- package/dist/generated/storage/storage.js +30 -0
- package/dist/generated/user/user.d.ts +130 -0
- package/dist/generated/user/user.js +140 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/package.json +12 -10
- package/src/generated/index.ts +0 -3
- package/src/generated/storage/storage.ts +0 -85
- package/src/generated/user/user.ts +0 -343
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
* This API is for storing files for different users
|
|
6
6
|
* OpenAPI spec version: 1.0
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
8
|
export * from './createUserDto';
|
|
10
9
|
export * from './loginDto';
|
|
11
10
|
export * from './refreshTokenDto';
|
|
12
11
|
export * from './storageControllerGetPresignedUrlParams';
|
|
13
12
|
export * from './user';
|
|
14
|
-
export * from './userLogin';
|
|
13
|
+
export * from './userLogin';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.4.1 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* files-storage
|
|
5
|
+
* This API is for storing files for different users
|
|
6
|
+
* OpenAPI spec version: 1.0
|
|
7
|
+
*/
|
|
8
|
+
export * from './createUserDto';
|
|
9
|
+
export * from './loginDto';
|
|
10
|
+
export * from './refreshTokenDto';
|
|
11
|
+
export * from './storageControllerGetPresignedUrlParams';
|
|
12
|
+
export * from './user';
|
|
13
|
+
export * from './userLogin';
|
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
* This API is for storing files for different users
|
|
6
6
|
* OpenAPI spec version: 1.0
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
8
|
export type StorageControllerGetPresignedUrlParams = {
|
|
10
|
-
fileName: string;
|
|
11
|
-
fileType: string;
|
|
12
|
-
fileSize: number;
|
|
9
|
+
fileName: string;
|
|
10
|
+
fileType: string;
|
|
11
|
+
fileSize: number;
|
|
13
12
|
};
|
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
* This API is for storing files for different users
|
|
6
6
|
* OpenAPI spec version: 1.0
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
8
|
export interface User {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
id: string;
|
|
10
|
+
_id: string;
|
|
11
|
+
email: string;
|
|
12
|
+
refreshToken: string;
|
|
14
13
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { QueryKey, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
3
|
+
import type { StorageControllerGetPresignedUrlParams } from '.././model';
|
|
4
|
+
export declare const storageControllerGetPresignedUrl: (params: StorageControllerGetPresignedUrlParams, options?: AxiosRequestConfig) => Promise<AxiosResponse<void>>;
|
|
5
|
+
export declare const getStorageControllerGetPresignedUrlQueryKey: (params: StorageControllerGetPresignedUrlParams) => readonly ["/uploads/presigned-url", ...StorageControllerGetPresignedUrlParams[]];
|
|
6
|
+
export declare const getStorageControllerGetPresignedUrlQueryOptions: <TData = AxiosResponse<void, any>, TError = AxiosError<unknown, any>>(params: StorageControllerGetPresignedUrlParams, options?: {
|
|
7
|
+
query?: UseQueryOptions<Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>, TError, TData>;
|
|
8
|
+
axios?: AxiosRequestConfig;
|
|
9
|
+
}) => UseQueryOptions<Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>, TError, TData> & {
|
|
10
|
+
queryKey: QueryKey;
|
|
11
|
+
};
|
|
12
|
+
export type StorageControllerGetPresignedUrlQueryResult = NonNullable<Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>>;
|
|
13
|
+
export type StorageControllerGetPresignedUrlQueryError = AxiosError<unknown>;
|
|
14
|
+
export declare function useStorageControllerGetPresignedUrl<TData = Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>, TError = AxiosError<unknown>>(params: StorageControllerGetPresignedUrlParams, options?: {
|
|
15
|
+
query?: UseQueryOptions<Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>, TError, TData>;
|
|
16
|
+
axios?: AxiosRequestConfig;
|
|
17
|
+
}): UseQueryResult<TData, TError> & {
|
|
18
|
+
queryKey: QueryKey;
|
|
19
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.4.1 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* files-storage
|
|
5
|
+
* This API is for storing files for different users
|
|
6
|
+
* OpenAPI spec version: 1.0
|
|
7
|
+
*/
|
|
8
|
+
import { useQuery } from '@tanstack/react-query';
|
|
9
|
+
import axios from 'axios';
|
|
10
|
+
export const storageControllerGetPresignedUrl = (params, options) => {
|
|
11
|
+
return axios.get(`/uploads/presigned-url`, {
|
|
12
|
+
...options,
|
|
13
|
+
params: { ...params, ...options?.params },
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
export const getStorageControllerGetPresignedUrlQueryKey = (params) => {
|
|
17
|
+
return [`/uploads/presigned-url`, ...(params ? [params] : [])];
|
|
18
|
+
};
|
|
19
|
+
export const getStorageControllerGetPresignedUrlQueryOptions = (params, options) => {
|
|
20
|
+
const { query: queryOptions, axios: axiosOptions } = options ?? {};
|
|
21
|
+
const queryKey = queryOptions?.queryKey ?? getStorageControllerGetPresignedUrlQueryKey(params);
|
|
22
|
+
const queryFn = ({ signal }) => storageControllerGetPresignedUrl(params, { signal, ...axiosOptions });
|
|
23
|
+
return { queryKey, queryFn, ...queryOptions };
|
|
24
|
+
};
|
|
25
|
+
export function useStorageControllerGetPresignedUrl(params, options) {
|
|
26
|
+
const queryOptions = getStorageControllerGetPresignedUrlQueryOptions(params, options);
|
|
27
|
+
const query = useQuery(queryOptions);
|
|
28
|
+
query.queryKey = queryOptions.queryKey;
|
|
29
|
+
return query;
|
|
30
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { QueryKey, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
3
|
+
import type { CreateUserDto, LoginDto, RefreshTokenDto, User, UserLogin } from '.././model';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new user and returns the created user. We don't have plans for now to implement this on frontend, but it's here for testing purposes
|
|
6
|
+
* @summary Sign up route where a user is created
|
|
7
|
+
*/
|
|
8
|
+
export declare const createUser: (createUserDto: CreateUserDto, options?: AxiosRequestConfig) => Promise<AxiosResponse<void>>;
|
|
9
|
+
export declare const getCreateUserMutationOptions: <TData = AxiosResponse<void, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
|
|
10
|
+
mutation?: UseMutationOptions<TData, TError, {
|
|
11
|
+
data: CreateUserDto;
|
|
12
|
+
}, TContext>;
|
|
13
|
+
axios?: AxiosRequestConfig;
|
|
14
|
+
}) => UseMutationOptions<TData, TError, {
|
|
15
|
+
data: CreateUserDto;
|
|
16
|
+
}, TContext>;
|
|
17
|
+
export type CreateUserMutationResult = NonNullable<Awaited<ReturnType<typeof createUser>>>;
|
|
18
|
+
export type CreateUserMutationBody = CreateUserDto;
|
|
19
|
+
export type CreateUserMutationError = AxiosError<unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* @summary Sign up route where a user is created
|
|
22
|
+
*/
|
|
23
|
+
export declare const useCreateUser: <TData = AxiosResponse<void, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
|
|
24
|
+
mutation?: UseMutationOptions<TData, TError, {
|
|
25
|
+
data: CreateUserDto;
|
|
26
|
+
}, TContext>;
|
|
27
|
+
axios?: AxiosRequestConfig;
|
|
28
|
+
}) => UseMutationResult<TData, TError, {
|
|
29
|
+
data: CreateUserDto;
|
|
30
|
+
}, TContext>;
|
|
31
|
+
/**
|
|
32
|
+
* Receives user auth data, check the authentication and returns LoginData
|
|
33
|
+
* @summary Sign in route for authentication
|
|
34
|
+
*/
|
|
35
|
+
export declare const login: (loginDto: LoginDto, options?: AxiosRequestConfig) => Promise<AxiosResponse<UserLogin>>;
|
|
36
|
+
export declare const getLoginMutationOptions: <TData = AxiosResponse<UserLogin, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
|
|
37
|
+
mutation?: UseMutationOptions<TData, TError, {
|
|
38
|
+
data: LoginDto;
|
|
39
|
+
}, TContext>;
|
|
40
|
+
axios?: AxiosRequestConfig;
|
|
41
|
+
}) => UseMutationOptions<TData, TError, {
|
|
42
|
+
data: LoginDto;
|
|
43
|
+
}, TContext>;
|
|
44
|
+
export type LoginMutationResult = NonNullable<Awaited<ReturnType<typeof login>>>;
|
|
45
|
+
export type LoginMutationBody = LoginDto;
|
|
46
|
+
export type LoginMutationError = AxiosError<unknown>;
|
|
47
|
+
/**
|
|
48
|
+
* @summary Sign in route for authentication
|
|
49
|
+
*/
|
|
50
|
+
export declare const useLogin: <TData = AxiosResponse<UserLogin, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
|
|
51
|
+
mutation?: UseMutationOptions<TData, TError, {
|
|
52
|
+
data: LoginDto;
|
|
53
|
+
}, TContext>;
|
|
54
|
+
axios?: AxiosRequestConfig;
|
|
55
|
+
}) => UseMutationResult<TData, TError, {
|
|
56
|
+
data: LoginDto;
|
|
57
|
+
}, TContext>;
|
|
58
|
+
/**
|
|
59
|
+
* Receives the user refresh token, validates it and return an updated token
|
|
60
|
+
* @summary Refreshes the user token
|
|
61
|
+
*/
|
|
62
|
+
export declare const refreshToken: (refreshTokenDto: RefreshTokenDto, options?: AxiosRequestConfig) => Promise<AxiosResponse<UserLogin>>;
|
|
63
|
+
export declare const getRefreshTokenMutationOptions: <TData = AxiosResponse<UserLogin, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
|
|
64
|
+
mutation?: UseMutationOptions<TData, TError, {
|
|
65
|
+
data: RefreshTokenDto;
|
|
66
|
+
}, TContext>;
|
|
67
|
+
axios?: AxiosRequestConfig;
|
|
68
|
+
}) => UseMutationOptions<TData, TError, {
|
|
69
|
+
data: RefreshTokenDto;
|
|
70
|
+
}, TContext>;
|
|
71
|
+
export type RefreshTokenMutationResult = NonNullable<Awaited<ReturnType<typeof refreshToken>>>;
|
|
72
|
+
export type RefreshTokenMutationBody = RefreshTokenDto;
|
|
73
|
+
export type RefreshTokenMutationError = AxiosError<unknown>;
|
|
74
|
+
/**
|
|
75
|
+
* @summary Refreshes the user token
|
|
76
|
+
*/
|
|
77
|
+
export declare const useRefreshToken: <TData = AxiosResponse<UserLogin, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
|
|
78
|
+
mutation?: UseMutationOptions<TData, TError, {
|
|
79
|
+
data: RefreshTokenDto;
|
|
80
|
+
}, TContext>;
|
|
81
|
+
axios?: AxiosRequestConfig;
|
|
82
|
+
}) => UseMutationResult<TData, TError, {
|
|
83
|
+
data: RefreshTokenDto;
|
|
84
|
+
}, TContext>;
|
|
85
|
+
/**
|
|
86
|
+
* Returns the authenticated user data using the token as reference
|
|
87
|
+
* @summary Get the authenticated user data
|
|
88
|
+
*/
|
|
89
|
+
export declare const me: (options?: AxiosRequestConfig) => Promise<AxiosResponse<User>>;
|
|
90
|
+
export declare const getMeQueryKey: () => readonly ["/users/me"];
|
|
91
|
+
export declare const getMeQueryOptions: <TData = AxiosResponse<User, any>, TError = AxiosError<unknown, any>>(options?: {
|
|
92
|
+
query?: UseQueryOptions<Awaited<ReturnType<typeof me>>, TError, TData>;
|
|
93
|
+
axios?: AxiosRequestConfig;
|
|
94
|
+
}) => UseQueryOptions<Awaited<ReturnType<typeof me>>, TError, TData> & {
|
|
95
|
+
queryKey: QueryKey;
|
|
96
|
+
};
|
|
97
|
+
export type MeQueryResult = NonNullable<Awaited<ReturnType<typeof me>>>;
|
|
98
|
+
export type MeQueryError = AxiosError<unknown>;
|
|
99
|
+
/**
|
|
100
|
+
* @summary Get the authenticated user data
|
|
101
|
+
*/
|
|
102
|
+
export declare function useMe<TData = Awaited<ReturnType<typeof me>>, TError = AxiosError<unknown>>(options?: {
|
|
103
|
+
query?: UseQueryOptions<Awaited<ReturnType<typeof me>>, TError, TData>;
|
|
104
|
+
axios?: AxiosRequestConfig;
|
|
105
|
+
}): UseQueryResult<TData, TError> & {
|
|
106
|
+
queryKey: QueryKey;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Returns the authenticated user files URLs
|
|
110
|
+
* @summary Get the authenticated user files URLs
|
|
111
|
+
*/
|
|
112
|
+
export declare const myFiles: (options?: AxiosRequestConfig) => Promise<AxiosResponse<string[]>>;
|
|
113
|
+
export declare const getMyFilesQueryKey: () => readonly ["/users/me/files"];
|
|
114
|
+
export declare const getMyFilesQueryOptions: <TData = AxiosResponse<string[], any>, TError = AxiosError<unknown, any>>(options?: {
|
|
115
|
+
query?: UseQueryOptions<Awaited<ReturnType<typeof myFiles>>, TError, TData>;
|
|
116
|
+
axios?: AxiosRequestConfig;
|
|
117
|
+
}) => UseQueryOptions<Awaited<ReturnType<typeof myFiles>>, TError, TData> & {
|
|
118
|
+
queryKey: QueryKey;
|
|
119
|
+
};
|
|
120
|
+
export type MyFilesQueryResult = NonNullable<Awaited<ReturnType<typeof myFiles>>>;
|
|
121
|
+
export type MyFilesQueryError = AxiosError<unknown>;
|
|
122
|
+
/**
|
|
123
|
+
* @summary Get the authenticated user files URLs
|
|
124
|
+
*/
|
|
125
|
+
export declare function useMyFiles<TData = Awaited<ReturnType<typeof myFiles>>, TError = AxiosError<unknown>>(options?: {
|
|
126
|
+
query?: UseQueryOptions<Awaited<ReturnType<typeof myFiles>>, TError, TData>;
|
|
127
|
+
axios?: AxiosRequestConfig;
|
|
128
|
+
}): UseQueryResult<TData, TError> & {
|
|
129
|
+
queryKey: QueryKey;
|
|
130
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.4.1 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* files-storage
|
|
5
|
+
* This API is for storing files for different users
|
|
6
|
+
* OpenAPI spec version: 1.0
|
|
7
|
+
*/
|
|
8
|
+
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
9
|
+
import axios from 'axios';
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new user and returns the created user. We don't have plans for now to implement this on frontend, but it's here for testing purposes
|
|
12
|
+
* @summary Sign up route where a user is created
|
|
13
|
+
*/
|
|
14
|
+
export const createUser = (createUserDto, options) => {
|
|
15
|
+
return axios.post(`/users`, createUserDto, options);
|
|
16
|
+
};
|
|
17
|
+
export const getCreateUserMutationOptions = (options) => {
|
|
18
|
+
const mutationKey = ['createUser'];
|
|
19
|
+
const { mutation: mutationOptions, axios: axiosOptions } = options ?
|
|
20
|
+
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
21
|
+
options
|
|
22
|
+
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
23
|
+
: { mutation: { mutationKey, }, axios: undefined };
|
|
24
|
+
const mutationFn = (props) => {
|
|
25
|
+
const { data } = props ?? {};
|
|
26
|
+
return createUser(data, axiosOptions);
|
|
27
|
+
};
|
|
28
|
+
return { mutationFn, ...mutationOptions };
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* @summary Sign up route where a user is created
|
|
32
|
+
*/
|
|
33
|
+
export const useCreateUser = (options) => {
|
|
34
|
+
const mutationOptions = getCreateUserMutationOptions(options);
|
|
35
|
+
return useMutation(mutationOptions);
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Receives user auth data, check the authentication and returns LoginData
|
|
39
|
+
* @summary Sign in route for authentication
|
|
40
|
+
*/
|
|
41
|
+
export const login = (loginDto, options) => {
|
|
42
|
+
return axios.post(`/users/login`, loginDto, options);
|
|
43
|
+
};
|
|
44
|
+
export const getLoginMutationOptions = (options) => {
|
|
45
|
+
const mutationKey = ['login'];
|
|
46
|
+
const { mutation: mutationOptions, axios: axiosOptions } = options ?
|
|
47
|
+
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
48
|
+
options
|
|
49
|
+
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
50
|
+
: { mutation: { mutationKey, }, axios: undefined };
|
|
51
|
+
const mutationFn = (props) => {
|
|
52
|
+
const { data } = props ?? {};
|
|
53
|
+
return login(data, axiosOptions);
|
|
54
|
+
};
|
|
55
|
+
return { mutationFn, ...mutationOptions };
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* @summary Sign in route for authentication
|
|
59
|
+
*/
|
|
60
|
+
export const useLogin = (options) => {
|
|
61
|
+
const mutationOptions = getLoginMutationOptions(options);
|
|
62
|
+
return useMutation(mutationOptions);
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Receives the user refresh token, validates it and return an updated token
|
|
66
|
+
* @summary Refreshes the user token
|
|
67
|
+
*/
|
|
68
|
+
export const refreshToken = (refreshTokenDto, options) => {
|
|
69
|
+
return axios.post(`/users/refresh-token`, refreshTokenDto, options);
|
|
70
|
+
};
|
|
71
|
+
export const getRefreshTokenMutationOptions = (options) => {
|
|
72
|
+
const mutationKey = ['refreshToken'];
|
|
73
|
+
const { mutation: mutationOptions, axios: axiosOptions } = options ?
|
|
74
|
+
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
75
|
+
options
|
|
76
|
+
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
77
|
+
: { mutation: { mutationKey, }, axios: undefined };
|
|
78
|
+
const mutationFn = (props) => {
|
|
79
|
+
const { data } = props ?? {};
|
|
80
|
+
return refreshToken(data, axiosOptions);
|
|
81
|
+
};
|
|
82
|
+
return { mutationFn, ...mutationOptions };
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* @summary Refreshes the user token
|
|
86
|
+
*/
|
|
87
|
+
export const useRefreshToken = (options) => {
|
|
88
|
+
const mutationOptions = getRefreshTokenMutationOptions(options);
|
|
89
|
+
return useMutation(mutationOptions);
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Returns the authenticated user data using the token as reference
|
|
93
|
+
* @summary Get the authenticated user data
|
|
94
|
+
*/
|
|
95
|
+
export const me = (options) => {
|
|
96
|
+
return axios.get(`/users/me`, options);
|
|
97
|
+
};
|
|
98
|
+
export const getMeQueryKey = () => {
|
|
99
|
+
return [`/users/me`];
|
|
100
|
+
};
|
|
101
|
+
export const getMeQueryOptions = (options) => {
|
|
102
|
+
const { query: queryOptions, axios: axiosOptions } = options ?? {};
|
|
103
|
+
const queryKey = queryOptions?.queryKey ?? getMeQueryKey();
|
|
104
|
+
const queryFn = ({ signal }) => me({ signal, ...axiosOptions });
|
|
105
|
+
return { queryKey, queryFn, ...queryOptions };
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* @summary Get the authenticated user data
|
|
109
|
+
*/
|
|
110
|
+
export function useMe(options) {
|
|
111
|
+
const queryOptions = getMeQueryOptions(options);
|
|
112
|
+
const query = useQuery(queryOptions);
|
|
113
|
+
query.queryKey = queryOptions.queryKey;
|
|
114
|
+
return query;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Returns the authenticated user files URLs
|
|
118
|
+
* @summary Get the authenticated user files URLs
|
|
119
|
+
*/
|
|
120
|
+
export const myFiles = (options) => {
|
|
121
|
+
return axios.get(`/users/me/files`, options);
|
|
122
|
+
};
|
|
123
|
+
export const getMyFilesQueryKey = () => {
|
|
124
|
+
return [`/users/me/files`];
|
|
125
|
+
};
|
|
126
|
+
export const getMyFilesQueryOptions = (options) => {
|
|
127
|
+
const { query: queryOptions, axios: axiosOptions } = options ?? {};
|
|
128
|
+
const queryKey = queryOptions?.queryKey ?? getMyFilesQueryKey();
|
|
129
|
+
const queryFn = ({ signal }) => myFiles({ signal, ...axiosOptions });
|
|
130
|
+
return { queryKey, queryFn, ...queryOptions };
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* @summary Get the authenticated user files URLs
|
|
134
|
+
*/
|
|
135
|
+
export function useMyFiles(options) {
|
|
136
|
+
const queryOptions = getMyFilesQueryOptions(options);
|
|
137
|
+
const query = useQuery(queryOptions);
|
|
138
|
+
query.queryKey = queryOptions.queryKey;
|
|
139
|
+
return query;
|
|
140
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htkimura/files-storage-backend.rest-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "REST client of files-storage-backend",
|
|
5
5
|
"author": "Henry Kimura",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
10
14
|
},
|
|
11
|
-
"main": "src/index.ts",
|
|
12
15
|
"files": [
|
|
13
|
-
"
|
|
14
|
-
"src/index.ts"
|
|
16
|
+
"dist"
|
|
15
17
|
],
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
+
"scripts": {
|
|
19
|
+
"buildPackage": "tsc -p tsconfig.build.json",
|
|
20
|
+
"publish": "buildPackage && npm publish --access public"
|
|
18
21
|
},
|
|
19
22
|
"peerDependencies": {
|
|
20
23
|
"@tanstack/react-query": "^5.66.0",
|
|
@@ -25,7 +28,6 @@
|
|
|
25
28
|
"axios": "^1.7.9"
|
|
26
29
|
},
|
|
27
30
|
"devDependencies": {
|
|
28
|
-
"@tanstack/react-query": "^5.66.0",
|
|
29
31
|
"@types/node": "^22.13.5",
|
|
30
32
|
"@types/react": "^19.0.10",
|
|
31
33
|
"@types/react-dom": "^19.0.4",
|
package/src/generated/index.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generated by orval v7.4.1 🍺
|
|
3
|
-
* Do not edit manually.
|
|
4
|
-
* files-storage
|
|
5
|
-
* This API is for storing files for different users
|
|
6
|
-
* OpenAPI spec version: 1.0
|
|
7
|
-
*/
|
|
8
|
-
import {
|
|
9
|
-
useQuery
|
|
10
|
-
} from '@tanstack/react-query'
|
|
11
|
-
import type {
|
|
12
|
-
QueryFunction,
|
|
13
|
-
QueryKey,
|
|
14
|
-
UseQueryOptions,
|
|
15
|
-
UseQueryResult
|
|
16
|
-
} from '@tanstack/react-query'
|
|
17
|
-
import axios from 'axios'
|
|
18
|
-
import type {
|
|
19
|
-
AxiosError,
|
|
20
|
-
AxiosRequestConfig,
|
|
21
|
-
AxiosResponse
|
|
22
|
-
} from 'axios'
|
|
23
|
-
import type {
|
|
24
|
-
StorageControllerGetPresignedUrlParams
|
|
25
|
-
} from '.././model'
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export const storageControllerGetPresignedUrl = (
|
|
30
|
-
params: StorageControllerGetPresignedUrlParams, options?: AxiosRequestConfig
|
|
31
|
-
): Promise<AxiosResponse<void>> => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return axios.get(
|
|
35
|
-
`/uploads/presigned-url`,{
|
|
36
|
-
...options,
|
|
37
|
-
params: {...params, ...options?.params},}
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
export const getStorageControllerGetPresignedUrlQueryKey = (params: StorageControllerGetPresignedUrlParams,) => {
|
|
43
|
-
return [`/uploads/presigned-url`, ...(params ? [params]: [])] as const;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
export const getStorageControllerGetPresignedUrlQueryOptions = <TData = Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>, TError = AxiosError<unknown>>(params: StorageControllerGetPresignedUrlParams, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>, TError, TData>, axios?: AxiosRequestConfig}
|
|
48
|
-
) => {
|
|
49
|
-
|
|
50
|
-
const {query: queryOptions, axios: axiosOptions} = options ?? {};
|
|
51
|
-
|
|
52
|
-
const queryKey = queryOptions?.queryKey ?? getStorageControllerGetPresignedUrlQueryKey(params);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const queryFn: QueryFunction<Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>> = ({ signal }) => storageControllerGetPresignedUrl(params, { signal, ...axiosOptions });
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>, TError, TData> & { queryKey: QueryKey }
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export type StorageControllerGetPresignedUrlQueryResult = NonNullable<Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>>
|
|
66
|
-
export type StorageControllerGetPresignedUrlQueryError = AxiosError<unknown>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
export function useStorageControllerGetPresignedUrl<TData = Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>, TError = AxiosError<unknown>>(
|
|
71
|
-
params: StorageControllerGetPresignedUrlParams, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>, TError, TData>, axios?: AxiosRequestConfig}
|
|
72
|
-
|
|
73
|
-
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
|
|
74
|
-
|
|
75
|
-
const queryOptions = getStorageControllerGetPresignedUrlQueryOptions(params,options)
|
|
76
|
-
|
|
77
|
-
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
78
|
-
|
|
79
|
-
query.queryKey = queryOptions.queryKey ;
|
|
80
|
-
|
|
81
|
-
return query;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generated by orval v7.4.1 🍺
|
|
3
|
-
* Do not edit manually.
|
|
4
|
-
* files-storage
|
|
5
|
-
* This API is for storing files for different users
|
|
6
|
-
* OpenAPI spec version: 1.0
|
|
7
|
-
*/
|
|
8
|
-
import {
|
|
9
|
-
useMutation,
|
|
10
|
-
useQuery
|
|
11
|
-
} from '@tanstack/react-query'
|
|
12
|
-
import type {
|
|
13
|
-
MutationFunction,
|
|
14
|
-
QueryFunction,
|
|
15
|
-
QueryKey,
|
|
16
|
-
UseMutationOptions,
|
|
17
|
-
UseMutationResult,
|
|
18
|
-
UseQueryOptions,
|
|
19
|
-
UseQueryResult
|
|
20
|
-
} from '@tanstack/react-query'
|
|
21
|
-
import axios from 'axios'
|
|
22
|
-
import type {
|
|
23
|
-
AxiosError,
|
|
24
|
-
AxiosRequestConfig,
|
|
25
|
-
AxiosResponse
|
|
26
|
-
} from 'axios'
|
|
27
|
-
import type {
|
|
28
|
-
CreateUserDto,
|
|
29
|
-
LoginDto,
|
|
30
|
-
RefreshTokenDto,
|
|
31
|
-
User,
|
|
32
|
-
UserLogin
|
|
33
|
-
} from '.././model'
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Creates a new user and returns the created user. We don't have plans for now to implement this on frontend, but it's here for testing purposes
|
|
39
|
-
* @summary Sign up route where a user is created
|
|
40
|
-
*/
|
|
41
|
-
export const createUser = (
|
|
42
|
-
createUserDto: CreateUserDto, options?: AxiosRequestConfig
|
|
43
|
-
): Promise<AxiosResponse<void>> => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return axios.post(
|
|
47
|
-
`/users`,
|
|
48
|
-
createUserDto,options
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
export const getCreateUserMutationOptions = <TData = Awaited<ReturnType<typeof createUser>>, TError = AxiosError<unknown>,
|
|
55
|
-
TContext = unknown>(options?: { mutation?:UseMutationOptions<TData, TError,{data: CreateUserDto}, TContext>, axios?: AxiosRequestConfig}
|
|
56
|
-
) => {
|
|
57
|
-
const mutationKey = ['createUser'];
|
|
58
|
-
const {mutation: mutationOptions, axios: axiosOptions} = options ?
|
|
59
|
-
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
60
|
-
options
|
|
61
|
-
: {...options, mutation: {...options.mutation, mutationKey}}
|
|
62
|
-
: {mutation: { mutationKey, }, axios: undefined};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const mutationFn: MutationFunction<Awaited<ReturnType<typeof createUser>>, {data: CreateUserDto}> = (props) => {
|
|
68
|
-
const {data} = props ?? {};
|
|
69
|
-
|
|
70
|
-
return createUser(data,axiosOptions)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return { mutationFn, ...mutationOptions } as UseMutationOptions<TData, TError,{data: CreateUserDto}, TContext>}
|
|
77
|
-
|
|
78
|
-
export type CreateUserMutationResult = NonNullable<Awaited<ReturnType<typeof createUser>>>
|
|
79
|
-
export type CreateUserMutationBody = CreateUserDto
|
|
80
|
-
export type CreateUserMutationError = AxiosError<unknown>
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @summary Sign up route where a user is created
|
|
84
|
-
*/
|
|
85
|
-
export const useCreateUser = <TData = Awaited<ReturnType<typeof createUser>>, TError = AxiosError<unknown>,
|
|
86
|
-
TContext = unknown>(options?: { mutation?:UseMutationOptions<TData, TError,{data: CreateUserDto}, TContext>, axios?: AxiosRequestConfig}
|
|
87
|
-
): UseMutationResult<
|
|
88
|
-
TData,
|
|
89
|
-
TError,
|
|
90
|
-
{data: CreateUserDto},
|
|
91
|
-
TContext
|
|
92
|
-
> => {
|
|
93
|
-
|
|
94
|
-
const mutationOptions = getCreateUserMutationOptions(options);
|
|
95
|
-
|
|
96
|
-
return useMutation(mutationOptions);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Receives user auth data, check the authentication and returns LoginData
|
|
100
|
-
* @summary Sign in route for authentication
|
|
101
|
-
*/
|
|
102
|
-
export const login = (
|
|
103
|
-
loginDto: LoginDto, options?: AxiosRequestConfig
|
|
104
|
-
): Promise<AxiosResponse<UserLogin>> => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return axios.post(
|
|
108
|
-
`/users/login`,
|
|
109
|
-
loginDto,options
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
export const getLoginMutationOptions = <TData = Awaited<ReturnType<typeof login>>, TError = AxiosError<unknown>,
|
|
116
|
-
TContext = unknown>(options?: { mutation?:UseMutationOptions<TData, TError,{data: LoginDto}, TContext>, axios?: AxiosRequestConfig}
|
|
117
|
-
) => {
|
|
118
|
-
const mutationKey = ['login'];
|
|
119
|
-
const {mutation: mutationOptions, axios: axiosOptions} = options ?
|
|
120
|
-
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
121
|
-
options
|
|
122
|
-
: {...options, mutation: {...options.mutation, mutationKey}}
|
|
123
|
-
: {mutation: { mutationKey, }, axios: undefined};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const mutationFn: MutationFunction<Awaited<ReturnType<typeof login>>, {data: LoginDto}> = (props) => {
|
|
129
|
-
const {data} = props ?? {};
|
|
130
|
-
|
|
131
|
-
return login(data,axiosOptions)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return { mutationFn, ...mutationOptions } as UseMutationOptions<TData, TError,{data: LoginDto}, TContext>}
|
|
138
|
-
|
|
139
|
-
export type LoginMutationResult = NonNullable<Awaited<ReturnType<typeof login>>>
|
|
140
|
-
export type LoginMutationBody = LoginDto
|
|
141
|
-
export type LoginMutationError = AxiosError<unknown>
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* @summary Sign in route for authentication
|
|
145
|
-
*/
|
|
146
|
-
export const useLogin = <TData = Awaited<ReturnType<typeof login>>, TError = AxiosError<unknown>,
|
|
147
|
-
TContext = unknown>(options?: { mutation?:UseMutationOptions<TData, TError,{data: LoginDto}, TContext>, axios?: AxiosRequestConfig}
|
|
148
|
-
): UseMutationResult<
|
|
149
|
-
TData,
|
|
150
|
-
TError,
|
|
151
|
-
{data: LoginDto},
|
|
152
|
-
TContext
|
|
153
|
-
> => {
|
|
154
|
-
|
|
155
|
-
const mutationOptions = getLoginMutationOptions(options);
|
|
156
|
-
|
|
157
|
-
return useMutation(mutationOptions);
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Receives the user refresh token, validates it and return an updated token
|
|
161
|
-
* @summary Refreshes the user token
|
|
162
|
-
*/
|
|
163
|
-
export const refreshToken = (
|
|
164
|
-
refreshTokenDto: RefreshTokenDto, options?: AxiosRequestConfig
|
|
165
|
-
): Promise<AxiosResponse<UserLogin>> => {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return axios.post(
|
|
169
|
-
`/users/refresh-token`,
|
|
170
|
-
refreshTokenDto,options
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
export const getRefreshTokenMutationOptions = <TData = Awaited<ReturnType<typeof refreshToken>>, TError = AxiosError<unknown>,
|
|
177
|
-
TContext = unknown>(options?: { mutation?:UseMutationOptions<TData, TError,{data: RefreshTokenDto}, TContext>, axios?: AxiosRequestConfig}
|
|
178
|
-
) => {
|
|
179
|
-
const mutationKey = ['refreshToken'];
|
|
180
|
-
const {mutation: mutationOptions, axios: axiosOptions} = options ?
|
|
181
|
-
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
182
|
-
options
|
|
183
|
-
: {...options, mutation: {...options.mutation, mutationKey}}
|
|
184
|
-
: {mutation: { mutationKey, }, axios: undefined};
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
const mutationFn: MutationFunction<Awaited<ReturnType<typeof refreshToken>>, {data: RefreshTokenDto}> = (props) => {
|
|
190
|
-
const {data} = props ?? {};
|
|
191
|
-
|
|
192
|
-
return refreshToken(data,axiosOptions)
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
return { mutationFn, ...mutationOptions } as UseMutationOptions<TData, TError,{data: RefreshTokenDto}, TContext>}
|
|
199
|
-
|
|
200
|
-
export type RefreshTokenMutationResult = NonNullable<Awaited<ReturnType<typeof refreshToken>>>
|
|
201
|
-
export type RefreshTokenMutationBody = RefreshTokenDto
|
|
202
|
-
export type RefreshTokenMutationError = AxiosError<unknown>
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* @summary Refreshes the user token
|
|
206
|
-
*/
|
|
207
|
-
export const useRefreshToken = <TData = Awaited<ReturnType<typeof refreshToken>>, TError = AxiosError<unknown>,
|
|
208
|
-
TContext = unknown>(options?: { mutation?:UseMutationOptions<TData, TError,{data: RefreshTokenDto}, TContext>, axios?: AxiosRequestConfig}
|
|
209
|
-
): UseMutationResult<
|
|
210
|
-
TData,
|
|
211
|
-
TError,
|
|
212
|
-
{data: RefreshTokenDto},
|
|
213
|
-
TContext
|
|
214
|
-
> => {
|
|
215
|
-
|
|
216
|
-
const mutationOptions = getRefreshTokenMutationOptions(options);
|
|
217
|
-
|
|
218
|
-
return useMutation(mutationOptions);
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Returns the authenticated user data using the token as reference
|
|
222
|
-
* @summary Get the authenticated user data
|
|
223
|
-
*/
|
|
224
|
-
export const me = (
|
|
225
|
-
options?: AxiosRequestConfig
|
|
226
|
-
): Promise<AxiosResponse<User>> => {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
return axios.get(
|
|
230
|
-
`/users/me`,options
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
export const getMeQueryKey = () => {
|
|
236
|
-
return [`/users/me`] as const;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
export const getMeQueryOptions = <TData = Awaited<ReturnType<typeof me>>, TError = AxiosError<unknown>>( options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof me>>, TError, TData>, axios?: AxiosRequestConfig}
|
|
241
|
-
) => {
|
|
242
|
-
|
|
243
|
-
const {query: queryOptions, axios: axiosOptions} = options ?? {};
|
|
244
|
-
|
|
245
|
-
const queryKey = queryOptions?.queryKey ?? getMeQueryKey();
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
const queryFn: QueryFunction<Awaited<ReturnType<typeof me>>> = ({ signal }) => me({ signal, ...axiosOptions });
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof me>>, TError, TData> & { queryKey: QueryKey }
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
export type MeQueryResult = NonNullable<Awaited<ReturnType<typeof me>>>
|
|
259
|
-
export type MeQueryError = AxiosError<unknown>
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* @summary Get the authenticated user data
|
|
264
|
-
*/
|
|
265
|
-
|
|
266
|
-
export function useMe<TData = Awaited<ReturnType<typeof me>>, TError = AxiosError<unknown>>(
|
|
267
|
-
options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof me>>, TError, TData>, axios?: AxiosRequestConfig}
|
|
268
|
-
|
|
269
|
-
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
|
|
270
|
-
|
|
271
|
-
const queryOptions = getMeQueryOptions(options)
|
|
272
|
-
|
|
273
|
-
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
274
|
-
|
|
275
|
-
query.queryKey = queryOptions.queryKey ;
|
|
276
|
-
|
|
277
|
-
return query;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* Returns the authenticated user files URLs
|
|
284
|
-
* @summary Get the authenticated user files URLs
|
|
285
|
-
*/
|
|
286
|
-
export const myFiles = (
|
|
287
|
-
options?: AxiosRequestConfig
|
|
288
|
-
): Promise<AxiosResponse<string[]>> => {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
return axios.get(
|
|
292
|
-
`/users/me/files`,options
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
export const getMyFilesQueryKey = () => {
|
|
298
|
-
return [`/users/me/files`] as const;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
export const getMyFilesQueryOptions = <TData = Awaited<ReturnType<typeof myFiles>>, TError = AxiosError<unknown>>( options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof myFiles>>, TError, TData>, axios?: AxiosRequestConfig}
|
|
303
|
-
) => {
|
|
304
|
-
|
|
305
|
-
const {query: queryOptions, axios: axiosOptions} = options ?? {};
|
|
306
|
-
|
|
307
|
-
const queryKey = queryOptions?.queryKey ?? getMyFilesQueryKey();
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
const queryFn: QueryFunction<Awaited<ReturnType<typeof myFiles>>> = ({ signal }) => myFiles({ signal, ...axiosOptions });
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof myFiles>>, TError, TData> & { queryKey: QueryKey }
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
export type MyFilesQueryResult = NonNullable<Awaited<ReturnType<typeof myFiles>>>
|
|
321
|
-
export type MyFilesQueryError = AxiosError<unknown>
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* @summary Get the authenticated user files URLs
|
|
326
|
-
*/
|
|
327
|
-
|
|
328
|
-
export function useMyFiles<TData = Awaited<ReturnType<typeof myFiles>>, TError = AxiosError<unknown>>(
|
|
329
|
-
options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof myFiles>>, TError, TData>, axios?: AxiosRequestConfig}
|
|
330
|
-
|
|
331
|
-
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
|
|
332
|
-
|
|
333
|
-
const queryOptions = getMyFilesQueryOptions(options)
|
|
334
|
-
|
|
335
|
-
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
336
|
-
|
|
337
|
-
query.queryKey = queryOptions.queryKey ;
|
|
338
|
-
|
|
339
|
-
return query;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|