@htkimura/files-storage-backend.rest-client 0.0.28 → 0.0.29

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.
@@ -0,0 +1,118 @@
1
+ import type { UseMutationOptions, UseMutationResult } from '@tanstack/react-query';
2
+ import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';
3
+ import type { CreateFolderDto, Folder, RenameFolderDto, UpdateParentFolderDto } from '.././model';
4
+ /**
5
+ * Creates a new folder for the authenticated user. Optionally, can specify a parent folder to create it inside.
6
+ * @summary Create a new folder
7
+ */
8
+ export declare const createFolder: (createFolderDto: CreateFolderDto, options?: AxiosRequestConfig) => Promise<AxiosResponse<Folder>>;
9
+ export declare const getCreateFolderMutationOptions: <TData = AxiosResponse<Folder, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
10
+ mutation?: UseMutationOptions<TData, TError, {
11
+ data: CreateFolderDto;
12
+ }, TContext>;
13
+ axios?: AxiosRequestConfig;
14
+ }) => UseMutationOptions<TData, TError, {
15
+ data: CreateFolderDto;
16
+ }, TContext>;
17
+ export type CreateFolderMutationResult = NonNullable<Awaited<ReturnType<typeof createFolder>>>;
18
+ export type CreateFolderMutationBody = CreateFolderDto;
19
+ export type CreateFolderMutationError = AxiosError<unknown>;
20
+ /**
21
+ * @summary Create a new folder
22
+ */
23
+ export declare const useCreateFolder: <TData = AxiosResponse<Folder, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
24
+ mutation?: UseMutationOptions<TData, TError, {
25
+ data: CreateFolderDto;
26
+ }, TContext>;
27
+ axios?: AxiosRequestConfig;
28
+ }) => UseMutationResult<TData, TError, {
29
+ data: CreateFolderDto;
30
+ }, TContext>;
31
+ /**
32
+ * Renames a folder belonging to the authenticated user
33
+ * @summary Rename a folder
34
+ */
35
+ export declare const renameFolder: (id: string, renameFolderDto: RenameFolderDto, options?: AxiosRequestConfig) => Promise<AxiosResponse<Folder>>;
36
+ export declare const getRenameFolderMutationOptions: <TData = AxiosResponse<Folder, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
37
+ mutation?: UseMutationOptions<TData, TError, {
38
+ id: string;
39
+ data: RenameFolderDto;
40
+ }, TContext>;
41
+ axios?: AxiosRequestConfig;
42
+ }) => UseMutationOptions<TData, TError, {
43
+ id: string;
44
+ data: RenameFolderDto;
45
+ }, TContext>;
46
+ export type RenameFolderMutationResult = NonNullable<Awaited<ReturnType<typeof renameFolder>>>;
47
+ export type RenameFolderMutationBody = RenameFolderDto;
48
+ export type RenameFolderMutationError = AxiosError<unknown>;
49
+ /**
50
+ * @summary Rename a folder
51
+ */
52
+ export declare const useRenameFolder: <TData = AxiosResponse<Folder, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
53
+ mutation?: UseMutationOptions<TData, TError, {
54
+ id: string;
55
+ data: RenameFolderDto;
56
+ }, TContext>;
57
+ axios?: AxiosRequestConfig;
58
+ }) => UseMutationResult<TData, TError, {
59
+ id: string;
60
+ data: RenameFolderDto;
61
+ }, TContext>;
62
+ /**
63
+ * Moves a folder to another folder or removes it from its parent folder. Set parentFolderId to null to remove from parent folder.
64
+ * @summary Update folder parent
65
+ */
66
+ export declare const updateParentFolder: (id: string, updateParentFolderDto: UpdateParentFolderDto, options?: AxiosRequestConfig) => Promise<AxiosResponse<Folder>>;
67
+ export declare const getUpdateParentFolderMutationOptions: <TData = AxiosResponse<Folder, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
68
+ mutation?: UseMutationOptions<TData, TError, {
69
+ id: string;
70
+ data: UpdateParentFolderDto;
71
+ }, TContext>;
72
+ axios?: AxiosRequestConfig;
73
+ }) => UseMutationOptions<TData, TError, {
74
+ id: string;
75
+ data: UpdateParentFolderDto;
76
+ }, TContext>;
77
+ export type UpdateParentFolderMutationResult = NonNullable<Awaited<ReturnType<typeof updateParentFolder>>>;
78
+ export type UpdateParentFolderMutationBody = UpdateParentFolderDto;
79
+ export type UpdateParentFolderMutationError = AxiosError<unknown>;
80
+ /**
81
+ * @summary Update folder parent
82
+ */
83
+ export declare const useUpdateParentFolder: <TData = AxiosResponse<Folder, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
84
+ mutation?: UseMutationOptions<TData, TError, {
85
+ id: string;
86
+ data: UpdateParentFolderDto;
87
+ }, TContext>;
88
+ axios?: AxiosRequestConfig;
89
+ }) => UseMutationResult<TData, TError, {
90
+ id: string;
91
+ data: UpdateParentFolderDto;
92
+ }, TContext>;
93
+ /**
94
+ * Deletes a folder belonging to the authenticated user
95
+ * @summary Delete a folder
96
+ */
97
+ export declare const deleteFolder: (id: string, options?: AxiosRequestConfig) => Promise<AxiosResponse<boolean>>;
98
+ export declare const getDeleteFolderMutationOptions: <TData = AxiosResponse<boolean, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
99
+ mutation?: UseMutationOptions<TData, TError, {
100
+ id: string;
101
+ }, TContext>;
102
+ axios?: AxiosRequestConfig;
103
+ }) => UseMutationOptions<TData, TError, {
104
+ id: string;
105
+ }, TContext>;
106
+ export type DeleteFolderMutationResult = NonNullable<Awaited<ReturnType<typeof deleteFolder>>>;
107
+ export type DeleteFolderMutationError = AxiosError<unknown>;
108
+ /**
109
+ * @summary Delete a folder
110
+ */
111
+ export declare const useDeleteFolder: <TData = AxiosResponse<boolean, any>, TError = AxiosError<unknown, any>, TContext = unknown>(options?: {
112
+ mutation?: UseMutationOptions<TData, TError, {
113
+ id: string;
114
+ }, TContext>;
115
+ axios?: AxiosRequestConfig;
116
+ }) => UseMutationResult<TData, TError, {
117
+ id: string;
118
+ }, TContext>;
@@ -0,0 +1,117 @@
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 } from '@tanstack/react-query';
9
+ import axios from 'axios';
10
+ /**
11
+ * Creates a new folder for the authenticated user. Optionally, can specify a parent folder to create it inside.
12
+ * @summary Create a new folder
13
+ */
14
+ export const createFolder = (createFolderDto, options) => {
15
+ return axios.post(`/folders`, createFolderDto, options);
16
+ };
17
+ export const getCreateFolderMutationOptions = (options) => {
18
+ const mutationKey = ['createFolder'];
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 createFolder(data, axiosOptions);
27
+ };
28
+ return { mutationFn, ...mutationOptions };
29
+ };
30
+ /**
31
+ * @summary Create a new folder
32
+ */
33
+ export const useCreateFolder = (options) => {
34
+ const mutationOptions = getCreateFolderMutationOptions(options);
35
+ return useMutation(mutationOptions);
36
+ };
37
+ /**
38
+ * Renames a folder belonging to the authenticated user
39
+ * @summary Rename a folder
40
+ */
41
+ export const renameFolder = (id, renameFolderDto, options) => {
42
+ return axios.patch(`/folders/${id}/rename`, renameFolderDto, options);
43
+ };
44
+ export const getRenameFolderMutationOptions = (options) => {
45
+ const mutationKey = ['renameFolder'];
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 { id, data } = props ?? {};
53
+ return renameFolder(id, data, axiosOptions);
54
+ };
55
+ return { mutationFn, ...mutationOptions };
56
+ };
57
+ /**
58
+ * @summary Rename a folder
59
+ */
60
+ export const useRenameFolder = (options) => {
61
+ const mutationOptions = getRenameFolderMutationOptions(options);
62
+ return useMutation(mutationOptions);
63
+ };
64
+ /**
65
+ * Moves a folder to another folder or removes it from its parent folder. Set parentFolderId to null to remove from parent folder.
66
+ * @summary Update folder parent
67
+ */
68
+ export const updateParentFolder = (id, updateParentFolderDto, options) => {
69
+ return axios.put(`/folders/${id}/parent`, updateParentFolderDto, options);
70
+ };
71
+ export const getUpdateParentFolderMutationOptions = (options) => {
72
+ const mutationKey = ['updateParentFolder'];
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 { id, data } = props ?? {};
80
+ return updateParentFolder(id, data, axiosOptions);
81
+ };
82
+ return { mutationFn, ...mutationOptions };
83
+ };
84
+ /**
85
+ * @summary Update folder parent
86
+ */
87
+ export const useUpdateParentFolder = (options) => {
88
+ const mutationOptions = getUpdateParentFolderMutationOptions(options);
89
+ return useMutation(mutationOptions);
90
+ };
91
+ /**
92
+ * Deletes a folder belonging to the authenticated user
93
+ * @summary Delete a folder
94
+ */
95
+ export const deleteFolder = (id, options) => {
96
+ return axios.delete(`/folders/${id}`, options);
97
+ };
98
+ export const getDeleteFolderMutationOptions = (options) => {
99
+ const mutationKey = ['deleteFolder'];
100
+ const { mutation: mutationOptions, axios: axiosOptions } = options ?
101
+ options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
102
+ options
103
+ : { ...options, mutation: { ...options.mutation, mutationKey } }
104
+ : { mutation: { mutationKey, }, axios: undefined };
105
+ const mutationFn = (props) => {
106
+ const { id } = props ?? {};
107
+ return deleteFolder(id, axiosOptions);
108
+ };
109
+ return { mutationFn, ...mutationOptions };
110
+ };
111
+ /**
112
+ * @summary Delete a folder
113
+ */
114
+ export const useDeleteFolder = (options) => {
115
+ const mutationOptions = getDeleteFolderMutationOptions(options);
116
+ return useMutation(mutationOptions);
117
+ };
@@ -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 CreateFolderDto {
9
+ name: string;
10
+ parentFolderId?: string;
11
+ }
@@ -15,4 +15,5 @@ export interface File {
15
15
  path: string;
16
16
  thumbnailPath?: string;
17
17
  userId: string;
18
+ folderId?: string;
18
19
  }
@@ -15,5 +15,6 @@ export interface FileWithPresignedThumbnailUrl {
15
15
  path: string;
16
16
  thumbnailPath?: string;
17
17
  userId: string;
18
+ folderId?: string;
18
19
  presignedThumbnailUrl: string;
19
20
  }
@@ -15,5 +15,6 @@ export interface FileWithPresignedUrl {
15
15
  path: string;
16
16
  thumbnailPath?: string;
17
17
  userId: string;
18
+ folderId?: string;
18
19
  presignedUrl: string;
19
20
  }
@@ -5,8 +5,11 @@
5
5
  * This API is for storing files for different users
6
6
  * OpenAPI spec version: 1.0
7
7
  */
8
- export type GetPresignedUrlParams = {
9
- fileName: string;
10
- fileType: string;
11
- fileSize: number;
12
- };
8
+ export interface Folder {
9
+ id: string;
10
+ createdAt: string;
11
+ updatedAt: string;
12
+ name: string;
13
+ userId: string;
14
+ parentFolderId?: string;
15
+ }
@@ -5,6 +5,7 @@
5
5
  * This API is for storing files for different users
6
6
  * OpenAPI spec version: 1.0
7
7
  */
8
+ export * from './createFolderDto';
8
9
  export * from './createUserDto';
9
10
  export * from './deleteBulkFilesByIdsParams';
10
11
  export * from './deleteBulkFilesOutput';
@@ -12,12 +13,15 @@ export * from './file';
12
13
  export * from './fileFilterType';
13
14
  export * from './fileWithPresignedThumbnailUrl';
14
15
  export * from './fileWithPresignedUrl';
16
+ export * from './folder';
15
17
  export * from './getBulkFilesByIdsParams';
16
18
  export * from './getPresignedUploadUrlParams';
17
19
  export * from './getUserFilesOutput';
18
20
  export * from './loginDto';
19
21
  export * from './myFilesParams';
20
22
  export * from './refreshTokenDto';
23
+ export * from './renameFolderDto';
24
+ export * from './updateParentFolderDto';
21
25
  export * from './uploadFileOutput';
22
26
  export * from './user';
23
27
  export * from './userLogin';
@@ -5,6 +5,7 @@
5
5
  * This API is for storing files for different users
6
6
  * OpenAPI spec version: 1.0
7
7
  */
8
+ export * from './createFolderDto';
8
9
  export * from './createUserDto';
9
10
  export * from './deleteBulkFilesByIdsParams';
10
11
  export * from './deleteBulkFilesOutput';
@@ -12,12 +13,15 @@ export * from './file';
12
13
  export * from './fileFilterType';
13
14
  export * from './fileWithPresignedThumbnailUrl';
14
15
  export * from './fileWithPresignedUrl';
16
+ export * from './folder';
15
17
  export * from './getBulkFilesByIdsParams';
16
18
  export * from './getPresignedUploadUrlParams';
17
19
  export * from './getUserFilesOutput';
18
20
  export * from './loginDto';
19
21
  export * from './myFilesParams';
20
22
  export * from './refreshTokenDto';
23
+ export * from './renameFolderDto';
24
+ export * from './updateParentFolderDto';
21
25
  export * from './uploadFileOutput';
22
26
  export * from './user';
23
27
  export * from './userLogin';
@@ -5,6 +5,6 @@
5
5
  * This API is for storing files for different users
6
6
  * OpenAPI spec version: 1.0
7
7
  */
8
- export interface FileFilters {
9
- [key: string]: unknown;
8
+ export interface RenameFolderDto {
9
+ name: string;
10
10
  }
@@ -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 UpdateParentFolderDto {
9
+ /**
10
+ * ID of the parent folder to move this folder into. Set to null to remove from parent folder.
11
+ * @nullable
12
+ */
13
+ parentFolderId?: string | null;
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 {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htkimura/files-storage-backend.rest-client",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "description": "REST client of files-storage-backend",
5
5
  "author": "Henry Kimura",
6
6
  "license": "MIT",
@@ -28,9 +28,12 @@
28
28
  "axios": "^1.7.9"
29
29
  },
30
30
  "devDependencies": {
31
+ "@tanstack/react-query": "^5.66.0",
31
32
  "@types/node": "^22.13.5",
32
33
  "@types/react": "^19.0.10",
33
34
  "@types/react-dom": "^19.0.4",
35
+ "react": "^19.0.0",
36
+ "react-dom": "^19.0.0",
34
37
  "typescript": "^5.7.3"
35
38
  }
36
39
  }
@@ -1,12 +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
- export type StorageControllerGetPresignedUrlParams = {
9
- fileName: string;
10
- fileType: string;
11
- fileSize: number;
12
- };