@voyantjs/bookings 0.35.0 → 0.37.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.
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { bookingTravelerBedPreferenceSchema, travelerAllocationMapSchema, } from "./schema/travel-details.js";
2
3
  import { bookingAllocationStatusSchema, bookingAllocationTypeSchema, bookingDocumentTypeSchema, bookingFulfillmentDeliveryChannelSchema, bookingFulfillmentStatusSchema, bookingFulfillmentTypeSchema, bookingItemParticipantRoleSchema, bookingItemStatusSchema, bookingItemTypeSchema, bookingParticipantTypeSchema, bookingRedemptionMethodSchema, bookingSourceTypeSchema, bookingStatusSchema, bookingTravelerCategorySchema, supplierConfirmationStatusSchema, } from "./validation-shared.js";
3
4
  // ---------- bookings ----------
4
5
  const bookingDepositRuleSchema = z.object({
@@ -12,6 +13,15 @@ const bookingCustomerPaymentPolicySchema = z.object({
12
13
  balanceDueDaysBeforeDeparture: z.number().int().min(0),
13
14
  balanceDueMinDaysFromNow: z.number().int().min(0),
14
15
  });
16
+ export const bookingPriceOverrideSchema = z.object({
17
+ isManual: z.literal(true),
18
+ originalAmountCents: z.number().int().min(0).nullable(),
19
+ overriddenAmountCents: z.number().int().min(0),
20
+ currency: z.string().min(3).max(3),
21
+ reason: z.string().trim().min(1).max(1000),
22
+ overriddenBy: z.string().min(1),
23
+ overriddenAt: z.string().datetime(),
24
+ });
15
25
  const bookingCoreSchema = z.object({
16
26
  bookingNumber: z.string().min(1).max(50),
17
27
  status: bookingStatusSchema.default("draft"),
@@ -42,6 +52,7 @@ const bookingCoreSchema = z.object({
42
52
  pax: z.number().int().positive().optional().nullable(),
43
53
  internalNotes: z.string().optional().nullable(),
44
54
  customerPaymentPolicy: bookingCustomerPaymentPolicySchema.optional().nullable(),
55
+ priceOverride: bookingPriceOverrideSchema.optional().nullable(),
45
56
  holdExpiresAt: z.string().datetime().optional().nullable(),
46
57
  confirmedAt: z.string().datetime().optional().nullable(),
47
58
  expiredAt: z.string().datetime().optional().nullable(),
@@ -78,6 +89,8 @@ export const bookingListQuerySchema = z.object({
78
89
  search: z.string().optional(),
79
90
  productId: z.string().optional(),
80
91
  optionId: z.string().optional(),
92
+ supplierId: z.string().optional(),
93
+ productCategoryId: z.string().optional(),
81
94
  personId: z.string().optional(),
82
95
  organizationId: z.string().optional(),
83
96
  dateFrom: z.string().optional(),
@@ -99,7 +112,11 @@ export const bookingAggregatesQuerySchema = z.object({
99
112
  */
100
113
  upcomingLimit: z.coerce.number().int().min(0).max(20).default(8),
101
114
  });
102
- export const convertProductSchema = z.object({
115
+ export const sharingGroupsForSlotQuerySchema = z.object({
116
+ slotId: z.string().min(1),
117
+ });
118
+ export const convertProductSchema = z
119
+ .object({
103
120
  productId: z.string().min(1),
104
121
  optionId: z.string().optional().nullable(),
105
122
  slotId: z.string().optional().nullable(),
@@ -116,6 +133,33 @@ export const convertProductSchema = z.object({
116
133
  * (per docs/architecture/promotions-architecture.md §7.1).
117
134
  */
118
135
  sellAmountCentsOverride: z.number().int().min(0).optional().nullable(),
136
+ /**
137
+ * Catalog-resolved preview total shown to the operator. Unlike
138
+ * `sellAmountCentsOverride`, this is not a promotion adjustment; it lets
139
+ * the create flow seed the booking total from the pricing preview even
140
+ * when the legacy product row has no static price.
141
+ */
142
+ catalogSellAmountCents: z.number().int().min(0).optional().nullable(),
143
+ /**
144
+ * Operator-confirmed booking total. If it differs from the catalog preview
145
+ * (or there was no catalog preview), `priceOverrideReason` is required and
146
+ * the service stamps an audit payload onto `bookings.price_override`.
147
+ */
148
+ confirmedSellAmountCents: z.number().int().min(0).optional().nullable(),
149
+ priceOverrideReason: z.string().trim().min(1).max(1000).optional().nullable(),
150
+ })
151
+ .superRefine((value, ctx) => {
152
+ if (value.confirmedSellAmountCents == null)
153
+ return;
154
+ if (value.catalogSellAmountCents === value.confirmedSellAmountCents)
155
+ return;
156
+ if (value.priceOverrideReason)
157
+ return;
158
+ ctx.addIssue({
159
+ code: z.ZodIssueCode.custom,
160
+ path: ["priceOverrideReason"],
161
+ message: "A price override reason is required when the confirmed total differs from catalog pricing",
162
+ });
119
163
  });
120
164
  /**
121
165
  * Admin pricing-preview request. Mirrors the storefront pricing session
@@ -283,6 +327,10 @@ export const upsertTravelerTravelDetailsSchema = z.object({
283
327
  dietaryRequirements: z.string().optional().nullable(),
284
328
  accessibilityNeeds: z.string().optional().nullable(),
285
329
  isLeadTraveler: z.boolean().optional().nullable(),
330
+ sharingGroupId: z.string().max(255).optional().nullable(),
331
+ roomTypeId: z.string().max(255).optional().nullable(),
332
+ bedPreference: bookingTravelerBedPreferenceSchema.optional().nullable(),
333
+ allocations: travelerAllocationMapSchema.optional(),
286
334
  });
287
335
  // Flat shape combining plaintext traveler columns + encrypted travel-details
288
336
  // fields, matching the pre-0.10 `createTravelerRecord` ergonomics. Migration
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyantjs/bookings",
3
- "version": "0.35.0",
3
+ "version": "0.37.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -64,14 +64,14 @@
64
64
  "drizzle-orm": "^0.45.2",
65
65
  "hono": "^4.12.10",
66
66
  "zod": "^4.3.6",
67
- "@voyantjs/core": "0.35.0",
68
- "@voyantjs/db": "0.35.0",
69
- "@voyantjs/hono": "0.35.0",
70
- "@voyantjs/utils": "0.35.0"
67
+ "@voyantjs/core": "0.37.0",
68
+ "@voyantjs/db": "0.37.0",
69
+ "@voyantjs/hono": "0.37.0",
70
+ "@voyantjs/utils": "0.37.0"
71
71
  },
72
72
  "devDependencies": {
73
73
  "typescript": "^6.0.2",
74
- "@voyantjs/products": "0.35.0",
74
+ "@voyantjs/products": "0.37.0",
75
75
  "@voyantjs/voyant-typescript-config": "0.1.0"
76
76
  },
77
77
  "files": [