eventhr-http-client 0.1.1

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/lib/index.d.ts ADDED
@@ -0,0 +1,493 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { AxiosResponse } from 'axios';
3
+ import { InternalAxiosRequestConfig } from 'axios';
4
+ import { QueryClient } from '@tanstack/react-query';
5
+ import { UseMutationOptions } from '@tanstack/react-query';
6
+ import { UseMutationResult } from '@tanstack/react-query';
7
+ import { UseQueryOptions } from '@tanstack/react-query';
8
+ import { UseQueryResult } from '@tanstack/react-query';
9
+
10
+ export declare const addRequestInterceptor: (onFulfilled: (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig>, onRejected?: (error: unknown) => unknown) => number;
11
+
12
+ export declare const Auth: {
13
+ v1: {
14
+ endpoint: string;
15
+ login(data: LoginDto): Promise<AxiosResponse<AuthTokenResponse, any, {}>>;
16
+ refresh(data: RefreshTokenDto): Promise<AxiosResponse<AuthTokenResponse, any, {}>>;
17
+ readonly client: AxiosInstance;
18
+ list(..._args: unknown[]): Promise<unknown>;
19
+ get(..._args: unknown[]): Promise<unknown>;
20
+ create(..._args: unknown[]): Promise<unknown>;
21
+ update(..._args: unknown[]): Promise<unknown>;
22
+ remove(..._args: unknown[]): Promise<unknown>;
23
+ };
24
+ };
25
+
26
+ export declare interface AuthTokenResponse {
27
+ authenticationToken: string;
28
+ refreshToken: string;
29
+ }
30
+
31
+ export declare const Categories: {
32
+ v1: {
33
+ endpoint: string;
34
+ getAll(params?: GetCategoriesParams): Promise<AxiosResponse<Page<Category>, any, {}>>;
35
+ create(data: CreateCategoryDto): Promise<AxiosResponse<void, any, {}>>;
36
+ update(id: string, data: UpdateCategoryDto): Promise<AxiosResponse<void, any, {}>>;
37
+ remove(id: string): Promise<AxiosResponse<void, any, {}>>;
38
+ readonly client: AxiosInstance;
39
+ list(..._args: unknown[]): Promise<unknown>;
40
+ get(..._args: unknown[]): Promise<unknown>;
41
+ };
42
+ };
43
+
44
+ export declare interface Category {
45
+ id: string;
46
+ name: string;
47
+ isDeleted: boolean;
48
+ createdAt: string;
49
+ updatedAt: string;
50
+ }
51
+
52
+ export declare interface Collection {
53
+ id: string;
54
+ name: string;
55
+ customer: {
56
+ id: string;
57
+ };
58
+ events: EventVo[];
59
+ createdAt: string;
60
+ updatedAt: string;
61
+ }
62
+
63
+ export declare const Collections: {
64
+ v1: {
65
+ endpoint: string;
66
+ getAll(params?: GetCollectionsParams): Promise<AxiosResponse<Page<Collection>, any, {}>>;
67
+ getById(id: string): Promise<AxiosResponse<Collection, any, {}>>;
68
+ create(data: CreateCollectionDto): Promise<AxiosResponse<void, any, {}>>;
69
+ update(id: string, data: UpdateCollectionDto): Promise<AxiosResponse<void, any, {}>>;
70
+ remove(id: string): Promise<AxiosResponse<void, any, {}>>;
71
+ readonly client: AxiosInstance;
72
+ list(..._args: unknown[]): Promise<unknown>;
73
+ get(..._args: unknown[]): Promise<unknown>;
74
+ };
75
+ };
76
+
77
+ export declare interface CreateCategoryDto {
78
+ name: string;
79
+ }
80
+
81
+ export declare interface CreateCollectionDto {
82
+ name: string;
83
+ eventIds: string[];
84
+ }
85
+
86
+ export declare interface CreateEventDto {
87
+ name: string;
88
+ description?: string;
89
+ startAt: string;
90
+ endAt: string;
91
+ address: EventAddress;
92
+ coordinates: EventCoordinates;
93
+ price?: number;
94
+ capacity?: number;
95
+ }
96
+
97
+ export declare interface CreateUserDto {
98
+ name: string;
99
+ username: string;
100
+ password: string;
101
+ }
102
+
103
+ export declare interface EditUserDto {
104
+ name: string;
105
+ username: string;
106
+ password?: string;
107
+ imageId?: string;
108
+ }
109
+
110
+ declare interface Event_2 {
111
+ id: string;
112
+ name: string;
113
+ description?: string;
114
+ startAt: string;
115
+ endAt: string;
116
+ address: EventAddress;
117
+ coordinates: EventCoordinates;
118
+ price?: number;
119
+ capacity?: number;
120
+ organizer: EventOrganizer;
121
+ isDeleted: boolean;
122
+ createdAt: string;
123
+ updatedAt: string;
124
+ }
125
+ export { Event_2 as Event }
126
+
127
+ export declare interface EventAddress {
128
+ city: string;
129
+ address: string;
130
+ postalCode?: string;
131
+ locationName?: string;
132
+ }
133
+
134
+ export declare interface EventCoordinates {
135
+ latitude: number;
136
+ longitude: number;
137
+ }
138
+
139
+ export declare const EVENTHR_QUERY_KEYS: {
140
+ readonly events: {
141
+ readonly all: readonly ["events"];
142
+ readonly list: (params?: GetEventsParams) => readonly ["events", "list", GetEventsParams | undefined];
143
+ };
144
+ readonly categories: {
145
+ readonly all: readonly ["categories"];
146
+ readonly list: (params?: GetCategoriesParams) => readonly ["categories", "list", GetCategoriesParams | undefined];
147
+ };
148
+ readonly collections: {
149
+ readonly all: readonly ["collections"];
150
+ readonly list: (params?: GetCollectionsParams) => readonly ["collections", "list", GetCollectionsParams | undefined];
151
+ readonly detail: (id: string) => readonly ["collections", "detail", string];
152
+ };
153
+ readonly users: {
154
+ readonly all: readonly ["users"];
155
+ readonly list: (params?: PageRequest) => readonly ["users", "list", PageRequest | undefined];
156
+ readonly profile: () => readonly ["users", "profile"];
157
+ };
158
+ readonly files: {
159
+ readonly all: readonly ["files"];
160
+ };
161
+ };
162
+
163
+ declare const EventhrHttp: EventhrHttpClient;
164
+ export default EventhrHttp;
165
+
166
+ export declare class EventhrHttpClient {
167
+ readonly Auth: {
168
+ v1: {
169
+ endpoint: string;
170
+ login(data: LoginDto): Promise<AxiosResponse<AuthTokenResponse, any, {}>>;
171
+ refresh(data: RefreshTokenDto): Promise<AxiosResponse<AuthTokenResponse, any, {}>>;
172
+ readonly client: AxiosInstance;
173
+ list(..._args: unknown[]): Promise<unknown>;
174
+ get(..._args: unknown[]): Promise<unknown>;
175
+ create(..._args: unknown[]): Promise<unknown>;
176
+ update(..._args: unknown[]): Promise<unknown>;
177
+ remove(..._args: unknown[]): Promise<unknown>;
178
+ };
179
+ };
180
+ readonly Events: {
181
+ v1: {
182
+ endpoint: string;
183
+ getAll(params?: GetEventsParams): Promise<AxiosResponse<Page<Event_2>, any, {}>>;
184
+ create(data: CreateEventDto): Promise<AxiosResponse<void, any, {}>>;
185
+ update(id: string, data: UpdateEventDto): Promise<AxiosResponse<void, any, {}>>;
186
+ remove(id: string): Promise<AxiosResponse<void, any, {}>>;
187
+ readonly client: AxiosInstance;
188
+ list(..._args: unknown[]): Promise<unknown>;
189
+ get(..._args: unknown[]): Promise<unknown>;
190
+ };
191
+ };
192
+ readonly Categories: {
193
+ v1: {
194
+ endpoint: string;
195
+ getAll(params?: GetCategoriesParams): Promise<AxiosResponse<Page<Category>, any, {}>>;
196
+ create(data: CreateCategoryDto): Promise<AxiosResponse<void, any, {}>>;
197
+ update(id: string, data: UpdateCategoryDto): Promise<AxiosResponse<void, any, {}>>;
198
+ remove(id: string): Promise<AxiosResponse<void, any, {}>>;
199
+ readonly client: AxiosInstance;
200
+ list(..._args: unknown[]): Promise<unknown>;
201
+ get(..._args: unknown[]): Promise<unknown>;
202
+ };
203
+ };
204
+ readonly Collections: {
205
+ v1: {
206
+ endpoint: string;
207
+ getAll(params?: GetCollectionsParams): Promise<AxiosResponse<Page<Collection>, any, {}>>;
208
+ getById(id: string): Promise<AxiosResponse<Collection, any, {}>>;
209
+ create(data: CreateCollectionDto): Promise<AxiosResponse<void, any, {}>>;
210
+ update(id: string, data: UpdateCollectionDto): Promise<AxiosResponse<void, any, {}>>;
211
+ remove(id: string): Promise<AxiosResponse<void, any, {}>>;
212
+ readonly client: AxiosInstance;
213
+ list(..._args: unknown[]): Promise<unknown>;
214
+ get(..._args: unknown[]): Promise<unknown>;
215
+ };
216
+ };
217
+ readonly Users: {
218
+ v1: {
219
+ endpoint: string;
220
+ getAll(params?: PageRequest): Promise<AxiosResponse<Page<User>, any, {}>>;
221
+ getProfile(): Promise<AxiosResponse<User, any, {}>>;
222
+ create(data: CreateUserDto): Promise<AxiosResponse<void, any, {}>>;
223
+ edit(id: string, data: EditUserDto): Promise<AxiosResponse<void, any, {}>>;
224
+ readonly client: AxiosInstance;
225
+ list(..._args: unknown[]): Promise<unknown>;
226
+ get(..._args: unknown[]): Promise<unknown>;
227
+ update(..._args: unknown[]): Promise<unknown>;
228
+ remove(..._args: unknown[]): Promise<unknown>;
229
+ };
230
+ };
231
+ readonly Files: {
232
+ v1: {
233
+ endpoint: string;
234
+ upload(file: File): Promise<AxiosResponse<UploadedFile, any, {}>>;
235
+ remove(id: string): Promise<AxiosResponse<void, any, {}>>;
236
+ readonly client: AxiosInstance;
237
+ list(..._args: unknown[]): Promise<unknown>;
238
+ get(..._args: unknown[]): Promise<unknown>;
239
+ create(..._args: unknown[]): Promise<unknown>;
240
+ update(..._args: unknown[]): Promise<unknown>;
241
+ };
242
+ };
243
+ configure({ baseUrl, headers }: EventhrHttpConfig): void;
244
+ removeHeader(key: string): void;
245
+ addInterceptor(onFulfilled: (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig>, onRejected?: (error: unknown) => unknown): number;
246
+ removeInterceptor(id: number): void;
247
+ }
248
+
249
+ export declare interface EventhrHttpConfig {
250
+ baseUrl?: string;
251
+ headers?: Record<string, string>;
252
+ }
253
+
254
+ export declare interface EventOrganizer {
255
+ id: string;
256
+ }
257
+
258
+ export declare const Events: {
259
+ v1: {
260
+ endpoint: string;
261
+ getAll(params?: GetEventsParams): Promise<AxiosResponse<Page<Event_2>, any, {}>>;
262
+ create(data: CreateEventDto): Promise<AxiosResponse<void, any, {}>>;
263
+ update(id: string, data: UpdateEventDto): Promise<AxiosResponse<void, any, {}>>;
264
+ remove(id: string): Promise<AxiosResponse<void, any, {}>>;
265
+ readonly client: AxiosInstance;
266
+ list(..._args: unknown[]): Promise<unknown>;
267
+ get(..._args: unknown[]): Promise<unknown>;
268
+ };
269
+ };
270
+
271
+ export declare interface EventVo {
272
+ id: string;
273
+ name: string;
274
+ }
275
+
276
+ export declare const Files: {
277
+ v1: {
278
+ endpoint: string;
279
+ upload(file: File): Promise<AxiosResponse<UploadedFile, any, {}>>;
280
+ remove(id: string): Promise<AxiosResponse<void, any, {}>>;
281
+ readonly client: AxiosInstance;
282
+ list(..._args: unknown[]): Promise<unknown>;
283
+ get(..._args: unknown[]): Promise<unknown>;
284
+ create(..._args: unknown[]): Promise<unknown>;
285
+ update(..._args: unknown[]): Promise<unknown>;
286
+ };
287
+ };
288
+
289
+ export declare type FileType = 'IMAGE' | 'VIDEO' | 'DOCUMENT';
290
+
291
+ export declare interface GetCategoriesParams extends PageRequest {
292
+ name?: string;
293
+ }
294
+
295
+ export declare interface GetCollectionsParams extends PageRequest {
296
+ name?: string;
297
+ }
298
+
299
+ export declare interface GetEventsParams extends PageRequest {
300
+ name?: string;
301
+ latitude?: number;
302
+ longitude?: number;
303
+ radiusKm?: number;
304
+ }
305
+
306
+ export declare abstract class HttpClient {
307
+ abstract endpoint: string;
308
+ readonly client: AxiosInstance;
309
+ list(..._args: unknown[]): Promise<unknown>;
310
+ get(..._args: unknown[]): Promise<unknown>;
311
+ create(..._args: unknown[]): Promise<unknown>;
312
+ update(..._args: unknown[]): Promise<unknown>;
313
+ remove(..._args: unknown[]): Promise<unknown>;
314
+ }
315
+
316
+ export declare const instance: AxiosInstance;
317
+
318
+ export declare const invalidateCategoriesCache: () => Promise<void>;
319
+
320
+ export declare const invalidateCollectionsCache: () => Promise<void>;
321
+
322
+ export declare const invalidateEventsCache: () => Promise<void>;
323
+
324
+ export declare interface LoginDto {
325
+ username: string;
326
+ password: string;
327
+ notificationToken?: string;
328
+ }
329
+
330
+ export declare type MutationOptions<TData, TVariables, TError = Error> = Omit<UseMutationOptions<TData, TError, TVariables>, 'mutationFn'>;
331
+
332
+ export declare interface Page<T> {
333
+ content: T[];
334
+ totalElements: number;
335
+ totalPages: number;
336
+ number: number;
337
+ size: number;
338
+ first: boolean;
339
+ last: boolean;
340
+ empty: boolean;
341
+ numberOfElements: number;
342
+ }
343
+
344
+ export declare interface PageRequest {
345
+ page?: number;
346
+ size?: number;
347
+ sort?: string;
348
+ }
349
+
350
+ export declare const queryClient: QueryClient;
351
+
352
+ export declare type QueryOptions<T> = Omit<UseQueryOptions<T>, 'queryKey' | 'queryFn'>;
353
+
354
+ export declare interface RefreshTokenDto {
355
+ refreshToken: string;
356
+ }
357
+
358
+ export declare const removeHeader: (key: string) => void;
359
+
360
+ export declare const removeRequestInterceptor: (id: number) => void;
361
+
362
+ export declare const setBaseUrl: (url: string) => void;
363
+
364
+ export declare const setHeaders: (headers: Record<string, string>) => void;
365
+
366
+ export declare interface UpdateCategoryDto {
367
+ name: string;
368
+ }
369
+
370
+ export declare interface UpdateCollectionDto {
371
+ name: string;
372
+ eventIds: string[];
373
+ }
374
+
375
+ export declare type UpdateEventDto = CreateEventDto;
376
+
377
+ export declare interface UploadedFile {
378
+ id: string;
379
+ fileName: string;
380
+ url: string;
381
+ fileSize: number;
382
+ fileType: FileType;
383
+ createdAt: string;
384
+ updatedAt: string;
385
+ }
386
+
387
+ export declare const useCreateCategoryMutation: (options?: MutationOptions<void, CreateCategoryDto>) => UseMutationResult<void, Error, CreateCategoryDto, unknown>;
388
+
389
+ export declare const useCreateCollectionMutation: (options?: MutationOptions<void, CreateCollectionDto>) => UseMutationResult<void, Error, CreateCollectionDto, unknown>;
390
+
391
+ export declare const useCreateEventMutation: (options?: MutationOptions<void, CreateEventDto>) => UseMutationResult<void, Error, CreateEventDto, unknown>;
392
+
393
+ export declare const useCreateUserMutation: (options?: MutationOptions<void, CreateUserDto>) => UseMutationResult<void, Error, CreateUserDto, unknown>;
394
+
395
+ export declare const useDeleteCategoryMutation: (options?: MutationOptions<void, {
396
+ id: string;
397
+ }>) => UseMutationResult<void, Error, {
398
+ id: string;
399
+ }, unknown>;
400
+
401
+ export declare const useDeleteCollectionMutation: (options?: MutationOptions<void, {
402
+ id: string;
403
+ }>) => UseMutationResult<void, Error, {
404
+ id: string;
405
+ }, unknown>;
406
+
407
+ export declare const useDeleteEventMutation: (options?: MutationOptions<void, {
408
+ id: string;
409
+ }>) => UseMutationResult<void, Error, {
410
+ id: string;
411
+ }, unknown>;
412
+
413
+ export declare const useDeleteFileMutation: (options?: MutationOptions<void, {
414
+ id: string;
415
+ }>) => UseMutationResult<void, Error, {
416
+ id: string;
417
+ }, unknown>;
418
+
419
+ export declare const useEditUserMutation: (options?: MutationOptions<void, {
420
+ id: string;
421
+ data: EditUserDto;
422
+ }>) => UseMutationResult<void, Error, {
423
+ id: string;
424
+ data: EditUserDto;
425
+ }, unknown>;
426
+
427
+ export declare const useGetCategoriesQuery: (params?: GetCategoriesParams, options?: QueryOptions<Page<Category>>) => UseQueryResult<NoInfer<Page<Category>>, Error>;
428
+
429
+ export declare const useGetCollectionByIdQuery: (id: string, options?: QueryOptions<Collection>) => UseQueryResult<NoInfer<Collection>, Error>;
430
+
431
+ export declare const useGetCollectionsQuery: (params?: GetCollectionsParams, options?: QueryOptions<Page<Collection>>) => UseQueryResult<NoInfer<Page<Collection>>, Error>;
432
+
433
+ export declare const useGetEventsQuery: (params?: GetEventsParams, options?: QueryOptions<Page<Event_2>>) => UseQueryResult<NoInfer<Page<Event_2>>, Error>;
434
+
435
+ export declare const useGetProfileQuery: (options?: QueryOptions<User>) => UseQueryResult<NoInfer<User>, Error>;
436
+
437
+ export declare const useGetUsersQuery: (params?: PageRequest, options?: QueryOptions<Page<User>>) => UseQueryResult<NoInfer<Page<User>>, Error>;
438
+
439
+ export declare const useLoginMutation: (options?: MutationOptions<AuthTokenResponse, LoginDto>) => UseMutationResult<AuthTokenResponse, Error, LoginDto, unknown>;
440
+
441
+ export declare interface User {
442
+ id: string;
443
+ name: string;
444
+ username: string;
445
+ imageId?: string;
446
+ createdAt: string;
447
+ updatedAt: string;
448
+ }
449
+
450
+ export declare const useRefreshTokenMutation: (options?: MutationOptions<AuthTokenResponse, RefreshTokenDto>) => UseMutationResult<AuthTokenResponse, Error, RefreshTokenDto, unknown>;
451
+
452
+ export declare const Users: {
453
+ v1: {
454
+ endpoint: string;
455
+ getAll(params?: PageRequest): Promise<AxiosResponse<Page<User>, any, {}>>;
456
+ getProfile(): Promise<AxiosResponse<User, any, {}>>;
457
+ create(data: CreateUserDto): Promise<AxiosResponse<void, any, {}>>;
458
+ edit(id: string, data: EditUserDto): Promise<AxiosResponse<void, any, {}>>;
459
+ readonly client: AxiosInstance;
460
+ list(..._args: unknown[]): Promise<unknown>;
461
+ get(..._args: unknown[]): Promise<unknown>;
462
+ update(..._args: unknown[]): Promise<unknown>;
463
+ remove(..._args: unknown[]): Promise<unknown>;
464
+ };
465
+ };
466
+
467
+ export declare const useUpdateCategoryMutation: (options?: MutationOptions<void, {
468
+ id: string;
469
+ data: UpdateCategoryDto;
470
+ }>) => UseMutationResult<void, Error, {
471
+ id: string;
472
+ data: UpdateCategoryDto;
473
+ }, unknown>;
474
+
475
+ export declare const useUpdateCollectionMutation: (options?: MutationOptions<void, {
476
+ id: string;
477
+ data: UpdateCollectionDto;
478
+ }>) => UseMutationResult<void, Error, {
479
+ id: string;
480
+ data: UpdateCollectionDto;
481
+ }, unknown>;
482
+
483
+ export declare const useUpdateEventMutation: (options?: MutationOptions<void, {
484
+ id: string;
485
+ data: UpdateEventDto;
486
+ }>) => UseMutationResult<void, Error, {
487
+ id: string;
488
+ data: UpdateEventDto;
489
+ }, unknown>;
490
+
491
+ export declare const useUploadFileMutation: (options?: MutationOptions<UploadedFile, File>) => UseMutationResult<UploadedFile, Error, File, unknown>;
492
+
493
+ export { }