@htkimura/files-storage-backend.rest-client 0.0.22 → 0.0.24

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 (27) hide show
  1. package/dist/generated/model/deleteBulkFilesByIdsParams.d.ts +10 -0
  2. package/dist/generated/model/deleteBulkFilesByIdsParams.js +8 -0
  3. package/dist/generated/model/deleteBulkFilesOutput.d.ts +11 -0
  4. package/dist/generated/model/deleteBulkFilesOutput.js +8 -0
  5. package/dist/generated/model/file.d.ts +17 -0
  6. package/dist/generated/model/file.js +8 -0
  7. package/dist/generated/model/fileWithPresignedUrl.d.ts +18 -0
  8. package/dist/generated/model/fileWithPresignedUrl.js +8 -0
  9. package/dist/generated/model/getBulkFilesByIdsParams.d.ts +10 -0
  10. package/dist/generated/model/getBulkFilesByIdsParams.js +8 -0
  11. package/dist/generated/model/getPresignedUploadUrlParams.d.ts +12 -0
  12. package/dist/generated/model/getPresignedUploadUrlParams.js +8 -0
  13. package/dist/generated/model/getPresignedUrlParams.d.ts +12 -0
  14. package/dist/generated/model/getPresignedUrlParams.js +8 -0
  15. package/dist/generated/model/getUserFilesOutput.d.ts +14 -0
  16. package/dist/generated/model/getUserFilesOutput.js +8 -0
  17. package/dist/generated/model/index.d.ts +9 -1
  18. package/dist/generated/model/index.js +9 -1
  19. package/dist/generated/model/myFilesParams.d.ts +11 -0
  20. package/dist/generated/model/myFilesParams.js +8 -0
  21. package/dist/generated/model/uploadFileOutput.d.ts +12 -0
  22. package/dist/generated/model/uploadFileOutput.js +1 -0
  23. package/dist/generated/storage/storage.d.ts +116 -11
  24. package/dist/generated/storage/storage.js +125 -8
  25. package/dist/generated/user/user.d.ts +5 -5
  26. package/dist/generated/user/user.js +12 -9
  27. package/package.json +2 -2
@@ -0,0 +1,10 @@
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 type DeleteBulkFilesByIdsParams = {
9
+ ids: string[];
10
+ };
@@ -0,0 +1,8 @@
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 {};
@@ -0,0 +1,11 @@
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 interface DeleteBulkFilesOutput {
9
+ deleted: string[];
10
+ failed: string[];
11
+ }
@@ -0,0 +1,8 @@
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 {};
@@ -0,0 +1,17 @@
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 interface File {
9
+ id: string;
10
+ createdAt: string;
11
+ updatedAt: string;
12
+ name: string;
13
+ type: string;
14
+ size: number;
15
+ path: string;
16
+ userId: string;
17
+ }
@@ -0,0 +1,8 @@
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 {};
@@ -0,0 +1,18 @@
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 interface FileWithPresignedUrl {
9
+ id: string;
10
+ createdAt: string;
11
+ updatedAt: string;
12
+ name: string;
13
+ type: string;
14
+ size: number;
15
+ path: string;
16
+ userId: string;
17
+ presignedUrl: string;
18
+ }
@@ -0,0 +1,8 @@
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 {};
@@ -0,0 +1,10 @@
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 type GetBulkFilesByIdsParams = {
9
+ ids: string[];
10
+ };
@@ -0,0 +1,8 @@
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 {};
@@ -0,0 +1,12 @@
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 type GetPresignedUploadUrlParams = {
9
+ fileName: string;
10
+ fileType: string;
11
+ fileSize: number;
12
+ };
@@ -0,0 +1,8 @@
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 {};
@@ -0,0 +1,12 @@
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 type GetPresignedUrlParams = {
9
+ fileName: string;
10
+ fileType: string;
11
+ fileSize: number;
12
+ };
@@ -0,0 +1,8 @@
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 {};
@@ -0,0 +1,14 @@
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 interface GetUserFilesOutput {
9
+ data: string[];
10
+ page: number;
11
+ size: number;
12
+ total: number;
13
+ hasMore: boolean;
14
+ }
@@ -0,0 +1,8 @@
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 {};
@@ -6,8 +6,16 @@
6
6
  * OpenAPI spec version: 1.0
7
7
  */
8
8
  export * from './createUserDto';
9
+ export * from './deleteBulkFilesByIdsParams';
10
+ export * from './deleteBulkFilesOutput';
11
+ export * from './file';
12
+ export * from './fileWithPresignedUrl';
13
+ export * from './getBulkFilesByIdsParams';
14
+ export * from './getPresignedUploadUrlParams';
15
+ export * from './getUserFilesOutput';
9
16
  export * from './loginDto';
17
+ export * from './myFilesParams';
10
18
  export * from './refreshTokenDto';
11
- export * from './storageControllerGetPresignedUrlParams';
19
+ export * from './uploadFileOutput';
12
20
  export * from './user';
13
21
  export * from './userLogin';
@@ -6,8 +6,16 @@
6
6
  * OpenAPI spec version: 1.0
7
7
  */
8
8
  export * from './createUserDto';
9
+ export * from './deleteBulkFilesByIdsParams';
10
+ export * from './deleteBulkFilesOutput';
11
+ export * from './file';
12
+ export * from './fileWithPresignedUrl';
13
+ export * from './getBulkFilesByIdsParams';
14
+ export * from './getPresignedUploadUrlParams';
15
+ export * from './getUserFilesOutput';
9
16
  export * from './loginDto';
17
+ export * from './myFilesParams';
10
18
  export * from './refreshTokenDto';
11
- export * from './storageControllerGetPresignedUrlParams';
19
+ export * from './uploadFileOutput';
12
20
  export * from './user';
13
21
  export * from './userLogin';
@@ -0,0 +1,11 @@
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 type MyFilesParams = {
9
+ page?: number;
10
+ size?: number;
11
+ };
@@ -0,0 +1,8 @@
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 {};
@@ -0,0 +1,12 @@
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 type { File } from './file';
9
+ export interface UploadFileOutput {
10
+ file: File;
11
+ presignedUploadUrl: string;
12
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,19 +1,124 @@
1
- import type { QueryKey, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
1
+ import type { QueryKey, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
2
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>;
3
+ import type { DeleteBulkFilesByIdsParams, DeleteBulkFilesOutput, FileWithPresignedUrl, GetBulkFilesByIdsParams, GetPresignedUploadUrlParams, UploadFileOutput } from '.././model';
4
+ /**
5
+ * Returns presigned url to upload file
6
+ * @summary Get presigned url to upload file
7
+ */
8
+ export declare const getPresignedUploadUrl: (params: GetPresignedUploadUrlParams, options?: AxiosRequestConfig) => Promise<AxiosResponse<UploadFileOutput>>;
9
+ export declare const getGetPresignedUploadUrlQueryKey: (params: GetPresignedUploadUrlParams) => readonly ["/uploads/presigned-url", ...GetPresignedUploadUrlParams[]];
10
+ export declare const getGetPresignedUploadUrlQueryOptions: <TData = AxiosResponse<UploadFileOutput, any>, TError = AxiosError<unknown, any>>(params: GetPresignedUploadUrlParams, options?: {
11
+ query?: UseQueryOptions<Awaited<ReturnType<typeof getPresignedUploadUrl>>, TError, TData>;
8
12
  axios?: AxiosRequestConfig;
9
- }) => UseQueryOptions<Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>, TError, TData> & {
13
+ }) => UseQueryOptions<Awaited<ReturnType<typeof getPresignedUploadUrl>>, TError, TData> & {
10
14
  queryKey: QueryKey;
11
15
  };
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
+ export type GetPresignedUploadUrlQueryResult = NonNullable<Awaited<ReturnType<typeof getPresignedUploadUrl>>>;
17
+ export type GetPresignedUploadUrlQueryError = AxiosError<unknown>;
18
+ /**
19
+ * @summary Get presigned url to upload file
20
+ */
21
+ export declare function useGetPresignedUploadUrl<TData = Awaited<ReturnType<typeof getPresignedUploadUrl>>, TError = AxiosError<unknown>>(params: GetPresignedUploadUrlParams, options?: {
22
+ query?: UseQueryOptions<Awaited<ReturnType<typeof getPresignedUploadUrl>>, TError, TData>;
16
23
  axios?: AxiosRequestConfig;
17
24
  }): UseQueryResult<TData, TError> & {
18
25
  queryKey: QueryKey;
19
26
  };
27
+ /**
28
+ * Returns the authenticated user files by ids with presigned urls
29
+ * @summary Get the authenticated user files by ids with presigned urls
30
+ */
31
+ export declare const getBulkFilesByIds: (params: GetBulkFilesByIdsParams, options?: AxiosRequestConfig) => Promise<AxiosResponse<FileWithPresignedUrl[]>>;
32
+ export declare const getGetBulkFilesByIdsQueryKey: (params: GetBulkFilesByIdsParams) => readonly ["/files/bulk", ...GetBulkFilesByIdsParams[]];
33
+ export declare const getGetBulkFilesByIdsQueryOptions: <TData = AxiosResponse<FileWithPresignedUrl[], any>, TError = AxiosError<unknown, any>>(params: GetBulkFilesByIdsParams, options?: {
34
+ query?: UseQueryOptions<Awaited<ReturnType<typeof getBulkFilesByIds>>, TError, TData>;
35
+ axios?: AxiosRequestConfig;
36
+ }) => UseQueryOptions<Awaited<ReturnType<typeof getBulkFilesByIds>>, TError, TData> & {
37
+ queryKey: QueryKey;
38
+ };
39
+ export type GetBulkFilesByIdsQueryResult = NonNullable<Awaited<ReturnType<typeof getBulkFilesByIds>>>;
40
+ export type GetBulkFilesByIdsQueryError = AxiosError<unknown>;
41
+ /**
42
+ * @summary Get the authenticated user files by ids with presigned urls
43
+ */
44
+ export declare function useGetBulkFilesByIds<TData = Awaited<ReturnType<typeof getBulkFilesByIds>>, TError = AxiosError<unknown>>(params: GetBulkFilesByIdsParams, options?: {
45
+ query?: UseQueryOptions<Awaited<ReturnType<typeof getBulkFilesByIds>>, TError, TData>;
46
+ axios?: AxiosRequestConfig;
47
+ }): UseQueryResult<TData, TError> & {
48
+ queryKey: QueryKey;
49
+ };
50
+ /**
51
+ * Delete files on database and storage service by ids
52
+ * @summary Delete files by ids
53
+ */
54
+ export declare const deleteBulkFilesByIds: (params: DeleteBulkFilesByIdsParams, options?: AxiosRequestConfig) => Promise<AxiosResponse<DeleteBulkFilesOutput>>;
55
+ export declare const getDeleteBulkFilesByIdsMutationOptions: <TData = AxiosResponse<DeleteBulkFilesOutput, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
56
+ mutation?: UseMutationOptions<TData, TError, {
57
+ params: DeleteBulkFilesByIdsParams;
58
+ }, TContext>;
59
+ axios?: AxiosRequestConfig;
60
+ }) => UseMutationOptions<TData, TError, {
61
+ params: DeleteBulkFilesByIdsParams;
62
+ }, TContext>;
63
+ export type DeleteBulkFilesByIdsMutationResult = NonNullable<Awaited<ReturnType<typeof deleteBulkFilesByIds>>>;
64
+ export type DeleteBulkFilesByIdsMutationError = AxiosError<unknown>;
65
+ /**
66
+ * @summary Delete files by ids
67
+ */
68
+ export declare const useDeleteBulkFilesByIds: <TData = AxiosResponse<DeleteBulkFilesOutput, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
69
+ mutation?: UseMutationOptions<TData, TError, {
70
+ params: DeleteBulkFilesByIdsParams;
71
+ }, TContext>;
72
+ axios?: AxiosRequestConfig;
73
+ }) => UseMutationResult<TData, TError, {
74
+ params: DeleteBulkFilesByIdsParams;
75
+ }, TContext>;
76
+ /**
77
+ * Returns file by id with presigned url
78
+ * @summary Get file by id with presigned url
79
+ */
80
+ export declare const getFileById: (id: string, options?: AxiosRequestConfig) => Promise<AxiosResponse<FileWithPresignedUrl>>;
81
+ export declare const getGetFileByIdQueryKey: (id: string) => readonly [`/files/${string}`];
82
+ export declare const getGetFileByIdQueryOptions: <TData = AxiosResponse<FileWithPresignedUrl, any>, TError = AxiosError<unknown, any>>(id: string, options?: {
83
+ query?: UseQueryOptions<Awaited<ReturnType<typeof getFileById>>, TError, TData>;
84
+ axios?: AxiosRequestConfig;
85
+ }) => UseQueryOptions<Awaited<ReturnType<typeof getFileById>>, TError, TData> & {
86
+ queryKey: QueryKey;
87
+ };
88
+ export type GetFileByIdQueryResult = NonNullable<Awaited<ReturnType<typeof getFileById>>>;
89
+ export type GetFileByIdQueryError = AxiosError<unknown>;
90
+ /**
91
+ * @summary Get file by id with presigned url
92
+ */
93
+ export declare function useGetFileById<TData = Awaited<ReturnType<typeof getFileById>>, TError = AxiosError<unknown>>(id: string, options?: {
94
+ query?: UseQueryOptions<Awaited<ReturnType<typeof getFileById>>, TError, TData>;
95
+ axios?: AxiosRequestConfig;
96
+ }): UseQueryResult<TData, TError> & {
97
+ queryKey: QueryKey;
98
+ };
99
+ /**
100
+ * Delete file on database and storage service by id
101
+ * @summary Delete file by id
102
+ */
103
+ export declare const deleteFileById: (id: string, options?: AxiosRequestConfig) => Promise<AxiosResponse<boolean>>;
104
+ export declare const getDeleteFileByIdMutationOptions: <TData = AxiosResponse<boolean, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
105
+ mutation?: UseMutationOptions<TData, TError, {
106
+ id: string;
107
+ }, TContext>;
108
+ axios?: AxiosRequestConfig;
109
+ }) => UseMutationOptions<TData, TError, {
110
+ id: string;
111
+ }, TContext>;
112
+ export type DeleteFileByIdMutationResult = NonNullable<Awaited<ReturnType<typeof deleteFileById>>>;
113
+ export type DeleteFileByIdMutationError = AxiosError<unknown>;
114
+ /**
115
+ * @summary Delete file by id
116
+ */
117
+ export declare const useDeleteFileById: <TData = AxiosResponse<boolean, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
118
+ mutation?: UseMutationOptions<TData, TError, {
119
+ id: string;
120
+ }, TContext>;
121
+ axios?: AxiosRequestConfig;
122
+ }) => UseMutationResult<TData, TError, {
123
+ id: string;
124
+ }, TContext>;
@@ -5,26 +5,143 @@
5
5
  * This API is for storing files for different users
6
6
  * OpenAPI spec version: 1.0
7
7
  */
8
- import { useQuery } from '@tanstack/react-query';
8
+ import { useMutation, useQuery } from '@tanstack/react-query';
9
9
  import axios from 'axios';
10
- export const storageControllerGetPresignedUrl = (params, options) => {
10
+ /**
11
+ * Returns presigned url to upload file
12
+ * @summary Get presigned url to upload file
13
+ */
14
+ export const getPresignedUploadUrl = (params, options) => {
11
15
  return axios.get(`/uploads/presigned-url`, {
12
16
  ...options,
13
17
  params: { ...params, ...options?.params },
14
18
  });
15
19
  };
16
- export const getStorageControllerGetPresignedUrlQueryKey = (params) => {
20
+ export const getGetPresignedUploadUrlQueryKey = (params) => {
17
21
  return [`/uploads/presigned-url`, ...(params ? [params] : [])];
18
22
  };
19
- export const getStorageControllerGetPresignedUrlQueryOptions = (params, options) => {
23
+ export const getGetPresignedUploadUrlQueryOptions = (params, options) => {
20
24
  const { query: queryOptions, axios: axiosOptions } = options ?? {};
21
- const queryKey = queryOptions?.queryKey ?? getStorageControllerGetPresignedUrlQueryKey(params);
22
- const queryFn = ({ signal }) => storageControllerGetPresignedUrl(params, { signal, ...axiosOptions });
25
+ const queryKey = queryOptions?.queryKey ?? getGetPresignedUploadUrlQueryKey(params);
26
+ const queryFn = ({ signal }) => getPresignedUploadUrl(params, { signal, ...axiosOptions });
23
27
  return { queryKey, queryFn, ...queryOptions };
24
28
  };
25
- export function useStorageControllerGetPresignedUrl(params, options) {
26
- const queryOptions = getStorageControllerGetPresignedUrlQueryOptions(params, options);
29
+ /**
30
+ * @summary Get presigned url to upload file
31
+ */
32
+ export function useGetPresignedUploadUrl(params, options) {
33
+ const queryOptions = getGetPresignedUploadUrlQueryOptions(params, options);
34
+ const query = useQuery(queryOptions);
35
+ query.queryKey = queryOptions.queryKey;
36
+ return query;
37
+ }
38
+ /**
39
+ * Returns the authenticated user files by ids with presigned urls
40
+ * @summary Get the authenticated user files by ids with presigned urls
41
+ */
42
+ export const getBulkFilesByIds = (params, options) => {
43
+ return axios.get(`/files/bulk`, {
44
+ ...options,
45
+ params: { ...params, ...options?.params },
46
+ });
47
+ };
48
+ export const getGetBulkFilesByIdsQueryKey = (params) => {
49
+ return [`/files/bulk`, ...(params ? [params] : [])];
50
+ };
51
+ export const getGetBulkFilesByIdsQueryOptions = (params, options) => {
52
+ const { query: queryOptions, axios: axiosOptions } = options ?? {};
53
+ const queryKey = queryOptions?.queryKey ?? getGetBulkFilesByIdsQueryKey(params);
54
+ const queryFn = ({ signal }) => getBulkFilesByIds(params, { signal, ...axiosOptions });
55
+ return { queryKey, queryFn, ...queryOptions };
56
+ };
57
+ /**
58
+ * @summary Get the authenticated user files by ids with presigned urls
59
+ */
60
+ export function useGetBulkFilesByIds(params, options) {
61
+ const queryOptions = getGetBulkFilesByIdsQueryOptions(params, options);
62
+ const query = useQuery(queryOptions);
63
+ query.queryKey = queryOptions.queryKey;
64
+ return query;
65
+ }
66
+ /**
67
+ * Delete files on database and storage service by ids
68
+ * @summary Delete files by ids
69
+ */
70
+ export const deleteBulkFilesByIds = (params, options) => {
71
+ return axios.delete(`/files/bulk`, {
72
+ ...options,
73
+ params: { ...params, ...options?.params },
74
+ });
75
+ };
76
+ export const getDeleteBulkFilesByIdsMutationOptions = (options) => {
77
+ const mutationKey = ['deleteBulkFilesByIds'];
78
+ const { mutation: mutationOptions, axios: axiosOptions } = options ?
79
+ options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
80
+ options
81
+ : { ...options, mutation: { ...options.mutation, mutationKey } }
82
+ : { mutation: { mutationKey, }, axios: undefined };
83
+ const mutationFn = (props) => {
84
+ const { params } = props ?? {};
85
+ return deleteBulkFilesByIds(params, axiosOptions);
86
+ };
87
+ return { mutationFn, ...mutationOptions };
88
+ };
89
+ /**
90
+ * @summary Delete files by ids
91
+ */
92
+ export const useDeleteBulkFilesByIds = (options) => {
93
+ const mutationOptions = getDeleteBulkFilesByIdsMutationOptions(options);
94
+ return useMutation(mutationOptions);
95
+ };
96
+ /**
97
+ * Returns file by id with presigned url
98
+ * @summary Get file by id with presigned url
99
+ */
100
+ export const getFileById = (id, options) => {
101
+ return axios.get(`/files/${id}`, options);
102
+ };
103
+ export const getGetFileByIdQueryKey = (id) => {
104
+ return [`/files/${id}`];
105
+ };
106
+ export const getGetFileByIdQueryOptions = (id, options) => {
107
+ const { query: queryOptions, axios: axiosOptions } = options ?? {};
108
+ const queryKey = queryOptions?.queryKey ?? getGetFileByIdQueryKey(id);
109
+ const queryFn = ({ signal }) => getFileById(id, { signal, ...axiosOptions });
110
+ return { queryKey, queryFn, enabled: !!(id), ...queryOptions };
111
+ };
112
+ /**
113
+ * @summary Get file by id with presigned url
114
+ */
115
+ export function useGetFileById(id, options) {
116
+ const queryOptions = getGetFileByIdQueryOptions(id, options);
27
117
  const query = useQuery(queryOptions);
28
118
  query.queryKey = queryOptions.queryKey;
29
119
  return query;
30
120
  }
121
+ /**
122
+ * Delete file on database and storage service by id
123
+ * @summary Delete file by id
124
+ */
125
+ export const deleteFileById = (id, options) => {
126
+ return axios.delete(`/files/${id}`, options);
127
+ };
128
+ export const getDeleteFileByIdMutationOptions = (options) => {
129
+ const mutationKey = ['deleteFileById'];
130
+ const { mutation: mutationOptions, axios: axiosOptions } = options ?
131
+ options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
132
+ options
133
+ : { ...options, mutation: { ...options.mutation, mutationKey } }
134
+ : { mutation: { mutationKey, }, axios: undefined };
135
+ const mutationFn = (props) => {
136
+ const { id } = props ?? {};
137
+ return deleteFileById(id, axiosOptions);
138
+ };
139
+ return { mutationFn, ...mutationOptions };
140
+ };
141
+ /**
142
+ * @summary Delete file by id
143
+ */
144
+ export const useDeleteFileById = (options) => {
145
+ const mutationOptions = getDeleteFileByIdMutationOptions(options);
146
+ return useMutation(mutationOptions);
147
+ };
@@ -1,6 +1,6 @@
1
1
  import type { QueryKey, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
2
2
  import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';
3
- import type { CreateUserDto, LoginDto, RefreshTokenDto, User, UserLogin } from '.././model';
3
+ import type { CreateUserDto, GetUserFilesOutput, LoginDto, MyFilesParams, RefreshTokenDto, User, UserLogin } from '.././model';
4
4
  /**
5
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
6
  * @summary Sign up route where a user is created
@@ -109,9 +109,9 @@ export declare function useMe<TData = Awaited<ReturnType<typeof me>>, TError = A
109
109
  * Returns the authenticated user files URLs
110
110
  * @summary Get the authenticated user files URLs
111
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?: {
112
+ export declare const myFiles: (params: MyFilesParams, options?: AxiosRequestConfig) => Promise<AxiosResponse<GetUserFilesOutput>>;
113
+ export declare const getMyFilesQueryKey: (params: MyFilesParams) => readonly ["/users/me/files", ...MyFilesParams[]];
114
+ export declare const getMyFilesQueryOptions: <TData = AxiosResponse<GetUserFilesOutput, any>, TError = AxiosError<unknown, any>>(params: MyFilesParams, options?: {
115
115
  query?: UseQueryOptions<Awaited<ReturnType<typeof myFiles>>, TError, TData>;
116
116
  axios?: AxiosRequestConfig;
117
117
  }) => UseQueryOptions<Awaited<ReturnType<typeof myFiles>>, TError, TData> & {
@@ -122,7 +122,7 @@ export type MyFilesQueryError = AxiosError<unknown>;
122
122
  /**
123
123
  * @summary Get the authenticated user files URLs
124
124
  */
125
- export declare function useMyFiles<TData = Awaited<ReturnType<typeof myFiles>>, TError = AxiosError<unknown>>(options?: {
125
+ export declare function useMyFiles<TData = Awaited<ReturnType<typeof myFiles>>, TError = AxiosError<unknown>>(params: MyFilesParams, options?: {
126
126
  query?: UseQueryOptions<Awaited<ReturnType<typeof myFiles>>, TError, TData>;
127
127
  axios?: AxiosRequestConfig;
128
128
  }): UseQueryResult<TData, TError> & {
@@ -117,23 +117,26 @@ export function useMe(options) {
117
117
  * Returns the authenticated user files URLs
118
118
  * @summary Get the authenticated user files URLs
119
119
  */
120
- export const myFiles = (options) => {
121
- return axios.get(`/users/me/files`, options);
120
+ export const myFiles = (params, options) => {
121
+ return axios.get(`/users/me/files`, {
122
+ ...options,
123
+ params: { ...params, ...options?.params },
124
+ });
122
125
  };
123
- export const getMyFilesQueryKey = () => {
124
- return [`/users/me/files`];
126
+ export const getMyFilesQueryKey = (params) => {
127
+ return [`/users/me/files`, ...(params ? [params] : [])];
125
128
  };
126
- export const getMyFilesQueryOptions = (options) => {
129
+ export const getMyFilesQueryOptions = (params, options) => {
127
130
  const { query: queryOptions, axios: axiosOptions } = options ?? {};
128
- const queryKey = queryOptions?.queryKey ?? getMyFilesQueryKey();
129
- const queryFn = ({ signal }) => myFiles({ signal, ...axiosOptions });
131
+ const queryKey = queryOptions?.queryKey ?? getMyFilesQueryKey(params);
132
+ const queryFn = ({ signal }) => myFiles(params, { signal, ...axiosOptions });
130
133
  return { queryKey, queryFn, ...queryOptions };
131
134
  };
132
135
  /**
133
136
  * @summary Get the authenticated user files URLs
134
137
  */
135
- export function useMyFiles(options) {
136
- const queryOptions = getMyFilesQueryOptions(options);
138
+ export function useMyFiles(params, options) {
139
+ const queryOptions = getMyFilesQueryOptions(params, options);
137
140
  const query = useQuery(queryOptions);
138
141
  query.queryKey = queryOptions.queryKey;
139
142
  return query;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htkimura/files-storage-backend.rest-client",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "description": "REST client of files-storage-backend",
5
5
  "author": "Henry Kimura",
6
6
  "license": "MIT",
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "scripts": {
19
19
  "buildPackage": "tsc -p tsconfig.build.json",
20
- "publish": "yarn buildPackage && npm publish --access public"
20
+ "publishPackage": "yarn buildPackage && npm publish --access public"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@tanstack/react-query": "^5.66.0",