@voyant-travel/trips 0.111.1 → 0.112.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/dist/checkout/billing.d.ts +9 -0
- package/dist/checkout/billing.d.ts.map +1 -0
- package/dist/checkout/billing.js +54 -0
- package/dist/checkout/index.d.ts +5 -0
- package/dist/checkout/index.d.ts.map +1 -0
- package/dist/checkout/index.js +3 -0
- package/dist/checkout/pricing.d.ts +9 -0
- package/dist/checkout/pricing.d.ts.map +1 -0
- package/dist/checkout/pricing.js +100 -0
- package/dist/checkout/start-checkout.d.ts +14 -0
- package/dist/checkout/start-checkout.d.ts.map +1 -0
- package/dist/checkout/start-checkout.js +74 -0
- package/dist/checkout/types.d.ts +82 -0
- package/dist/checkout/types.d.ts.map +1 -0
- package/dist/checkout/types.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/mcp-routes.d.ts +30 -0
- package/dist/mcp-routes.d.ts.map +1 -0
- package/dist/mcp-routes.js +48 -0
- package/package.json +14 -3
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SynthesizedTripBilling, TripBillingInfo } from "./types.js";
|
|
2
|
+
export declare function readTripBilling(travelerParty: Record<string, unknown>): TripBillingInfo;
|
|
3
|
+
export declare function formatTripBillingName(billing: TripBillingInfo): string | null;
|
|
4
|
+
export declare function synthesizeTripBilling(billing: TripBillingInfo): SynthesizedTripBilling;
|
|
5
|
+
export declare function splitTripBillingName(value: string): {
|
|
6
|
+
firstName: string;
|
|
7
|
+
lastName: string;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=billing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../src/checkout/billing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEzE,wBAAgB,eAAe,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,eAAe,CAcvF;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,CAS7E;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAG,sBAAsB,CAatF;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAM3F"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export function readTripBilling(travelerParty) {
|
|
2
|
+
const billing = asRecord(travelerParty.billing);
|
|
3
|
+
const contact = asRecord(billing?.contact);
|
|
4
|
+
return {
|
|
5
|
+
buyerType: stringValue(billing?.buyerType),
|
|
6
|
+
personId: stringValue(billing?.personId),
|
|
7
|
+
organizationId: stringValue(billing?.organizationId),
|
|
8
|
+
contact: {
|
|
9
|
+
firstName: stringValue(contact?.firstName),
|
|
10
|
+
lastName: stringValue(contact?.lastName),
|
|
11
|
+
email: stringValue(contact?.email),
|
|
12
|
+
phone: stringValue(contact?.phone),
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function formatTripBillingName(billing) {
|
|
17
|
+
return [billing.contact?.firstName, billing.contact?.lastName]
|
|
18
|
+
.filter((part) => Boolean(part))
|
|
19
|
+
.join(" ")
|
|
20
|
+
.trim()
|
|
21
|
+
? [billing.contact?.firstName, billing.contact?.lastName]
|
|
22
|
+
.filter((part) => Boolean(part))
|
|
23
|
+
.join(" ")
|
|
24
|
+
: null;
|
|
25
|
+
}
|
|
26
|
+
export function synthesizeTripBilling(billing) {
|
|
27
|
+
const names = splitTripBillingName(formatTripBillingName(billing) ?? "Trip customer");
|
|
28
|
+
return {
|
|
29
|
+
email: billing.contact?.email ?? "",
|
|
30
|
+
phone: billing.contact?.phone ?? "0000000000",
|
|
31
|
+
firstName: names.firstName,
|
|
32
|
+
lastName: names.lastName,
|
|
33
|
+
city: "TBD",
|
|
34
|
+
country: 642,
|
|
35
|
+
state: "TBD",
|
|
36
|
+
postalCode: "00000",
|
|
37
|
+
details: "Pending — customer to confirm at payment.",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export function splitTripBillingName(value) {
|
|
41
|
+
const parts = value.trim().split(/\s+/).filter(Boolean);
|
|
42
|
+
return {
|
|
43
|
+
firstName: parts[0] ?? "Trip",
|
|
44
|
+
lastName: parts.slice(1).join(" ") || "Customer",
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function asRecord(value) {
|
|
48
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
49
|
+
? value
|
|
50
|
+
: undefined;
|
|
51
|
+
}
|
|
52
|
+
function stringValue(value) {
|
|
53
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
54
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { formatTripBillingName, readTripBilling, splitTripBillingName, synthesizeTripBilling, } from "./billing.js";
|
|
2
|
+
export { buildTripPaymentSummary, checkoutPricingForTrip } from "./pricing.js";
|
|
3
|
+
export { startTripCheckout } from "./start-checkout.js";
|
|
4
|
+
export type { FxQuote, SynthesizedTripBilling, Trip, TripBillingInfo, TripCheckoutAllocation, TripCheckoutDeps, TripCheckoutInput, TripCheckoutResult, } from "./types.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/checkout/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,YAAY,EACV,OAAO,EACP,sBAAsB,EACtB,IAAI,EACJ,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Trip } from "../service.js";
|
|
2
|
+
import type { TripCheckoutAllocation, TripCheckoutDeps } from "./types.js";
|
|
3
|
+
export declare function checkoutPricingForTrip(quoteFx: TripCheckoutDeps["quoteFx"], trip: Trip, request: Record<string, unknown>): Promise<{
|
|
4
|
+
currency: string;
|
|
5
|
+
totalAmountCents: number;
|
|
6
|
+
allocations: TripCheckoutAllocation[];
|
|
7
|
+
}>;
|
|
8
|
+
export declare function buildTripPaymentSummary(trip: Trip, currency: string, allocations?: TripCheckoutAllocation[]): string;
|
|
9
|
+
//# sourceMappingURL=pricing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../../src/checkout/pricing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAE1E,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,EACpC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC;IACT,QAAQ,EAAE,MAAM,CAAA;IAChB,gBAAgB,EAAE,MAAM,CAAA;IACxB,WAAW,EAAE,sBAAsB,EAAE,CAAA;CACtC,CAAC,CAsDD;AAED,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,sBAAsB,EAAE,GACrC,MAAM,CAwCR"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export async function checkoutPricingForTrip(quoteFx, trip, request) {
|
|
2
|
+
const active = trip.components.filter((component) => component.status !== "removed" && component.status !== "cancelled");
|
|
3
|
+
const collectionCurrency = stringValue(request.collectionCurrency) ?? trip.envelope.aggregateCurrency ?? "EUR";
|
|
4
|
+
const allocations = [];
|
|
5
|
+
for (const component of active) {
|
|
6
|
+
const sourceCurrency = component.componentCurrency ?? collectionCurrency;
|
|
7
|
+
const sourceAmountCents = component.componentTotalAmountCents ?? 0;
|
|
8
|
+
if (sourceAmountCents <= 0)
|
|
9
|
+
continue;
|
|
10
|
+
if (sourceCurrency === collectionCurrency) {
|
|
11
|
+
allocations.push({
|
|
12
|
+
componentId: component.id,
|
|
13
|
+
kind: component.kind,
|
|
14
|
+
bookingId: component.bookingId,
|
|
15
|
+
orderId: component.orderId,
|
|
16
|
+
sourceCurrency,
|
|
17
|
+
sourceAmountCents,
|
|
18
|
+
targetCurrency: collectionCurrency,
|
|
19
|
+
targetAmountCents: sourceAmountCents,
|
|
20
|
+
});
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const fx = await quoteFx(sourceCurrency, collectionCurrency);
|
|
24
|
+
allocations.push({
|
|
25
|
+
componentId: component.id,
|
|
26
|
+
kind: component.kind,
|
|
27
|
+
bookingId: component.bookingId,
|
|
28
|
+
orderId: component.orderId,
|
|
29
|
+
sourceCurrency,
|
|
30
|
+
sourceAmountCents,
|
|
31
|
+
targetCurrency: collectionCurrency,
|
|
32
|
+
targetAmountCents: convertCents(sourceAmountCents, fx.rate),
|
|
33
|
+
fx: {
|
|
34
|
+
rate: fx.rate,
|
|
35
|
+
provider: "voyant_data_fx",
|
|
36
|
+
quotedAt: fx.quotedAt,
|
|
37
|
+
validUntil: fx.validUntil,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
currency: collectionCurrency,
|
|
43
|
+
totalAmountCents: allocations.reduce((sum, allocation) => sum + allocation.targetAmountCents, 0),
|
|
44
|
+
allocations,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export function buildTripPaymentSummary(trip, currency, allocations) {
|
|
48
|
+
const lines = ["Trip payment summary"];
|
|
49
|
+
const byComponentId = new Map(allocations?.map((allocation) => [allocation.componentId, allocation]));
|
|
50
|
+
for (const component of trip.components.filter((item) => item.status !== "removed" && item.status !== "cancelled")) {
|
|
51
|
+
const allocation = byComponentId.get(component.id);
|
|
52
|
+
if (allocation?.fx) {
|
|
53
|
+
lines.push(`${componentDisplayName(component)} — ${formatCents(allocation.sourceAmountCents, allocation.sourceCurrency)} -> ${formatCents(allocation.targetAmountCents, allocation.targetCurrency)}`);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
lines.push(`${componentDisplayName(component)} — ${formatCents(allocation?.targetAmountCents ?? component.componentTotalAmountCents, allocation?.targetCurrency ?? component.componentCurrency ?? currency)}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const total = allocations?.reduce((sum, allocation) => sum + allocation.targetAmountCents, 0);
|
|
60
|
+
lines.push(`Total payable — ${formatCents(total ?? trip.envelope.aggregateTotalAmountCents, currency)}`);
|
|
61
|
+
const fxAllocations = allocations?.filter((allocation) => allocation.fx) ?? [];
|
|
62
|
+
if (fxAllocations.length > 0) {
|
|
63
|
+
lines.push("");
|
|
64
|
+
lines.push("FX rates");
|
|
65
|
+
for (const allocation of fxAllocations) {
|
|
66
|
+
lines.push(`${allocation.sourceCurrency}->${allocation.targetCurrency}: ${allocation.fx?.rate} quoted ${allocation.fx?.quotedAt}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return lines.join("\n");
|
|
70
|
+
}
|
|
71
|
+
function componentDisplayName(component) {
|
|
72
|
+
const metadata = asRecord(component.metadata);
|
|
73
|
+
const catalogItem = asRecord(metadata?.catalogItem);
|
|
74
|
+
const flightDraft = asRecord(metadata?.flightDraft);
|
|
75
|
+
const origin = stringValue(flightDraft?.origin);
|
|
76
|
+
const destination = stringValue(flightDraft?.destination);
|
|
77
|
+
if (origin && destination)
|
|
78
|
+
return `${origin} -> ${destination}`;
|
|
79
|
+
return (stringValue(catalogItem?.name) ||
|
|
80
|
+
stringValue(component.title) ||
|
|
81
|
+
stringValue(component.description) ||
|
|
82
|
+
component.kind.replaceAll("_", " "));
|
|
83
|
+
}
|
|
84
|
+
function formatCents(amountCents, currency) {
|
|
85
|
+
return ((amountCents ?? 0) / 100).toLocaleString("en-GB", {
|
|
86
|
+
style: "currency",
|
|
87
|
+
currency,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function convertCents(amountCents, rate) {
|
|
91
|
+
return Math.round(amountCents * rate);
|
|
92
|
+
}
|
|
93
|
+
function asRecord(value) {
|
|
94
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
95
|
+
? value
|
|
96
|
+
: undefined;
|
|
97
|
+
}
|
|
98
|
+
function stringValue(value) {
|
|
99
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
100
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TripCheckoutInput, TripCheckoutResult } from "../service.js";
|
|
2
|
+
import type { TripCheckoutDeps } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Orchestrate a trip checkout: price the trip's components into the collection
|
|
5
|
+
* currency, create the finance payment session, optionally start the payment
|
|
6
|
+
* provider, and return the customer-facing checkout link / bank-transfer
|
|
7
|
+
* instructions.
|
|
8
|
+
*
|
|
9
|
+
* Finance (`createPaymentSession` + `buildPaymentLinkUrl`) is composed
|
|
10
|
+
* directly. The deployment supplies FX quoting, the checkout base URL, and the
|
|
11
|
+
* payment-provider start via `deps`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function startTripCheckout(deps: TripCheckoutDeps, input: TripCheckoutInput): Promise<TripCheckoutResult>;
|
|
14
|
+
//# sourceMappingURL=start-checkout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-checkout.d.ts","sourceRoot":"","sources":["../../src/checkout/start-checkout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAG1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,gBAAgB,EACtB,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,kBAAkB,CAAC,CA8D7B"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { buildPaymentLinkUrl, financeService } from "@voyant-travel/finance";
|
|
2
|
+
import { formatTripBillingName, readTripBilling, synthesizeTripBilling } from "./billing.js";
|
|
3
|
+
import { buildTripPaymentSummary, checkoutPricingForTrip } from "./pricing.js";
|
|
4
|
+
/**
|
|
5
|
+
* Orchestrate a trip checkout: price the trip's components into the collection
|
|
6
|
+
* currency, create the finance payment session, optionally start the payment
|
|
7
|
+
* provider, and return the customer-facing checkout link / bank-transfer
|
|
8
|
+
* instructions.
|
|
9
|
+
*
|
|
10
|
+
* Finance (`createPaymentSession` + `buildPaymentLinkUrl`) is composed
|
|
11
|
+
* directly. The deployment supplies FX quoting, the checkout base URL, and the
|
|
12
|
+
* payment-provider start via `deps`.
|
|
13
|
+
*/
|
|
14
|
+
export async function startTripCheckout(deps, input) {
|
|
15
|
+
const db = deps.db;
|
|
16
|
+
const pricing = await checkoutPricingForTrip(deps.quoteFx, input.trip, input.request);
|
|
17
|
+
if (pricing.totalAmountCents <= 0) {
|
|
18
|
+
throw new Error("trip_checkout_total_required");
|
|
19
|
+
}
|
|
20
|
+
const billing = readTripBilling(input.trip.envelope.travelerParty);
|
|
21
|
+
const payerName = formatTripBillingName(billing);
|
|
22
|
+
const payerEmail = billing.contact?.email ?? null;
|
|
23
|
+
if (!payerName || !payerEmail) {
|
|
24
|
+
throw new Error("trip_checkout_billing_required");
|
|
25
|
+
}
|
|
26
|
+
const paymentMethod = input.intent === "bank_transfer" ? "bank_transfer" : "credit_card";
|
|
27
|
+
const session = await financeService.createPaymentSession(db, {
|
|
28
|
+
targetType: "other",
|
|
29
|
+
targetId: input.trip.envelope.id,
|
|
30
|
+
idempotencyKey: `trip-checkout:${input.trip.envelope.id}:${pricing.currency}:${pricing.totalAmountCents}`,
|
|
31
|
+
clientReference: input.trip.envelope.id,
|
|
32
|
+
currency: pricing.currency,
|
|
33
|
+
amountCents: pricing.totalAmountCents,
|
|
34
|
+
status: "pending",
|
|
35
|
+
provider: input.intent === "bank_transfer" ? null : "netopia",
|
|
36
|
+
paymentMethod,
|
|
37
|
+
payerPersonId: billing.personId ?? null,
|
|
38
|
+
payerOrganizationId: billing.organizationId ?? null,
|
|
39
|
+
payerEmail,
|
|
40
|
+
payerName,
|
|
41
|
+
notes: buildTripPaymentSummary(input.trip, pricing.currency, pricing.allocations),
|
|
42
|
+
metadata: {
|
|
43
|
+
tripEnvelopeId: input.trip.envelope.id,
|
|
44
|
+
collectionCurrency: pricing.currency,
|
|
45
|
+
componentAllocations: pricing.allocations,
|
|
46
|
+
fxAllocations: pricing.allocations.filter((allocation) => allocation.fx),
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
if (!session) {
|
|
50
|
+
throw new Error("trip_checkout_session_create_failed");
|
|
51
|
+
}
|
|
52
|
+
if (input.intent !== "bank_transfer") {
|
|
53
|
+
try {
|
|
54
|
+
if (deps.startProviderPayment) {
|
|
55
|
+
await deps.startProviderPayment({
|
|
56
|
+
paymentSessionId: session.id,
|
|
57
|
+
billing: synthesizeTripBilling(billing),
|
|
58
|
+
description: `Trip ${input.trip.envelope.id}`,
|
|
59
|
+
trip: input.trip,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
console.warn("[trips] netopia start failed for trip payment session:", error);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
kind: input.intent === "bank_transfer" ? "bank_transfer_instructions" : "payment_session",
|
|
69
|
+
paymentSessionId: session.id,
|
|
70
|
+
checkoutUrl: buildPaymentLinkUrl(session.id, {
|
|
71
|
+
baseUrl: deps.resolveCheckoutBaseUrl(),
|
|
72
|
+
}),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Trip, TripCheckoutInput, TripCheckoutResult } from "../service.js";
|
|
2
|
+
/** A per-component currency allocation produced while pricing a trip checkout. */
|
|
3
|
+
export interface TripCheckoutAllocation {
|
|
4
|
+
componentId: string;
|
|
5
|
+
kind: string;
|
|
6
|
+
bookingId: string | null;
|
|
7
|
+
orderId: string | null;
|
|
8
|
+
sourceCurrency: string;
|
|
9
|
+
sourceAmountCents: number;
|
|
10
|
+
targetCurrency: string;
|
|
11
|
+
targetAmountCents: number;
|
|
12
|
+
fx?: {
|
|
13
|
+
rate: number;
|
|
14
|
+
provider: "voyant_data_fx";
|
|
15
|
+
quotedAt: string;
|
|
16
|
+
validUntil?: string | null;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** A resolved FX quote between two currencies. */
|
|
20
|
+
export interface FxQuote {
|
|
21
|
+
rate: number;
|
|
22
|
+
quotedAt: string;
|
|
23
|
+
validUntil?: string | null;
|
|
24
|
+
}
|
|
25
|
+
/** Billing details extracted from a trip's traveler party. */
|
|
26
|
+
export interface TripBillingInfo {
|
|
27
|
+
buyerType?: string | null;
|
|
28
|
+
personId?: string | null;
|
|
29
|
+
organizationId?: string | null;
|
|
30
|
+
contact?: {
|
|
31
|
+
firstName?: string | null;
|
|
32
|
+
lastName?: string | null;
|
|
33
|
+
email?: string | null;
|
|
34
|
+
phone?: string | null;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** Synthesized billing payload handed to a payment provider. */
|
|
38
|
+
export interface SynthesizedTripBilling {
|
|
39
|
+
email: string;
|
|
40
|
+
phone: string;
|
|
41
|
+
firstName: string;
|
|
42
|
+
lastName: string;
|
|
43
|
+
city: string;
|
|
44
|
+
country: number;
|
|
45
|
+
state: string;
|
|
46
|
+
postalCode: string;
|
|
47
|
+
details: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Deployment-supplied dependencies for the trip-checkout orchestration. The
|
|
51
|
+
* trips package composes finance (`createPaymentSession` + payment-link URL)
|
|
52
|
+
* directly, but everything that is a deployment provider choice — FX rates,
|
|
53
|
+
* the public checkout base URL, and the payment-provider start (Netopia) —
|
|
54
|
+
* is injected here.
|
|
55
|
+
*/
|
|
56
|
+
export interface TripCheckoutDeps {
|
|
57
|
+
/** The finance-compatible drizzle db used for `createPaymentSession`. */
|
|
58
|
+
db: unknown;
|
|
59
|
+
/**
|
|
60
|
+
* Quote an FX rate from `sourceCurrency` to `targetCurrency`. Called only
|
|
61
|
+
* when a component's currency differs from the collection currency.
|
|
62
|
+
*/
|
|
63
|
+
quoteFx(sourceCurrency: string, targetCurrency: string): Promise<FxQuote>;
|
|
64
|
+
/**
|
|
65
|
+
* Resolve the customer-facing checkout base URL used to build the payment
|
|
66
|
+
* link. May return `null` (the helper falls back to a root-relative URL).
|
|
67
|
+
*/
|
|
68
|
+
resolveCheckoutBaseUrl(): string | null;
|
|
69
|
+
/**
|
|
70
|
+
* Start the payment-provider session for a non-bank-transfer checkout. This
|
|
71
|
+
* is best-effort; the orchestration logs and continues on failure. Omit to
|
|
72
|
+
* skip provider start entirely.
|
|
73
|
+
*/
|
|
74
|
+
startProviderPayment?(args: {
|
|
75
|
+
paymentSessionId: string;
|
|
76
|
+
billing: SynthesizedTripBilling;
|
|
77
|
+
description: string;
|
|
78
|
+
trip: Trip;
|
|
79
|
+
}): Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
export type { Trip, TripCheckoutInput, TripCheckoutResult };
|
|
82
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceR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B;IACrC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,yEAAyE;IACzE,EAAE,EAAE,OAAO,CAAA;IACX;;;OAGG;IACH,OAAO,CAAC,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACzE;;;OAGG;IACH,sBAAsB,IAAI,MAAM,GAAG,IAAI,CAAA;IACvC;;;;OAIG;IACH,oBAAoB,CAAC,CAAC,IAAI,EAAE;QAC1B,gBAAgB,EAAE,MAAM,CAAA;QACxB,OAAO,EAAE,sBAAsB,CAAA;QAC/B,WAAW,EAAE,MAAM,CAAA;QACnB,IAAI,EAAE,IAAI,CAAA;KACX,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAClB;AAED,YAAY,EAAE,IAAI,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare function createTripsHonoModule(options?: TripsHonoModuleOptions):
|
|
|
14
14
|
export type { McpToolContent, McpToolContext, McpToolDefinition, McpToolErrorCode, McpToolHandler, McpToolResult, } from "./mcp-contract.js";
|
|
15
15
|
export { McpToolError } from "./mcp-contract.js";
|
|
16
16
|
export { type CreateMcpToolRegistryOptions, createMcpToolRegistry, enforceAudienceAuthorization, type McpToolListEntry, type McpToolRegistry, requireService, } from "./mcp-registry.js";
|
|
17
|
+
export { createTripMcpRoutes, type TripMcpRoutesOptions } from "./mcp-routes.js";
|
|
17
18
|
export { type CreateTripArgs, createTripTool, type PriceTripArgs, priceTripTool, type ReserveTripArgs, type ReviseTripArgs, reserveTripTool, reviseTripTool, type TripsMcpServices, tripsMcpTools, } from "./mcp-tools.js";
|
|
18
19
|
export { tripsRoutes } from "./routes.js";
|
|
19
20
|
export type { NewTripComponent, NewTripComponentEvent, NewTripEnvelope, NewTripReservationPlan, NewTripSnapshot, TripComponent, TripComponentEvent, TripComponentPricingSnapshot, TripComponentTaxLineSnapshot, TripEnvelope, TripEnvelopePricingSnapshot, TripReservationPlan, TripReservationPlanCompensationSnapshot, TripReservationPlanComponentSnapshot, TripReservationPlanFailureSnapshot, TripSnapshot, TripSnapshotProposal, TripSnapshotProposalLine, } from "./schema.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAE5D,OAAO,EAAqB,KAAK,kBAAkB,EAAe,MAAM,aAAa,CAAA;AAErF,OAAO,EACL,KAAK,qCAAqC,EAC1C,4BAA4B,EAC5B,gBAAgB,GACjB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,8BAA8B,EAC9B,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,EAClC,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,8BAA8B,EAC9B,0BAA0B,EAC1B,gCAAgC,EAChC,sBAAsB,EACtB,kCAAkC,EAClC,iCAAiC,GAClC,MAAM,uBAAuB,CAAA;AAC9B,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAClE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CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ export function createTripsHonoModule(options = {}) {
|
|
|
23
23
|
}
|
|
24
24
|
export { McpToolError } from "./mcp-contract.js";
|
|
25
25
|
export { createMcpToolRegistry, enforceAudienceAuthorization, requireService, } from "./mcp-registry.js";
|
|
26
|
+
export { createTripMcpRoutes } from "./mcp-routes.js";
|
|
26
27
|
export { createTripTool, priceTripTool, reserveTripTool, reviseTripTool, tripsMcpTools, } from "./mcp-tools.js";
|
|
27
28
|
export { tripsRoutes } from "./routes.js";
|
|
28
29
|
export { tripComponentEvents, tripComponentEventTypeEnum, tripComponentKindEnum, tripComponentStatusEnum, tripComponents, tripEnvelopeStatusEnum, tripEnvelopes, tripReservationPlanStatusEnum, tripReservationPlans, tripSnapshots, } from "./schema.js";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trips agent tool surface (transport: HTTP).
|
|
3
|
+
*
|
|
4
|
+
* A generic tool-dispatch route owned by the trips package. It registers the
|
|
5
|
+
* trips command tools (create / revise / price / reserve) and dispatches a
|
|
6
|
+
* `POST /tools/:tool` call against them.
|
|
7
|
+
*
|
|
8
|
+
* The deployment supplies the per-request `McpToolContext` and the
|
|
9
|
+
* `TripsMcpServices` (which bind the trips service to the deployment's db +
|
|
10
|
+
* dependency wiring) via `options`. Mount the returned router at
|
|
11
|
+
* `/v1/admin/mcp`.
|
|
12
|
+
*/
|
|
13
|
+
import { type Context, Hono } from "hono";
|
|
14
|
+
import type { McpToolContext } from "./mcp-contract.js";
|
|
15
|
+
import { type TripsMcpServices } from "./mcp-tools.js";
|
|
16
|
+
export interface TripMcpRoutesOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Build the per-request MCP tool context (actor / tenant / default scope).
|
|
19
|
+
* Derived from the request's auth + the deployment's defaults.
|
|
20
|
+
*/
|
|
21
|
+
buildContext(c: Context): McpToolContext;
|
|
22
|
+
/**
|
|
23
|
+
* Build the trips MCP services for this request — binds the trips service to
|
|
24
|
+
* the deployment's db + dependency wiring.
|
|
25
|
+
*/
|
|
26
|
+
buildTripsServices(c: Context): TripsMcpServices;
|
|
27
|
+
}
|
|
28
|
+
/** Build the trips MCP admin routes (relative paths; mount at `/v1/admin/mcp`). */
|
|
29
|
+
export declare function createTripMcpRoutes(options: TripMcpRoutesOptions): Hono;
|
|
30
|
+
//# sourceMappingURL=mcp-routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-routes.d.ts","sourceRoot":"","sources":["../src/mcp-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,KAAK,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAA;AAEvB,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,cAAc,CAAA;IACxC;;;OAGG;IACH,kBAAkB,CAAC,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAA;CACjD;AASD,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,CA0BvE"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trips agent tool surface (transport: HTTP).
|
|
3
|
+
*
|
|
4
|
+
* A generic tool-dispatch route owned by the trips package. It registers the
|
|
5
|
+
* trips command tools (create / revise / price / reserve) and dispatches a
|
|
6
|
+
* `POST /tools/:tool` call against them.
|
|
7
|
+
*
|
|
8
|
+
* The deployment supplies the per-request `McpToolContext` and the
|
|
9
|
+
* `TripsMcpServices` (which bind the trips service to the deployment's db +
|
|
10
|
+
* dependency wiring) via `options`. Mount the returned router at
|
|
11
|
+
* `/v1/admin/mcp`.
|
|
12
|
+
*/
|
|
13
|
+
import { Hono } from "hono";
|
|
14
|
+
import { createMcpToolRegistry } from "./mcp-registry.js";
|
|
15
|
+
import { createTripTool, priceTripTool, reserveTripTool, reviseTripTool, } from "./mcp-tools.js";
|
|
16
|
+
function registerAdminTools(registry) {
|
|
17
|
+
registry.register(createTripTool);
|
|
18
|
+
registry.register(reviseTripTool);
|
|
19
|
+
registry.register(priceTripTool);
|
|
20
|
+
registry.register(reserveTripTool);
|
|
21
|
+
}
|
|
22
|
+
/** Build the trips MCP admin routes (relative paths; mount at `/v1/admin/mcp`). */
|
|
23
|
+
export function createTripMcpRoutes(options) {
|
|
24
|
+
async function handle(c) {
|
|
25
|
+
const tool = c.req.param("tool");
|
|
26
|
+
if (!tool)
|
|
27
|
+
return c.json({ error: "Missing tool name" }, 400);
|
|
28
|
+
let body;
|
|
29
|
+
try {
|
|
30
|
+
body = await c.req.json();
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
body = {};
|
|
34
|
+
}
|
|
35
|
+
const registry = createMcpToolRegistry({
|
|
36
|
+
context: {
|
|
37
|
+
...options.buildContext(c),
|
|
38
|
+
trips: options.buildTripsServices(c),
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
registerAdminTools(registry);
|
|
42
|
+
const result = await registry.dispatchTool(tool, body);
|
|
43
|
+
return c.json(result);
|
|
44
|
+
}
|
|
45
|
+
const routes = new Hono();
|
|
46
|
+
routes.post("/tools/:tool", handle);
|
|
47
|
+
return routes;
|
|
48
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyant-travel/trips",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.112.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -29,6 +29,16 @@
|
|
|
29
29
|
"import": "./dist/mcp-tools.js",
|
|
30
30
|
"default": "./dist/mcp-tools.js"
|
|
31
31
|
},
|
|
32
|
+
"./mcp": {
|
|
33
|
+
"types": "./dist/mcp-routes.d.ts",
|
|
34
|
+
"import": "./dist/mcp-routes.js",
|
|
35
|
+
"default": "./dist/mcp-routes.js"
|
|
36
|
+
},
|
|
37
|
+
"./checkout": {
|
|
38
|
+
"types": "./dist/checkout/index.d.ts",
|
|
39
|
+
"import": "./dist/checkout/index.js",
|
|
40
|
+
"default": "./dist/checkout/index.js"
|
|
41
|
+
},
|
|
32
42
|
"./cruise-extension": {
|
|
33
43
|
"types": "./dist/cruise-extension.d.ts",
|
|
34
44
|
"import": "./dist/cruise-extension.js",
|
|
@@ -51,9 +61,10 @@
|
|
|
51
61
|
"hono": "^4.12.10",
|
|
52
62
|
"zod": "^4.3.6",
|
|
53
63
|
"@voyant-travel/core": "^0.109.0",
|
|
54
|
-
"@voyant-travel/catalog": "^0.
|
|
64
|
+
"@voyant-travel/catalog": "^0.119.0",
|
|
55
65
|
"@voyant-travel/db": "^0.108.1",
|
|
56
|
-
"@voyant-travel/
|
|
66
|
+
"@voyant-travel/finance": "^0.121.0",
|
|
67
|
+
"@voyant-travel/hono": "^0.111.0"
|
|
57
68
|
},
|
|
58
69
|
"devDependencies": {
|
|
59
70
|
"typescript": "^6.0.2",
|