@voyantjs/storefront 0.49.0 → 0.50.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,5 +1,38 @@
1
1
  import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
- import type { StorefrontDepartureListQuery, StorefrontDeparturePricePreviewInput, StorefrontProductAvailabilitySummaryQuery } from "./validation.js";
2
+ import type { StorefrontDepartureListQuery, StorefrontDeparturePricePreviewInput, StorefrontOfferMutationResult, StorefrontProductAvailabilitySummaryQuery, StorefrontPromotionalOffer } from "./validation.js";
3
+ export interface StorefrontDeparturePricePreviewOfferResolvers {
4
+ listApplicableOffers?: (input: {
5
+ productId: string;
6
+ departureId?: string;
7
+ locale?: string;
8
+ }) => Promise<StorefrontPromotionalOffer[]> | StorefrontPromotionalOffer[];
9
+ applyOffer?: (input: {
10
+ slug: string;
11
+ body: {
12
+ productId: string;
13
+ departureId?: string | null;
14
+ pax: number;
15
+ audience: "customer";
16
+ market: string;
17
+ basePriceCents: number;
18
+ currency: string;
19
+ locale?: string;
20
+ };
21
+ }) => Promise<StorefrontOfferMutationResult | null> | StorefrontOfferMutationResult | null;
22
+ redeemOffer?: (input: {
23
+ body: {
24
+ code: string;
25
+ productId: string;
26
+ departureId?: string | null;
27
+ pax: number;
28
+ audience: "customer";
29
+ market: string;
30
+ basePriceCents: number;
31
+ currency: string;
32
+ locale?: string;
33
+ };
34
+ }) => Promise<StorefrontOfferMutationResult | null> | StorefrontOfferMutationResult | null;
35
+ }
3
36
  export declare function getStorefrontDeparture(db: PostgresJsDatabase, departureId: string): Promise<{
4
37
  id: string;
5
38
  productId: string;
@@ -129,7 +162,7 @@ export declare function getStorefrontProductAvailabilitySummary(db: PostgresJsDa
129
162
  limit: number;
130
163
  offset: number;
131
164
  }>;
132
- export declare function previewStorefrontDeparturePrice(db: PostgresJsDatabase, departureId: string, input: StorefrontDeparturePricePreviewInput): Promise<{
165
+ export declare function previewStorefrontDeparturePrice(db: PostgresJsDatabase, departureId: string, input: StorefrontDeparturePricePreviewInput, offerResolvers?: StorefrontDeparturePricePreviewOfferResolvers): Promise<{
133
166
  departureId: string;
134
167
  productId: string;
135
168
  optionId: string | null;
@@ -144,6 +177,272 @@ export declare function previewStorefrontDeparturePrice(db: PostgresJsDatabase,
144
177
  quantity: number;
145
178
  unitPrice: number;
146
179
  }[];
180
+ allocation: {
181
+ slot: {
182
+ id: string;
183
+ productId: string;
184
+ optionId: string | null;
185
+ dateLocal: string | null;
186
+ startAt: string | null;
187
+ endAt: string | null;
188
+ timezone: string;
189
+ status: "cancelled" | "open" | "closed" | "sold_out" | "on_request";
190
+ availabilityState: StorefrontProductAvailabilityState;
191
+ capacity: number | null;
192
+ remaining: number | null;
193
+ pastCutoff: boolean;
194
+ tooEarly: boolean;
195
+ };
196
+ pax: {
197
+ adults: number;
198
+ children: number;
199
+ infants: number;
200
+ total: number;
201
+ };
202
+ requestedUnits: {
203
+ unitId: string | null;
204
+ requestRef: string | null;
205
+ name: string;
206
+ unitType: string | null;
207
+ quantity: number;
208
+ pricingMode: string | null;
209
+ unitPrice: number;
210
+ total: number;
211
+ currencyCode: string;
212
+ tierId: string | null;
213
+ }[];
214
+ rooms: {
215
+ unitId: string;
216
+ name: string;
217
+ occupancy: number;
218
+ quantity: number;
219
+ pax: number;
220
+ pricingMode: string | null;
221
+ unitPrice: number;
222
+ total: number;
223
+ currencyCode: string;
224
+ tierId: string | null;
225
+ }[];
226
+ };
227
+ units: {
228
+ unitId: string | null;
229
+ requestRef: string | null;
230
+ name: string;
231
+ unitType: string | null;
232
+ quantity: number;
233
+ pricingMode: string | null;
234
+ unitPrice: number;
235
+ total: number;
236
+ currencyCode: string;
237
+ tierId: string | null;
238
+ }[];
239
+ rooms: {
240
+ unitId: string;
241
+ name: string;
242
+ occupancy: number;
243
+ quantity: number;
244
+ pax: number;
245
+ pricingMode: string | null;
246
+ unitPrice: number;
247
+ total: number;
248
+ currencyCode: string;
249
+ tierId: string | null;
250
+ }[];
251
+ extras: {
252
+ extraId: string;
253
+ name: string;
254
+ required: boolean;
255
+ selectable: boolean;
256
+ selected: boolean;
257
+ pricingMode: string;
258
+ quantity: number;
259
+ unitPrice: number;
260
+ total: number;
261
+ currencyCode: string;
262
+ }[];
263
+ offers: {
264
+ available: {
265
+ offer: {
266
+ id: string;
267
+ name: string;
268
+ slug: string | null;
269
+ description: string | null;
270
+ discountType: "percentage" | "fixed_amount";
271
+ discountValue: string;
272
+ currency: string | null;
273
+ applicableProductIds: string[];
274
+ applicableDepartureIds: string[];
275
+ validFrom: string | null;
276
+ validTo: string | null;
277
+ minTravelers: number | null;
278
+ imageMobileUrl: string | null;
279
+ imageDesktopUrl: string | null;
280
+ stackable: boolean;
281
+ createdAt: string;
282
+ updatedAt: string;
283
+ };
284
+ status: string;
285
+ reason: string | null;
286
+ selected: boolean;
287
+ discountAppliedCents: number;
288
+ discountedPriceCents: number;
289
+ }[];
290
+ requested: ({
291
+ kind: "slug";
292
+ value: string;
293
+ result: {
294
+ status: "applied" | "not_applicable" | "conflict" | "invalid";
295
+ reason: "scope" | "currency" | "booking_mismatch" | "conflict" | "min_pax" | "no_discount" | "offer_not_found" | "offer_expired" | "offer_not_yet_valid" | "code_not_found" | "code_required" | "code_expired" | "code_not_yet_valid" | "session_mismatch" | null;
296
+ offer: {
297
+ id: string;
298
+ name: string;
299
+ slug: string | null;
300
+ description: string | null;
301
+ discountType: "percentage" | "fixed_amount";
302
+ discountValue: string;
303
+ currency: string | null;
304
+ applicableProductIds: string[];
305
+ applicableDepartureIds: string[];
306
+ validFrom: string | null;
307
+ validTo: string | null;
308
+ minTravelers: number | null;
309
+ imageMobileUrl: string | null;
310
+ imageDesktopUrl: string | null;
311
+ stackable: boolean;
312
+ createdAt: string;
313
+ updatedAt: string;
314
+ } | null;
315
+ target: {
316
+ bookingId: string | null;
317
+ sessionId: string | null;
318
+ productId: string;
319
+ departureId: string | null;
320
+ };
321
+ pricing: {
322
+ basePriceCents: number;
323
+ currency: string;
324
+ discountAppliedCents: number;
325
+ discountedPriceCents: number;
326
+ };
327
+ appliedOffers: {
328
+ offerId: string;
329
+ offerName: string;
330
+ discountAppliedCents: number;
331
+ discountedPriceCents: number;
332
+ currency: string;
333
+ discountKind: "percentage" | "fixed_amount";
334
+ discountPercent: number | null;
335
+ discountAmountCents: number | null;
336
+ appliedCode: string | null;
337
+ stackable: boolean;
338
+ }[];
339
+ conflict: {
340
+ policy: "best_discount_wins" | "stackable_compose";
341
+ autoAppliedOfferIds: string[];
342
+ manualOfferId: string | null;
343
+ selectedOfferIds: string[];
344
+ message: string;
345
+ } | null;
346
+ } | null;
347
+ } | {
348
+ kind: "code";
349
+ value: string;
350
+ result: {
351
+ status: "applied" | "not_applicable" | "conflict" | "invalid";
352
+ reason: "scope" | "currency" | "booking_mismatch" | "conflict" | "min_pax" | "no_discount" | "offer_not_found" | "offer_expired" | "offer_not_yet_valid" | "code_not_found" | "code_required" | "code_expired" | "code_not_yet_valid" | "session_mismatch" | null;
353
+ offer: {
354
+ id: string;
355
+ name: string;
356
+ slug: string | null;
357
+ description: string | null;
358
+ discountType: "percentage" | "fixed_amount";
359
+ discountValue: string;
360
+ currency: string | null;
361
+ applicableProductIds: string[];
362
+ applicableDepartureIds: string[];
363
+ validFrom: string | null;
364
+ validTo: string | null;
365
+ minTravelers: number | null;
366
+ imageMobileUrl: string | null;
367
+ imageDesktopUrl: string | null;
368
+ stackable: boolean;
369
+ createdAt: string;
370
+ updatedAt: string;
371
+ } | null;
372
+ target: {
373
+ bookingId: string | null;
374
+ sessionId: string | null;
375
+ productId: string;
376
+ departureId: string | null;
377
+ };
378
+ pricing: {
379
+ basePriceCents: number;
380
+ currency: string;
381
+ discountAppliedCents: number;
382
+ discountedPriceCents: number;
383
+ };
384
+ appliedOffers: {
385
+ offerId: string;
386
+ offerName: string;
387
+ discountAppliedCents: number;
388
+ discountedPriceCents: number;
389
+ currency: string;
390
+ discountKind: "percentage" | "fixed_amount";
391
+ discountPercent: number | null;
392
+ discountAmountCents: number | null;
393
+ appliedCode: string | null;
394
+ stackable: boolean;
395
+ }[];
396
+ conflict: {
397
+ policy: "best_discount_wins" | "stackable_compose";
398
+ autoAppliedOfferIds: string[];
399
+ manualOfferId: string | null;
400
+ selectedOfferIds: string[];
401
+ message: string;
402
+ } | null;
403
+ } | null;
404
+ })[];
405
+ applied: {
406
+ offerId: string;
407
+ offerName: string;
408
+ discountAppliedCents: number;
409
+ discountedPriceCents: number;
410
+ currency: string;
411
+ discountKind: "percentage" | "fixed_amount";
412
+ discountPercent: number | null;
413
+ discountAmountCents: number | null;
414
+ appliedCode: string | null;
415
+ stackable: boolean;
416
+ }[];
417
+ conflict: {
418
+ policy: "best_discount_wins" | "stackable_compose";
419
+ autoAppliedOfferIds: string[];
420
+ manualOfferId: string | null;
421
+ selectedOfferIds: string[];
422
+ message: string;
423
+ } | {
424
+ policy: string;
425
+ autoAppliedOfferIds: string[];
426
+ manualOfferId: null;
427
+ selectedOfferIds: string[];
428
+ message: string;
429
+ } | null;
430
+ discountTotal: number;
431
+ discountTotalCents: number;
432
+ totalAfterDiscount: number;
433
+ currencyCode: string;
434
+ };
435
+ totals: {
436
+ currencyCode: string;
437
+ base: number;
438
+ extras: number;
439
+ subtotal: number;
440
+ discount: number;
441
+ tax: number;
442
+ total: number;
443
+ perPerson: number;
444
+ perBooking: number;
445
+ };
147
446
  } | null>;
148
447
  export declare function getStorefrontProductExtensions(db: PostgresJsDatabase, productId: string, optionId?: string): Promise<{
149
448
  extensions: {
@@ -1 +1 @@
1
- {"version":3,"file":"service-departures.d.ts","sourceRoot":"","sources":["../src/service-departures.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,yCAAyC,EAC1C,MAAM,iBAAiB,CAAA;AA40BxB,wBAAsB,sBAAsB,CAAC,EAAE,EAAE,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