@htkimura/files-storage-backend.rest-client 0.0.34 → 0.0.35

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,13 +1,13 @@
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 { CreateFolderDto, Folder, RenameFolderDto, UpdateParentFolderDto } from '.././model';
3
+ import type { CreateFolderDto, Folder, ListMyFoldersParams, RenameFolderDto, UpdateParentFolderDto } from '.././model';
4
4
  /**
5
- * Returns every folder belonging to the authenticated user, in any parent location.
5
+ * Returns folders for the authenticated user. Omit parentFolderId to return all folders, pass null for root-level folders only, or pass a folder ID to return direct child folders.
6
6
  * @summary List all folders
7
7
  */
8
- export declare const listMyFolders: (options?: AxiosRequestConfig) => Promise<AxiosResponse<Folder[]>>;
9
- export declare const getListMyFoldersQueryKey: () => readonly ["/folders"];
10
- export declare const getListMyFoldersQueryOptions: <TData = AxiosResponse<Folder[], any>, TError = AxiosError<unknown, any>>(options?: {
8
+ export declare const listMyFolders: (params?: ListMyFoldersParams, options?: AxiosRequestConfig) => Promise<AxiosResponse<Folder[]>>;
9
+ export declare const getListMyFoldersQueryKey: (params?: ListMyFoldersParams) => readonly ["/folders", ...ListMyFoldersParams[]];
10
+ export declare const getListMyFoldersQueryOptions: <TData = AxiosResponse<Folder[], any>, TError = AxiosError<unknown, any>>(params?: ListMyFoldersParams, options?: {
11
11
  query?: UseQueryOptions<Awaited<ReturnType<typeof listMyFolders>>, TError, TData>;
12
12
  axios?: AxiosRequestConfig;
13
13
  }) => UseQueryOptions<Awaited<ReturnType<typeof listMyFolders>>, TError, TData> & {
@@ -18,7 +18,7 @@ export type ListMyFoldersQueryError = AxiosError<unknown>;
18
18
  /**
19
19
  * @summary List all folders
20
20
  */
21
- export declare function useListMyFolders<TData = Awaited<ReturnType<typeof listMyFolders>>, TError = AxiosError<unknown>>(options?: {
21
+ export declare function useListMyFolders<TData = Awaited<ReturnType<typeof listMyFolders>>, TError = AxiosError<unknown>>(params?: ListMyFoldersParams, options?: {
22
22
  query?: UseQueryOptions<Awaited<ReturnType<typeof listMyFolders>>, TError, TData>;
23
23
  axios?: AxiosRequestConfig;
24
24
  }): UseQueryResult<TData, TError> & {
@@ -8,26 +8,29 @@
8
8
  import { useMutation, useQuery } from '@tanstack/react-query';
9
9
  import axios from 'axios';
10
10
  /**
11
- * Returns every folder belonging to the authenticated user, in any parent location.
11
+ * Returns folders for the authenticated user. Omit parentFolderId to return all folders, pass null for root-level folders only, or pass a folder ID to return direct child folders.
12
12
  * @summary List all folders
13
13
  */
14
- export const listMyFolders = (options) => {
15
- return axios.get(`/folders`, options);
14
+ export const listMyFolders = (params, options) => {
15
+ return axios.get(`/folders`, {
16
+ ...options,
17
+ params: { ...params, ...options?.params },
18
+ });
16
19
  };
17
- export const getListMyFoldersQueryKey = () => {
18
- return [`/folders`];
20
+ export const getListMyFoldersQueryKey = (params) => {
21
+ return [`/folders`, ...(params ? [params] : [])];
19
22
  };
20
- export const getListMyFoldersQueryOptions = (options) => {
23
+ export const getListMyFoldersQueryOptions = (params, options) => {
21
24
  const { query: queryOptions, axios: axiosOptions } = options ?? {};
22
- const queryKey = queryOptions?.queryKey ?? getListMyFoldersQueryKey();
23
- const queryFn = ({ signal }) => listMyFolders({ signal, ...axiosOptions });
25
+ const queryKey = queryOptions?.queryKey ?? getListMyFoldersQueryKey(params);
26
+ const queryFn = ({ signal }) => listMyFolders(params, { signal, ...axiosOptions });
24
27
  return { queryKey, queryFn, ...queryOptions };
25
28
  };
26
29
  /**
27
30
  * @summary List all folders
28
31
  */
29
- export function useListMyFolders(options) {
30
- const queryOptions = getListMyFoldersQueryOptions(options);
32
+ export function useListMyFolders(params, options) {
33
+ const queryOptions = getListMyFoldersQueryOptions(params, options);
31
34
  const query = useQuery(queryOptions);
32
35
  query.queryKey = queryOptions.queryKey;
33
36
  return query;
@@ -25,12 +25,14 @@ export * from './initMultipartUploadOutput';
25
25
  export * from './listChildrenData';
26
26
  export * from './listChildrenOutput';
27
27
  export * from './listChildrenParams';
28
+ export * from './listMyFoldersParams';
28
29
  export * from './loginDto';
29
30
  export * from './moveFileToFolderDto';
30
31
  export * from './multipartPartUrlOutput';
31
32
  export * from './multipartUploadedPartDto';
32
33
  export * from './myFilesParams';
33
34
  export * from './refreshTokenDto';
35
+ export * from './renameFileDto';
34
36
  export * from './renameFolderDto';
35
37
  export * from './updateParentFolderDto';
36
38
  export * from './uploadFileOutput';
@@ -25,12 +25,14 @@ export * from './initMultipartUploadOutput';
25
25
  export * from './listChildrenData';
26
26
  export * from './listChildrenOutput';
27
27
  export * from './listChildrenParams';
28
+ export * from './listMyFoldersParams';
28
29
  export * from './loginDto';
29
30
  export * from './moveFileToFolderDto';
30
31
  export * from './multipartPartUrlOutput';
31
32
  export * from './multipartUploadedPartDto';
32
33
  export * from './myFilesParams';
33
34
  export * from './refreshTokenDto';
35
+ export * from './renameFileDto';
34
36
  export * from './renameFolderDto';
35
37
  export * from './updateParentFolderDto';
36
38
  export * from './uploadFileOutput';
@@ -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 type ListMyFoldersParams = {
9
+ /**
10
+ * Filter by parent folder. Omit to return all folders. Pass null for root-level folders only.
11
+ */
12
+ parentFolderId?: string | null;
13
+ };
@@ -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 interface RenameFileDto {
9
+ name: 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 {};
@@ -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 { AbortMultipartUploadParams, CompleteMultipartUploadDto, DeleteBulkFilesByIdsParams, DeleteBulkFilesOutput, File, FileWithPresignedUrl, GetBulkFilesByIdsParams, GetMultipartPartUrlParams, GetPresignedUploadUrlParams, InitMultipartUploadDto, InitMultipartUploadOutput, ListChildrenOutput, ListChildrenParams, MoveFileToFolderDto, MultipartPartUrlOutput, UploadFileOutput } from '.././model';
3
+ import type { AbortMultipartUploadParams, CompleteMultipartUploadDto, DeleteBulkFilesByIdsParams, DeleteBulkFilesOutput, File, FileWithPresignedUrl, GetBulkFilesByIdsParams, GetMultipartPartUrlParams, GetPresignedUploadUrlParams, InitMultipartUploadDto, InitMultipartUploadOutput, ListChildrenOutput, ListChildrenParams, MoveFileToFolderDto, MultipartPartUrlOutput, RenameFileDto, UploadFileOutput } from '.././model';
4
4
  /**
5
5
  * Returns presigned url to upload file
6
6
  * @summary Get presigned url to upload file
@@ -296,3 +296,34 @@ export declare const useMoveFileToFolder: <TData = AxiosResponse<File, any>, TEr
296
296
  id: string;
297
297
  data: MoveFileToFolderDto;
298
298
  }, TContext>;
299
+ /**
300
+ * Renames a file belonging to the authenticated user
301
+ * @summary Rename a file
302
+ */
303
+ export declare const renameFile: (id: string, renameFileDto: RenameFileDto, options?: AxiosRequestConfig) => Promise<AxiosResponse<File>>;
304
+ export declare const getRenameFileMutationOptions: <TData = AxiosResponse<File, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
305
+ mutation?: UseMutationOptions<TData, TError, {
306
+ id: string;
307
+ data: RenameFileDto;
308
+ }, TContext>;
309
+ axios?: AxiosRequestConfig;
310
+ }) => UseMutationOptions<TData, TError, {
311
+ id: string;
312
+ data: RenameFileDto;
313
+ }, TContext>;
314
+ export type RenameFileMutationResult = NonNullable<Awaited<ReturnType<typeof renameFile>>>;
315
+ export type RenameFileMutationBody = RenameFileDto;
316
+ export type RenameFileMutationError = AxiosError<unknown>;
317
+ /**
318
+ * @summary Rename a file
319
+ */
320
+ export declare const useRenameFile: <TData = AxiosResponse<File, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
321
+ mutation?: UseMutationOptions<TData, TError, {
322
+ id: string;
323
+ data: RenameFileDto;
324
+ }, TContext>;
325
+ axios?: AxiosRequestConfig;
326
+ }) => UseMutationResult<TData, TError, {
327
+ id: string;
328
+ data: RenameFileDto;
329
+ }, TContext>;
@@ -337,3 +337,30 @@ export const useMoveFileToFolder = (options) => {
337
337
  const mutationOptions = getMoveFileToFolderMutationOptions(options);
338
338
  return useMutation(mutationOptions);
339
339
  };
340
+ /**
341
+ * Renames a file belonging to the authenticated user
342
+ * @summary Rename a file
343
+ */
344
+ export const renameFile = (id, renameFileDto, options) => {
345
+ return axios.patch(`/files/${id}/rename`, renameFileDto, options);
346
+ };
347
+ export const getRenameFileMutationOptions = (options) => {
348
+ const mutationKey = ['renameFile'];
349
+ const { mutation: mutationOptions, axios: axiosOptions } = options ?
350
+ options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
351
+ options
352
+ : { ...options, mutation: { ...options.mutation, mutationKey } }
353
+ : { mutation: { mutationKey, }, axios: undefined };
354
+ const mutationFn = (props) => {
355
+ const { id, data } = props ?? {};
356
+ return renameFile(id, data, axiosOptions);
357
+ };
358
+ return { mutationFn, ...mutationOptions };
359
+ };
360
+ /**
361
+ * @summary Rename a file
362
+ */
363
+ export const useRenameFile = (options) => {
364
+ const mutationOptions = getRenameFileMutationOptions(options);
365
+ return useMutation(mutationOptions);
366
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htkimura/files-storage-backend.rest-client",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "description": "REST client of files-storage-backend",
5
5
  "author": "Henry Kimura",
6
6
  "license": "MIT",