@htkimura/files-storage-backend.rest-client 0.0.22 → 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.
@@ -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,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,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,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 type GetBulkFilesByIdsParams = {
9
+ ids: 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 {};
@@ -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
+ };
@@ -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 {};
@@ -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 { StorageControllerGetPresignedUrlParams } from '.././model';
4
- export declare const storageControllerGetPresignedUrl: (params: StorageControllerGetPresignedUrlParams, options?: AxiosRequestConfig) => Promise<AxiosResponse<void>>;
5
- export declare const getStorageControllerGetPresignedUrlQueryKey: (params: StorageControllerGetPresignedUrlParams) => readonly ["/uploads/presigned-url", ...StorageControllerGetPresignedUrlParams[]];
6
- export declare const getStorageControllerGetPresignedUrlQueryOptions: <TData = AxiosResponse<void, any>, TError = AxiosError<unknown, any>>(params: StorageControllerGetPresignedUrlParams, options?: {
7
- query?: UseQueryOptions<Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>, TError, TData>;
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 storageControllerGetPresignedUrl>>, TError, TData> & {
13
+ }) => UseQueryOptions<Awaited<ReturnType<typeof getPresignedUrl>>, TError, TData> & {
10
14
  queryKey: QueryKey;
11
15
  };
12
- export type StorageControllerGetPresignedUrlQueryResult = NonNullable<Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>>;
13
- export type StorageControllerGetPresignedUrlQueryError = AxiosError<unknown>;
14
- export declare function useStorageControllerGetPresignedUrl<TData = Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>, TError = AxiosError<unknown>>(params: StorageControllerGetPresignedUrlParams, options?: {
15
- query?: UseQueryOptions<Awaited<ReturnType<typeof storageControllerGetPresignedUrl>>, TError, TData>;
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
- export const storageControllerGetPresignedUrl = (params, options) => {
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 getStorageControllerGetPresignedUrlQueryKey = (params) => {
20
+ export const getGetPresignedUrlQueryKey = (params) => {
17
21
  return [`/uploads/presigned-url`, ...(params ? [params] : [])];
18
22
  };
19
- export const getStorageControllerGetPresignedUrlQueryOptions = (params, options) => {
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 ?? getStorageControllerGetPresignedUrlQueryKey(params);
22
- const queryFn = ({ signal }) => storageControllerGetPresignedUrl(params, { signal, ...axiosOptions });
53
+ const queryKey = queryOptions?.queryKey ?? getGetBulkFilesByIdsQueryKey(params);
54
+ const queryFn = ({ signal }) => getBulkFilesByIds(params, { signal, ...axiosOptions });
23
55
  return { queryKey, queryFn, ...queryOptions };
24
56
  };
25
- export function useStorageControllerGetPresignedUrl(params, options) {
26
- const queryOptions = getStorageControllerGetPresignedUrlQueryOptions(params, options);
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<string[]>>;
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<string[], any>, TError = AxiosError<unknown, any>>(options?: {
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.22",
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
- "publish": "yarn buildPackage && npm publish --access public"
20
+ "publishPackage": "yarn buildPackage && npm publish --access public"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@tanstack/react-query": "^5.66.0",