@htkimura/files-storage-backend.rest-client 0.0.12 → 0.0.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htkimura/files-storage-backend.rest-client",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "REST client of files-storage-backend",
5
5
  "author": "Henry Kimura",
6
6
  "license": "MIT",
@@ -23,6 +23,7 @@
23
23
  "axios": "^1.7.9"
24
24
  },
25
25
  "devDependencies": {
26
+ "@tanstack/react-query": "^5.66.0",
26
27
  "@types/node": "^22.13.5",
27
28
  "@types/react": "^19.0.10",
28
29
  "@types/react-dom": "^19.0.4",
@@ -9,5 +9,6 @@
9
9
  export * from './createUserDto';
10
10
  export * from './loginDto';
11
11
  export * from './refreshTokenDto';
12
+ export * from './storageControllerGetPresignedUrlParams';
12
13
  export * from './user';
13
14
  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
+
9
+ export type StorageControllerGetPresignedUrlParams = {
10
+ fileName: string;
11
+ fileType: string;
12
+ fileSize: number;
13
+ };
@@ -6,15 +6,11 @@
6
6
  * OpenAPI spec version: 1.0
7
7
  */
8
8
  import {
9
- useMutation,
10
9
  useQuery
11
10
  } from '@tanstack/react-query'
12
11
  import type {
13
- MutationFunction,
14
12
  QueryFunction,
15
13
  QueryKey,
16
- UseMutationOptions,
17
- UseMutationResult,
18
14
  UseQueryOptions,
19
15
  UseQueryResult
20
16
  } from '@tanstack/react-query'
@@ -24,54 +20,59 @@ import type {
24
20
  AxiosRequestConfig,
25
21
  AxiosResponse
26
22
  } from 'axios'
23
+ import type {
24
+ StorageControllerGetPresignedUrlParams
25
+ } from '.././model'
27
26
 
28
27
 
29
28
 
30
- export const storageControllerGetObjectUrl = (
31
- objectName: string, options?: AxiosRequestConfig
29
+ export const storageControllerGetPresignedUrl = (
30
+ params: StorageControllerGetPresignedUrlParams, options?: AxiosRequestConfig
32
31
  ): Promise<AxiosResponse<void>> => {
33
32
 
34
33
 
35
34
  return axios.get(
36
- `/objects/${objectName}`,options
35
+ `/uploads/presigned-url`,{
36
+ ...options,
37
+ params: {...params, ...options?.params},}
37
38
  );
38
39
  }
39
40
 
40
41
 
41
- export const getStorageControllerGetObjectUrlQueryKey = (objectName: string,) => {
42
- return [`/objects/${objectName}`] as const;
42
+ export const getStorageControllerGetPresignedUrlQueryKey = (params: StorageControllerGetPresignedUrlParams,) => {
43
+ return [`/uploads/presigned-url`, ...(params ? [params]: [])] as const;
43
44
  }
44
45
 
45
46
 
46
- export const getStorageControllerGetObjectUrlQueryOptions = <TData = Awaited<ReturnType<typeof storageControllerGetObjectUrl>>, TError = AxiosError<unknown>>(objectName: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof storageControllerGetObjectUrl>>, TError, TData>, axios?: AxiosRequestConfig}
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}
47
48
  ) => {
48
49
 
49
50
  const {query: queryOptions, axios: axiosOptions} = options ?? {};
50
51
 
51
- const queryKey = queryOptions?.queryKey ?? getStorageControllerGetObjectUrlQueryKey(objectName);
52
+ const queryKey = queryOptions?.queryKey ?? getStorageControllerGetPresignedUrlQueryKey(params);
52
53
 
53
54
 
54
55
 
55
- const queryFn: QueryFunction<Awaited<ReturnType<typeof storageControllerGetObjectUrl>>> = ({ signal }) => storageControllerGetObjectUrl(objectName, { signal, ...axiosOptions });
56
+ const queryFn: QueryFunction<Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>> = ({ signal }) => storageControllerGetPresignedUrl(params, { signal, ...axiosOptions });
56
57
 
57
58
 
58
59
 
59
60
 
60
61
 
61
- return { queryKey, queryFn, enabled: !!(objectName), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof storageControllerGetObjectUrl>>, TError, TData> & { queryKey: QueryKey }
62
+ return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>, TError, TData> & { queryKey: QueryKey }
62
63
  }
63
64
 
64
- export type StorageControllerGetObjectUrlQueryResult = NonNullable<Awaited<ReturnType<typeof storageControllerGetObjectUrl>>>
65
- export type StorageControllerGetObjectUrlQueryError = AxiosError<unknown>
65
+ export type StorageControllerGetPresignedUrlQueryResult = NonNullable<Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>>
66
+ export type StorageControllerGetPresignedUrlQueryError = AxiosError<unknown>
66
67
 
67
68
 
68
69
 
69
- export function useStorageControllerGetObjectUrl<TData = Awaited<ReturnType<typeof storageControllerGetObjectUrl>>, TError = AxiosError<unknown>>(
70
- objectName: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof storageControllerGetObjectUrl>>, TError, TData>, axios?: AxiosRequestConfig}
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}
71
72
 
72
73
  ): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
73
74
 
74
- const queryOptions = getStorageControllerGetObjectUrlQueryOptions(objectName,options)
75
+ const queryOptions = getStorageControllerGetPresignedUrlQueryOptions(params,options)
75
76
 
76
77
  const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
77
78
 
@@ -82,57 +83,3 @@ export function useStorageControllerGetObjectUrl<TData = Awaited<ReturnType<type
82
83
 
83
84
 
84
85
 
85
- export const storageControllerUploadObject = (
86
- options?: AxiosRequestConfig
87
- ): Promise<AxiosResponse<void>> => {
88
-
89
-
90
- return axios.post(
91
- `/objects`,undefined,options
92
- );
93
- }
94
-
95
-
96
-
97
- export const getStorageControllerUploadObjectMutationOptions = <TData = Awaited<ReturnType<typeof storageControllerUploadObject>>, TError = AxiosError<unknown>,
98
- TContext = unknown>(options?: { mutation?:UseMutationOptions<TData, TError,void, TContext>, axios?: AxiosRequestConfig}
99
- ) => {
100
- const mutationKey = ['storageControllerUploadObject'];
101
- const {mutation: mutationOptions, axios: axiosOptions} = options ?
102
- options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
103
- options
104
- : {...options, mutation: {...options.mutation, mutationKey}}
105
- : {mutation: { mutationKey, }, axios: undefined};
106
-
107
-
108
-
109
-
110
- const mutationFn: MutationFunction<Awaited<ReturnType<typeof storageControllerUploadObject>>, void> = () => {
111
-
112
-
113
- return storageControllerUploadObject(axiosOptions)
114
- }
115
-
116
-
117
-
118
-
119
- return { mutationFn, ...mutationOptions } as UseMutationOptions<TData, TError,void, TContext>}
120
-
121
- export type StorageControllerUploadObjectMutationResult = NonNullable<Awaited<ReturnType<typeof storageControllerUploadObject>>>
122
-
123
- export type StorageControllerUploadObjectMutationError = AxiosError<unknown>
124
-
125
- export const useStorageControllerUploadObject = <TData = Awaited<ReturnType<typeof storageControllerUploadObject>>, TError = AxiosError<unknown>,
126
- TContext = unknown>(options?: { mutation?:UseMutationOptions<TData, TError,void, TContext>, axios?: AxiosRequestConfig}
127
- ): UseMutationResult<
128
- TData,
129
- TError,
130
- void,
131
- TContext
132
- > => {
133
-
134
- const mutationOptions = getStorageControllerUploadObjectMutationOptions(options);
135
-
136
- return useMutation(mutationOptions);
137
- }
138
-
@@ -1,3 +0,0 @@
1
- export * from './model';
2
- export * from './storage/storage';
3
- export * from './user/user';