balendar 0.0.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/dist/lib/client.d.ts +807 -0
- package/dist/lib/client.js +6 -0
- package/package.json +25 -0
|
@@ -0,0 +1,807 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Eden Treaty client for the Calendar Service API
|
|
3
|
+
*
|
|
4
|
+
* This file exports a factory function to create a type-safe client
|
|
5
|
+
* for consumers of this API.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Configuration options for the Balendar client
|
|
9
|
+
*/
|
|
10
|
+
export interface BalendarConfig {
|
|
11
|
+
/**
|
|
12
|
+
* Base URL of the Calendar Service API
|
|
13
|
+
* @example 'https://calendar-api.balendar.com'
|
|
14
|
+
* @example 'http://localhost:3003'
|
|
15
|
+
*/
|
|
16
|
+
baseUrl: string;
|
|
17
|
+
/**
|
|
18
|
+
* API key for authentication (X-API-Key header)
|
|
19
|
+
*/
|
|
20
|
+
apiKey: string;
|
|
21
|
+
/**
|
|
22
|
+
* Optional additional fetch configuration
|
|
23
|
+
*/
|
|
24
|
+
fetch?: RequestInit;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates a type-safe client for the Balendar Calendar Service API
|
|
28
|
+
*
|
|
29
|
+
* @param config - Client configuration options
|
|
30
|
+
* @returns A fully type-safe Eden Treaty client for the Calendar Service
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import { Balendar } from 'balendar/client'
|
|
35
|
+
*
|
|
36
|
+
* const client = Balendar({
|
|
37
|
+
* baseUrl: 'https://calendar-api.balendar.com',
|
|
38
|
+
* apiKey: 'your-api-key-here'
|
|
39
|
+
* })
|
|
40
|
+
*
|
|
41
|
+
* // Make type-safe API calls
|
|
42
|
+
* const { data } = await client.api.events.get({
|
|
43
|
+
* query: {
|
|
44
|
+
* startDate: '2025-01-01',
|
|
45
|
+
* endDate: '2025-01-31'
|
|
46
|
+
* }
|
|
47
|
+
* })
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function Balendar(config: BalendarConfig): {
|
|
51
|
+
health: {
|
|
52
|
+
get: (options?: {
|
|
53
|
+
headers?: Record<string, unknown> | undefined;
|
|
54
|
+
query?: Record<string, unknown> | undefined;
|
|
55
|
+
fetch?: RequestInit | undefined;
|
|
56
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
|
57
|
+
200: {
|
|
58
|
+
status: string;
|
|
59
|
+
};
|
|
60
|
+
}>>;
|
|
61
|
+
};
|
|
62
|
+
api: {
|
|
63
|
+
"external-calendars": {
|
|
64
|
+
oauth: {
|
|
65
|
+
callback: {
|
|
66
|
+
get: (options?: {
|
|
67
|
+
headers?: Record<string, unknown> | undefined;
|
|
68
|
+
query?: Record<string, unknown> | undefined;
|
|
69
|
+
fetch?: RequestInit | undefined;
|
|
70
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
|
71
|
+
200: Response;
|
|
72
|
+
422: {
|
|
73
|
+
type: "validation";
|
|
74
|
+
on: string;
|
|
75
|
+
summary?: string;
|
|
76
|
+
message?: string;
|
|
77
|
+
found?: unknown;
|
|
78
|
+
property?: string;
|
|
79
|
+
expected?: string;
|
|
80
|
+
};
|
|
81
|
+
}>>;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
api: {
|
|
85
|
+
"external-calendars": {
|
|
86
|
+
users: ((params: {
|
|
87
|
+
userId: string | number;
|
|
88
|
+
}) => {
|
|
89
|
+
oauth: {
|
|
90
|
+
url: {
|
|
91
|
+
get: (options: {
|
|
92
|
+
headers?: Record<string, unknown> | undefined;
|
|
93
|
+
query: {
|
|
94
|
+
externalProvider: "google" | "microsoft" | "apple";
|
|
95
|
+
redirectUri: string;
|
|
96
|
+
scopes?: string | undefined;
|
|
97
|
+
state?: string | undefined;
|
|
98
|
+
};
|
|
99
|
+
fetch?: RequestInit | undefined;
|
|
100
|
+
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
|
101
|
+
200: {
|
|
102
|
+
url: string;
|
|
103
|
+
};
|
|
104
|
+
400: {
|
|
105
|
+
error: string;
|
|
106
|
+
};
|
|
107
|
+
422: {
|
|
108
|
+
type: "validation";
|
|
109
|
+
on: string;
|
|
110
|
+
summary?: string;
|
|
111
|
+
message?: string;
|
|
112
|
+
found?: unknown;
|
|
113
|
+
property?: string;
|
|
114
|
+
expected?: string;
|
|
115
|
+
};
|
|
116
|
+
}>>;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
"is-connected-google": {
|
|
120
|
+
get: (options?: {
|
|
121
|
+
headers?: Record<string, unknown> | undefined;
|
|
122
|
+
query?: Record<string, unknown> | undefined;
|
|
123
|
+
fetch?: RequestInit | undefined;
|
|
124
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
|
125
|
+
200: {
|
|
126
|
+
isConnected: boolean;
|
|
127
|
+
};
|
|
128
|
+
422: {
|
|
129
|
+
type: "validation";
|
|
130
|
+
on: string;
|
|
131
|
+
summary?: string;
|
|
132
|
+
message?: string;
|
|
133
|
+
found?: unknown;
|
|
134
|
+
property?: string;
|
|
135
|
+
expected?: string;
|
|
136
|
+
};
|
|
137
|
+
}>>;
|
|
138
|
+
};
|
|
139
|
+
} & ((params: {
|
|
140
|
+
externalCalendarId: string | number;
|
|
141
|
+
}) => {
|
|
142
|
+
get: (options?: {
|
|
143
|
+
headers?: Record<string, unknown> | undefined;
|
|
144
|
+
query?: Record<string, unknown> | undefined;
|
|
145
|
+
fetch?: RequestInit | undefined;
|
|
146
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
|
147
|
+
200: {
|
|
148
|
+
externalCalendar: {
|
|
149
|
+
lastSyncedAt: string | null;
|
|
150
|
+
syncStatus: "error" | "pending" | "syncing" | "synced";
|
|
151
|
+
syncError: string | null;
|
|
152
|
+
retryCount: number;
|
|
153
|
+
externalProvider: "google" | "microsoft" | "apple";
|
|
154
|
+
externalId: string;
|
|
155
|
+
connectionId: string;
|
|
156
|
+
accessToken: string;
|
|
157
|
+
expiresAt: string;
|
|
158
|
+
createdAt: string;
|
|
159
|
+
updatedAt: string;
|
|
160
|
+
externalCalendarId: number;
|
|
161
|
+
userId: number;
|
|
162
|
+
status: "error" | "active" | "expired" | "revoked";
|
|
163
|
+
refreshToken?: string | undefined;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
404: {
|
|
167
|
+
error: string;
|
|
168
|
+
};
|
|
169
|
+
422: {
|
|
170
|
+
type: "validation";
|
|
171
|
+
on: string;
|
|
172
|
+
summary?: string;
|
|
173
|
+
message?: string;
|
|
174
|
+
found?: unknown;
|
|
175
|
+
property?: string;
|
|
176
|
+
expected?: string;
|
|
177
|
+
};
|
|
178
|
+
}>>;
|
|
179
|
+
})) & {};
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
events: ((params: {
|
|
184
|
+
eventId: string | number;
|
|
185
|
+
}) => {
|
|
186
|
+
get: (options?: {
|
|
187
|
+
headers?: Record<string, unknown> | undefined;
|
|
188
|
+
query?: Record<string, unknown> | undefined;
|
|
189
|
+
fetch?: RequestInit | undefined;
|
|
190
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
|
191
|
+
200: {
|
|
192
|
+
userId: number;
|
|
193
|
+
title: string;
|
|
194
|
+
startTime: string;
|
|
195
|
+
endTime: string;
|
|
196
|
+
status: "confirmed" | "cancelled" | "tentative";
|
|
197
|
+
busyStatus: "busy" | "free";
|
|
198
|
+
createdAt: string;
|
|
199
|
+
updatedAt: string;
|
|
200
|
+
eventId: number;
|
|
201
|
+
bookingId: number | null;
|
|
202
|
+
description: string | null;
|
|
203
|
+
location: string | null;
|
|
204
|
+
};
|
|
205
|
+
404: {
|
|
206
|
+
error: string;
|
|
207
|
+
};
|
|
208
|
+
422: {
|
|
209
|
+
type: "validation";
|
|
210
|
+
on: string;
|
|
211
|
+
summary?: string;
|
|
212
|
+
message?: string;
|
|
213
|
+
found?: unknown;
|
|
214
|
+
property?: string;
|
|
215
|
+
expected?: string;
|
|
216
|
+
};
|
|
217
|
+
}>>;
|
|
218
|
+
}) & {
|
|
219
|
+
search: {
|
|
220
|
+
post: (body: {
|
|
221
|
+
userId: number;
|
|
222
|
+
startDate: string;
|
|
223
|
+
endDate: string;
|
|
224
|
+
pagination: {
|
|
225
|
+
limit: number;
|
|
226
|
+
offset: number;
|
|
227
|
+
};
|
|
228
|
+
status?: "confirmed" | "cancelled" | "tentative" | undefined;
|
|
229
|
+
busyStatus?: "busy" | "free" | undefined;
|
|
230
|
+
}, options?: {
|
|
231
|
+
headers?: Record<string, unknown> | undefined;
|
|
232
|
+
query?: Record<string, unknown> | undefined;
|
|
233
|
+
fetch?: RequestInit | undefined;
|
|
234
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
|
235
|
+
200: {
|
|
236
|
+
items: {
|
|
237
|
+
userId: number;
|
|
238
|
+
title: string;
|
|
239
|
+
startTime: string;
|
|
240
|
+
endTime: string;
|
|
241
|
+
status: "confirmed" | "cancelled" | "tentative";
|
|
242
|
+
busyStatus: "busy" | "free";
|
|
243
|
+
createdAt: string;
|
|
244
|
+
updatedAt: string;
|
|
245
|
+
eventId: number;
|
|
246
|
+
bookingId: number | null;
|
|
247
|
+
description: string | null;
|
|
248
|
+
location: string | null;
|
|
249
|
+
}[];
|
|
250
|
+
pagination: {
|
|
251
|
+
total: number;
|
|
252
|
+
limit: number;
|
|
253
|
+
offset: number;
|
|
254
|
+
hasMore: boolean;
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
400: {
|
|
258
|
+
error: string;
|
|
259
|
+
};
|
|
260
|
+
422: {
|
|
261
|
+
type: "validation";
|
|
262
|
+
on: string;
|
|
263
|
+
summary?: string;
|
|
264
|
+
message?: string;
|
|
265
|
+
found?: unknown;
|
|
266
|
+
property?: string;
|
|
267
|
+
expected?: string;
|
|
268
|
+
};
|
|
269
|
+
}>>;
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
"availability-rules": ((params: {
|
|
273
|
+
availabilityRuleId: string | number;
|
|
274
|
+
}) => {
|
|
275
|
+
get: (options?: {
|
|
276
|
+
headers?: Record<string, unknown> | undefined;
|
|
277
|
+
query?: Record<string, unknown> | undefined;
|
|
278
|
+
fetch?: RequestInit | undefined;
|
|
279
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
|
280
|
+
200: {
|
|
281
|
+
userId: number;
|
|
282
|
+
weekdays: ("sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday")[];
|
|
283
|
+
windowStartTime: string;
|
|
284
|
+
windowEndTime: string;
|
|
285
|
+
active: boolean;
|
|
286
|
+
isAvailable: boolean;
|
|
287
|
+
availabilityRuleMetadata: {
|
|
288
|
+
bookingLocationIds: number[];
|
|
289
|
+
serviceIds?: number[] | undefined;
|
|
290
|
+
};
|
|
291
|
+
availabilityRuleId: number;
|
|
292
|
+
recurrence: "one_off";
|
|
293
|
+
date: string;
|
|
294
|
+
dateRangeStart: null;
|
|
295
|
+
dateRangeEnd: null;
|
|
296
|
+
} | {
|
|
297
|
+
userId: number;
|
|
298
|
+
weekdays: ("sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday")[];
|
|
299
|
+
windowStartTime: string;
|
|
300
|
+
windowEndTime: string;
|
|
301
|
+
active: boolean;
|
|
302
|
+
isAvailable: boolean;
|
|
303
|
+
availabilityRuleMetadata: {
|
|
304
|
+
bookingLocationIds: number[];
|
|
305
|
+
serviceIds?: number[] | undefined;
|
|
306
|
+
};
|
|
307
|
+
availabilityRuleId: number;
|
|
308
|
+
recurrence: "daily" | "weekly";
|
|
309
|
+
dateRangeStart: string;
|
|
310
|
+
dateRangeEnd: string | null;
|
|
311
|
+
date: null;
|
|
312
|
+
};
|
|
313
|
+
404: {
|
|
314
|
+
error: string;
|
|
315
|
+
};
|
|
316
|
+
422: {
|
|
317
|
+
type: "validation";
|
|
318
|
+
on: string;
|
|
319
|
+
summary?: string;
|
|
320
|
+
message?: string;
|
|
321
|
+
found?: unknown;
|
|
322
|
+
property?: string;
|
|
323
|
+
expected?: string;
|
|
324
|
+
};
|
|
325
|
+
}>>;
|
|
326
|
+
patch: (body: {
|
|
327
|
+
date: string;
|
|
328
|
+
dateRangeStart: null;
|
|
329
|
+
dateRangeEnd: null;
|
|
330
|
+
userId?: number | undefined;
|
|
331
|
+
recurrence?: "one_off" | "daily" | "weekly" | undefined;
|
|
332
|
+
weekdays?: ("sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday")[] | undefined;
|
|
333
|
+
windowStartTime?: string | undefined;
|
|
334
|
+
windowEndTime?: string | undefined;
|
|
335
|
+
availabilityRuleMetadata?: {
|
|
336
|
+
bookingLocationIds: number[];
|
|
337
|
+
serviceIds?: number[] | undefined;
|
|
338
|
+
} | undefined;
|
|
339
|
+
isAvailable?: boolean | undefined;
|
|
340
|
+
} | {
|
|
341
|
+
dateRangeStart: string;
|
|
342
|
+
dateRangeEnd: string | null;
|
|
343
|
+
userId?: number | undefined;
|
|
344
|
+
recurrence?: "one_off" | "daily" | "weekly" | undefined;
|
|
345
|
+
weekdays?: ("sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday")[] | undefined;
|
|
346
|
+
windowStartTime?: string | undefined;
|
|
347
|
+
windowEndTime?: string | undefined;
|
|
348
|
+
availabilityRuleMetadata?: {
|
|
349
|
+
bookingLocationIds: number[];
|
|
350
|
+
serviceIds?: number[] | undefined;
|
|
351
|
+
} | undefined;
|
|
352
|
+
isAvailable?: boolean | undefined;
|
|
353
|
+
}, options?: {
|
|
354
|
+
headers?: Record<string, unknown> | undefined;
|
|
355
|
+
query?: Record<string, unknown> | undefined;
|
|
356
|
+
fetch?: RequestInit | undefined;
|
|
357
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
|
358
|
+
200: {
|
|
359
|
+
userId: number;
|
|
360
|
+
weekdays: ("sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday")[];
|
|
361
|
+
windowStartTime: string;
|
|
362
|
+
windowEndTime: string;
|
|
363
|
+
active: boolean;
|
|
364
|
+
isAvailable: boolean;
|
|
365
|
+
availabilityRuleMetadata: {
|
|
366
|
+
bookingLocationIds: number[];
|
|
367
|
+
serviceIds?: number[] | undefined;
|
|
368
|
+
};
|
|
369
|
+
availabilityRuleId: number;
|
|
370
|
+
recurrence: "one_off";
|
|
371
|
+
date: string;
|
|
372
|
+
dateRangeStart: null;
|
|
373
|
+
dateRangeEnd: null;
|
|
374
|
+
} | {
|
|
375
|
+
userId: number;
|
|
376
|
+
weekdays: ("sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday")[];
|
|
377
|
+
windowStartTime: string;
|
|
378
|
+
windowEndTime: string;
|
|
379
|
+
active: boolean;
|
|
380
|
+
isAvailable: boolean;
|
|
381
|
+
availabilityRuleMetadata: {
|
|
382
|
+
bookingLocationIds: number[];
|
|
383
|
+
serviceIds?: number[] | undefined;
|
|
384
|
+
};
|
|
385
|
+
availabilityRuleId: number;
|
|
386
|
+
recurrence: "daily" | "weekly";
|
|
387
|
+
dateRangeStart: string;
|
|
388
|
+
dateRangeEnd: string | null;
|
|
389
|
+
date: null;
|
|
390
|
+
};
|
|
391
|
+
400: {
|
|
392
|
+
error: string;
|
|
393
|
+
};
|
|
394
|
+
404: {
|
|
395
|
+
error: string;
|
|
396
|
+
};
|
|
397
|
+
422: {
|
|
398
|
+
type: "validation";
|
|
399
|
+
on: string;
|
|
400
|
+
summary?: string;
|
|
401
|
+
message?: string;
|
|
402
|
+
found?: unknown;
|
|
403
|
+
property?: string;
|
|
404
|
+
expected?: string;
|
|
405
|
+
};
|
|
406
|
+
}>>;
|
|
407
|
+
delete: (body?: unknown, options?: {
|
|
408
|
+
headers?: Record<string, unknown> | undefined;
|
|
409
|
+
query?: Record<string, unknown> | undefined;
|
|
410
|
+
fetch?: RequestInit | undefined;
|
|
411
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
|
412
|
+
200: {
|
|
413
|
+
success: boolean;
|
|
414
|
+
};
|
|
415
|
+
404: {
|
|
416
|
+
error: string;
|
|
417
|
+
};
|
|
418
|
+
422: {
|
|
419
|
+
type: "validation";
|
|
420
|
+
on: string;
|
|
421
|
+
summary?: string;
|
|
422
|
+
message?: string;
|
|
423
|
+
found?: unknown;
|
|
424
|
+
property?: string;
|
|
425
|
+
expected?: string;
|
|
426
|
+
};
|
|
427
|
+
}>>;
|
|
428
|
+
}) & {
|
|
429
|
+
post: (body: {
|
|
430
|
+
userId: number;
|
|
431
|
+
weekdays: ("sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday")[];
|
|
432
|
+
windowStartTime: string;
|
|
433
|
+
windowEndTime: string;
|
|
434
|
+
active: boolean;
|
|
435
|
+
isAvailable: boolean;
|
|
436
|
+
availabilityRuleMetadata: {
|
|
437
|
+
bookingLocationIds: number[];
|
|
438
|
+
serviceIds?: number[] | undefined;
|
|
439
|
+
};
|
|
440
|
+
recurrence: "one_off";
|
|
441
|
+
date: string;
|
|
442
|
+
dateRangeStart: null;
|
|
443
|
+
dateRangeEnd: null;
|
|
444
|
+
} | {
|
|
445
|
+
userId: number;
|
|
446
|
+
weekdays: ("sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday")[];
|
|
447
|
+
windowStartTime: string;
|
|
448
|
+
windowEndTime: string;
|
|
449
|
+
active: boolean;
|
|
450
|
+
isAvailable: boolean;
|
|
451
|
+
availabilityRuleMetadata: {
|
|
452
|
+
bookingLocationIds: number[];
|
|
453
|
+
serviceIds?: number[] | undefined;
|
|
454
|
+
};
|
|
455
|
+
recurrence: "daily" | "weekly";
|
|
456
|
+
dateRangeStart: string;
|
|
457
|
+
dateRangeEnd: string | null;
|
|
458
|
+
date: null;
|
|
459
|
+
}, options?: {
|
|
460
|
+
headers?: Record<string, unknown> | undefined;
|
|
461
|
+
query?: Record<string, unknown> | undefined;
|
|
462
|
+
fetch?: RequestInit | undefined;
|
|
463
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
|
464
|
+
200: {
|
|
465
|
+
userId: number;
|
|
466
|
+
weekdays: ("sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday")[];
|
|
467
|
+
windowStartTime: string;
|
|
468
|
+
windowEndTime: string;
|
|
469
|
+
active: boolean;
|
|
470
|
+
isAvailable: boolean;
|
|
471
|
+
availabilityRuleMetadata: {
|
|
472
|
+
bookingLocationIds: number[];
|
|
473
|
+
serviceIds?: number[] | undefined;
|
|
474
|
+
};
|
|
475
|
+
availabilityRuleId: number;
|
|
476
|
+
recurrence: "one_off";
|
|
477
|
+
date: string;
|
|
478
|
+
dateRangeStart: null;
|
|
479
|
+
dateRangeEnd: null;
|
|
480
|
+
} | {
|
|
481
|
+
userId: number;
|
|
482
|
+
weekdays: ("sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday")[];
|
|
483
|
+
windowStartTime: string;
|
|
484
|
+
windowEndTime: string;
|
|
485
|
+
active: boolean;
|
|
486
|
+
isAvailable: boolean;
|
|
487
|
+
availabilityRuleMetadata: {
|
|
488
|
+
bookingLocationIds: number[];
|
|
489
|
+
serviceIds?: number[] | undefined;
|
|
490
|
+
};
|
|
491
|
+
availabilityRuleId: number;
|
|
492
|
+
recurrence: "daily" | "weekly";
|
|
493
|
+
dateRangeStart: string;
|
|
494
|
+
dateRangeEnd: string | null;
|
|
495
|
+
date: null;
|
|
496
|
+
};
|
|
497
|
+
400: {
|
|
498
|
+
error: string;
|
|
499
|
+
};
|
|
500
|
+
422: {
|
|
501
|
+
type: "validation";
|
|
502
|
+
on: string;
|
|
503
|
+
summary?: string;
|
|
504
|
+
message?: string;
|
|
505
|
+
found?: unknown;
|
|
506
|
+
property?: string;
|
|
507
|
+
expected?: string;
|
|
508
|
+
};
|
|
509
|
+
}>>;
|
|
510
|
+
search: {
|
|
511
|
+
post: (body: {
|
|
512
|
+
userId: number;
|
|
513
|
+
pagination: {
|
|
514
|
+
limit: number;
|
|
515
|
+
offset: number;
|
|
516
|
+
};
|
|
517
|
+
availabilityRuleId?: number | undefined;
|
|
518
|
+
active?: boolean | undefined;
|
|
519
|
+
isAvailable?: boolean | undefined;
|
|
520
|
+
dateFrom?: string | undefined;
|
|
521
|
+
dateTo?: string | undefined;
|
|
522
|
+
}, options?: {
|
|
523
|
+
headers?: Record<string, unknown> | undefined;
|
|
524
|
+
query?: Record<string, unknown> | undefined;
|
|
525
|
+
fetch?: RequestInit | undefined;
|
|
526
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
|
527
|
+
200: {
|
|
528
|
+
items: ({
|
|
529
|
+
userId: number;
|
|
530
|
+
weekdays: ("sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday")[];
|
|
531
|
+
windowStartTime: string;
|
|
532
|
+
windowEndTime: string;
|
|
533
|
+
active: boolean;
|
|
534
|
+
isAvailable: boolean;
|
|
535
|
+
availabilityRuleMetadata: {
|
|
536
|
+
bookingLocationIds: number[];
|
|
537
|
+
serviceIds?: number[] | undefined;
|
|
538
|
+
};
|
|
539
|
+
availabilityRuleId: number;
|
|
540
|
+
recurrence: "one_off";
|
|
541
|
+
date: string;
|
|
542
|
+
dateRangeStart: null;
|
|
543
|
+
dateRangeEnd: null;
|
|
544
|
+
} | {
|
|
545
|
+
userId: number;
|
|
546
|
+
weekdays: ("sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday")[];
|
|
547
|
+
windowStartTime: string;
|
|
548
|
+
windowEndTime: string;
|
|
549
|
+
active: boolean;
|
|
550
|
+
isAvailable: boolean;
|
|
551
|
+
availabilityRuleMetadata: {
|
|
552
|
+
bookingLocationIds: number[];
|
|
553
|
+
serviceIds?: number[] | undefined;
|
|
554
|
+
};
|
|
555
|
+
availabilityRuleId: number;
|
|
556
|
+
recurrence: "daily" | "weekly";
|
|
557
|
+
dateRangeStart: string;
|
|
558
|
+
dateRangeEnd: string | null;
|
|
559
|
+
date: null;
|
|
560
|
+
})[];
|
|
561
|
+
pagination: {
|
|
562
|
+
total: number;
|
|
563
|
+
limit: number;
|
|
564
|
+
offset: number;
|
|
565
|
+
hasMore: boolean;
|
|
566
|
+
};
|
|
567
|
+
};
|
|
568
|
+
400: {
|
|
569
|
+
error: string;
|
|
570
|
+
};
|
|
571
|
+
422: {
|
|
572
|
+
type: "validation";
|
|
573
|
+
on: string;
|
|
574
|
+
summary?: string;
|
|
575
|
+
message?: string;
|
|
576
|
+
found?: unknown;
|
|
577
|
+
property?: string;
|
|
578
|
+
expected?: string;
|
|
579
|
+
};
|
|
580
|
+
}>>;
|
|
581
|
+
};
|
|
582
|
+
};
|
|
583
|
+
availability: {
|
|
584
|
+
"user-time-slots": {
|
|
585
|
+
post: (body: {
|
|
586
|
+
filters: {
|
|
587
|
+
dateFrom: string;
|
|
588
|
+
dateTo: string;
|
|
589
|
+
timeFrom: string;
|
|
590
|
+
timeTo: string;
|
|
591
|
+
userId: number;
|
|
592
|
+
bookingLocations: {
|
|
593
|
+
bookingLocationId: number;
|
|
594
|
+
bufferMinutes: number;
|
|
595
|
+
leadMinutes: number;
|
|
596
|
+
}[];
|
|
597
|
+
bookingDurationMinutes: number;
|
|
598
|
+
slotGapMinutes: number;
|
|
599
|
+
timeZone: string;
|
|
600
|
+
};
|
|
601
|
+
}, options?: {
|
|
602
|
+
headers?: Record<string, unknown> | undefined;
|
|
603
|
+
query?: Record<string, unknown> | undefined;
|
|
604
|
+
fetch?: RequestInit | undefined;
|
|
605
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
|
606
|
+
200: {
|
|
607
|
+
userId: number;
|
|
608
|
+
timeZone: string;
|
|
609
|
+
bookingLocationAvailability: {
|
|
610
|
+
bookingLocationId: number;
|
|
611
|
+
timeSlotCount: number;
|
|
612
|
+
timeSlots: {
|
|
613
|
+
date: string;
|
|
614
|
+
time: string[];
|
|
615
|
+
}[];
|
|
616
|
+
}[];
|
|
617
|
+
};
|
|
618
|
+
400: {
|
|
619
|
+
error: string;
|
|
620
|
+
};
|
|
621
|
+
422: {
|
|
622
|
+
type: "validation";
|
|
623
|
+
on: string;
|
|
624
|
+
summary?: string;
|
|
625
|
+
message?: string;
|
|
626
|
+
found?: unknown;
|
|
627
|
+
property?: string;
|
|
628
|
+
expected?: string;
|
|
629
|
+
};
|
|
630
|
+
}>>;
|
|
631
|
+
};
|
|
632
|
+
"users-time-slots": {
|
|
633
|
+
post: (body: {
|
|
634
|
+
baseFilters: {
|
|
635
|
+
dateFrom: string;
|
|
636
|
+
dateTo: string;
|
|
637
|
+
timeFrom: string;
|
|
638
|
+
timeTo: string;
|
|
639
|
+
};
|
|
640
|
+
userFilters: {
|
|
641
|
+
userId: number;
|
|
642
|
+
bookingLocations: {
|
|
643
|
+
bookingLocationId: number;
|
|
644
|
+
bufferMinutes: number;
|
|
645
|
+
leadMinutes: number;
|
|
646
|
+
}[];
|
|
647
|
+
bookingDurationMinutes: number;
|
|
648
|
+
slotGapMinutes: number;
|
|
649
|
+
timeZone: string;
|
|
650
|
+
}[];
|
|
651
|
+
}, options?: {
|
|
652
|
+
headers?: Record<string, unknown> | undefined;
|
|
653
|
+
query?: Record<string, unknown> | undefined;
|
|
654
|
+
fetch?: RequestInit | undefined;
|
|
655
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
|
656
|
+
200: {
|
|
657
|
+
userId: number;
|
|
658
|
+
timeZone: string;
|
|
659
|
+
bookingLocationAvailability: {
|
|
660
|
+
bookingLocationId: number;
|
|
661
|
+
timeSlotCount: number;
|
|
662
|
+
timeSlots: {
|
|
663
|
+
date: string;
|
|
664
|
+
time: string[];
|
|
665
|
+
}[];
|
|
666
|
+
}[];
|
|
667
|
+
}[];
|
|
668
|
+
400: {
|
|
669
|
+
error: string;
|
|
670
|
+
};
|
|
671
|
+
422: {
|
|
672
|
+
type: "validation";
|
|
673
|
+
on: string;
|
|
674
|
+
summary?: string;
|
|
675
|
+
message?: string;
|
|
676
|
+
found?: unknown;
|
|
677
|
+
property?: string;
|
|
678
|
+
expected?: string;
|
|
679
|
+
};
|
|
680
|
+
}>>;
|
|
681
|
+
};
|
|
682
|
+
};
|
|
683
|
+
"event-sync": {
|
|
684
|
+
event: ((params: {
|
|
685
|
+
eventId: string | number;
|
|
686
|
+
}) => {
|
|
687
|
+
patch: (body?: {
|
|
688
|
+
userId?: number | undefined;
|
|
689
|
+
status?: "confirmed" | "cancelled" | "tentative" | undefined;
|
|
690
|
+
title?: string | undefined;
|
|
691
|
+
description?: string | null | undefined;
|
|
692
|
+
startTime?: string | undefined;
|
|
693
|
+
endTime?: string | undefined;
|
|
694
|
+
location?: string | null | undefined;
|
|
695
|
+
busyStatus?: "busy" | "free" | undefined;
|
|
696
|
+
} | undefined, options?: {
|
|
697
|
+
headers?: Record<string, unknown> | undefined;
|
|
698
|
+
query?: Record<string, unknown> | undefined;
|
|
699
|
+
fetch?: RequestInit | undefined;
|
|
700
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
|
701
|
+
500: {
|
|
702
|
+
error: string;
|
|
703
|
+
};
|
|
704
|
+
200: {
|
|
705
|
+
userId: number;
|
|
706
|
+
title: string;
|
|
707
|
+
startTime: string;
|
|
708
|
+
endTime: string;
|
|
709
|
+
status: "confirmed" | "cancelled" | "tentative";
|
|
710
|
+
busyStatus: "busy" | "free";
|
|
711
|
+
createdAt: string;
|
|
712
|
+
updatedAt: string;
|
|
713
|
+
eventId: number;
|
|
714
|
+
bookingId: number | null;
|
|
715
|
+
description: string | null;
|
|
716
|
+
location: string | null;
|
|
717
|
+
};
|
|
718
|
+
400: {
|
|
719
|
+
error: string;
|
|
720
|
+
};
|
|
721
|
+
404: {
|
|
722
|
+
error: string;
|
|
723
|
+
};
|
|
724
|
+
422: {
|
|
725
|
+
type: "validation";
|
|
726
|
+
on: string;
|
|
727
|
+
summary?: string;
|
|
728
|
+
message?: string;
|
|
729
|
+
found?: unknown;
|
|
730
|
+
property?: string;
|
|
731
|
+
expected?: string;
|
|
732
|
+
};
|
|
733
|
+
}>>;
|
|
734
|
+
delete: (body?: unknown, options?: {
|
|
735
|
+
headers?: Record<string, unknown> | undefined;
|
|
736
|
+
query?: Record<string, unknown> | undefined;
|
|
737
|
+
fetch?: RequestInit | undefined;
|
|
738
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
|
739
|
+
500: {
|
|
740
|
+
error: string;
|
|
741
|
+
};
|
|
742
|
+
200: {
|
|
743
|
+
success: boolean;
|
|
744
|
+
};
|
|
745
|
+
404: {
|
|
746
|
+
error: string;
|
|
747
|
+
};
|
|
748
|
+
422: {
|
|
749
|
+
type: "validation";
|
|
750
|
+
on: string;
|
|
751
|
+
summary?: string;
|
|
752
|
+
message?: string;
|
|
753
|
+
found?: unknown;
|
|
754
|
+
property?: string;
|
|
755
|
+
expected?: string;
|
|
756
|
+
};
|
|
757
|
+
}>>;
|
|
758
|
+
}) & {
|
|
759
|
+
post: (body: {
|
|
760
|
+
userId: number;
|
|
761
|
+
bookingId: number | null;
|
|
762
|
+
title: string;
|
|
763
|
+
description: string | null;
|
|
764
|
+
location: string | null;
|
|
765
|
+
startTime: string;
|
|
766
|
+
endTime: string;
|
|
767
|
+
status: "confirmed" | "cancelled" | "tentative";
|
|
768
|
+
busyStatus: "busy" | "free";
|
|
769
|
+
}, options?: {
|
|
770
|
+
headers?: Record<string, unknown> | undefined;
|
|
771
|
+
query?: Record<string, unknown> | undefined;
|
|
772
|
+
fetch?: RequestInit | undefined;
|
|
773
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
|
774
|
+
500: {
|
|
775
|
+
error: string;
|
|
776
|
+
};
|
|
777
|
+
200: {
|
|
778
|
+
userId: number;
|
|
779
|
+
title: string;
|
|
780
|
+
startTime: string;
|
|
781
|
+
endTime: string;
|
|
782
|
+
status: "confirmed" | "cancelled" | "tentative";
|
|
783
|
+
busyStatus: "busy" | "free";
|
|
784
|
+
createdAt: string;
|
|
785
|
+
updatedAt: string;
|
|
786
|
+
eventId: number;
|
|
787
|
+
bookingId: number | null;
|
|
788
|
+
description: string | null;
|
|
789
|
+
location: string | null;
|
|
790
|
+
};
|
|
791
|
+
400: {
|
|
792
|
+
error: string;
|
|
793
|
+
};
|
|
794
|
+
422: {
|
|
795
|
+
type: "validation";
|
|
796
|
+
on: string;
|
|
797
|
+
summary?: string;
|
|
798
|
+
message?: string;
|
|
799
|
+
found?: unknown;
|
|
800
|
+
property?: string;
|
|
801
|
+
expected?: string;
|
|
802
|
+
};
|
|
803
|
+
}>>;
|
|
804
|
+
};
|
|
805
|
+
};
|
|
806
|
+
};
|
|
807
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
var v=class extends Error{constructor(e,t){super(t+"");this.status=e,this.value=t}},U=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,B=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,H=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,I=(e)=>e.trim().length!==0&&!Number.isNaN(Number(e)),N=(e)=>{if(typeof e!="string")return null;let t=e.replace(/"/g,"");if(U.test(t)||B.test(t)||H.test(t)){let r=new Date(t);if(!Number.isNaN(r.getTime()))return r}return null},G=(e)=>{let t=e.charCodeAt(0),r=e.charCodeAt(e.length-1);return t===123&&r===125||t===91&&r===93},Z=(e)=>JSON.parse(e,(t,r)=>{return N(r)||r}),g=(e)=>{if(!e)return e;if(I(e))return+e;if(e==="true")return!0;if(e==="false")return!1;let t=N(e);if(t)return t;if(G(e))try{return Z(e)}catch{}return e},T=(e)=>{let t=e.data.toString();return t==="null"?null:g(t)};var z=class{constructor(e){this.url=e,this.ws=new WebSocket(e)}ws;send(e){return Array.isArray(e)?(e.forEach((t)=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,r){return this.addEventListener(e,t,r)}off(e,t,r){return this.ws.removeEventListener(e,t,r),this}subscribe(e,t){return this.addEventListener("message",e,t)}addEventListener(e,t,r){return this.ws.addEventListener(e,(s)=>{if(e==="message"){let d=T(s);t({...s,data:d})}else t(s)},r),this}removeEventListener(e,t,r){return this.off(e,t,r),this}close(){return this.ws.close(),this}},Q=["get","post","put","delete","patch","options","head","connect","subscribe"],W=["localhost","127.0.0.1","0.0.0.0"],C=typeof FileList>"u",M=(e)=>C?e instanceof Blob:e instanceof FileList||e instanceof File,_=(e)=>{if(!e)return!1;for(let t in e)if(M(e[t])||Array.isArray(e[t])&&e[t].find(M))return!0;return!1},k=(e)=>C?e:new Promise((t)=>{let r=new FileReader;r.onload=()=>{let s=new File([r.result],e.name,{lastModified:e.lastModified,type:e.type});t(s)},r.readAsArrayBuffer(e)}),A=(e,t,r={},s={})=>{if(Array.isArray(e)){for(let d of e)if(!Array.isArray(d))s=A(d,t,r,s);else{let o=d[0];if(typeof o=="string")s[o.toLowerCase()]=d[1];else for(let[n,h]of o)s[n.toLowerCase()]=h}return s}if(!e)return s;switch(typeof e){case"function":if(e instanceof Headers)return A(e,t,r,s);let d=e(t,r);return d?A(d,t,r,s):s;case"object":if(e instanceof Headers)return e.forEach((o,n)=>{s[n.toLowerCase()]=o}),s;for(let[o,n]of Object.entries(e))s[o.toLowerCase()]=n;return s;default:return s}};async function*K(e){let t=e.body;if(!t)return;let r=t.getReader(),s=new TextDecoder;try{for(;;){let{done:d,value:o}=await r.read();if(d)break;let n=typeof o=="string"?o:s.decode(o);n.includes(`
|
|
2
|
+
|
|
3
|
+
`)?yield*V(n):yield g(n)}}finally{r.releaseLock()}}function*V(e){let t=e.split(`
|
|
4
|
+
|
|
5
|
+
`);for(let r of t){if(r.indexOf(":")<=0){r&&(yield g(r));continue}let s=r.split(`
|
|
6
|
+
`),d={};for(let o of s){let n=o.indexOf(":");if(n>0){let h=o.slice(0,n).trim(),$=o.slice(n+1).trim();d[h]=g($)}}yield d}}var F=(e,t,r=[],s)=>new Proxy(()=>{},{get(d,o){return F(e,t,o==="index"?r:[...r,o],s)},apply(d,o,[n,h]){if(!n||h||typeof n=="object"&&Object.keys(n).length!==1||Q.includes(r.at(-1))){let $=[...r],L=$.pop(),m="/"+$.join("/"),{fetcher:P=fetch,headers:S,onRequest:y,onResponse:E,fetch:q}=t,j=L==="get"||L==="head"||L==="subscribe";S=A(S,m,h);let D=j?n?.query:h?.query,x="";if(D){let a=(b,p)=>{x+=(x?"&":"?")+`${encodeURIComponent(b)}=${encodeURIComponent(p)}`};for(let[b,p]of Object.entries(D)){if(Array.isArray(p)){for(let f of p)a(b,f);continue}if(p!=null){if(typeof p=="object"){a(b,JSON.stringify(p));continue}a(b,`${p}`)}}}if(L==="subscribe"){let a=e.replace(/^([^]+):\/\//,e.startsWith("https://")?"wss://":e.startsWith("http://")||W.find((b)=>e.includes(b))?"ws://":"wss://")+m+x;return new z(a)}return(async()=>{let a={method:L?.toUpperCase(),body:n,...q,headers:S};a.headers={...S,...A(j?n?.headers:h?.headers,m,a)};let b=j&&typeof n=="object"?n.fetch:h?.fetch;if(a={...a,...b},j&&delete a.body,y){Array.isArray(y)||(y=[y]);for(let u of y){let i=await u(m,a);typeof i=="object"&&(a={...a,...i,headers:{...a.headers,...A(i.headers,m,a)}})}}if(j&&delete a.body,_(n)){let u=new FormData;for(let[i,l]of Object.entries(a.body)){if(Array.isArray(l)){for(let w=0;w<l.length;w++){let R=l[w];u.append(i,R instanceof File?await k(R):R)}continue}if(C){if(Array.isArray(l))for(let w of l)u.append(i,w);else u.append(i,l);continue}if(l instanceof File){u.append(i,await k(l));continue}if(l instanceof FileList){for(let w=0;w<l.length;w++)u.append(i,await k(l[w]));continue}u.append(i,l)}a.body=u}else typeof n=="object"?(a.headers["content-type"]="application/json",a.body=JSON.stringify(n)):n!=null&&(a.headers["content-type"]="text/plain");if(j&&delete a.body,y){Array.isArray(y)||(y=[y]);for(let u of y){let i=await u(m,a);typeof i=="object"&&(a={...a,...i,headers:{...a.headers,...A(i.headers,m,a)}})}}h?.headers?.["content-type"]&&(a.headers["content-type"]=h?.headers["content-type"]);let p=e+m+x,f=await(s?.handle(new Request(p,a))??P(p,a)),c=null,O=null;if(E){Array.isArray(E)||(E=[E]);for(let u of E)try{let i=await u(f.clone());if(i!=null){c=i;break}}catch(i){i instanceof v?O=i:O=new v(422,i);break}}if(c!==null)return{data:c,error:O,response:f,status:f.status,headers:f.headers};switch(f.headers.get("Content-Type")?.split(";")[0]){case"text/event-stream":c=K(f);break;case"application/json":c=JSON.parse(await f.text(),(i,l)=>{if(typeof l!="string")return l;return N(l)||l});break;case"application/octet-stream":c=await f.arrayBuffer();break;case"multipart/form-data":let u=await f.formData();c={},u.forEach((i,l)=>{c[l]=i});break;default:c=await f.text().then(g)}return(f.status>=300||f.status<200)&&(O=new v(f.status,c),c=null),{data:c,error:O,response:f,status:f.status,headers:f.headers}})()}return typeof n=="object"?F(e,t,[...r,Object.values(n)[0]],s):F(e,t,r)}}),J=(e,t={})=>typeof e=="string"?(t.keepDomain||(e.includes("://")||(e=(W.find((r)=>e.includes(r))?"http://":"https://")+e),e.endsWith("/")&&(e=e.slice(0,-1))),F(e,t)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),F("http://e.ly",t,[],e));function ye(e){let{baseUrl:t,apiKey:r,fetch:s}=e;return J(t,{headers:{"X-API-Key":r},fetch:s})}export{ye as Balendar};
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "balendar",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"module": "client.ts",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"private": false,
|
|
7
|
+
"exports": {
|
|
8
|
+
"./client": "./dist/lib/client.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/lib/client.d.ts",
|
|
12
|
+
"dist/lib/client.js"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"lib.build": "rm -rf dist && tsc --project tsconfig.json && bun build --minify --outfile=dist/lib/client.js ./client.ts",
|
|
16
|
+
"lib.publish": "bun lib.build && bun publish"
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"typescript": "5.9.3"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@elysiajs/eden": "1.4.4",
|
|
23
|
+
"elysia": "1.4.15"
|
|
24
|
+
}
|
|
25
|
+
}
|