@devpablocristo/modules-scheduling 0.4.0

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/src/types.ts ADDED
@@ -0,0 +1,653 @@
1
+ export type SchedulingRequestOptions = {
2
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
3
+ body?: unknown;
4
+ };
5
+
6
+ export type SchedulingTransport = <T>(path: string, options?: SchedulingRequestOptions) => Promise<T>;
7
+
8
+ export type FulfillmentMode = 'schedule' | 'queue' | 'hybrid';
9
+ export type ResourceKind = 'professional' | 'desk' | 'counter' | 'box' | 'room' | 'generic';
10
+ export type AvailabilityRuleKind = 'branch' | 'resource';
11
+ export type BookingStatus =
12
+ | 'hold'
13
+ | 'pending_confirmation'
14
+ | 'confirmed'
15
+ | 'checked_in'
16
+ | 'in_service'
17
+ | 'completed'
18
+ | 'cancelled'
19
+ | 'no_show'
20
+ | 'expired';
21
+ export type BookingSource = 'admin' | 'public_web' | 'whatsapp' | 'api';
22
+ export type QueueStatus = 'active' | 'paused' | 'closed';
23
+ export type QueueStrategy = 'fifo' | 'priority';
24
+ export type QueueTicketStatus = 'waiting' | 'called' | 'serving' | 'completed' | 'no_show' | 'cancelled';
25
+ export type QueueTicketSource = 'reception' | 'web' | 'whatsapp' | 'api';
26
+ export type WaitlistStatus = 'pending' | 'notified' | 'booked' | 'cancelled' | 'expired';
27
+ export type WaitlistSource = 'admin' | 'public_web' | 'whatsapp' | 'api';
28
+
29
+ export type Branch = {
30
+ id: string;
31
+ org_id: string;
32
+ code: string;
33
+ name: string;
34
+ timezone: string;
35
+ address: string;
36
+ active: boolean;
37
+ metadata?: Record<string, unknown>;
38
+ created_at: string;
39
+ updated_at: string;
40
+ };
41
+
42
+ export type Service = {
43
+ id: string;
44
+ org_id: string;
45
+ code: string;
46
+ name: string;
47
+ description: string;
48
+ fulfillment_mode: FulfillmentMode;
49
+ default_duration_minutes: number;
50
+ buffer_before_minutes: number;
51
+ buffer_after_minutes: number;
52
+ slot_granularity_minutes: number;
53
+ max_concurrent_bookings: number;
54
+ min_cancel_notice_minutes: number;
55
+ allow_waitlist: boolean;
56
+ active: boolean;
57
+ resource_ids?: string[];
58
+ metadata?: Record<string, unknown>;
59
+ created_at: string;
60
+ updated_at: string;
61
+ };
62
+
63
+ export type Resource = {
64
+ id: string;
65
+ org_id: string;
66
+ branch_id: string;
67
+ code: string;
68
+ name: string;
69
+ kind: ResourceKind;
70
+ capacity: number;
71
+ timezone?: string;
72
+ active: boolean;
73
+ metadata?: Record<string, unknown>;
74
+ created_at: string;
75
+ updated_at: string;
76
+ };
77
+
78
+ export type AvailabilityRule = {
79
+ id: string;
80
+ org_id: string;
81
+ branch_id: string;
82
+ resource_id?: string | null;
83
+ kind: AvailabilityRuleKind;
84
+ weekday: number;
85
+ start_time: string;
86
+ end_time: string;
87
+ slot_granularity_minutes?: number | null;
88
+ valid_from?: string | null;
89
+ valid_until?: string | null;
90
+ active: boolean;
91
+ metadata?: Record<string, unknown>;
92
+ created_at: string;
93
+ updated_at: string;
94
+ };
95
+
96
+ export type BlockedRangeKind = 'holiday' | 'manual' | 'maintenance' | 'leave';
97
+
98
+ export type BlockedRange = {
99
+ id: string;
100
+ org_id: string;
101
+ branch_id: string;
102
+ resource_id?: string | null;
103
+ kind: BlockedRangeKind;
104
+ reason: string;
105
+ start_at: string;
106
+ end_at: string;
107
+ all_day: boolean;
108
+ created_by?: string;
109
+ metadata?: Record<string, unknown>;
110
+ created_at: string;
111
+ };
112
+
113
+ export type BlockedRangePayload = {
114
+ branch_id: string;
115
+ resource_id?: string | null;
116
+ kind: BlockedRangeKind;
117
+ reason?: string;
118
+ start_at: string;
119
+ end_at: string;
120
+ all_day?: boolean;
121
+ metadata?: Record<string, unknown>;
122
+ };
123
+
124
+ export type ListBlockedRangesQuery = {
125
+ branchId?: string | null;
126
+ resourceId?: string | null;
127
+ date?: string | null;
128
+ };
129
+
130
+ export type TimeSlot = {
131
+ resource_id: string;
132
+ resource_name: string;
133
+ start_at: string;
134
+ end_at: string;
135
+ occupies_from: string;
136
+ occupies_until: string;
137
+ timezone: string;
138
+ remaining: number;
139
+ conflict_count: number;
140
+ granularity_minutes: number;
141
+ };
142
+
143
+ export type Booking = {
144
+ id: string;
145
+ org_id: string;
146
+ branch_id: string;
147
+ service_id: string;
148
+ resource_id: string;
149
+ party_id?: string | null;
150
+ reference: string;
151
+ customer_name: string;
152
+ customer_phone: string;
153
+ customer_email?: string;
154
+ status: BookingStatus;
155
+ source: BookingSource;
156
+ idempotency_key?: string;
157
+ start_at: string;
158
+ end_at: string;
159
+ occupies_from: string;
160
+ occupies_until: string;
161
+ hold_expires_at?: string | null;
162
+ notes: string;
163
+ metadata?: Record<string, unknown>;
164
+ created_by?: string;
165
+ confirmed_at?: string | null;
166
+ cancelled_at?: string | null;
167
+ reminder_sent_at?: string | null;
168
+ created_at: string;
169
+ updated_at: string;
170
+ };
171
+
172
+ export type CalendarEventKind = 'booking';
173
+ export type CalendarEventSourceType = 'booking';
174
+
175
+ export type CalendarEvent = {
176
+ id: string;
177
+ kind: CalendarEventKind;
178
+ sourceId: string;
179
+ sourceType: CalendarEventSourceType;
180
+ title: string;
181
+ start_at: string;
182
+ end_at: string;
183
+ color: string;
184
+ status: BookingStatus;
185
+ serviceName?: string;
186
+ resourceName?: string;
187
+ sourceBooking: Booking;
188
+ };
189
+
190
+ export type DashboardStats = {
191
+ date: string;
192
+ timezone: string;
193
+ bookings_today: number;
194
+ confirmed_bookings_today: number;
195
+ active_queues: number;
196
+ waiting_tickets: number;
197
+ tickets_in_service: number;
198
+ };
199
+
200
+ export type DayAgendaItem = {
201
+ type: string;
202
+ id: string;
203
+ branch_id: string;
204
+ service_id?: string | null;
205
+ start_at?: string | null;
206
+ end_at?: string | null;
207
+ status: string;
208
+ label: string;
209
+ metadata?: Record<string, unknown>;
210
+ };
211
+
212
+ export type Queue = {
213
+ id: string;
214
+ org_id: string;
215
+ branch_id: string;
216
+ service_id?: string | null;
217
+ code: string;
218
+ name: string;
219
+ status: QueueStatus;
220
+ strategy: QueueStrategy;
221
+ ticket_prefix: string;
222
+ avg_service_seconds: number;
223
+ allow_remote_join: boolean;
224
+ metadata?: Record<string, unknown>;
225
+ created_by?: string;
226
+ created_at: string;
227
+ updated_at: string;
228
+ };
229
+
230
+ export type QueueTicket = {
231
+ id: string;
232
+ org_id: string;
233
+ queue_id: string;
234
+ branch_id: string;
235
+ service_id?: string | null;
236
+ party_id?: string | null;
237
+ number: number;
238
+ display_code: string;
239
+ customer_name: string;
240
+ customer_phone: string;
241
+ customer_email?: string;
242
+ status: QueueTicketStatus;
243
+ source: QueueTicketSource;
244
+ priority: number;
245
+ idempotency_key?: string;
246
+ notes: string;
247
+ metadata?: Record<string, unknown>;
248
+ requested_at: string;
249
+ called_at?: string | null;
250
+ started_at?: string | null;
251
+ completed_at?: string | null;
252
+ cancelled_at?: string | null;
253
+ no_show_at?: string | null;
254
+ serving_resource_id?: string | null;
255
+ operator_user_id?: string | null;
256
+ created_by?: string;
257
+ updated_at: string;
258
+ };
259
+
260
+ export type QueuePosition = {
261
+ ticket_id: string;
262
+ queue_id: string;
263
+ status: QueueTicketStatus;
264
+ position: number;
265
+ estimated_wait_seconds: number;
266
+ };
267
+
268
+ export type WaitlistEntry = {
269
+ id: string;
270
+ org_id: string;
271
+ branch_id: string;
272
+ service_id: string;
273
+ resource_id?: string | null;
274
+ party_id?: string | null;
275
+ customer_name: string;
276
+ customer_phone: string;
277
+ customer_email?: string;
278
+ requested_start_at: string;
279
+ status: WaitlistStatus;
280
+ source: WaitlistSource;
281
+ idempotency_key?: string;
282
+ notes: string;
283
+ metadata?: Record<string, unknown>;
284
+ created_by?: string;
285
+ created_at: string;
286
+ updated_at: string;
287
+ };
288
+
289
+ export type ListBookingsFilter = {
290
+ branchId?: string | null;
291
+ date?: string | null;
292
+ status?: string;
293
+ limit?: number;
294
+ };
295
+
296
+ export type SlotQuery = {
297
+ branchId: string;
298
+ serviceId: string;
299
+ date: string;
300
+ resourceId?: string | null;
301
+ };
302
+
303
+ export type BookingRecurrence = {
304
+ freq: 'daily' | 'weekly' | 'monthly';
305
+ interval?: number;
306
+ count?: number;
307
+ until?: string;
308
+ by_weekday?: number[];
309
+ };
310
+
311
+ export type CreateBookingPayload = {
312
+ branch_id: string;
313
+ service_id: string;
314
+ resource_id?: string;
315
+ party_id?: string;
316
+ customer_name: string;
317
+ customer_phone: string;
318
+ customer_email?: string;
319
+ start_at: string;
320
+ end_at?: string;
321
+ status?: BookingStatus;
322
+ source?: BookingSource;
323
+ idempotency_key?: string;
324
+ hold_until?: string;
325
+ notes?: string;
326
+ metadata?: Record<string, unknown>;
327
+ recurrence?: BookingRecurrence;
328
+ };
329
+
330
+ export type RescheduleBookingPayload = {
331
+ branch_id?: string;
332
+ resource_id?: string;
333
+ start_at: string;
334
+ end_at?: string;
335
+ };
336
+
337
+ export type BookingActionResult = Booking;
338
+
339
+ export type PublicService = {
340
+ id: string;
341
+ name: string;
342
+ type: string;
343
+ description: string;
344
+ unit: string;
345
+ price: number;
346
+ currency: string;
347
+ };
348
+
349
+ export type PublicAvailabilitySlot = {
350
+ start_at: string;
351
+ end_at: string;
352
+ remaining: number;
353
+ };
354
+
355
+ export type PublicBookingActionLinks = {
356
+ confirm_token?: string;
357
+ cancel_token?: string;
358
+ confirm_path?: string;
359
+ cancel_path?: string;
360
+ };
361
+
362
+ export type PublicBooking = {
363
+ id: string;
364
+ party_name: string;
365
+ party_phone: string;
366
+ customer_email?: string;
367
+ title: string;
368
+ status: BookingStatus;
369
+ start_at: string;
370
+ end_at: string;
371
+ duration: number;
372
+ actions?: PublicBookingActionLinks;
373
+ };
374
+
375
+ export type PublicBusinessInfo = {
376
+ org_id: string;
377
+ name: string;
378
+ slug: string;
379
+ business_name: string;
380
+ business_address: string;
381
+ business_phone: string;
382
+ business_email: string;
383
+ scheduling_enabled: boolean;
384
+ appointments_enabled?: boolean;
385
+ };
386
+
387
+ export type PublicQueueSummary = {
388
+ id: string;
389
+ code: string;
390
+ name: string;
391
+ status: QueueStatus;
392
+ allow_remote_join: boolean;
393
+ avg_service_seconds: number;
394
+ };
395
+
396
+ export type PublicQueueTicket = {
397
+ ticket: QueueTicket;
398
+ position: PublicQueuePosition;
399
+ };
400
+
401
+ export type PublicQueuePosition = {
402
+ ticket_id: string;
403
+ queue_id: string;
404
+ status: QueueTicketStatus;
405
+ position: number;
406
+ estimated_wait_seconds: number;
407
+ };
408
+
409
+ export type PublicWaitlistEntry = {
410
+ id: string;
411
+ branch_id: string;
412
+ service_id: string;
413
+ resource_id?: string | null;
414
+ customer_name: string;
415
+ customer_phone: string;
416
+ customer_email?: string;
417
+ requested_start_at: string;
418
+ status: WaitlistStatus;
419
+ };
420
+
421
+ export type PublicAvailabilityQuery = {
422
+ branchId?: string | null;
423
+ serviceId?: string | null;
424
+ date: string;
425
+ resourceId?: string | null;
426
+ duration?: number;
427
+ };
428
+
429
+ export type PublicBookPayload = {
430
+ branch_id?: string;
431
+ service_id?: string;
432
+ resource_id?: string;
433
+ customer_name: string;
434
+ customer_phone: string;
435
+ customer_email?: string;
436
+ start_at: string;
437
+ notes?: string;
438
+ };
439
+
440
+ export type PublicMyBookingsQuery = {
441
+ phone: string;
442
+ limit?: number;
443
+ };
444
+
445
+ export type PublicQueueTicketPayload = {
446
+ customer_name: string;
447
+ customer_phone: string;
448
+ customer_email?: string;
449
+ priority?: number;
450
+ notes?: string;
451
+ };
452
+
453
+ export type PublicWaitlistPayload = {
454
+ branch_id: string;
455
+ service_id: string;
456
+ resource_id?: string;
457
+ customer_name: string;
458
+ customer_phone: string;
459
+ customer_email?: string;
460
+ requested_start_at: string;
461
+ notes?: string;
462
+ };
463
+
464
+ export type QueueOperatorBoardStatusCopy = Record<QueueTicketStatus | QueueStatus, string>;
465
+
466
+ export type QueueOperatorBoardCopy = {
467
+ title: string;
468
+ description: string;
469
+ branchLabel: string;
470
+ dateLabel: string;
471
+ loading: string;
472
+ noQueues: string;
473
+ issueTicketTitle: string;
474
+ issueTicketDescription: string;
475
+ customerNameLabel: string;
476
+ customerPhoneLabel: string;
477
+ customerEmailLabel: string;
478
+ priorityLabel: string;
479
+ issueTicket: string;
480
+ issuingTicket: string;
481
+ callNext: string;
482
+ pauseQueue: string;
483
+ reopenQueue: string;
484
+ closeQueue: string;
485
+ waitingColumn: string;
486
+ activeColumn: string;
487
+ finishedColumn: string;
488
+ noTickets: string;
489
+ requestedAtLabel: string;
490
+ statusLabel: string;
491
+ serveTicket: string;
492
+ completeTicket: string;
493
+ noShowTicket: string;
494
+ cancelTicket: string;
495
+ returnToWaiting: string;
496
+ nextTicketTitle: string;
497
+ queueMetricsIssued: string;
498
+ queueMetricsWaiting: string;
499
+ queueMetricsServing: string;
500
+ queueMetricsDone: string;
501
+ confirmDangerTitle: string;
502
+ dismissConfirm: string;
503
+ confirmCancelDescription: string;
504
+ confirmNoShowDescription: string;
505
+ closeQueueDescription: string;
506
+ statuses: QueueOperatorBoardStatusCopy;
507
+ };
508
+
509
+ export type PublicSchedulingFlowCopy = {
510
+ title: string;
511
+ description: string;
512
+ orgRefLabel: string;
513
+ orgRefHelp: string;
514
+ loadOrg: string;
515
+ businessInfoTitle: string;
516
+ serviceLabel: string;
517
+ dateLabel: string;
518
+ phoneLabel: string;
519
+ nameLabel: string;
520
+ emailLabel: string;
521
+ notesLabel: string;
522
+ availabilityTitle: string;
523
+ availabilityDescription: string;
524
+ availabilityEmpty: string;
525
+ availabilityLoading: string;
526
+ selectSlot: string;
527
+ selectedSlotLabel: string;
528
+ bookNow: string;
529
+ booking: string;
530
+ myBookingsTitle: string;
531
+ myBookingsDescription: string;
532
+ findBookings: string;
533
+ findingBookings: string;
534
+ noBookings: string;
535
+ queuesTitle: string;
536
+ queuesDescription: string;
537
+ joinQueue: string;
538
+ joiningQueue: string;
539
+ etaLabel: string;
540
+ positionLabel: string;
541
+ ticketCodeLabel: string;
542
+ publicDisabledTitle: string;
543
+ publicDisabledDescription: string;
544
+ loading: string;
545
+ bookingCreatedTitle: string;
546
+ queueCreatedTitle: string;
547
+ confirmBooking: string;
548
+ cancelBooking: string;
549
+ cancelBookingReason: string;
550
+ statuses: Record<string, string>;
551
+ };
552
+
553
+ export type SchedulingCalendarStatusCopy = Record<BookingStatus, string>;
554
+
555
+ export type SchedulingCalendarCopy = {
556
+ branchLabel: string;
557
+ serviceLabel: string;
558
+ resourceLabel: string;
559
+ anyResource: string;
560
+ focusDateLabel: string;
561
+ summaryTitle: string;
562
+ summaryBookings: string;
563
+ summaryConfirmed: string;
564
+ summaryQueues: string;
565
+ summaryWaiting: string;
566
+ slotsTitle: string;
567
+ slotsDescription: string;
568
+ slotsEmpty: string;
569
+ slotsLoading: string;
570
+ loading: string;
571
+ unavailableTitle: string;
572
+ unavailableDescription: string;
573
+ filtersTitle: string;
574
+ filtersDescription: string;
575
+ timelineTitle: string;
576
+ timelineDescription: string;
577
+ openBooking: string;
578
+ titleLabel: string;
579
+ repeatLabel: string;
580
+ repeatNever: string;
581
+ repeatDaily: string;
582
+ repeatWeekly: string;
583
+ repeatMonthly: string;
584
+ repeatCustom: string;
585
+ repeatFrequencyLabel: string;
586
+ repeatIntervalLabel: string;
587
+ repeatCountLabel: string;
588
+ repeatWeekdaysLabel: string;
589
+ bookingTitleCreate: string;
590
+ bookingTitleDetails: string;
591
+ bookingSubtitleCreate: string;
592
+ bookingSubtitleDetails: string;
593
+ availableSlotLabel: string;
594
+ availableSlotHint: string;
595
+ availableSlotLoading: string;
596
+ unavailableSlotMessage: string;
597
+ slotSummaryTitle: string;
598
+ bookingPreviewTitle: string;
599
+ customerNameLabel: string;
600
+ customerPhoneLabel: string;
601
+ customerEmailLabel: string;
602
+ notesLabel: string;
603
+ statusLabel: string;
604
+ serviceNameLabel: string;
605
+ resourceNameLabel: string;
606
+ slotLabel: string;
607
+ slotStartLabel: string;
608
+ slotEndLabel: string;
609
+ durationLabel: string;
610
+ timezoneLabel: string;
611
+ occupiesLabel: string;
612
+ conflictLabel: string;
613
+ slotRemainingLabel: string;
614
+ referenceLabel: string;
615
+ close: string;
616
+ create: string;
617
+ saving: string;
618
+ cancelBooking: string;
619
+ confirmBooking: string;
620
+ checkInBooking: string;
621
+ startService: string;
622
+ completeBooking: string;
623
+ noShowBooking: string;
624
+ rescheduleBooking: string;
625
+ dragRescheduleTitle: string;
626
+ dragRescheduleDescription: string;
627
+ destructiveTitle: string;
628
+ cancelActionDescription: string;
629
+ noShowActionDescription: string;
630
+ closeDirtyTitle: string;
631
+ closeDirtyDescription: string;
632
+ keepEditing: string;
633
+ discard: string;
634
+ resizeLockedMessage: string;
635
+ resizeBookingTitle: string;
636
+ resizeBookingDescription: string;
637
+ searchPlaceholder: string;
638
+ statuses: SchedulingCalendarStatusCopy;
639
+ blockedRangeAction: string;
640
+ blockedRangeEyebrow: string;
641
+ blockedRangeCreateTitle: string;
642
+ blockedRangeEditTitle: string;
643
+ blockedRangeKindLabel: string;
644
+ blockedRangeKindOptions: Record<BlockedRangeKind, string>;
645
+ blockedRangeReasonLabel: string;
646
+ blockedRangeReasonPlaceholder: string;
647
+ blockedRangeCreate: string;
648
+ blockedRangeUpdate: string;
649
+ blockedRangeDelete: string;
650
+ blockedRangeDeleteTitle: string;
651
+ blockedRangeDeleteDescription: string;
652
+ blockedRangeFallbackTitle: string;
653
+ };