@voyantjs/flights 0.19.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/README.md +98 -0
- package/dist/contract/adapter.d.ts +121 -0
- package/dist/contract/adapter.d.ts.map +1 -0
- package/dist/contract/adapter.js +43 -0
- package/dist/contract/types.d.ts +222 -0
- package/dist/contract/types.d.ts.map +1 -0
- package/dist/contract/types.js +33 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/orchestration/fan-out.d.ts +81 -0
- package/dist/orchestration/fan-out.d.ts.map +1 -0
- package/dist/orchestration/fan-out.js +132 -0
- package/dist/orchestration/fan-out.test.d.ts +2 -0
- package/dist/orchestration/fan-out.test.d.ts.map +1 -0
- package/dist/orchestration/fan-out.test.js +237 -0
- package/dist/orchestration/fingerprint.d.ts +20 -0
- package/dist/orchestration/fingerprint.d.ts.map +1 -0
- package/dist/orchestration/fingerprint.js +22 -0
- package/dist/orchestration/fingerprint.test.d.ts +2 -0
- package/dist/orchestration/fingerprint.test.d.ts.map +1 -0
- package/dist/orchestration/fingerprint.test.js +91 -0
- package/dist/reference/contract.d.ts +90 -0
- package/dist/reference/contract.d.ts.map +1 -0
- package/dist/reference/contract.js +26 -0
- package/dist/reference/local-postgres.d.ts +390 -0
- package/dist/reference/local-postgres.d.ts.map +1 -0
- package/dist/reference/local-postgres.js +194 -0
- package/dist/reference/static-bundle.d.ts +29 -0
- package/dist/reference/static-bundle.d.ts.map +1 -0
- package/dist/reference/static-bundle.js +83 -0
- package/dist/reference/static-bundle.test.d.ts +2 -0
- package/dist/reference/static-bundle.test.d.ts.map +1 -0
- package/dist/reference/static-bundle.test.js +75 -0
- package/dist/snapshot.d.ts +50 -0
- package/dist/snapshot.d.ts.map +1 -0
- package/dist/snapshot.js +65 -0
- package/dist/snapshot.test.d.ts +2 -0
- package/dist/snapshot.test.d.ts.map +1 -0
- package/dist/snapshot.test.js +96 -0
- package/package.json +95 -0
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# @voyantjs/flights
|
|
2
|
+
|
|
3
|
+
Phase 3 of the catalog plane. The flights vertical — a partial-adoption module
|
|
4
|
+
for live-API flight search and booking.
|
|
5
|
+
|
|
6
|
+
See [`docs/architecture/catalog-flights-architecture.md`](../../docs/architecture/catalog-flights-architecture.md)
|
|
7
|
+
for the full design.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @voyantjs/flights
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## What's in the box
|
|
16
|
+
|
|
17
|
+
- **`./contract/types`** — `FlightOffer`, `FlightOrder`, `FlightSegment`,
|
|
18
|
+
`FlightSearchRequest`, `FlightBookRequest`, capability ids, `paymentIntent`
|
|
19
|
+
discriminated union. Shapes mirror voyant-cloud's `connect-flight-contract`
|
|
20
|
+
so adapters are portable across `voyant-cloud` and Voyant Catalog.
|
|
21
|
+
- **`./contract/adapter`** — `FlightConnectorAdapter` interface (5 core methods
|
|
22
|
+
+ capability declarations). Provider-agnostic; implementations come from
|
|
23
|
+
Voyant Connect, third-party providers, or operator-built adapters.
|
|
24
|
+
- **`./orchestration/fingerprint`** — Itinerary fingerprint helper. Two
|
|
25
|
+
providers selling the same flight produce identical fingerprints.
|
|
26
|
+
- **`./orchestration/fan-out`** — Multi-connection fan-out search:
|
|
27
|
+
parallel `searchFlights` across all of an operator's flight connections,
|
|
28
|
+
per-provider timeout + circuit breaker, dedupe by itinerary fingerprint,
|
|
29
|
+
merged result with `cheapest` + `alternates[]`.
|
|
30
|
+
- **`./snapshot`** — Booking-time snapshot capture. Builds a
|
|
31
|
+
`CaptureSnapshotInput` for the catalog plane's `captureSnapshot` /
|
|
32
|
+
`captureSnapshotGraph` from a flight `FlightOffer` + `FlightOrder` pair.
|
|
33
|
+
- **`./reference/contract`** — `ReferenceDataProvider` contract (airlines,
|
|
34
|
+
airports, aircraft). Implementable at any layer.
|
|
35
|
+
- **`./reference/local-postgres`** — Reference data from plain Postgres
|
|
36
|
+
tables in the operator's own database. **No external service, no network
|
|
37
|
+
call.** The simplest deployment option.
|
|
38
|
+
- **`./reference/static-bundle`** — Reference data from a bundled JSON / CSV.
|
|
39
|
+
|
|
40
|
+
## Phase relationship
|
|
41
|
+
|
|
42
|
+
Phase 3 is independent of Phase 2 (RAG). Either can ship first; both build on
|
|
43
|
+
Phase 1 (`@voyantjs/catalog`).
|
|
44
|
+
|
|
45
|
+
Flights opt **in** to:
|
|
46
|
+
- Booking snapshot graph (the most important participation)
|
|
47
|
+
- Provenance shape
|
|
48
|
+
- Webhook events
|
|
49
|
+
- Source disconnection lifecycle
|
|
50
|
+
|
|
51
|
+
Flights opt **out** of:
|
|
52
|
+
- Search index projection (live fan-out replaces it)
|
|
53
|
+
- Editorial overlays (no marketing copy on a flight)
|
|
54
|
+
- Embeddings / RAG (Phase 2 explicitly excludes flights)
|
|
55
|
+
- Pricing tiers (built into the multi-connection fan-out itself)
|
|
56
|
+
- Drift detection (live by definition)
|
|
57
|
+
|
|
58
|
+
## Usage
|
|
59
|
+
|
|
60
|
+
### Multi-connection search
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { fanOutFlightSearch } from "@voyantjs/flights/orchestration/fan-out"
|
|
64
|
+
|
|
65
|
+
const result = await fanOutFlightSearch({
|
|
66
|
+
adapters: [hiskyAdapter, amadeusAdapter, charterConsolidatorAdapter],
|
|
67
|
+
request: {
|
|
68
|
+
slices: [
|
|
69
|
+
{ origin: "LHR", destination: "JFK", departureDate: "2026-10-15" },
|
|
70
|
+
{ origin: "JFK", destination: "LHR", departureDate: "2026-10-22" },
|
|
71
|
+
],
|
|
72
|
+
passengers: { adults: 2 },
|
|
73
|
+
cabin: "economy",
|
|
74
|
+
},
|
|
75
|
+
perConnectionTimeoutMs: 5000,
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
// result.offers — merged offers across all connections, deduped by
|
|
79
|
+
// itinerary fingerprint, sorted by cheapest price ascending.
|
|
80
|
+
// result.perConnection — status + latency per connection.
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Reference data — operator's own Postgres tables
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import {
|
|
87
|
+
createLocalPostgresReferenceProvider,
|
|
88
|
+
createReferenceDataTables,
|
|
89
|
+
} from "@voyantjs/flights/reference/local-postgres"
|
|
90
|
+
|
|
91
|
+
// Schema lives in the operator's own DB. No external service required.
|
|
92
|
+
const reference = createLocalPostgresReferenceProvider({ db })
|
|
93
|
+
|
|
94
|
+
const ba = await reference.getAirline("BA")
|
|
95
|
+
// → { iataCode: "BA", icaoCode: "BAW", name: "British Airways", country: "GB" }
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
See `docs/architecture/catalog-flights-architecture.md` for the full design.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `FlightConnectorAdapter` contract — the seam through which any flight
|
|
3
|
+
* provider integrates with Voyant.
|
|
4
|
+
*
|
|
5
|
+
* Five core methods every adapter must implement; capability-gated
|
|
6
|
+
* methods exist as optional members on the interface and stub with
|
|
7
|
+
* `CAPABILITY_NOT_SUPPORTED` if the adapter doesn't declare them.
|
|
8
|
+
*
|
|
9
|
+
* Implementations come from anywhere — Voyant Connect, a wholesaler's own
|
|
10
|
+
* engineering team, a cruise line direct API, an operator-built GDS
|
|
11
|
+
* connector, a third-party integrator. No implementer is privileged.
|
|
12
|
+
*
|
|
13
|
+
* See `docs/architecture/catalog-flights-architecture.md` §3.
|
|
14
|
+
*/
|
|
15
|
+
import type { FlightBookRequest, FlightCapability, FlightOffer, FlightOrder, FlightSearchRequest } from "./types.js";
|
|
16
|
+
/**
|
|
17
|
+
* Context passed to every adapter call. Identifies the connection and
|
|
18
|
+
* carries credentials, optional point-of-sale, tracing identifiers.
|
|
19
|
+
*/
|
|
20
|
+
export interface FlightAdapterContext {
|
|
21
|
+
connectionId: string;
|
|
22
|
+
credentials?: Record<string, string>;
|
|
23
|
+
/** Operator's IATA office id / pseudo-city / point-of-sale, when applicable. */
|
|
24
|
+
pointOfSale?: string;
|
|
25
|
+
correlationId?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface FlightSearchResponse {
|
|
28
|
+
offers: FlightOffer[];
|
|
29
|
+
/** Provider-specific data, opaque to the consumer. */
|
|
30
|
+
providerData?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
export interface FlightPriceRequest {
|
|
33
|
+
offerId: string;
|
|
34
|
+
/** Some providers require the offer payload echoed back to re-price. */
|
|
35
|
+
offer?: FlightOffer;
|
|
36
|
+
}
|
|
37
|
+
export interface FlightPriceResponse {
|
|
38
|
+
offer: FlightOffer;
|
|
39
|
+
/** Whether the offer's price/availability is still valid for booking. */
|
|
40
|
+
valid: boolean;
|
|
41
|
+
/** When `valid: false`, why the offer was invalidated. */
|
|
42
|
+
invalidReason?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface FlightBookResponse {
|
|
45
|
+
order: FlightOrder;
|
|
46
|
+
}
|
|
47
|
+
export interface FlightGetOrderResponse {
|
|
48
|
+
order: FlightOrder;
|
|
49
|
+
}
|
|
50
|
+
export interface FlightCancelResponse {
|
|
51
|
+
order: FlightOrder;
|
|
52
|
+
refundedAmount?: {
|
|
53
|
+
amount: string;
|
|
54
|
+
currency: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export type FlightCancelReason = "customer_request" | "schedule_change" | "operational" | "fraud";
|
|
58
|
+
/**
|
|
59
|
+
* Capability declaration returned by the adapter at registration time.
|
|
60
|
+
* The orchestration layer reads `capabilities` to route requests and to
|
|
61
|
+
* fail fast on unsupported operations.
|
|
62
|
+
*/
|
|
63
|
+
export interface FlightAdapterCapabilities {
|
|
64
|
+
/** Provider identifier — e.g. `"hisky"`, `"amadeus"`, `"duffel"`, `"sabre"`, `"travelport-ndc"`. */
|
|
65
|
+
provider: string;
|
|
66
|
+
/** Capabilities declared by this connection. */
|
|
67
|
+
declared: FlightCapability[];
|
|
68
|
+
/**
|
|
69
|
+
* Maximum slices per search request supported. Many providers cap at
|
|
70
|
+
* 1 (single-carrier point-to-point), 2 (round-trip), or 4-6 (multi-city).
|
|
71
|
+
*/
|
|
72
|
+
maxSlicesPerSearch?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Default per-source timeout hint for the orchestration layer.
|
|
75
|
+
*/
|
|
76
|
+
defaultTimeoutMs?: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The flight connector contract. Five core methods + optional capability-
|
|
80
|
+
* gated methods. Adapters that don't support a capability either omit the
|
|
81
|
+
* method or have it throw `CAPABILITY_NOT_SUPPORTED`.
|
|
82
|
+
*/
|
|
83
|
+
export interface FlightConnectorAdapter {
|
|
84
|
+
readonly capabilities: FlightAdapterCapabilities;
|
|
85
|
+
/** Search flights matching the request's slices + passengers + cabin. */
|
|
86
|
+
searchFlights(ctx: FlightAdapterContext, request: FlightSearchRequest): Promise<FlightSearchResponse>;
|
|
87
|
+
/** Re-price an offer immediately before booking. */
|
|
88
|
+
priceOffer(ctx: FlightAdapterContext, request: FlightPriceRequest): Promise<FlightPriceResponse>;
|
|
89
|
+
/**
|
|
90
|
+
* Book the flight. Behavior depends on `paymentIntent`:
|
|
91
|
+
* - `hold` → returns order with status `confirmed`; caller must call
|
|
92
|
+
* `ticketOrder` later (capability-gated).
|
|
93
|
+
* - `card` / `ticket_on_credit` → returns order with status `ticketed`.
|
|
94
|
+
*/
|
|
95
|
+
bookFlight(ctx: FlightAdapterContext, request: FlightBookRequest): Promise<FlightBookResponse>;
|
|
96
|
+
/** Get an order by id (for status checks, post-book operations). */
|
|
97
|
+
getOrder(ctx: FlightAdapterContext, orderId: string): Promise<FlightGetOrderResponse>;
|
|
98
|
+
/** Cancel an order. */
|
|
99
|
+
cancelOrder(ctx: FlightAdapterContext, orderId: string, reason?: FlightCancelReason): Promise<FlightCancelResponse>;
|
|
100
|
+
/** `flight/holds` — promote a held order to ticketed. */
|
|
101
|
+
ticketOrder?(ctx: FlightAdapterContext, orderId: string): Promise<FlightGetOrderResponse>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Standard error code for capability-gated methods that aren't supported
|
|
105
|
+
* by the adapter. Mirrors voyant-cloud's convention so behavior is
|
|
106
|
+
* portable across runtimes.
|
|
107
|
+
*/
|
|
108
|
+
export declare const CAPABILITY_NOT_SUPPORTED: "CAPABILITY_NOT_SUPPORTED";
|
|
109
|
+
export declare class FlightCapabilityNotSupportedError extends Error {
|
|
110
|
+
readonly provider: string;
|
|
111
|
+
readonly capability: FlightCapability;
|
|
112
|
+
readonly operation: string;
|
|
113
|
+
readonly code: "CAPABILITY_NOT_SUPPORTED";
|
|
114
|
+
constructor(provider: string, capability: FlightCapability, operation: string);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Helper for adapters that want to short-circuit at the start of a method
|
|
118
|
+
* when a required capability isn't declared.
|
|
119
|
+
*/
|
|
120
|
+
export declare function requireCapability(capabilities: FlightAdapterCapabilities, capability: FlightCapability, operation: string): void;
|
|
121
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/contract/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,mBAAmB,EACpB,MAAM,YAAY,CAAA;AAEnB;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpC,gFAAgF;IAChF,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;A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CAAA;IAEhC,oDAAoD;IACpD,UAAU,CAAC,GAAG,EAAE,oBAAoB,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;IAEhG;;;;;OAKG;IACH,UAAU,CAAC,GAAG,EAAE,oBAAoB,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAE9F,oEAAoE;IACpE,QAAQ,CAAC,GAAG,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAA;IAErF,uBAAuB;IACvB,WAAW,CACT,GAAG,EAAE,oBAAoB,EACzB,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,CAAA;IAOhC,yDAAyD;IACzD,WAAW,CAAC,CAAC,GAAG,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAA;CAC1F;AAED;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAG,0BAAmC,CAAA;AAE3E,qBAAa,iCAAkC,SAAQ,KAAK;aAGxC,QAAQ,EAAE,MAAM;aAChB,UAAU,EAAE,gBAAgB;aAC5B,SAAS,EAAE,MAAM;IAJnC,QAAQ,CAAC,IAAI,6BAA2B;gBAEtB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,gBAAgB,EAC5B,SAAS,EAAE,MAAM;CAQpC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,yBAAyB,EACvC,UAAU,EAAE,gBAAgB,EAC5B,SAAS,EAAE,MAAM,GAChB,IAAI,CAIN"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `FlightConnectorAdapter` contract — the seam through which any flight
|
|
3
|
+
* provider integrates with Voyant.
|
|
4
|
+
*
|
|
5
|
+
* Five core methods every adapter must implement; capability-gated
|
|
6
|
+
* methods exist as optional members on the interface and stub with
|
|
7
|
+
* `CAPABILITY_NOT_SUPPORTED` if the adapter doesn't declare them.
|
|
8
|
+
*
|
|
9
|
+
* Implementations come from anywhere — Voyant Connect, a wholesaler's own
|
|
10
|
+
* engineering team, a cruise line direct API, an operator-built GDS
|
|
11
|
+
* connector, a third-party integrator. No implementer is privileged.
|
|
12
|
+
*
|
|
13
|
+
* See `docs/architecture/catalog-flights-architecture.md` §3.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Standard error code for capability-gated methods that aren't supported
|
|
17
|
+
* by the adapter. Mirrors voyant-cloud's convention so behavior is
|
|
18
|
+
* portable across runtimes.
|
|
19
|
+
*/
|
|
20
|
+
export const CAPABILITY_NOT_SUPPORTED = "CAPABILITY_NOT_SUPPORTED";
|
|
21
|
+
export class FlightCapabilityNotSupportedError extends Error {
|
|
22
|
+
provider;
|
|
23
|
+
capability;
|
|
24
|
+
operation;
|
|
25
|
+
code = CAPABILITY_NOT_SUPPORTED;
|
|
26
|
+
constructor(provider, capability, operation) {
|
|
27
|
+
super(`Flight provider "${provider}" does not declare capability "${capability}" (operation: ${operation}). ` +
|
|
28
|
+
`Either configure the request to skip this operation or register a connector that supports it.`);
|
|
29
|
+
this.provider = provider;
|
|
30
|
+
this.capability = capability;
|
|
31
|
+
this.operation = operation;
|
|
32
|
+
this.name = "FlightCapabilityNotSupportedError";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Helper for adapters that want to short-circuit at the start of a method
|
|
37
|
+
* when a required capability isn't declared.
|
|
38
|
+
*/
|
|
39
|
+
export function requireCapability(capabilities, capability, operation) {
|
|
40
|
+
if (!capabilities.declared.includes(capability)) {
|
|
41
|
+
throw new FlightCapabilityNotSupportedError(capabilities.provider, capability, operation);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flight contract types — shapes mirror voyant-cloud's `connect-flight-contract`
|
|
3
|
+
* so adapters are portable across Voyant Cloud and Voyant Catalog deployments.
|
|
4
|
+
*
|
|
5
|
+
* These are the load-bearing data structures: `FlightSegment`, `Itinerary`,
|
|
6
|
+
* `FlightOffer`, `FlightOrder`, `FlightSearchRequest`, `FlightBookRequest`,
|
|
7
|
+
* the `paymentIntent` discriminated union, and the capability id namespace.
|
|
8
|
+
*
|
|
9
|
+
* **Drift policy:** when voyant-cloud's `connect-flight-contract` evolves,
|
|
10
|
+
* mirror the additive changes here. Breaking changes flow through a
|
|
11
|
+
* coordinated release across both packages.
|
|
12
|
+
*
|
|
13
|
+
* See `docs/architecture/catalog-flights-architecture.md` §3.
|
|
14
|
+
*/
|
|
15
|
+
/** Cabin class. Standard IATA-aligned vocabulary. */
|
|
16
|
+
export type CabinClass = "economy" | "premium_economy" | "business" | "first";
|
|
17
|
+
/** Passenger type. Affects fare lookup and ticketing rules. */
|
|
18
|
+
export type PassengerType = "adult" | "child" | "infant" | "senior" | "youth";
|
|
19
|
+
/** Currency + amount. */
|
|
20
|
+
export interface Money {
|
|
21
|
+
amount: string;
|
|
22
|
+
currency: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* One segment of an itinerary — from departure airport to arrival airport
|
|
26
|
+
* on a specific carrier + flight number.
|
|
27
|
+
*/
|
|
28
|
+
export interface FlightSegment {
|
|
29
|
+
segmentId: string;
|
|
30
|
+
carrierCode: string;
|
|
31
|
+
flightNumber: string;
|
|
32
|
+
/** Operating carrier when different from the marketing carrier. */
|
|
33
|
+
operatingCarrierCode?: string;
|
|
34
|
+
operatingFlightNumber?: string;
|
|
35
|
+
departure: {
|
|
36
|
+
iataCode: string;
|
|
37
|
+
terminal?: string;
|
|
38
|
+
at: string;
|
|
39
|
+
};
|
|
40
|
+
arrival: {
|
|
41
|
+
iataCode: string;
|
|
42
|
+
terminal?: string;
|
|
43
|
+
at: string;
|
|
44
|
+
};
|
|
45
|
+
duration?: string;
|
|
46
|
+
aircraft?: string;
|
|
47
|
+
cabin: CabinClass;
|
|
48
|
+
fareClass?: string;
|
|
49
|
+
fareBasis?: string;
|
|
50
|
+
status?: string;
|
|
51
|
+
/** Provider-specific data — opaque round-trip. */
|
|
52
|
+
providerData?: Record<string, unknown>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* One itinerary (journey leg) — a sequence of segments. Round-trip and
|
|
56
|
+
* multi-city offers have multiple itineraries.
|
|
57
|
+
*/
|
|
58
|
+
export interface Itinerary {
|
|
59
|
+
segments: FlightSegment[];
|
|
60
|
+
duration?: string;
|
|
61
|
+
}
|
|
62
|
+
/** Per-passenger fare breakdown line. */
|
|
63
|
+
export interface FareBreakdown {
|
|
64
|
+
passengerType: PassengerType;
|
|
65
|
+
passengerCount: number;
|
|
66
|
+
baseFare: Money;
|
|
67
|
+
taxes: Money;
|
|
68
|
+
fees?: Money;
|
|
69
|
+
total: Money;
|
|
70
|
+
fareFamily?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A priced flight proposition. Returned by `searchFlights`; passed back to
|
|
74
|
+
* `priceOffer` and `bookFlight`. Always vertical-specific — never collapse
|
|
75
|
+
* into a generic `Offer` (per architecture §1.1 and `UBIQUITOUS_LANGUAGE.md`).
|
|
76
|
+
*/
|
|
77
|
+
export interface FlightOffer {
|
|
78
|
+
offerId: string;
|
|
79
|
+
/** Source identifier — typically the connection id or adapter slug. */
|
|
80
|
+
source: string;
|
|
81
|
+
itineraries: Itinerary[];
|
|
82
|
+
fareBreakdowns: FareBreakdown[];
|
|
83
|
+
totalPrice: Money;
|
|
84
|
+
validatingCarrier?: string;
|
|
85
|
+
/** ISO 8601 — when the offer expires (provider may refuse to book after). */
|
|
86
|
+
expiresAt?: string;
|
|
87
|
+
/** ISO 8601 — last ticketing date. */
|
|
88
|
+
lastTicketingDate?: string;
|
|
89
|
+
instantTicketing?: boolean;
|
|
90
|
+
/** Provider-specific data — opaque round-trip. */
|
|
91
|
+
providerData?: Record<string, unknown>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* One slice of a search request. Slice count determines trip type:
|
|
95
|
+
* - 1 slice → one-way
|
|
96
|
+
* - 2 slices → round-trip
|
|
97
|
+
* - 3+ → multi-city / open-jaw
|
|
98
|
+
*/
|
|
99
|
+
export interface FlightSlice {
|
|
100
|
+
origin: string;
|
|
101
|
+
destination: string;
|
|
102
|
+
departureDate: string;
|
|
103
|
+
departureTimeWindow?: {
|
|
104
|
+
earliest?: string;
|
|
105
|
+
latest?: string;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export interface PassengerCounts {
|
|
109
|
+
adults: number;
|
|
110
|
+
children?: number;
|
|
111
|
+
infants?: number;
|
|
112
|
+
}
|
|
113
|
+
export interface FlightSearchRequest {
|
|
114
|
+
slices: FlightSlice[];
|
|
115
|
+
passengers: PassengerCounts;
|
|
116
|
+
cabin?: CabinClass;
|
|
117
|
+
searchOptions?: {
|
|
118
|
+
directOnly?: boolean;
|
|
119
|
+
maxStops?: number;
|
|
120
|
+
minConnectionMinutes?: number;
|
|
121
|
+
includeCarriers?: string[];
|
|
122
|
+
excludeCarriers?: string[];
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Intent-driven booking — caller declares what they want, system honors
|
|
127
|
+
* or rejects per the adapter's declared capabilities. Default if omitted:
|
|
128
|
+
* `{ type: "hold" }`.
|
|
129
|
+
*/
|
|
130
|
+
export type PaymentIntent = {
|
|
131
|
+
type: "hold";
|
|
132
|
+
} | {
|
|
133
|
+
type: "card";
|
|
134
|
+
token: string;
|
|
135
|
+
cardholderName?: string;
|
|
136
|
+
billingAddress?: BillingAddress;
|
|
137
|
+
} | {
|
|
138
|
+
type: "ticket_on_credit";
|
|
139
|
+
iataCode?: string;
|
|
140
|
+
};
|
|
141
|
+
export interface BillingAddress {
|
|
142
|
+
line1: string;
|
|
143
|
+
line2?: string;
|
|
144
|
+
city: string;
|
|
145
|
+
region?: string;
|
|
146
|
+
postalCode?: string;
|
|
147
|
+
countryCode: string;
|
|
148
|
+
}
|
|
149
|
+
export interface FlightPassenger {
|
|
150
|
+
passengerId: string;
|
|
151
|
+
type: PassengerType;
|
|
152
|
+
givenNames: string;
|
|
153
|
+
surname: string;
|
|
154
|
+
birthDate: string;
|
|
155
|
+
gender?: "M" | "F" | "X";
|
|
156
|
+
email?: string;
|
|
157
|
+
phone?: string;
|
|
158
|
+
documents?: TravelDocument[];
|
|
159
|
+
}
|
|
160
|
+
export interface TravelDocument {
|
|
161
|
+
type: "passport" | "national_id" | "visa";
|
|
162
|
+
number: string;
|
|
163
|
+
countryOfIssue: string;
|
|
164
|
+
countryOfNationality?: string;
|
|
165
|
+
expiryDate?: string;
|
|
166
|
+
}
|
|
167
|
+
export interface FlightBookRequest {
|
|
168
|
+
offerId: string;
|
|
169
|
+
/** Provider-specific re-priced offer payload, when the adapter requires it. */
|
|
170
|
+
offer?: FlightOffer;
|
|
171
|
+
passengers: FlightPassenger[];
|
|
172
|
+
contact?: {
|
|
173
|
+
email?: string;
|
|
174
|
+
phone?: string;
|
|
175
|
+
};
|
|
176
|
+
paymentIntent?: PaymentIntent;
|
|
177
|
+
}
|
|
178
|
+
export type FlightOrderStatus = "pending" | "confirmed" | "ticketed" | "cancelled" | "failed";
|
|
179
|
+
export interface FlightTicket {
|
|
180
|
+
ticketNumber: string;
|
|
181
|
+
passengerId: string;
|
|
182
|
+
segmentIds: string[];
|
|
183
|
+
status?: string;
|
|
184
|
+
}
|
|
185
|
+
export interface FlightOrder {
|
|
186
|
+
orderId: string;
|
|
187
|
+
/** PNR / record locator. */
|
|
188
|
+
pnr?: string;
|
|
189
|
+
status: FlightOrderStatus;
|
|
190
|
+
offer: FlightOffer;
|
|
191
|
+
passengers: FlightPassenger[];
|
|
192
|
+
contact?: {
|
|
193
|
+
email?: string;
|
|
194
|
+
phone?: string;
|
|
195
|
+
};
|
|
196
|
+
tickets?: FlightTicket[];
|
|
197
|
+
totalPrice: Money;
|
|
198
|
+
/** ISO 8601 — deadline before the hold expires (held orders only). */
|
|
199
|
+
paymentDeadline?: string;
|
|
200
|
+
createdAt: string;
|
|
201
|
+
updatedAt?: string;
|
|
202
|
+
/** Provider-specific data — opaque round-trip. */
|
|
203
|
+
providerData?: Record<string, unknown>;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Capability ids declared per connection. Adapters that don't declare a
|
|
207
|
+
* capability stub the corresponding method with `CAPABILITY_NOT_SUPPORTED`.
|
|
208
|
+
*/
|
|
209
|
+
export declare const FLIGHT_CAPABILITIES: {
|
|
210
|
+
readonly HOLDS: "flight/holds";
|
|
211
|
+
readonly SEATMAP: "flight/seatmap";
|
|
212
|
+
readonly SEAT_SELECTION: "flight/seat-selection";
|
|
213
|
+
readonly ANCILLARIES: "flight/ancillaries";
|
|
214
|
+
readonly CHECKIN: "flight/checkin";
|
|
215
|
+
readonly EXCHANGE: "flight/exchange";
|
|
216
|
+
readonly REFUND: "flight/refund";
|
|
217
|
+
readonly VOID: "flight/void";
|
|
218
|
+
readonly SSR: "flight/ssr";
|
|
219
|
+
readonly BRANDED_FARES: "flight/branded-fares";
|
|
220
|
+
};
|
|
221
|
+
export type FlightCapability = (typeof FLIGHT_CAPABILITIES)[keyof typeof FLIGHT_CAPABILITIES];
|
|
222
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/contract/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,qDAAqD;AACrD,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,iBAAiB,GAAG,UAAU,GAAG,OAAO,CAAA;AAE7E,+DAA+D;AAC/D,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAA;AAE7E,yBAAyB;AACzB,MAAM,WAAW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|
+
* Flight contract types — shapes mirror voyant-cloud's `connect-flight-contract`
|
|
3
|
+
* so adapters are portable across Voyant Cloud and Voyant Catalog deployments.
|
|
4
|
+
*
|
|
5
|
+
* These are the load-bearing data structures: `FlightSegment`, `Itinerary`,
|
|
6
|
+
* `FlightOffer`, `FlightOrder`, `FlightSearchRequest`, `FlightBookRequest`,
|
|
7
|
+
* the `paymentIntent` discriminated union, and the capability id namespace.
|
|
8
|
+
*
|
|
9
|
+
* **Drift policy:** when voyant-cloud's `connect-flight-contract` evolves,
|
|
10
|
+
* mirror the additive changes here. Breaking changes flow through a
|
|
11
|
+
* coordinated release across both packages.
|
|
12
|
+
*
|
|
13
|
+
* See `docs/architecture/catalog-flights-architecture.md` §3.
|
|
14
|
+
*/
|
|
15
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
16
|
+
// Capability ids
|
|
17
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
18
|
+
/**
|
|
19
|
+
* Capability ids declared per connection. Adapters that don't declare a
|
|
20
|
+
* capability stub the corresponding method with `CAPABILITY_NOT_SUPPORTED`.
|
|
21
|
+
*/
|
|
22
|
+
export const FLIGHT_CAPABILITIES = {
|
|
23
|
+
HOLDS: "flight/holds",
|
|
24
|
+
SEATMAP: "flight/seatmap",
|
|
25
|
+
SEAT_SELECTION: "flight/seat-selection",
|
|
26
|
+
ANCILLARIES: "flight/ancillaries",
|
|
27
|
+
CHECKIN: "flight/checkin",
|
|
28
|
+
EXCHANGE: "flight/exchange",
|
|
29
|
+
REFUND: "flight/refund",
|
|
30
|
+
VOID: "flight/void",
|
|
31
|
+
SSR: "flight/ssr",
|
|
32
|
+
BRANDED_FARES: "flight/branded-fares",
|
|
33
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { CAPABILITY_NOT_SUPPORTED, type FlightAdapterCapabilities, type FlightAdapterContext, type FlightBookResponse, type FlightCancelReason, type FlightCancelResponse, FlightCapabilityNotSupportedError, type FlightConnectorAdapter, type FlightGetOrderResponse, type FlightPriceRequest, type FlightPriceResponse, type FlightSearchResponse, requireCapability, } from "./contract/adapter.js";
|
|
2
|
+
export * from "./contract/types.js";
|
|
3
|
+
export { type ConnectionResult, type ConnectionSearchStatus, type FanOutFlightSearchOptions, type FanOutFlightSearchResult, fanOutFlightSearch, type MergedFlightOffer, } from "./orchestration/fan-out.js";
|
|
4
|
+
export { itineraryFingerprint } from "./orchestration/fingerprint.js";
|
|
5
|
+
export { type Aircraft, type Airline, type Airport, dedupeCodes, type ReferenceDataCapabilities, type ReferenceDataProvider, } from "./reference/contract.js";
|
|
6
|
+
export { createLocalPostgresReferenceProvider, type LocalPostgresReferenceProviderOptions, referenceAircraft, referenceAirlines, referenceAirports, } from "./reference/local-postgres.js";
|
|
7
|
+
export { createStaticBundleReferenceProvider, type StaticBundleProviderOptions, type StaticBundleReferenceData, } from "./reference/static-bundle.js";
|
|
8
|
+
export { type BuildFlightSnapshotInputOptions, buildFlightSnapshotInput, } from "./snapshot.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,wBAAwB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,iCAAiC,EACjC,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,iBAAiB,GAClB,MAAM,uBAAuB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,kBAAkB,EAClB,KAAK,iBAAiB,GACvB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AAErE,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,WAAW,EACX,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,GAC3B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,oCAAoC,EACpC,KAAK,qCAAqC,EAC1C,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EACL,mCAAmC,EACnC,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,GAC/B,MAAM,8BAA8B,CAAA;AAErC,OAAO,EACL,KAAK,+BAA+B,EACpC,wBAAwB,GACzB,MAAM,eAAe,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Flight contract types — offers, orders, segments, search, booking.
|
|
2
|
+
// FlightConnectorAdapter contract.
|
|
3
|
+
export { CAPABILITY_NOT_SUPPORTED, FlightCapabilityNotSupportedError, requireCapability, } from "./contract/adapter.js";
|
|
4
|
+
export * from "./contract/types.js";
|
|
5
|
+
export { fanOutFlightSearch, } from "./orchestration/fan-out.js";
|
|
6
|
+
// Orchestration — fingerprinting + multi-connection fan-out.
|
|
7
|
+
export { itineraryFingerprint } from "./orchestration/fingerprint.js";
|
|
8
|
+
// ReferenceDataProvider — swappable provider for global reference data.
|
|
9
|
+
export { dedupeCodes, } from "./reference/contract.js";
|
|
10
|
+
export { createLocalPostgresReferenceProvider, referenceAircraft, referenceAirlines, referenceAirports, } from "./reference/local-postgres.js";
|
|
11
|
+
export { createStaticBundleReferenceProvider, } from "./reference/static-bundle.js";
|
|
12
|
+
// Snapshot capture for booking-time integration with the catalog plane.
|
|
13
|
+
export { buildFlightSnapshotInput, } from "./snapshot.js";
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-connection fan-out search.
|
|
3
|
+
*
|
|
4
|
+
* Parallel `searchFlights` across all of an operator's flight connections
|
|
5
|
+
* with per-connection timeouts, partial-success handling, and merge by
|
|
6
|
+
* itinerary fingerprint. Returns a merged result set with the cheapest
|
|
7
|
+
* offer per itinerary as the primary rank, alternates from other
|
|
8
|
+
* connections beneath it, and a per-connection status map.
|
|
9
|
+
*
|
|
10
|
+
* Implements voyant-cloud's `MergedFlightOffer` shape so consumers see the
|
|
11
|
+
* same result format regardless of where the orchestration runs.
|
|
12
|
+
*
|
|
13
|
+
* See `docs/architecture/catalog-flights-architecture.md` §4.
|
|
14
|
+
*/
|
|
15
|
+
import type { FlightAdapterContext, FlightConnectorAdapter } from "../contract/adapter.js";
|
|
16
|
+
import type { FlightOffer, FlightSearchRequest } from "../contract/types.js";
|
|
17
|
+
/**
|
|
18
|
+
* One source's result — the primary offer plus alternates from other
|
|
19
|
+
* connections selling the same flight.
|
|
20
|
+
*/
|
|
21
|
+
export interface MergedFlightOffer {
|
|
22
|
+
itineraryFingerprint: string;
|
|
23
|
+
/** Cheapest offer for this itinerary across all responding connections. */
|
|
24
|
+
cheapest: FlightOffer;
|
|
25
|
+
/** Other offers for the same itinerary, sorted by total price ascending. */
|
|
26
|
+
alternates: FlightOffer[];
|
|
27
|
+
/** Connection ids that returned an offer for this itinerary. */
|
|
28
|
+
sourceConnectionIds: string[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Per-connection status, returned alongside the merged offers so callers
|
|
32
|
+
* can surface "X provider timed out" without losing the rest of the results.
|
|
33
|
+
*/
|
|
34
|
+
export type ConnectionSearchStatus = "ok" | "timeout" | "error" | "not_found" | "capability_missing";
|
|
35
|
+
export interface ConnectionResult {
|
|
36
|
+
connectionId: string;
|
|
37
|
+
status: ConnectionSearchStatus;
|
|
38
|
+
count: number;
|
|
39
|
+
latencyMs: number;
|
|
40
|
+
errorMessage?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface FanOutFlightSearchOptions {
|
|
43
|
+
/** Adapters to fan out across. Each carries its own connectionId in capabilities. */
|
|
44
|
+
adapters: ReadonlyArray<{
|
|
45
|
+
connectionId: string;
|
|
46
|
+
adapter: FlightConnectorAdapter;
|
|
47
|
+
/** Optional override for the adapter context per connection. */
|
|
48
|
+
context?: Partial<FlightAdapterContext>;
|
|
49
|
+
}>;
|
|
50
|
+
request: FlightSearchRequest;
|
|
51
|
+
/**
|
|
52
|
+
* Per-connection timeout. Default 5000ms. One slow provider doesn't
|
|
53
|
+
* tank the whole search — its slot is reported as `timeout` and other
|
|
54
|
+
* results return on time.
|
|
55
|
+
*/
|
|
56
|
+
perConnectionTimeoutMs?: number;
|
|
57
|
+
/**
|
|
58
|
+
* Optional caller-supplied limit on the merged offer count. The fan-out
|
|
59
|
+
* still queries every connection in full; this caps the merged result.
|
|
60
|
+
*/
|
|
61
|
+
limit?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface FanOutFlightSearchResult {
|
|
64
|
+
offers: MergedFlightOffer[];
|
|
65
|
+
perConnection: ConnectionResult[];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Fan out a flight search across an operator's connections, parallelized
|
|
69
|
+
* with per-connection timeout, then merge by itinerary fingerprint.
|
|
70
|
+
*
|
|
71
|
+
* Partial-success semantics: connections that time out / error / report
|
|
72
|
+
* capability-missing are flagged in `perConnection`; the orchestration
|
|
73
|
+
* still returns whatever responding connections produced.
|
|
74
|
+
*/
|
|
75
|
+
export declare function fanOutFlightSearch(options: FanOutFlightSearchOptions): Promise<FanOutFlightSearchResult>;
|
|
76
|
+
interface ConnectionFanOutOk {
|
|
77
|
+
connectionId: string;
|
|
78
|
+
offers: FlightOffer[];
|
|
79
|
+
}
|
|
80
|
+
export type { ConnectionFanOutOk };
|
|
81
|
+
//# sourceMappingURL=fan-out.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fan-out.d.ts","sourceRoot":"","sources":["../../src/orchestration/fan-out.ts"],"names":[],"mappings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