@htkimura/files-storage-backend.rest-client 0.0.29 → 0.0.30
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/dist/generated/model/getUserFilesOutput.d.ts +1 -1
- package/dist/generated/model/index.d.ts +2 -0
- package/dist/generated/model/index.js +2 -0
- package/dist/generated/model/listChildrenParams.d.ts +12 -0
- package/dist/generated/model/listChildrenParams.js +8 -0
- package/dist/generated/model/moveFileToFolderDto.d.ts +14 -0
- package/dist/generated/model/moveFileToFolderDto.js +8 -0
- package/dist/generated/storage/storage.d.ts +55 -1
- package/dist/generated/storage/storage.js +55 -0
- package/package.json +1 -1
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { FileWithPresignedThumbnailUrl } from './fileWithPresignedThumbnailUrl';
|
|
9
9
|
export interface GetUserFilesOutput {
|
|
10
|
-
data: FileWithPresignedThumbnailUrl[];
|
|
11
10
|
page: number;
|
|
12
11
|
size: number;
|
|
13
12
|
total: number;
|
|
14
13
|
hasMore: boolean;
|
|
14
|
+
data: FileWithPresignedThumbnailUrl[];
|
|
15
15
|
}
|
|
@@ -17,7 +17,9 @@ export * from './folder';
|
|
|
17
17
|
export * from './getBulkFilesByIdsParams';
|
|
18
18
|
export * from './getPresignedUploadUrlParams';
|
|
19
19
|
export * from './getUserFilesOutput';
|
|
20
|
+
export * from './listChildrenParams';
|
|
20
21
|
export * from './loginDto';
|
|
22
|
+
export * from './moveFileToFolderDto';
|
|
21
23
|
export * from './myFilesParams';
|
|
22
24
|
export * from './refreshTokenDto';
|
|
23
25
|
export * from './renameFolderDto';
|
|
@@ -17,7 +17,9 @@ export * from './folder';
|
|
|
17
17
|
export * from './getBulkFilesByIdsParams';
|
|
18
18
|
export * from './getPresignedUploadUrlParams';
|
|
19
19
|
export * from './getUserFilesOutput';
|
|
20
|
+
export * from './listChildrenParams';
|
|
20
21
|
export * from './loginDto';
|
|
22
|
+
export * from './moveFileToFolderDto';
|
|
21
23
|
export * from './myFilesParams';
|
|
22
24
|
export * from './refreshTokenDto';
|
|
23
25
|
export * from './renameFolderDto';
|
|
@@ -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 ListChildrenParams = {
|
|
9
|
+
page?: number;
|
|
10
|
+
size?: number;
|
|
11
|
+
parentFolderId?: string;
|
|
12
|
+
};
|
|
@@ -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 MoveFileToFolderDto {
|
|
9
|
+
/**
|
|
10
|
+
* ID of the folder to move this file into. Set to null to remove from folder.
|
|
11
|
+
* @nullable
|
|
12
|
+
*/
|
|
13
|
+
folderId?: string | null;
|
|
14
|
+
}
|
|
@@ -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 { DeleteBulkFilesByIdsParams, DeleteBulkFilesOutput, FileWithPresignedUrl, GetBulkFilesByIdsParams, GetPresignedUploadUrlParams, UploadFileOutput } from '.././model';
|
|
3
|
+
import type { DeleteBulkFilesByIdsParams, DeleteBulkFilesOutput, File, FileWithPresignedUrl, GetBulkFilesByIdsParams, GetPresignedUploadUrlParams, ListChildrenParams, MoveFileToFolderDto, UploadFileOutput } from '.././model';
|
|
4
4
|
/**
|
|
5
5
|
* Returns presigned url to upload file
|
|
6
6
|
* @summary Get presigned url to upload file
|
|
@@ -140,3 +140,57 @@ export declare const useDeleteFileById: <TData = AxiosResponse<boolean, any>, TE
|
|
|
140
140
|
}) => UseMutationResult<TData, TError, {
|
|
141
141
|
id: string;
|
|
142
142
|
}, TContext>;
|
|
143
|
+
/**
|
|
144
|
+
* Returns content of a folder. If no folder is provided, list content of root folder
|
|
145
|
+
* @summary Get content of a folder (also works for root folder)
|
|
146
|
+
*/
|
|
147
|
+
export declare const listChildren: (params: ListChildrenParams, options?: AxiosRequestConfig) => Promise<AxiosResponse<FileWithPresignedUrl>>;
|
|
148
|
+
export declare const getListChildrenQueryKey: (params: ListChildrenParams) => readonly ["/children", ...ListChildrenParams[]];
|
|
149
|
+
export declare const getListChildrenQueryOptions: <TData = AxiosResponse<FileWithPresignedUrl, any>, TError = AxiosError<unknown, any>>(params: ListChildrenParams, options?: {
|
|
150
|
+
query?: UseQueryOptions<Awaited<ReturnType<typeof listChildren>>, TError, TData>;
|
|
151
|
+
axios?: AxiosRequestConfig;
|
|
152
|
+
}) => UseQueryOptions<Awaited<ReturnType<typeof listChildren>>, TError, TData> & {
|
|
153
|
+
queryKey: QueryKey;
|
|
154
|
+
};
|
|
155
|
+
export type ListChildrenQueryResult = NonNullable<Awaited<ReturnType<typeof listChildren>>>;
|
|
156
|
+
export type ListChildrenQueryError = AxiosError<unknown>;
|
|
157
|
+
/**
|
|
158
|
+
* @summary Get content of a folder (also works for root folder)
|
|
159
|
+
*/
|
|
160
|
+
export declare function useListChildren<TData = Awaited<ReturnType<typeof listChildren>>, TError = AxiosError<unknown>>(params: ListChildrenParams, options?: {
|
|
161
|
+
query?: UseQueryOptions<Awaited<ReturnType<typeof listChildren>>, TError, TData>;
|
|
162
|
+
axios?: AxiosRequestConfig;
|
|
163
|
+
}): UseQueryResult<TData, TError> & {
|
|
164
|
+
queryKey: QueryKey;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Moves a file to a folder or removes it from its folder. Set folderId to null to remove from folder.
|
|
168
|
+
* @summary Move file to folder
|
|
169
|
+
*/
|
|
170
|
+
export declare const moveFileToFolder: (id: string, moveFileToFolderDto: MoveFileToFolderDto, options?: AxiosRequestConfig) => Promise<AxiosResponse<File>>;
|
|
171
|
+
export declare const getMoveFileToFolderMutationOptions: <TData = AxiosResponse<File, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
|
|
172
|
+
mutation?: UseMutationOptions<TData, TError, {
|
|
173
|
+
id: string;
|
|
174
|
+
data: MoveFileToFolderDto;
|
|
175
|
+
}, TContext>;
|
|
176
|
+
axios?: AxiosRequestConfig;
|
|
177
|
+
}) => UseMutationOptions<TData, TError, {
|
|
178
|
+
id: string;
|
|
179
|
+
data: MoveFileToFolderDto;
|
|
180
|
+
}, TContext>;
|
|
181
|
+
export type MoveFileToFolderMutationResult = NonNullable<Awaited<ReturnType<typeof moveFileToFolder>>>;
|
|
182
|
+
export type MoveFileToFolderMutationBody = MoveFileToFolderDto;
|
|
183
|
+
export type MoveFileToFolderMutationError = AxiosError<unknown>;
|
|
184
|
+
/**
|
|
185
|
+
* @summary Move file to folder
|
|
186
|
+
*/
|
|
187
|
+
export declare const useMoveFileToFolder: <TData = AxiosResponse<File, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
|
|
188
|
+
mutation?: UseMutationOptions<TData, TError, {
|
|
189
|
+
id: string;
|
|
190
|
+
data: MoveFileToFolderDto;
|
|
191
|
+
}, TContext>;
|
|
192
|
+
axios?: AxiosRequestConfig;
|
|
193
|
+
}) => UseMutationResult<TData, TError, {
|
|
194
|
+
id: string;
|
|
195
|
+
data: MoveFileToFolderDto;
|
|
196
|
+
}, TContext>;
|
|
@@ -171,3 +171,58 @@ export const useDeleteFileById = (options) => {
|
|
|
171
171
|
const mutationOptions = getDeleteFileByIdMutationOptions(options);
|
|
172
172
|
return useMutation(mutationOptions);
|
|
173
173
|
};
|
|
174
|
+
/**
|
|
175
|
+
* Returns content of a folder. If no folder is provided, list content of root folder
|
|
176
|
+
* @summary Get content of a folder (also works for root folder)
|
|
177
|
+
*/
|
|
178
|
+
export const listChildren = (params, options) => {
|
|
179
|
+
return axios.get(`/children`, {
|
|
180
|
+
...options,
|
|
181
|
+
params: { ...params, ...options?.params },
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
export const getListChildrenQueryKey = (params) => {
|
|
185
|
+
return [`/children`, ...(params ? [params] : [])];
|
|
186
|
+
};
|
|
187
|
+
export const getListChildrenQueryOptions = (params, options) => {
|
|
188
|
+
const { query: queryOptions, axios: axiosOptions } = options ?? {};
|
|
189
|
+
const queryKey = queryOptions?.queryKey ?? getListChildrenQueryKey(params);
|
|
190
|
+
const queryFn = ({ signal }) => listChildren(params, { signal, ...axiosOptions });
|
|
191
|
+
return { queryKey, queryFn, ...queryOptions };
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* @summary Get content of a folder (also works for root folder)
|
|
195
|
+
*/
|
|
196
|
+
export function useListChildren(params, options) {
|
|
197
|
+
const queryOptions = getListChildrenQueryOptions(params, options);
|
|
198
|
+
const query = useQuery(queryOptions);
|
|
199
|
+
query.queryKey = queryOptions.queryKey;
|
|
200
|
+
return query;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Moves a file to a folder or removes it from its folder. Set folderId to null to remove from folder.
|
|
204
|
+
* @summary Move file to folder
|
|
205
|
+
*/
|
|
206
|
+
export const moveFileToFolder = (id, moveFileToFolderDto, options) => {
|
|
207
|
+
return axios.put(`/files/${id}/folder`, moveFileToFolderDto, options);
|
|
208
|
+
};
|
|
209
|
+
export const getMoveFileToFolderMutationOptions = (options) => {
|
|
210
|
+
const mutationKey = ['moveFileToFolder'];
|
|
211
|
+
const { mutation: mutationOptions, axios: axiosOptions } = options ?
|
|
212
|
+
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
213
|
+
options
|
|
214
|
+
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
215
|
+
: { mutation: { mutationKey, }, axios: undefined };
|
|
216
|
+
const mutationFn = (props) => {
|
|
217
|
+
const { id, data } = props ?? {};
|
|
218
|
+
return moveFileToFolder(id, data, axiosOptions);
|
|
219
|
+
};
|
|
220
|
+
return { mutationFn, ...mutationOptions };
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* @summary Move file to folder
|
|
224
|
+
*/
|
|
225
|
+
export const useMoveFileToFolder = (options) => {
|
|
226
|
+
const mutationOptions = getMoveFileToFolderMutationOptions(options);
|
|
227
|
+
return useMutation(mutationOptions);
|
|
228
|
+
};
|