@voyant-travel/storefront 0.120.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/LICENSE +201 -0
- package/README.md +231 -0
- package/dist/booking-intents.d.ts +42 -0
- package/dist/booking-intents.d.ts.map +1 -0
- package/dist/booking-intents.js +83 -0
- package/dist/customer-portal/index.d.ts +16 -0
- package/dist/customer-portal/index.d.ts.map +1 -0
- package/dist/customer-portal/index.js +23 -0
- package/dist/customer-portal/route-runtime.d.ts +16 -0
- package/dist/customer-portal/route-runtime.d.ts.map +1 -0
- package/dist/customer-portal/route-runtime.js +27 -0
- package/dist/customer-portal/routes-public.d.ts +1936 -0
- package/dist/customer-portal/routes-public.d.ts.map +1 -0
- package/dist/customer-portal/routes-public.js +165 -0
- package/dist/customer-portal/routes.d.ts +43 -0
- package/dist/customer-portal/routes.d.ts.map +1 -0
- package/dist/customer-portal/routes.js +17 -0
- package/dist/customer-portal/service-public-impl.d.ts +138 -0
- package/dist/customer-portal/service-public-impl.d.ts.map +1 -0
- package/dist/customer-portal/service-public-impl.js +1808 -0
- package/dist/customer-portal/service-public.d.ts +2 -0
- package/dist/customer-portal/service-public.d.ts.map +1 -0
- package/dist/customer-portal/service-public.js +1 -0
- package/dist/customer-portal/validation-public/bookings.d.ts +551 -0
- package/dist/customer-portal/validation-public/bookings.d.ts.map +1 -0
- package/dist/customer-portal/validation-public/bookings.js +132 -0
- package/dist/customer-portal/validation-public/common.d.ts +162 -0
- package/dist/customer-portal/validation-public/common.d.ts.map +1 -0
- package/dist/customer-portal/validation-public/common.js +139 -0
- package/dist/customer-portal/validation-public/profile.d.ts +749 -0
- package/dist/customer-portal/validation-public/profile.d.ts.map +1 -0
- package/dist/customer-portal/validation-public/profile.js +308 -0
- package/dist/customer-portal/validation-public.d.ts +3 -0
- package/dist/customer-portal/validation-public.d.ts.map +1 -0
- package/dist/customer-portal/validation-public.js +2 -0
- package/dist/guest-booking-guard.d.ts +24 -0
- package/dist/guest-booking-guard.d.ts.map +1 -0
- package/dist/guest-booking-guard.js +55 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/product-extra-ref.d.ts +238 -0
- package/dist/product-extra-ref.d.ts.map +1 -0
- package/dist/product-extra-ref.js +22 -0
- package/dist/routes-admin.d.ts +220 -0
- package/dist/routes-admin.d.ts.map +1 -0
- package/dist/routes-admin.js +28 -0
- package/dist/routes-public.d.ts +1475 -0
- package/dist/routes-public.d.ts.map +1 -0
- package/dist/routes-public.js +362 -0
- package/dist/service-booking-session-bootstrap.d.ts +227 -0
- package/dist/service-booking-session-bootstrap.d.ts.map +1 -0
- package/dist/service-booking-session-bootstrap.js +287 -0
- package/dist/service-boundary-resource-sql.d.ts +18 -0
- package/dist/service-boundary-resource-sql.d.ts.map +1 -0
- package/dist/service-boundary-resource-sql.js +73 -0
- package/dist/service-boundary-sql.d.ts +103 -0
- package/dist/service-boundary-sql.d.ts.map +1 -0
- package/dist/service-boundary-sql.js +307 -0
- package/dist/service-departures-core.d.ts +41 -0
- package/dist/service-departures-core.d.ts.map +1 -0
- package/dist/service-departures-core.js +92 -0
- package/dist/service-departures-extensions.d.ts +46 -0
- package/dist/service-departures-extensions.d.ts.map +1 -0
- package/dist/service-departures-extensions.js +81 -0
- package/dist/service-departures-offers.d.ts +220 -0
- package/dist/service-departures-offers.d.ts.map +1 -0
- package/dist/service-departures-offers.js +177 -0
- package/dist/service-departures-price-preview.d.ts +306 -0
- package/dist/service-departures-price-preview.d.ts.map +1 -0
- package/dist/service-departures-price-preview.js +383 -0
- package/dist/service-departures-pricing-context.d.ts +115 -0
- package/dist/service-departures-pricing-context.d.ts.map +1 -0
- package/dist/service-departures-pricing-context.js +237 -0
- package/dist/service-departures-pricing.d.ts +5 -0
- package/dist/service-departures-pricing.d.ts.map +1 -0
- package/dist/service-departures-pricing.js +4 -0
- package/dist/service-departures.d.ts +192 -0
- package/dist/service-departures.d.ts.map +1 -0
- package/dist/service-departures.js +213 -0
- package/dist/service-intake.d.ts +130 -0
- package/dist/service-intake.d.ts.map +1 -0
- package/dist/service-intake.js +274 -0
- package/dist/service-transport-eligibility.d.ts +10 -0
- package/dist/service-transport-eligibility.d.ts.map +1 -0
- package/dist/service-transport-eligibility.js +198 -0
- package/dist/service.d.ts +1062 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +332 -0
- package/dist/transport-eligibility.d.ts +4 -0
- package/dist/transport-eligibility.d.ts.map +1 -0
- package/dist/transport-eligibility.js +2 -0
- package/dist/validation/departures.d.ts +1669 -0
- package/dist/validation/departures.d.ts.map +1 -0
- package/dist/validation/departures.js +397 -0
- package/dist/validation/intake.d.ts +147 -0
- package/dist/validation/intake.d.ts.map +1 -0
- package/dist/validation/intake.js +69 -0
- package/dist/validation/offers.d.ts +340 -0
- package/dist/validation/offers.d.ts.map +1 -0
- package/dist/validation/offers.js +117 -0
- package/dist/validation-settings.d.ts +609 -0
- package/dist/validation-settings.d.ts.map +1 -0
- package/dist/validation-settings.js +235 -0
- package/dist/validation-transport-eligibility.d.ts +314 -0
- package/dist/validation-transport-eligibility.d.ts.map +1 -0
- package/dist/validation-transport-eligibility.js +97 -0
- package/dist/validation.d.ts +6 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +4 -0
- package/dist/verification/index.d.ts +12 -0
- package/dist/verification/index.d.ts.map +1 -0
- package/dist/verification/index.js +18 -0
- package/dist/verification/routes-public.d.ts +121 -0
- package/dist/verification/routes-public.d.ts.map +1 -0
- package/dist/verification/routes-public.js +125 -0
- package/dist/verification/schema.d.ts +273 -0
- package/dist/verification/schema.d.ts.map +1 -0
- package/dist/verification/schema.js +50 -0
- package/dist/verification/service.d.ts +114 -0
- package/dist/verification/service.d.ts.map +1 -0
- package/dist/verification/service.js +283 -0
- package/dist/verification/validation.d.ts +98 -0
- package/dist/verification/validation.d.ts.map +1 -0
- package/dist/verification/validation.js +54 -0
- package/package.json +148 -0
|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bootstrapStorefrontBookingSession, } from "./service-booking-session-bootstrap.js";
|
|
2
|
+
import { getStorefrontDeparture, getStorefrontDepartureItinerary, getStorefrontProductAvailabilitySummary, getStorefrontProductExtensions, listStorefrontProductDepartures, previewStorefrontDeparturePrice, } from "./service-departures.js";
|
|
3
|
+
import { createStorefrontLeadSignal, subscribeStorefrontNewsletter, } from "./service-intake.js";
|
|
4
|
+
import { evaluateStorefrontTransportEligibility } from "./service-transport-eligibility.js";
|
|
5
|
+
import { storefrontSettingsInputSchema, storefrontSettingsSchema, } from "./validation.js";
|
|
6
|
+
const defaultPaymentLabels = {
|
|
7
|
+
card: "Card",
|
|
8
|
+
bank_transfer: "Bank transfer",
|
|
9
|
+
cash: "Cash",
|
|
10
|
+
voucher: "Voucher",
|
|
11
|
+
invoice: "Invoice",
|
|
12
|
+
};
|
|
13
|
+
function normalizeField(field) {
|
|
14
|
+
return {
|
|
15
|
+
key: field.key,
|
|
16
|
+
label: field.label,
|
|
17
|
+
type: field.type,
|
|
18
|
+
required: field.required,
|
|
19
|
+
placeholder: field.placeholder ?? null,
|
|
20
|
+
description: field.description ?? null,
|
|
21
|
+
autocomplete: field.autocomplete ?? null,
|
|
22
|
+
options: field.options,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function normalizePaymentMethod(method) {
|
|
26
|
+
return {
|
|
27
|
+
code: method.code,
|
|
28
|
+
label: method.label ?? defaultPaymentLabels[method.code],
|
|
29
|
+
description: method.description ?? null,
|
|
30
|
+
enabled: method.enabled,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function normalizePaymentSchedule(schedule) {
|
|
34
|
+
if (!schedule)
|
|
35
|
+
return null;
|
|
36
|
+
return {
|
|
37
|
+
depositPercent: schedule.depositPercent ?? null,
|
|
38
|
+
balanceDueDaysBeforeDeparture: schedule.balanceDueDaysBeforeDeparture ?? null,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function scheduleEntriesFromDefaultSchedule(schedule) {
|
|
42
|
+
if (!schedule?.depositPercent || schedule.depositPercent >= 100) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
const remainderPercent = 100 - schedule.depositPercent;
|
|
46
|
+
return [
|
|
47
|
+
{
|
|
48
|
+
percent: schedule.depositPercent,
|
|
49
|
+
dueInDays: 0,
|
|
50
|
+
dueCondition: "after_booking",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
percent: remainderPercent,
|
|
54
|
+
dueInDays: schedule.balanceDueDaysBeforeDeparture ?? 0,
|
|
55
|
+
dueCondition: "before_departure",
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
function normalizePaymentScheduleEntries(schedule, defaultSchedule) {
|
|
60
|
+
if (schedule)
|
|
61
|
+
return schedule;
|
|
62
|
+
return scheduleEntriesFromDefaultSchedule(defaultSchedule);
|
|
63
|
+
}
|
|
64
|
+
function normalizePaymentStructure(structure, schedule, defaultSchedule) {
|
|
65
|
+
if (structure)
|
|
66
|
+
return structure;
|
|
67
|
+
if (schedule.length > 0)
|
|
68
|
+
return "split";
|
|
69
|
+
return defaultSchedule?.depositPercent && defaultSchedule.depositPercent > 0 ? "split" : "full";
|
|
70
|
+
}
|
|
71
|
+
function normalizeBankTransferAccount(account, bankTransfer) {
|
|
72
|
+
const resolved = account ??
|
|
73
|
+
(bankTransfer.iban && bankTransfer.accountHolder && bankTransfer.bankName
|
|
74
|
+
? {
|
|
75
|
+
provider: null,
|
|
76
|
+
currency: null,
|
|
77
|
+
iban: bankTransfer.iban,
|
|
78
|
+
beneficiary: bankTransfer.accountHolder,
|
|
79
|
+
bank: bankTransfer.bankName,
|
|
80
|
+
}
|
|
81
|
+
: null);
|
|
82
|
+
if (!resolved)
|
|
83
|
+
return null;
|
|
84
|
+
return {
|
|
85
|
+
provider: resolved.provider ?? null,
|
|
86
|
+
currency: resolved.currency ?? null,
|
|
87
|
+
iban: resolved.iban,
|
|
88
|
+
beneficiary: resolved.beneficiary,
|
|
89
|
+
bank: resolved.bank,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function normalizeBankTransfer(bankTransfer) {
|
|
93
|
+
if (!bankTransfer)
|
|
94
|
+
return null;
|
|
95
|
+
return {
|
|
96
|
+
dueDays: bankTransfer.dueDays ?? null,
|
|
97
|
+
account: normalizeBankTransferAccount(bankTransfer.account, bankTransfer),
|
|
98
|
+
accountHolder: bankTransfer.accountHolder ?? null,
|
|
99
|
+
bankName: bankTransfer.bankName ?? null,
|
|
100
|
+
iban: bankTransfer.iban ?? null,
|
|
101
|
+
bic: bankTransfer.bic ?? null,
|
|
102
|
+
paymentReference: bankTransfer.paymentReference ?? null,
|
|
103
|
+
instructions: bankTransfer.instructions ?? null,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function mergePaymentSchedule(current, patch) {
|
|
107
|
+
if (patch === null)
|
|
108
|
+
return null;
|
|
109
|
+
return {
|
|
110
|
+
...(current ?? {
|
|
111
|
+
depositPercent: null,
|
|
112
|
+
balanceDueDaysBeforeDeparture: null,
|
|
113
|
+
}),
|
|
114
|
+
...patch,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function mergeBankTransfer(current, patch) {
|
|
118
|
+
if (patch === null)
|
|
119
|
+
return null;
|
|
120
|
+
const merged = {
|
|
121
|
+
...(current ?? {
|
|
122
|
+
dueDays: null,
|
|
123
|
+
account: null,
|
|
124
|
+
accountHolder: null,
|
|
125
|
+
bankName: null,
|
|
126
|
+
iban: null,
|
|
127
|
+
bic: null,
|
|
128
|
+
paymentReference: null,
|
|
129
|
+
instructions: null,
|
|
130
|
+
}),
|
|
131
|
+
...patch,
|
|
132
|
+
};
|
|
133
|
+
const shouldRefreshAccountFromLegacyFields = patch.account === undefined &&
|
|
134
|
+
("accountHolder" in patch || "bankName" in patch || "iban" in patch);
|
|
135
|
+
return {
|
|
136
|
+
...merged,
|
|
137
|
+
account: normalizeBankTransferAccount(shouldRefreshAccountFromLegacyFields ? null : merged.account, merged),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
export function resolveStorefrontSettings(input) {
|
|
141
|
+
const parsed = storefrontSettingsInputSchema.parse(input ?? {});
|
|
142
|
+
const defaultSchedule = normalizePaymentSchedule(parsed.payment?.defaultSchedule ?? null);
|
|
143
|
+
const schedule = normalizePaymentScheduleEntries(parsed.payment?.schedule, defaultSchedule);
|
|
144
|
+
return storefrontSettingsSchema.parse({
|
|
145
|
+
branding: {
|
|
146
|
+
logoUrl: parsed.branding?.logoUrl ?? null,
|
|
147
|
+
faviconUrl: parsed.branding?.faviconUrl ?? null,
|
|
148
|
+
brandMarkUrl: parsed.branding?.brandMarkUrl ?? null,
|
|
149
|
+
primaryColor: parsed.branding?.primaryColor ?? null,
|
|
150
|
+
accentColor: parsed.branding?.accentColor ?? null,
|
|
151
|
+
supportedLanguages: parsed.branding?.supportedLanguages ?? [],
|
|
152
|
+
},
|
|
153
|
+
support: {
|
|
154
|
+
email: parsed.support?.email ?? null,
|
|
155
|
+
phone: parsed.support?.phone ?? null,
|
|
156
|
+
links: parsed.support?.links ?? [],
|
|
157
|
+
},
|
|
158
|
+
legal: {
|
|
159
|
+
termsUrl: parsed.legal?.termsUrl ?? null,
|
|
160
|
+
privacyUrl: parsed.legal?.privacyUrl ?? null,
|
|
161
|
+
cancellationUrl: parsed.legal?.cancellationUrl ?? null,
|
|
162
|
+
defaultContractTemplateId: parsed.legal?.defaultContractTemplateId ?? null,
|
|
163
|
+
},
|
|
164
|
+
localization: {
|
|
165
|
+
defaultLocale: parsed.localization?.defaultLocale ?? null,
|
|
166
|
+
currencyDisplay: parsed.localization?.currencyDisplay ?? "code",
|
|
167
|
+
},
|
|
168
|
+
forms: {
|
|
169
|
+
billing: {
|
|
170
|
+
fields: (parsed.forms?.billing?.fields ?? []).map(normalizeField),
|
|
171
|
+
},
|
|
172
|
+
travelers: {
|
|
173
|
+
fields: (parsed.forms?.travelers?.fields ?? []).map(normalizeField),
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
payment: {
|
|
177
|
+
defaultMethod: parsed.payment?.defaultMethod ?? null,
|
|
178
|
+
methods: (parsed.payment?.methods ?? []).map(normalizePaymentMethod),
|
|
179
|
+
structure: normalizePaymentStructure(parsed.payment?.structure, schedule, defaultSchedule),
|
|
180
|
+
schedule,
|
|
181
|
+
defaultSchedule,
|
|
182
|
+
bankTransfer: normalizeBankTransfer(parsed.payment?.bankTransfer ?? null),
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
export function mergeStorefrontSettingsPatch(current, patch) {
|
|
187
|
+
return resolveStorefrontSettings({
|
|
188
|
+
branding: patch.branding ? { ...current.branding, ...patch.branding } : current.branding,
|
|
189
|
+
support: patch.support ? { ...current.support, ...patch.support } : current.support,
|
|
190
|
+
legal: patch.legal ? { ...current.legal, ...patch.legal } : current.legal,
|
|
191
|
+
localization: patch.localization
|
|
192
|
+
? { ...current.localization, ...patch.localization }
|
|
193
|
+
: current.localization,
|
|
194
|
+
forms: patch.forms
|
|
195
|
+
? {
|
|
196
|
+
billing: patch.forms.billing
|
|
197
|
+
? { ...current.forms.billing, ...patch.forms.billing }
|
|
198
|
+
: current.forms.billing,
|
|
199
|
+
travelers: patch.forms.travelers
|
|
200
|
+
? { ...current.forms.travelers, ...patch.forms.travelers }
|
|
201
|
+
: current.forms.travelers,
|
|
202
|
+
}
|
|
203
|
+
: current.forms,
|
|
204
|
+
payment: patch.payment
|
|
205
|
+
? {
|
|
206
|
+
...current.payment,
|
|
207
|
+
...patch.payment,
|
|
208
|
+
defaultSchedule: patch.payment.defaultSchedule === undefined
|
|
209
|
+
? current.payment.defaultSchedule
|
|
210
|
+
: mergePaymentSchedule(current.payment.defaultSchedule, patch.payment.defaultSchedule),
|
|
211
|
+
bankTransfer: patch.payment.bankTransfer === undefined
|
|
212
|
+
? current.payment.bankTransfer
|
|
213
|
+
: mergeBankTransfer(current.payment.bankTransfer, patch.payment.bankTransfer),
|
|
214
|
+
}
|
|
215
|
+
: current.payment,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
export function createStorefrontService(options) {
|
|
219
|
+
const settings = resolveStorefrontSettings(options?.settings);
|
|
220
|
+
async function resolveSettings(context = {}) {
|
|
221
|
+
if (!options?.resolveSettings) {
|
|
222
|
+
return settings;
|
|
223
|
+
}
|
|
224
|
+
return resolveStorefrontSettings(await options.resolveSettings(context));
|
|
225
|
+
}
|
|
226
|
+
async function updateSettings(patch, context = {}) {
|
|
227
|
+
if (!options?.updateSettings) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
const current = await resolveSettings(context);
|
|
231
|
+
const next = mergeStorefrontSettingsPatch(current, patch);
|
|
232
|
+
return resolveStorefrontSettings(await options.updateSettings(next, context));
|
|
233
|
+
}
|
|
234
|
+
async function resolveOffers(context = {}) {
|
|
235
|
+
return (await options?.resolveOffers?.(context)) ?? options?.offers;
|
|
236
|
+
}
|
|
237
|
+
async function resolveTransportEligibilityRules(input) {
|
|
238
|
+
return ((await options?.resolveTransportEligibilityRules?.(input)) ??
|
|
239
|
+
options?.transportEligibilityRules ??
|
|
240
|
+
[]);
|
|
241
|
+
}
|
|
242
|
+
async function checkIntakeGuard(input) {
|
|
243
|
+
return options?.intake?.guard?.(input);
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
getSettings() {
|
|
247
|
+
return settings;
|
|
248
|
+
},
|
|
249
|
+
resolveSettings,
|
|
250
|
+
updateSettings,
|
|
251
|
+
getDeparture(db, departureId) {
|
|
252
|
+
return getStorefrontDeparture(db, departureId);
|
|
253
|
+
},
|
|
254
|
+
listProductDepartures(db, productId, query) {
|
|
255
|
+
return listStorefrontProductDepartures(db, productId, query);
|
|
256
|
+
},
|
|
257
|
+
previewDeparturePrice(db, departureId, input, context = {}) {
|
|
258
|
+
const offerContext = { ...context, db: context.db ?? db };
|
|
259
|
+
return previewStorefrontDeparturePrice(db, departureId, input, {
|
|
260
|
+
listApplicableOffers: async (offerInput) => {
|
|
261
|
+
const offers = await resolveOffers(offerContext)?.then((resolvers) => resolvers?.listApplicableOffers?.({ ...offerInput, ...offerContext }));
|
|
262
|
+
return offers ?? [];
|
|
263
|
+
},
|
|
264
|
+
applyOffer: async (offerInput) => (await resolveOffers(offerContext)?.then((resolvers) => resolvers?.applyOffer?.({ ...offerInput, ...offerContext }))) ?? null,
|
|
265
|
+
redeemOffer: async (offerInput) => (await resolveOffers(offerContext)?.then((resolvers) => resolvers?.redeemOffer?.({ ...offerInput, ...offerContext }))) ?? null,
|
|
266
|
+
});
|
|
267
|
+
},
|
|
268
|
+
getProductExtensions(db, productId, optionId) {
|
|
269
|
+
return getStorefrontProductExtensions(db, productId, optionId);
|
|
270
|
+
},
|
|
271
|
+
getProductAvailabilitySummary(db, productId, query) {
|
|
272
|
+
return getStorefrontProductAvailabilitySummary(db, productId, query);
|
|
273
|
+
},
|
|
274
|
+
getDepartureItinerary(db, input) {
|
|
275
|
+
return getStorefrontDepartureItinerary(db, input);
|
|
276
|
+
},
|
|
277
|
+
async checkDepartureTransportEligibility(input) {
|
|
278
|
+
const { context, body, departureId } = input;
|
|
279
|
+
const needsDeparture = context?.db && (!input.productId || !body.travelStartsOn || !body.travelEndsOn);
|
|
280
|
+
const departure = needsDeparture && context?.db ? await getStorefrontDeparture(context.db, departureId) : null;
|
|
281
|
+
const productId = input.productId ?? departure?.productId ?? null;
|
|
282
|
+
const travelStartsOn = body.travelStartsOn ?? departure?.dateLocal ?? departure?.startAt?.slice(0, 10) ?? null;
|
|
283
|
+
const travelEndsOn = body.travelEndsOn ?? departure?.endAt?.slice(0, 10) ?? departure?.dateLocal ?? null;
|
|
284
|
+
const rules = await resolveTransportEligibilityRules({
|
|
285
|
+
...(context ?? {}),
|
|
286
|
+
departureId,
|
|
287
|
+
productId,
|
|
288
|
+
travelStartsOn,
|
|
289
|
+
travelEndsOn,
|
|
290
|
+
});
|
|
291
|
+
return evaluateStorefrontTransportEligibility({
|
|
292
|
+
departureId,
|
|
293
|
+
productId,
|
|
294
|
+
travelStartsOn,
|
|
295
|
+
travelEndsOn,
|
|
296
|
+
travelers: body.travelers,
|
|
297
|
+
rules,
|
|
298
|
+
});
|
|
299
|
+
},
|
|
300
|
+
async bootstrapBookingSession(context, input, userId) {
|
|
301
|
+
return bootstrapStorefrontBookingSession(context, input, options?.bookingSessionBootstrap, userId);
|
|
302
|
+
},
|
|
303
|
+
async listApplicableOffers(input) {
|
|
304
|
+
const { context, ...offerInput } = input;
|
|
305
|
+
const offers = await resolveOffers(context)?.then((resolvers) => resolvers?.listApplicableOffers?.({ ...offerInput, ...(context ?? {}) }));
|
|
306
|
+
return offers ?? [];
|
|
307
|
+
},
|
|
308
|
+
async getOfferBySlug(input) {
|
|
309
|
+
const { context, ...offerInput } = input;
|
|
310
|
+
return ((await resolveOffers(context)?.then((resolvers) => resolvers?.getOfferBySlug?.({ ...offerInput, ...(context ?? {}) }))) ?? null);
|
|
311
|
+
},
|
|
312
|
+
async applyOffer(input) {
|
|
313
|
+
const { context, ...offerInput } = input;
|
|
314
|
+
return ((await resolveOffers(context)?.then((resolvers) => resolvers?.applyOffer?.({ ...offerInput, ...(context ?? {}) }))) ?? null);
|
|
315
|
+
},
|
|
316
|
+
async redeemOffer(input) {
|
|
317
|
+
const { context, ...offerInput } = input;
|
|
318
|
+
return ((await resolveOffers(context)?.then((resolvers) => resolvers?.redeemOffer?.({ ...offerInput, ...(context ?? {}) }))) ?? null);
|
|
319
|
+
},
|
|
320
|
+
checkIntakeGuard,
|
|
321
|
+
createLead(input) {
|
|
322
|
+
return createStorefrontLeadSignal({ ...input, intake: options?.intake });
|
|
323
|
+
},
|
|
324
|
+
subscribeNewsletter(input) {
|
|
325
|
+
return subscribeStorefrontNewsletter({
|
|
326
|
+
...input,
|
|
327
|
+
intake: options?.intake,
|
|
328
|
+
requestDoubleOptIn: options?.intake?.requestNewsletterDoubleOptIn,
|
|
329
|
+
});
|
|
330
|
+
},
|
|
331
|
+
};
|
|
332
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { evaluateStorefrontTransportEligibility } from "./service-transport-eligibility.js";
|
|
2
|
+
export type { StorefrontTransportEligibilityInput, StorefrontTransportEligibilityIssue, StorefrontTransportEligibilityResult, StorefrontTransportEligibilityRule, StorefrontTransportEligibilityRuleInput, } from "./validation-transport-eligibility.js";
|
|
3
|
+
export { storefrontRequiredDocumentTypeSchema, storefrontTransportEligibilityDocumentInputSchema, storefrontTransportEligibilityInputSchema, storefrontTransportEligibilityIssueCodeSchema, storefrontTransportEligibilityIssueSchema, storefrontTransportEligibilityResultSchema, storefrontTransportEligibilityRuleSchema, storefrontTransportEligibilitySeveritySchema, storefrontTransportEligibilityTravelerInputSchema, storefrontTransportEligibilityTravelerResultSchema, storefrontTravelDocumentTypeSchema, } from "./validation-transport-eligibility.js";
|
|
4
|
+
//# sourceMappingURL=transport-eligibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport-eligibility.d.ts","sourceRoot":"","sources":["../src/transport-eligibility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sCAAsC,EAAE,MAAM,oCAAoC,CAAA;AAC3F,YAAY,EACV,mCAAmC,EACnC,mCAAmC,EACnC,oCAAoC,EACpC,kCAAkC,EAClC,uCAAuC,GACxC,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EACL,oCAAoC,EACpC,iDAAiD,EACjD,yCAAyC,EACzC,6CAA6C,EAC7C,yCAAyC,EACzC,0CAA0C,EAC1C,wCAAwC,EACxC,4CAA4C,EAC5C,iDAAiD,EACjD,kDAAkD,EAClD,kCAAkC,GACnC,MAAM,uCAAuC,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { evaluateStorefrontTransportEligibility } from "./service-transport-eligibility.js";
|
|
2
|
+
export { storefrontRequiredDocumentTypeSchema, storefrontTransportEligibilityDocumentInputSchema, storefrontTransportEligibilityInputSchema, storefrontTransportEligibilityIssueCodeSchema, storefrontTransportEligibilityIssueSchema, storefrontTransportEligibilityResultSchema, storefrontTransportEligibilityRuleSchema, storefrontTransportEligibilitySeveritySchema, storefrontTransportEligibilityTravelerInputSchema, storefrontTransportEligibilityTravelerResultSchema, storefrontTravelDocumentTypeSchema, } from "./validation-transport-eligibility.js";
|