@voyantjs/bookings 0.6.7 → 0.6.9
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/README.md +2 -2
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/pii.d.ts +10 -9
- package/dist/pii.d.ts.map +1 -1
- package/dist/pii.js +33 -33
- package/dist/routes-groups.d.ts +25 -5
- package/dist/routes-groups.d.ts.map +1 -1
- package/dist/routes-groups.js +3 -3
- package/dist/routes-public.d.ts +19 -21
- package/dist/routes-public.d.ts.map +1 -1
- package/dist/routes-public.js +1 -1
- package/dist/routes-shared.d.ts +1 -1
- package/dist/routes-shared.d.ts.map +1 -1
- package/dist/routes.d.ts +200 -187
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +65 -95
- package/dist/schema/travel-details.d.ts +27 -27
- package/dist/schema/travel-details.d.ts.map +1 -1
- package/dist/schema/travel-details.js +19 -14
- package/dist/schema-core.d.ts +194 -305
- package/dist/schema-core.d.ts.map +1 -1
- package/dist/schema-core.js +20 -8
- package/dist/schema-items.d.ts +15 -15
- package/dist/schema-items.d.ts.map +1 -1
- package/dist/schema-items.js +16 -11
- package/dist/schema-operations.d.ts +1 -1
- package/dist/schema-operations.d.ts.map +1 -1
- package/dist/schema-operations.js +13 -5
- package/dist/schema-relations.d.ts +26 -9
- package/dist/schema-relations.d.ts.map +1 -1
- package/dist/schema-relations.js +36 -21
- package/dist/schema-shared.d.ts +3 -2
- package/dist/schema-shared.d.ts.map +1 -1
- package/dist/schema-shared.js +4 -5
- package/dist/schema-staff.d.ts +267 -0
- package/dist/schema-staff.d.ts.map +1 -0
- package/dist/schema-staff.js +31 -0
- package/dist/schema.d.ts +1 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +1 -0
- package/dist/service-groups.d.ts +3 -7
- package/dist/service-groups.d.ts.map +1 -1
- package/dist/service-groups.js +6 -10
- package/dist/service-public.d.ts +49 -55
- package/dist/service-public.d.ts.map +1 -1
- package/dist/service-public.js +106 -53
- package/dist/service.d.ts +227 -99
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +321 -108
- package/dist/transactions-ref.d.ts +930 -66
- package/dist/transactions-ref.d.ts.map +1 -1
- package/dist/transactions-ref.js +56 -2
- package/dist/validation-public.d.ts +29 -69
- package/dist/validation-public.d.ts.map +1 -1
- package/dist/validation-public.js +21 -20
- package/dist/validation-shared.d.ts +4 -5
- package/dist/validation-shared.d.ts.map +1 -1
- package/dist/validation-shared.js +2 -10
- package/dist/validation.d.ts +229 -44
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +84 -28
- package/package.json +6 -6
package/dist/service-public.d.ts
CHANGED
|
@@ -21,9 +21,9 @@ export declare const publicBookingsService: {
|
|
|
21
21
|
expiredAt: string | null;
|
|
22
22
|
cancelledAt: string | null;
|
|
23
23
|
completedAt: string | null;
|
|
24
|
-
|
|
24
|
+
travelers: {
|
|
25
25
|
id: string;
|
|
26
|
-
participantType: "
|
|
26
|
+
participantType: "other" | "traveler" | "occupant";
|
|
27
27
|
travelerCategory: "other" | "adult" | "child" | "infant" | "senior" | null;
|
|
28
28
|
firstName: string;
|
|
29
29
|
lastName: string;
|
|
@@ -56,9 +56,9 @@ export declare const publicBookingsService: {
|
|
|
56
56
|
optionId: string | null;
|
|
57
57
|
optionUnitId: string | null;
|
|
58
58
|
pricingCategoryId: string | null;
|
|
59
|
-
|
|
59
|
+
travelerLinks: {
|
|
60
60
|
id: string;
|
|
61
|
-
|
|
61
|
+
travelerId: string;
|
|
62
62
|
role: string;
|
|
63
63
|
isPrimary: boolean;
|
|
64
64
|
}[];
|
|
@@ -79,9 +79,8 @@ export declare const publicBookingsService: {
|
|
|
79
79
|
releasedAt: string | null;
|
|
80
80
|
}[];
|
|
81
81
|
checklist: {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
hasPrimaryParticipant: boolean;
|
|
82
|
+
hasTravelers: boolean;
|
|
83
|
+
hasPrimaryTraveler: boolean;
|
|
85
84
|
hasItems: boolean;
|
|
86
85
|
hasAllocations: boolean;
|
|
87
86
|
readyForConfirmation: boolean;
|
|
@@ -114,9 +113,9 @@ export declare const publicBookingsService: {
|
|
|
114
113
|
expiredAt: string | null;
|
|
115
114
|
cancelledAt: string | null;
|
|
116
115
|
completedAt: string | null;
|
|
117
|
-
|
|
116
|
+
travelers: {
|
|
118
117
|
id: string;
|
|
119
|
-
participantType: "
|
|
118
|
+
participantType: "other" | "traveler" | "occupant";
|
|
120
119
|
travelerCategory: "other" | "adult" | "child" | "infant" | "senior" | null;
|
|
121
120
|
firstName: string;
|
|
122
121
|
lastName: string;
|
|
@@ -149,9 +148,9 @@ export declare const publicBookingsService: {
|
|
|
149
148
|
optionId: string | null;
|
|
150
149
|
optionUnitId: string | null;
|
|
151
150
|
pricingCategoryId: string | null;
|
|
152
|
-
|
|
151
|
+
travelerLinks: {
|
|
153
152
|
id: string;
|
|
154
|
-
|
|
153
|
+
travelerId: string;
|
|
155
154
|
role: string;
|
|
156
155
|
isPrimary: boolean;
|
|
157
156
|
}[];
|
|
@@ -172,9 +171,8 @@ export declare const publicBookingsService: {
|
|
|
172
171
|
releasedAt: string | null;
|
|
173
172
|
}[];
|
|
174
173
|
checklist: {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
hasPrimaryParticipant: boolean;
|
|
174
|
+
hasTravelers: boolean;
|
|
175
|
+
hasPrimaryTraveler: boolean;
|
|
178
176
|
hasItems: boolean;
|
|
179
177
|
hasAllocations: boolean;
|
|
180
178
|
readyForConfirmation: boolean;
|
|
@@ -214,7 +212,7 @@ export declare const publicBookingsService: {
|
|
|
214
212
|
version: number;
|
|
215
213
|
createdAt: string;
|
|
216
214
|
updatedAt: string;
|
|
217
|
-
}
|
|
215
|
+
};
|
|
218
216
|
}>;
|
|
219
217
|
updateSession(db: PostgresJsDatabase, bookingId: string, input: PublicUpdateBookingSessionInput, userId?: string): Promise<{
|
|
220
218
|
status: Exclude<string, "ok">;
|
|
@@ -236,9 +234,9 @@ export declare const publicBookingsService: {
|
|
|
236
234
|
expiredAt: string | null;
|
|
237
235
|
cancelledAt: string | null;
|
|
238
236
|
completedAt: string | null;
|
|
239
|
-
|
|
237
|
+
travelers: {
|
|
240
238
|
id: string;
|
|
241
|
-
participantType: "
|
|
239
|
+
participantType: "other" | "traveler" | "occupant";
|
|
242
240
|
travelerCategory: "other" | "adult" | "child" | "infant" | "senior" | null;
|
|
243
241
|
firstName: string;
|
|
244
242
|
lastName: string;
|
|
@@ -271,9 +269,9 @@ export declare const publicBookingsService: {
|
|
|
271
269
|
optionId: string | null;
|
|
272
270
|
optionUnitId: string | null;
|
|
273
271
|
pricingCategoryId: string | null;
|
|
274
|
-
|
|
272
|
+
travelerLinks: {
|
|
275
273
|
id: string;
|
|
276
|
-
|
|
274
|
+
travelerId: string;
|
|
277
275
|
role: string;
|
|
278
276
|
isPrimary: boolean;
|
|
279
277
|
}[];
|
|
@@ -294,9 +292,8 @@ export declare const publicBookingsService: {
|
|
|
294
292
|
releasedAt: string | null;
|
|
295
293
|
}[];
|
|
296
294
|
checklist: {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
hasPrimaryParticipant: boolean;
|
|
295
|
+
hasTravelers: boolean;
|
|
296
|
+
hasPrimaryTraveler: boolean;
|
|
300
297
|
hasItems: boolean;
|
|
301
298
|
hasAllocations: boolean;
|
|
302
299
|
readyForConfirmation: boolean;
|
|
@@ -370,9 +367,9 @@ export declare const publicBookingsService: {
|
|
|
370
367
|
expiredAt: string | null;
|
|
371
368
|
cancelledAt: string | null;
|
|
372
369
|
completedAt: string | null;
|
|
373
|
-
|
|
370
|
+
travelers: {
|
|
374
371
|
id: string;
|
|
375
|
-
participantType: "
|
|
372
|
+
participantType: "other" | "traveler" | "occupant";
|
|
376
373
|
travelerCategory: "other" | "adult" | "child" | "infant" | "senior" | null;
|
|
377
374
|
firstName: string;
|
|
378
375
|
lastName: string;
|
|
@@ -405,9 +402,9 @@ export declare const publicBookingsService: {
|
|
|
405
402
|
optionId: string | null;
|
|
406
403
|
optionUnitId: string | null;
|
|
407
404
|
pricingCategoryId: string | null;
|
|
408
|
-
|
|
405
|
+
travelerLinks: {
|
|
409
406
|
id: string;
|
|
410
|
-
|
|
407
|
+
travelerId: string;
|
|
411
408
|
role: string;
|
|
412
409
|
isPrimary: boolean;
|
|
413
410
|
}[];
|
|
@@ -428,9 +425,8 @@ export declare const publicBookingsService: {
|
|
|
428
425
|
releasedAt: string | null;
|
|
429
426
|
}[];
|
|
430
427
|
checklist: {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
hasPrimaryParticipant: boolean;
|
|
428
|
+
hasTravelers: boolean;
|
|
429
|
+
hasPrimaryTraveler: boolean;
|
|
434
430
|
hasItems: boolean;
|
|
435
431
|
hasAllocations: boolean;
|
|
436
432
|
readyForConfirmation: boolean;
|
|
@@ -467,9 +463,9 @@ export declare const publicBookingsService: {
|
|
|
467
463
|
expiredAt: string | null;
|
|
468
464
|
cancelledAt: string | null;
|
|
469
465
|
completedAt: string | null;
|
|
470
|
-
|
|
466
|
+
travelers: {
|
|
471
467
|
id: string;
|
|
472
|
-
participantType: "
|
|
468
|
+
participantType: "other" | "traveler" | "occupant";
|
|
473
469
|
travelerCategory: "other" | "adult" | "child" | "infant" | "senior" | null;
|
|
474
470
|
firstName: string;
|
|
475
471
|
lastName: string;
|
|
@@ -502,9 +498,9 @@ export declare const publicBookingsService: {
|
|
|
502
498
|
optionId: string | null;
|
|
503
499
|
optionUnitId: string | null;
|
|
504
500
|
pricingCategoryId: string | null;
|
|
505
|
-
|
|
501
|
+
travelerLinks: {
|
|
506
502
|
id: string;
|
|
507
|
-
|
|
503
|
+
travelerId: string;
|
|
508
504
|
role: string;
|
|
509
505
|
isPrimary: boolean;
|
|
510
506
|
}[];
|
|
@@ -525,9 +521,8 @@ export declare const publicBookingsService: {
|
|
|
525
521
|
releasedAt: string | null;
|
|
526
522
|
}[];
|
|
527
523
|
checklist: {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
hasPrimaryParticipant: boolean;
|
|
524
|
+
hasTravelers: boolean;
|
|
525
|
+
hasPrimaryTraveler: boolean;
|
|
531
526
|
hasItems: boolean;
|
|
532
527
|
hasAllocations: boolean;
|
|
533
528
|
readyForConfirmation: boolean;
|
|
@@ -564,9 +559,9 @@ export declare const publicBookingsService: {
|
|
|
564
559
|
expiredAt: string | null;
|
|
565
560
|
cancelledAt: string | null;
|
|
566
561
|
completedAt: string | null;
|
|
567
|
-
|
|
562
|
+
travelers: {
|
|
568
563
|
id: string;
|
|
569
|
-
participantType: "
|
|
564
|
+
participantType: "other" | "traveler" | "occupant";
|
|
570
565
|
travelerCategory: "other" | "adult" | "child" | "infant" | "senior" | null;
|
|
571
566
|
firstName: string;
|
|
572
567
|
lastName: string;
|
|
@@ -599,9 +594,9 @@ export declare const publicBookingsService: {
|
|
|
599
594
|
optionId: string | null;
|
|
600
595
|
optionUnitId: string | null;
|
|
601
596
|
pricingCategoryId: string | null;
|
|
602
|
-
|
|
597
|
+
travelerLinks: {
|
|
603
598
|
id: string;
|
|
604
|
-
|
|
599
|
+
travelerId: string;
|
|
605
600
|
role: string;
|
|
606
601
|
isPrimary: boolean;
|
|
607
602
|
}[];
|
|
@@ -622,9 +617,8 @@ export declare const publicBookingsService: {
|
|
|
622
617
|
releasedAt: string | null;
|
|
623
618
|
}[];
|
|
624
619
|
checklist: {
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
hasPrimaryParticipant: boolean;
|
|
620
|
+
hasTravelers: boolean;
|
|
621
|
+
hasPrimaryTraveler: boolean;
|
|
628
622
|
hasItems: boolean;
|
|
629
623
|
hasAllocations: boolean;
|
|
630
624
|
readyForConfirmation: boolean;
|
|
@@ -653,9 +647,9 @@ export declare const publicBookingsService: {
|
|
|
653
647
|
confirmedAt: string | null;
|
|
654
648
|
cancelledAt: string | null;
|
|
655
649
|
completedAt: string | null;
|
|
656
|
-
|
|
650
|
+
travelers: {
|
|
657
651
|
id: string;
|
|
658
|
-
participantType: "
|
|
652
|
+
participantType: "other" | "traveler" | "occupant";
|
|
659
653
|
firstName: string;
|
|
660
654
|
lastName: string;
|
|
661
655
|
isPrimary: boolean;
|
|
@@ -681,16 +675,16 @@ export declare const publicBookingsService: {
|
|
|
681
675
|
optionId: string | null;
|
|
682
676
|
optionUnitId: string | null;
|
|
683
677
|
pricingCategoryId: string | null;
|
|
684
|
-
|
|
678
|
+
travelerLinks: {
|
|
685
679
|
id: string;
|
|
686
|
-
|
|
680
|
+
travelerId: string;
|
|
687
681
|
role: string;
|
|
688
682
|
isPrimary: boolean;
|
|
689
683
|
}[];
|
|
690
684
|
}[];
|
|
691
685
|
documents: {
|
|
692
686
|
id: string;
|
|
693
|
-
|
|
687
|
+
travelerId: string | null;
|
|
694
688
|
type: "visa" | "other" | "insurance" | "health" | "passport_copy";
|
|
695
689
|
fileName: string;
|
|
696
690
|
fileUrl: string;
|
|
@@ -698,7 +692,7 @@ export declare const publicBookingsService: {
|
|
|
698
692
|
fulfillments: {
|
|
699
693
|
id: string;
|
|
700
694
|
bookingItemId: string | null;
|
|
701
|
-
|
|
695
|
+
travelerId: string | null;
|
|
702
696
|
fulfillmentType: "other" | "voucher" | "ticket" | "pdf" | "qr_code" | "barcode" | "mobile";
|
|
703
697
|
deliveryChannel: "email" | "other" | "download" | "api" | "wallet";
|
|
704
698
|
status: "pending" | "issued" | "reissued" | "revoked" | "failed";
|
|
@@ -717,9 +711,9 @@ export declare const publicBookingsService: {
|
|
|
717
711
|
confirmedAt: string | null;
|
|
718
712
|
cancelledAt: string | null;
|
|
719
713
|
completedAt: string | null;
|
|
720
|
-
|
|
714
|
+
travelers: {
|
|
721
715
|
id: string;
|
|
722
|
-
participantType: "
|
|
716
|
+
participantType: "other" | "traveler" | "occupant";
|
|
723
717
|
firstName: string;
|
|
724
718
|
lastName: string;
|
|
725
719
|
isPrimary: boolean;
|
|
@@ -745,16 +739,16 @@ export declare const publicBookingsService: {
|
|
|
745
739
|
optionId: string | null;
|
|
746
740
|
optionUnitId: string | null;
|
|
747
741
|
pricingCategoryId: string | null;
|
|
748
|
-
|
|
742
|
+
travelerLinks: {
|
|
749
743
|
id: string;
|
|
750
|
-
|
|
744
|
+
travelerId: string;
|
|
751
745
|
role: string;
|
|
752
746
|
isPrimary: boolean;
|
|
753
747
|
}[];
|
|
754
748
|
}[];
|
|
755
749
|
documents: {
|
|
756
750
|
id: string;
|
|
757
|
-
|
|
751
|
+
travelerId: string | null;
|
|
758
752
|
type: "visa" | "other" | "insurance" | "health" | "passport_copy";
|
|
759
753
|
fileName: string;
|
|
760
754
|
fileUrl: string;
|
|
@@ -762,7 +756,7 @@ export declare const publicBookingsService: {
|
|
|
762
756
|
fulfillments: {
|
|
763
757
|
id: string;
|
|
764
758
|
bookingItemId: string | null;
|
|
765
|
-
|
|
759
|
+
travelerId: string | null;
|
|
766
760
|
fulfillmentType: "other" | "voucher" | "ticket" | "pdf" | "qr_code" | "barcode" | "mobile";
|
|
767
761
|
deliveryChannel: "email" | "other" | "download" | "api" | "wallet";
|
|
768
762
|
status: "pending" | "issued" | "reissued" | "revoked" | "failed";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-public.d.ts","sourceRoot":"","sources":["../src/service-public.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAoBjE,OAAO,KAAK,EACV,kCAAkC,EAClC,gCAAgC,EAChC,iCAAiC,EACjC,gCAAgC,EAEhC,+BAA+B,EAC/B,+BAA+B,EAC/B,oCAAoC,EACrC,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"service-public.d.ts","sourceRoot":"","sources":["../src/service-public.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAoBjE,OAAO,KAAK,EACV,kCAAkC,EAClC,gCAAgC,EAChC,iCAAiC,EACjC,gCAAgC,EAEhC,+BAA+B,EAC/B,+BAA+B,EAC/B,oCAAoC,EACrC,MAAM,wBAAwB,CAAA;AA+xB/B,eAAO,MAAM,qBAAqB;sBAE1B,kBAAkB,SACf,+BAA+B,WAC7B,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAjHT,MAAM;gCACE,MAAM;0BACZ,MAAM;+BACD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAuLH,kBAAkB,aAAa,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBA1LhD,MAAM;4BACE,MAAM;sBACZ,MAAM;2BACD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA2LI,kBAAkB,aAAa,MAAM;;;;;;;;;;2BAUzD,kBAAkB,aACX,MAAM,SACV,oCAAoC;;;;;;;;;;;;;;;;sBAoBvC,kBAAkB,aACX,MAAM,SACV,+BAA+B,WAC7B,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAjOT,MAAM;gCACE,MAAM;0BACZ,MAAM;+BACD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA6UhB,kBAAkB,aACX,MAAM,SACV,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;wBAwC7B,MAAM;uBACP,MAAM;2BACF,MAAM,GAAG,IAAI;0BACd,MAAM,GAAG,IAAI;8BACT,MAAM,GAAG,IAAI;gCACX,MAAM,GAAG,IAAI;gCACb,MAAM,GAAG,IAAI;mCACV,MAAM,GAAG,IAAI;0BACtB,MAAM;6BACH,MAAM;qCACE,MAAM,GAAG,IAAI;sCACZ,MAAM,GAAG,IAAI;0BACzB,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAtYd,MAAM;gCACE,MAAM;0BACZ,MAAM;+BACD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAynBhB,kBAAkB,aACX,MAAM,SACV,iCAAiC,WAC/B,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA/nBT,MAAM;gCACE,MAAM;0BACZ,MAAM;+BACD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAwoBhB,kBAAkB,aACX,MAAM,SACV,iCAAiC,WAC/B,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA9oBT,MAAM;gCACE,MAAM;0BACZ,MAAM;+BACD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAspBA,kBAAkB,SAAS,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAt+BzE,MAAM;4BACE,MAAM;sBACZ,MAAM;2BACD,OAAO;;;;;;;;;;;;;;;;;;;;4BAu+BQ,kBAAkB,SAAS,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBA1+BnF,MAAM;4BACE,MAAM;sBACZ,MAAM;2BACD,OAAO;;;;;;;;;;;;;;;;;;;;CA0+BvB,CAAA"}
|
package/dist/service-public.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { and, asc, desc, eq, inArray, or } from "drizzle-orm";
|
|
2
2
|
import { optionPriceRulesRef, optionUnitPriceRulesRef, optionUnitTiersRef, priceCatalogsRef, } from "./pricing-ref.js";
|
|
3
3
|
import { optionUnitsRef, productOptionsRef, productsRef } from "./products-ref.js";
|
|
4
|
-
import { bookingAllocations, bookingDocuments, bookingFulfillments,
|
|
4
|
+
import { bookingAllocations, bookingDocuments, bookingFulfillments, bookingItems, bookingItemTravelers, bookingSessionStates, bookings, bookingTravelers, } from "./schema.js";
|
|
5
5
|
import { bookingsService } from "./service.js";
|
|
6
6
|
const travelerParticipantTypes = new Set(["traveler", "occupant"]);
|
|
7
7
|
const WIZARD_STATE_KEY = "wizard";
|
|
@@ -20,6 +20,50 @@ function normalizeDateTime(value) {
|
|
|
20
20
|
}
|
|
21
21
|
return value instanceof Date ? value.toISOString() : value;
|
|
22
22
|
}
|
|
23
|
+
function getRecord(value) {
|
|
24
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
25
|
+
? value
|
|
26
|
+
: null;
|
|
27
|
+
}
|
|
28
|
+
function getNestedRecord(record, keys) {
|
|
29
|
+
for (const key of keys) {
|
|
30
|
+
const value = getRecord(record?.[key]);
|
|
31
|
+
if (value) {
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
function getRecordString(record, keys) {
|
|
38
|
+
for (const key of keys) {
|
|
39
|
+
const value = record?.[key];
|
|
40
|
+
if (typeof value === "string" && value.length > 0) {
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
function extractBookingContactFromStatePayload(payload) {
|
|
47
|
+
const root = getRecord(payload);
|
|
48
|
+
const stepData = getNestedRecord(root, ["stepData", "steps"]);
|
|
49
|
+
const billingRecord = getNestedRecord(root, ["billing", "billingContact", "contact"]) ??
|
|
50
|
+
getNestedRecord(stepData, ["billing", "billingContact", "contact"]);
|
|
51
|
+
const billing = getNestedRecord(billingRecord, ["billing", "contact"]) ?? billingRecord;
|
|
52
|
+
if (!billing) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
contactFirstName: getRecordString(billing, ["firstName"]),
|
|
57
|
+
contactLastName: getRecordString(billing, ["lastName"]),
|
|
58
|
+
contactEmail: getRecordString(billing, ["email"]),
|
|
59
|
+
contactPhone: getRecordString(billing, ["phone"]),
|
|
60
|
+
contactCountry: getRecordString(billing, ["country"]),
|
|
61
|
+
contactRegion: getRecordString(billing, ["state", "region"]),
|
|
62
|
+
contactCity: getRecordString(billing, ["city"]),
|
|
63
|
+
contactAddressLine1: getRecordString(billing, ["addressLine1", "address1", "line1"]),
|
|
64
|
+
contactPostalCode: getRecordString(billing, ["postalCode", "postal", "zip"]),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
23
67
|
function countTravelerParticipants(participants) {
|
|
24
68
|
return participants.filter((participant) => travelerParticipantTypes.has(participant.participantType)).length;
|
|
25
69
|
}
|
|
@@ -141,9 +185,9 @@ async function buildOverviewSnapshot(db, query) {
|
|
|
141
185
|
const [participants, items, itemParticipantLinks, documents, fulfillments] = await Promise.all([
|
|
142
186
|
db
|
|
143
187
|
.select()
|
|
144
|
-
.from(
|
|
145
|
-
.where(eq(
|
|
146
|
-
.orderBy(asc(
|
|
188
|
+
.from(bookingTravelers)
|
|
189
|
+
.where(eq(bookingTravelers.bookingId, booking.id))
|
|
190
|
+
.orderBy(asc(bookingTravelers.createdAt)),
|
|
147
191
|
db
|
|
148
192
|
.select()
|
|
149
193
|
.from(bookingItems)
|
|
@@ -151,16 +195,16 @@ async function buildOverviewSnapshot(db, query) {
|
|
|
151
195
|
.orderBy(asc(bookingItems.createdAt)),
|
|
152
196
|
db
|
|
153
197
|
.select({
|
|
154
|
-
id:
|
|
155
|
-
bookingItemId:
|
|
156
|
-
|
|
157
|
-
role:
|
|
158
|
-
isPrimary:
|
|
198
|
+
id: bookingItemTravelers.id,
|
|
199
|
+
bookingItemId: bookingItemTravelers.bookingItemId,
|
|
200
|
+
travelerId: bookingItemTravelers.travelerId,
|
|
201
|
+
role: bookingItemTravelers.role,
|
|
202
|
+
isPrimary: bookingItemTravelers.isPrimary,
|
|
159
203
|
})
|
|
160
|
-
.from(
|
|
161
|
-
.innerJoin(bookingItems, eq(bookingItems.id,
|
|
204
|
+
.from(bookingItemTravelers)
|
|
205
|
+
.innerJoin(bookingItems, eq(bookingItems.id, bookingItemTravelers.bookingItemId))
|
|
162
206
|
.where(eq(bookingItems.bookingId, booking.id))
|
|
163
|
-
.orderBy(asc(
|
|
207
|
+
.orderBy(asc(bookingItemTravelers.createdAt)),
|
|
164
208
|
db
|
|
165
209
|
.select()
|
|
166
210
|
.from(bookingDocuments)
|
|
@@ -184,7 +228,7 @@ async function buildOverviewSnapshot(db, query) {
|
|
|
184
228
|
const existing = itemLinksByItemId.get(link.bookingItemId) ?? [];
|
|
185
229
|
existing.push({
|
|
186
230
|
id: link.id,
|
|
187
|
-
|
|
231
|
+
travelerId: link.travelerId,
|
|
188
232
|
role: link.role,
|
|
189
233
|
isPrimary: link.isPrimary,
|
|
190
234
|
});
|
|
@@ -202,7 +246,7 @@ async function buildOverviewSnapshot(db, query) {
|
|
|
202
246
|
confirmedAt: normalizeDateTime(booking.confirmedAt),
|
|
203
247
|
cancelledAt: normalizeDateTime(booking.cancelledAt),
|
|
204
248
|
completedAt: normalizeDateTime(booking.completedAt),
|
|
205
|
-
|
|
249
|
+
travelers: participants.map((participant) => ({
|
|
206
250
|
id: participant.id,
|
|
207
251
|
participantType: participant.participantType,
|
|
208
252
|
firstName: participant.firstName,
|
|
@@ -230,11 +274,11 @@ async function buildOverviewSnapshot(db, query) {
|
|
|
230
274
|
optionId: item.optionId ?? null,
|
|
231
275
|
optionUnitId: item.optionUnitId ?? null,
|
|
232
276
|
pricingCategoryId: item.pricingCategoryId ?? null,
|
|
233
|
-
|
|
277
|
+
travelerLinks: itemLinksByItemId.get(item.id) ?? [],
|
|
234
278
|
})),
|
|
235
279
|
documents: documents.map((document) => ({
|
|
236
280
|
id: document.id,
|
|
237
|
-
|
|
281
|
+
travelerId: document.travelerId ?? null,
|
|
238
282
|
type: document.type,
|
|
239
283
|
fileName: document.fileName,
|
|
240
284
|
fileUrl: document.fileUrl,
|
|
@@ -242,7 +286,7 @@ async function buildOverviewSnapshot(db, query) {
|
|
|
242
286
|
fulfillments: fulfillments.map((fulfillment) => ({
|
|
243
287
|
id: fulfillment.id,
|
|
244
288
|
bookingItemId: fulfillment.bookingItemId ?? null,
|
|
245
|
-
|
|
289
|
+
travelerId: fulfillment.travelerId ?? null,
|
|
246
290
|
fulfillmentType: fulfillment.fulfillmentType,
|
|
247
291
|
deliveryChannel: fulfillment.deliveryChannel,
|
|
248
292
|
status: fulfillment.status,
|
|
@@ -388,9 +432,9 @@ async function buildSessionSnapshot(db, bookingId) {
|
|
|
388
432
|
bookingsService.getBookingById(db, bookingId),
|
|
389
433
|
db
|
|
390
434
|
.select()
|
|
391
|
-
.from(
|
|
392
|
-
.where(eq(
|
|
393
|
-
.orderBy(asc(
|
|
435
|
+
.from(bookingTravelers)
|
|
436
|
+
.where(eq(bookingTravelers.bookingId, bookingId))
|
|
437
|
+
.orderBy(asc(bookingTravelers.createdAt)),
|
|
394
438
|
db
|
|
395
439
|
.select()
|
|
396
440
|
.from(bookingItems)
|
|
@@ -403,16 +447,16 @@ async function buildSessionSnapshot(db, bookingId) {
|
|
|
403
447
|
.orderBy(asc(bookingAllocations.createdAt)),
|
|
404
448
|
db
|
|
405
449
|
.select({
|
|
406
|
-
id:
|
|
407
|
-
bookingItemId:
|
|
408
|
-
|
|
409
|
-
role:
|
|
410
|
-
isPrimary:
|
|
450
|
+
id: bookingItemTravelers.id,
|
|
451
|
+
bookingItemId: bookingItemTravelers.bookingItemId,
|
|
452
|
+
travelerId: bookingItemTravelers.travelerId,
|
|
453
|
+
role: bookingItemTravelers.role,
|
|
454
|
+
isPrimary: bookingItemTravelers.isPrimary,
|
|
411
455
|
})
|
|
412
|
-
.from(
|
|
413
|
-
.innerJoin(bookingItems, eq(bookingItems.id,
|
|
456
|
+
.from(bookingItemTravelers)
|
|
457
|
+
.innerJoin(bookingItems, eq(bookingItems.id, bookingItemTravelers.bookingItemId))
|
|
414
458
|
.where(eq(bookingItems.bookingId, bookingId))
|
|
415
|
-
.orderBy(asc(
|
|
459
|
+
.orderBy(asc(bookingItemTravelers.createdAt)),
|
|
416
460
|
getWizardSessionState(db, bookingId),
|
|
417
461
|
]);
|
|
418
462
|
if (!booking) {
|
|
@@ -423,15 +467,15 @@ async function buildSessionSnapshot(db, bookingId) {
|
|
|
423
467
|
const existing = itemLinksByItemId.get(link.bookingItemId) ?? [];
|
|
424
468
|
existing.push({
|
|
425
469
|
id: link.id,
|
|
426
|
-
|
|
470
|
+
travelerId: link.travelerId,
|
|
427
471
|
role: link.role,
|
|
428
472
|
isPrimary: link.isPrimary,
|
|
429
473
|
});
|
|
430
474
|
itemLinksByItemId.set(link.bookingItemId, existing);
|
|
431
475
|
}
|
|
432
|
-
const hasParticipants = participants.length > 0;
|
|
433
476
|
const hasTraveler = countTravelerParticipants(participants) > 0;
|
|
434
|
-
const
|
|
477
|
+
const hasTravelers = participants.length > 0;
|
|
478
|
+
const hasPrimaryTraveler = participants.some((participant) => participant.isPrimary);
|
|
435
479
|
const hasItems = items.length > 0;
|
|
436
480
|
const hasAllocations = allocations.length > 0;
|
|
437
481
|
return {
|
|
@@ -450,7 +494,7 @@ async function buildSessionSnapshot(db, bookingId) {
|
|
|
450
494
|
expiredAt: normalizeDateTime(booking.expiredAt),
|
|
451
495
|
cancelledAt: normalizeDateTime(booking.cancelledAt),
|
|
452
496
|
completedAt: normalizeDateTime(booking.completedAt),
|
|
453
|
-
|
|
497
|
+
travelers: participants.map((participant) => ({
|
|
454
498
|
id: participant.id,
|
|
455
499
|
participantType: participant.participantType,
|
|
456
500
|
travelerCategory: participant.travelerCategory ?? null,
|
|
@@ -485,7 +529,7 @@ async function buildSessionSnapshot(db, bookingId) {
|
|
|
485
529
|
optionId: item.optionId ?? null,
|
|
486
530
|
optionUnitId: item.optionUnitId ?? null,
|
|
487
531
|
pricingCategoryId: item.pricingCategoryId ?? null,
|
|
488
|
-
|
|
532
|
+
travelerLinks: itemLinksByItemId.get(item.id) ?? [],
|
|
489
533
|
})),
|
|
490
534
|
allocations: allocations.map((allocation) => ({
|
|
491
535
|
id: allocation.id,
|
|
@@ -503,15 +547,14 @@ async function buildSessionSnapshot(db, bookingId) {
|
|
|
503
547
|
releasedAt: normalizeDateTime(allocation.releasedAt),
|
|
504
548
|
})),
|
|
505
549
|
checklist: {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
hasPrimaryParticipant,
|
|
550
|
+
hasTravelers,
|
|
551
|
+
hasPrimaryTraveler,
|
|
509
552
|
hasItems,
|
|
510
553
|
hasAllocations,
|
|
511
554
|
readyForConfirmation: booking.status === "on_hold" &&
|
|
512
|
-
|
|
555
|
+
hasTravelers &&
|
|
513
556
|
hasTraveler &&
|
|
514
|
-
|
|
557
|
+
hasPrimaryTraveler &&
|
|
515
558
|
hasItems &&
|
|
516
559
|
hasAllocations,
|
|
517
560
|
},
|
|
@@ -520,7 +563,8 @@ async function buildSessionSnapshot(db, bookingId) {
|
|
|
520
563
|
}
|
|
521
564
|
export const publicBookingsService = {
|
|
522
565
|
async createSession(db, input, userId) {
|
|
523
|
-
const
|
|
566
|
+
const travelers = input.travelers ?? [];
|
|
567
|
+
const travelerCount = countTravelerParticipants(travelers);
|
|
524
568
|
const bookingNumber = await generateBookingNumber(db);
|
|
525
569
|
const result = await bookingsService.reserveBooking(db, {
|
|
526
570
|
bookingNumber,
|
|
@@ -558,8 +602,8 @@ export const publicBookingsService = {
|
|
|
558
602
|
if (!("booking" in result) || !result.booking) {
|
|
559
603
|
return result;
|
|
560
604
|
}
|
|
561
|
-
for (const participant of
|
|
562
|
-
await bookingsService.
|
|
605
|
+
for (const participant of travelers) {
|
|
606
|
+
await bookingsService.createTravelerRecord(db, result.booking.id, {
|
|
563
607
|
participantType: participant.participantType,
|
|
564
608
|
travelerCategory: participant.travelerCategory ?? null,
|
|
565
609
|
firstName: participant.firstName,
|
|
@@ -593,6 +637,13 @@ export const publicBookingsService = {
|
|
|
593
637
|
return { status: "not_found" };
|
|
594
638
|
}
|
|
595
639
|
const state = await upsertWizardSessionState(db, bookingId, input);
|
|
640
|
+
if (!state) {
|
|
641
|
+
return { status: "not_found" };
|
|
642
|
+
}
|
|
643
|
+
const bookingContact = extractBookingContactFromStatePayload(state.payload);
|
|
644
|
+
if (bookingContact) {
|
|
645
|
+
await bookingsService.updateBooking(db, bookingId, bookingContact);
|
|
646
|
+
}
|
|
596
647
|
return { status: "ok", state };
|
|
597
648
|
},
|
|
598
649
|
async updateSession(db, bookingId, input, userId) {
|
|
@@ -609,20 +660,22 @@ export const publicBookingsService = {
|
|
|
609
660
|
pax: input.pax,
|
|
610
661
|
});
|
|
611
662
|
}
|
|
612
|
-
|
|
613
|
-
|
|
663
|
+
const travelers = input.travelers;
|
|
664
|
+
const removedTravelerIds = input.removedTravelerIds ?? [];
|
|
665
|
+
for (const travelerId of removedTravelerIds) {
|
|
666
|
+
const participant = await bookingsService.getTravelerRecordById(db, bookingId, travelerId);
|
|
614
667
|
if (participant) {
|
|
615
|
-
await bookingsService.
|
|
668
|
+
await bookingsService.deleteTravelerRecord(db, participant.id);
|
|
616
669
|
}
|
|
617
670
|
}
|
|
618
|
-
if (
|
|
619
|
-
for (const participant of
|
|
671
|
+
if (travelers) {
|
|
672
|
+
for (const participant of travelers) {
|
|
620
673
|
if (participant.id) {
|
|
621
|
-
const existing = await bookingsService.
|
|
674
|
+
const existing = await bookingsService.getTravelerRecordById(db, bookingId, participant.id);
|
|
622
675
|
if (!existing) {
|
|
623
676
|
return { status: "participant_not_found" };
|
|
624
677
|
}
|
|
625
|
-
await bookingsService.
|
|
678
|
+
await bookingsService.updateTravelerRecord(db, participant.id, {
|
|
626
679
|
participantType: participant.participantType,
|
|
627
680
|
travelerCategory: participant.travelerCategory ?? null,
|
|
628
681
|
firstName: participant.firstName,
|
|
@@ -637,7 +690,7 @@ export const publicBookingsService = {
|
|
|
637
690
|
});
|
|
638
691
|
continue;
|
|
639
692
|
}
|
|
640
|
-
await bookingsService.
|
|
693
|
+
await bookingsService.createTravelerRecord(db, bookingId, {
|
|
641
694
|
participantType: participant.participantType,
|
|
642
695
|
travelerCategory: participant.travelerCategory ?? null,
|
|
643
696
|
firstName: participant.firstName,
|
|
@@ -662,11 +715,11 @@ export const publicBookingsService = {
|
|
|
662
715
|
return holdResult;
|
|
663
716
|
}
|
|
664
717
|
}
|
|
665
|
-
if (input.pax === undefined && (
|
|
718
|
+
if (input.pax === undefined && (travelers || removedTravelerIds.length > 0)) {
|
|
666
719
|
const participants = await db
|
|
667
|
-
.select({ participantType:
|
|
668
|
-
.from(
|
|
669
|
-
.where(eq(
|
|
720
|
+
.select({ participantType: bookingTravelers.participantType })
|
|
721
|
+
.from(bookingTravelers)
|
|
722
|
+
.where(eq(bookingTravelers.bookingId, bookingId));
|
|
670
723
|
const travelerCount = countTravelerParticipants(participants);
|
|
671
724
|
await bookingsService.updateBooking(db, bookingId, {
|
|
672
725
|
pax: travelerCount > 0 ? travelerCount : null,
|