@htkimura/files-storage-backend.rest-client 0.0.21 → 0.0.23
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/file.d.ts +17 -0
- package/dist/generated/model/file.js +8 -0
- package/dist/generated/model/fileWithPresignedUrl.d.ts +18 -0
- package/dist/generated/model/fileWithPresignedUrl.js +8 -0
- package/dist/generated/model/getBulkFilesByIdsParams.d.ts +10 -0
- package/dist/generated/model/getBulkFilesByIdsParams.js +8 -0
- package/dist/generated/model/getPresignedUrlParams.d.ts +12 -0
- package/dist/generated/model/getPresignedUrlParams.js +8 -0
- package/dist/generated/model/index.d.ts +4 -1
- package/dist/generated/model/index.js +4 -1
- package/dist/generated/storage/storage.d.ts +63 -10
- package/dist/generated/storage/storage.js +67 -7
- package/dist/generated/user/user.d.ts +3 -3
- package/package.json +2 -2
|
@@ -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,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,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
|
+
};
|
|
@@ -6,8 +6,11 @@
|
|
|
6
6
|
* OpenAPI spec version: 1.0
|
|
7
7
|
*/
|
|
8
8
|
export * from './createUserDto';
|
|
9
|
+
export * from './file';
|
|
10
|
+
export * from './fileWithPresignedUrl';
|
|
11
|
+
export * from './getBulkFilesByIdsParams';
|
|
12
|
+
export * from './getPresignedUrlParams';
|
|
9
13
|
export * from './loginDto';
|
|
10
14
|
export * from './refreshTokenDto';
|
|
11
|
-
export * from './storageControllerGetPresignedUrlParams';
|
|
12
15
|
export * from './user';
|
|
13
16
|
export * from './userLogin';
|
|
@@ -6,8 +6,11 @@
|
|
|
6
6
|
* OpenAPI spec version: 1.0
|
|
7
7
|
*/
|
|
8
8
|
export * from './createUserDto';
|
|
9
|
+
export * from './file';
|
|
10
|
+
export * from './fileWithPresignedUrl';
|
|
11
|
+
export * from './getBulkFilesByIdsParams';
|
|
12
|
+
export * from './getPresignedUrlParams';
|
|
9
13
|
export * from './loginDto';
|
|
10
14
|
export * from './refreshTokenDto';
|
|
11
|
-
export * from './storageControllerGetPresignedUrlParams';
|
|
12
15
|
export * from './user';
|
|
13
16
|
export * from './userLogin';
|
|
@@ -1,18 +1,71 @@
|
|
|
1
1
|
import type { QueryKey, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
|
|
2
2
|
import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type { FileWithPresignedUrl, GetBulkFilesByIdsParams, GetPresignedUrlParams } from '.././model';
|
|
4
|
+
/**
|
|
5
|
+
* Returns presigned url to upload file
|
|
6
|
+
* @summary Get presigned url to upload file
|
|
7
|
+
*/
|
|
8
|
+
export declare const getPresignedUrl: (params: GetPresignedUrlParams, options?: AxiosRequestConfig) => Promise<AxiosResponse<string>>;
|
|
9
|
+
export declare const getGetPresignedUrlQueryKey: (params: GetPresignedUrlParams) => readonly ["/uploads/presigned-url", ...GetPresignedUrlParams[]];
|
|
10
|
+
export declare const getGetPresignedUrlQueryOptions: <TData = AxiosResponse<string, any>, TError = AxiosError<unknown, any>>(params: GetPresignedUrlParams, options?: {
|
|
11
|
+
query?: UseQueryOptions<Awaited<ReturnType<typeof getPresignedUrl>>, TError, TData>;
|
|
8
12
|
axios?: AxiosRequestConfig;
|
|
9
|
-
}) => UseQueryOptions<Awaited<ReturnType<typeof
|
|
13
|
+
}) => UseQueryOptions<Awaited<ReturnType<typeof getPresignedUrl>>, TError, TData> & {
|
|
10
14
|
queryKey: QueryKey;
|
|
11
15
|
};
|
|
12
|
-
export type
|
|
13
|
-
export type
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
export type GetPresignedUrlQueryResult = NonNullable<Awaited<ReturnType<typeof getPresignedUrl>>>;
|
|
17
|
+
export type GetPresignedUrlQueryError = AxiosError<unknown>;
|
|
18
|
+
/**
|
|
19
|
+
* @summary Get presigned url to upload file
|
|
20
|
+
*/
|
|
21
|
+
export declare function useGetPresignedUrl<TData = Awaited<ReturnType<typeof getPresignedUrl>>, TError = AxiosError<unknown>>(params: GetPresignedUrlParams, options?: {
|
|
22
|
+
query?: UseQueryOptions<Awaited<ReturnType<typeof getPresignedUrl>>, TError, TData>;
|
|
23
|
+
axios?: AxiosRequestConfig;
|
|
24
|
+
}): UseQueryResult<TData, TError> & {
|
|
25
|
+
queryKey: QueryKey;
|
|
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
|
+
* Returns file by id with presigned url
|
|
52
|
+
* @summary Get file by id with presigned url
|
|
53
|
+
*/
|
|
54
|
+
export declare const getFileById: (id: string, options?: AxiosRequestConfig) => Promise<AxiosResponse<FileWithPresignedUrl>>;
|
|
55
|
+
export declare const getGetFileByIdQueryKey: (id: string) => readonly [`/files/${string}`];
|
|
56
|
+
export declare const getGetFileByIdQueryOptions: <TData = AxiosResponse<FileWithPresignedUrl, any>, TError = AxiosError<unknown, any>>(id: string, options?: {
|
|
57
|
+
query?: UseQueryOptions<Awaited<ReturnType<typeof getFileById>>, TError, TData>;
|
|
58
|
+
axios?: AxiosRequestConfig;
|
|
59
|
+
}) => UseQueryOptions<Awaited<ReturnType<typeof getFileById>>, TError, TData> & {
|
|
60
|
+
queryKey: QueryKey;
|
|
61
|
+
};
|
|
62
|
+
export type GetFileByIdQueryResult = NonNullable<Awaited<ReturnType<typeof getFileById>>>;
|
|
63
|
+
export type GetFileByIdQueryError = AxiosError<unknown>;
|
|
64
|
+
/**
|
|
65
|
+
* @summary Get file by id with presigned url
|
|
66
|
+
*/
|
|
67
|
+
export declare function useGetFileById<TData = Awaited<ReturnType<typeof getFileById>>, TError = AxiosError<unknown>>(id: string, options?: {
|
|
68
|
+
query?: UseQueryOptions<Awaited<ReturnType<typeof getFileById>>, TError, TData>;
|
|
16
69
|
axios?: AxiosRequestConfig;
|
|
17
70
|
}): UseQueryResult<TData, TError> & {
|
|
18
71
|
queryKey: QueryKey;
|
|
@@ -7,23 +7,83 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { useQuery } from '@tanstack/react-query';
|
|
9
9
|
import axios from 'axios';
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Returns presigned url to upload file
|
|
12
|
+
* @summary Get presigned url to upload file
|
|
13
|
+
*/
|
|
14
|
+
export const getPresignedUrl = (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
|
|
20
|
+
export const getGetPresignedUrlQueryKey = (params) => {
|
|
17
21
|
return [`/uploads/presigned-url`, ...(params ? [params] : [])];
|
|
18
22
|
};
|
|
19
|
-
export const
|
|
23
|
+
export const getGetPresignedUrlQueryOptions = (params, options) => {
|
|
24
|
+
const { query: queryOptions, axios: axiosOptions } = options ?? {};
|
|
25
|
+
const queryKey = queryOptions?.queryKey ?? getGetPresignedUrlQueryKey(params);
|
|
26
|
+
const queryFn = ({ signal }) => getPresignedUrl(params, { signal, ...axiosOptions });
|
|
27
|
+
return { queryKey, queryFn, ...queryOptions };
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* @summary Get presigned url to upload file
|
|
31
|
+
*/
|
|
32
|
+
export function useGetPresignedUrl(params, options) {
|
|
33
|
+
const queryOptions = getGetPresignedUrlQueryOptions(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) => {
|
|
20
52
|
const { query: queryOptions, axios: axiosOptions } = options ?? {};
|
|
21
|
-
const queryKey = queryOptions?.queryKey ??
|
|
22
|
-
const queryFn = ({ signal }) =>
|
|
53
|
+
const queryKey = queryOptions?.queryKey ?? getGetBulkFilesByIdsQueryKey(params);
|
|
54
|
+
const queryFn = ({ signal }) => getBulkFilesByIds(params, { signal, ...axiosOptions });
|
|
23
55
|
return { queryKey, queryFn, ...queryOptions };
|
|
24
56
|
};
|
|
25
|
-
|
|
26
|
-
|
|
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
|
+
* Returns file by id with presigned url
|
|
68
|
+
* @summary Get file by id with presigned url
|
|
69
|
+
*/
|
|
70
|
+
export const getFileById = (id, options) => {
|
|
71
|
+
return axios.get(`/files/${id}`, options);
|
|
72
|
+
};
|
|
73
|
+
export const getGetFileByIdQueryKey = (id) => {
|
|
74
|
+
return [`/files/${id}`];
|
|
75
|
+
};
|
|
76
|
+
export const getGetFileByIdQueryOptions = (id, options) => {
|
|
77
|
+
const { query: queryOptions, axios: axiosOptions } = options ?? {};
|
|
78
|
+
const queryKey = queryOptions?.queryKey ?? getGetFileByIdQueryKey(id);
|
|
79
|
+
const queryFn = ({ signal }) => getFileById(id, { signal, ...axiosOptions });
|
|
80
|
+
return { queryKey, queryFn, enabled: !!(id), ...queryOptions };
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* @summary Get file by id with presigned url
|
|
84
|
+
*/
|
|
85
|
+
export function useGetFileById(id, options) {
|
|
86
|
+
const queryOptions = getGetFileByIdQueryOptions(id, options);
|
|
27
87
|
const query = useQuery(queryOptions);
|
|
28
88
|
query.queryKey = queryOptions.queryKey;
|
|
29
89
|
return query;
|
|
@@ -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, File, LoginDto, 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<
|
|
112
|
+
export declare const myFiles: (options?: AxiosRequestConfig) => Promise<AxiosResponse<File[]>>;
|
|
113
113
|
export declare const getMyFilesQueryKey: () => readonly ["/users/me/files"];
|
|
114
|
-
export declare const getMyFilesQueryOptions: <TData = AxiosResponse<
|
|
114
|
+
export declare const getMyFilesQueryOptions: <TData = AxiosResponse<File[], any>, TError = AxiosError<unknown, any>>(options?: {
|
|
115
115
|
query?: UseQueryOptions<Awaited<ReturnType<typeof myFiles>>, TError, TData>;
|
|
116
116
|
axios?: AxiosRequestConfig;
|
|
117
117
|
}) => UseQueryOptions<Awaited<ReturnType<typeof myFiles>>, TError, TData> & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htkimura/files-storage-backend.rest-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
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
|
-
"
|
|
20
|
+
"publishPackage": "yarn buildPackage && npm publish --access public"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@tanstack/react-query": "^5.66.0",
|