@voyantjs/flights-contracts 0.98.0 → 0.99.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/index.d.ts CHANGED
@@ -4,4 +4,5 @@ export * from "./contract/schemas.js";
4
4
  export * from "./contract/types.js";
5
5
  export * from "./reference/contract.js";
6
6
  export * from "./reference/static-bundle.js";
7
+ export * from "./snapshot.js";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,yBAAyB,CAAA;AACvC,cAAc,8BAA8B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,yBAAyB,CAAA;AACvC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,eAAe,CAAA"}
package/dist/index.js CHANGED
@@ -4,3 +4,4 @@ export * from "./contract/schemas.js";
4
4
  export * from "./contract/types.js";
5
5
  export * from "./reference/contract.js";
6
6
  export * from "./reference/static-bundle.js";
7
+ export * from "./snapshot.js";
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Booking-time snapshot capture for flight orders.
3
+ *
4
+ * Flights are a partial-adoption vertical: they participate in the catalog
5
+ * plane's snapshot graph but skip overlay / index / drift / RAG. This
6
+ * helper turns a `FlightOffer` + `FlightOrder` pair into a
7
+ * `CaptureSnapshotInput` ready for `captureSnapshot` /
8
+ * `captureSnapshotGraph`.
9
+ *
10
+ * Mirrors the per-vertical pattern (`buildProductSnapshotInput`,
11
+ * `buildCruiseSnapshotInput`, etc.) but skips the resolved-view step
12
+ * because flights have no overlay store.
13
+ *
14
+ * See `docs/architecture/catalog-flights-architecture.md` §5.1 for the
15
+ * full snapshot scope (frozen offer + order + segments + fare breakdown +
16
+ * pricing basis).
17
+ */
18
+ import type { CaptureSnapshotInput } from "@voyantjs/catalog-contracts/snapshot";
19
+ import type { FlightOffer, FlightOrder } from "./contract/types.js";
20
+ export interface BuildFlightSnapshotInputOptions {
21
+ /** The booked flight offer at booking time (frozen view). */
22
+ offer: FlightOffer;
23
+ /** The flight order returned by the adapter (PNR, ticket numbers, status). */
24
+ order: FlightOrder;
25
+ /** The source kind — typically `"voyant-connect"` or a direct adapter slug. */
26
+ sourceKind: string;
27
+ /** Source provider sub-identifier — e.g. `"hisky"`, `"amadeus"`. */
28
+ sourceProvider?: string;
29
+ /** The connection identifier the booking was placed against. */
30
+ sourceConnectionId?: string;
31
+ /** Optional override for the entity id; defaults to the adapter's `orderId`. */
32
+ entityId?: string;
33
+ }
34
+ /**
35
+ * Build a `CaptureSnapshotInput` from a flight offer + order. Use the
36
+ * result with `captureSnapshot` (single-flight bookings) or
37
+ * `captureSnapshotGraph` (composite bookings — flight inside a tour
38
+ * package, etc.).
39
+ *
40
+ * The `frozen_payload` carries the full FlightOffer and FlightOrder,
41
+ * structured as `{ offer, order }`, so refunds and post-book operations
42
+ * eight months later can read exactly what the customer paid for.
43
+ *
44
+ * The `pricing_basis` structured columns are populated from the offer's
45
+ * `totalPrice`. Taxes / fees / surcharges decomposition is left to the
46
+ * adapter — `FlightOffer` exposes `fareBreakdowns[]` per passenger which
47
+ * the caller can aggregate as needed and pass via `pricingBasis`.
48
+ */
49
+ export declare function buildFlightSnapshotInput(options: BuildFlightSnapshotInputOptions): Omit<CaptureSnapshotInput, "bookingId">;
50
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../src/snapshot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAgB,MAAM,sCAAsC,CAAA;AAE9F,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEnE,MAAM,WAAW,+BAA+B;IAC9C,6DAA6D;IAC7D,KAAK,EAAE,WAAW,CAAA;IAClB,8EAA8E;IAC9E,KAAK,EAAE,WAAW,CAAA;IAClB,+EAA+E;IAC/E,UAAU,EAAE,MAAM,CAAA;IAClB,oEAAoE;IACpE,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,gEAAgE;IAChE,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,+BAA+B,GACvC,IAAI,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAiCzC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Booking-time snapshot capture for flight orders.
3
+ *
4
+ * Flights are a partial-adoption vertical: they participate in the catalog
5
+ * plane's snapshot graph but skip overlay / index / drift / RAG. This
6
+ * helper turns a `FlightOffer` + `FlightOrder` pair into a
7
+ * `CaptureSnapshotInput` ready for `captureSnapshot` /
8
+ * `captureSnapshotGraph`.
9
+ *
10
+ * Mirrors the per-vertical pattern (`buildProductSnapshotInput`,
11
+ * `buildCruiseSnapshotInput`, etc.) but skips the resolved-view step
12
+ * because flights have no overlay store.
13
+ *
14
+ * See `docs/architecture/catalog-flights-architecture.md` §5.1 for the
15
+ * full snapshot scope (frozen offer + order + segments + fare breakdown +
16
+ * pricing basis).
17
+ */
18
+ /**
19
+ * Build a `CaptureSnapshotInput` from a flight offer + order. Use the
20
+ * result with `captureSnapshot` (single-flight bookings) or
21
+ * `captureSnapshotGraph` (composite bookings — flight inside a tour
22
+ * package, etc.).
23
+ *
24
+ * The `frozen_payload` carries the full FlightOffer and FlightOrder,
25
+ * structured as `{ offer, order }`, so refunds and post-book operations
26
+ * eight months later can read exactly what the customer paid for.
27
+ *
28
+ * The `pricing_basis` structured columns are populated from the offer's
29
+ * `totalPrice`. Taxes / fees / surcharges decomposition is left to the
30
+ * adapter — `FlightOffer` exposes `fareBreakdowns[]` per passenger which
31
+ * the caller can aggregate as needed and pass via `pricingBasis`.
32
+ */
33
+ export function buildFlightSnapshotInput(options) {
34
+ const { offer, order, sourceKind, sourceProvider, sourceConnectionId, entityId } = options;
35
+ const frozenPayload = {
36
+ offer,
37
+ order,
38
+ };
39
+ const pricingBasis = (() => {
40
+ const total = offer.totalPrice ?? order.totalPrice;
41
+ if (!total)
42
+ return undefined;
43
+ const baseAmount = Number.parseFloat(total.amount);
44
+ if (!Number.isFinite(baseAmount))
45
+ return undefined;
46
+ return {
47
+ base_amount: baseAmount,
48
+ taxes: 0, // adapter decomposes if it tracks taxes separately
49
+ fees: 0,
50
+ surcharges: 0,
51
+ currency: total.currency,
52
+ breakdown: { fareBreakdowns: offer.fareBreakdowns },
53
+ };
54
+ })();
55
+ return {
56
+ entityModule: "flights",
57
+ entityId: entityId ?? order.orderId,
58
+ sourceKind,
59
+ sourceProvider,
60
+ sourceConnectionId,
61
+ sourceRef: order.pnr ?? order.orderId,
62
+ frozenPayload,
63
+ pricingBasis,
64
+ };
65
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyantjs/flights-contracts",
3
- "version": "0.98.0",
3
+ "version": "0.99.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -38,6 +38,11 @@
38
38
  "types": "./dist/reference/static-bundle.d.ts",
39
39
  "import": "./dist/reference/static-bundle.js",
40
40
  "default": "./dist/reference/static-bundle.js"
41
+ },
42
+ "./snapshot": {
43
+ "types": "./dist/snapshot.d.ts",
44
+ "import": "./dist/snapshot.js",
45
+ "default": "./dist/snapshot.js"
41
46
  }
42
47
  },
43
48
  "files": [
@@ -47,7 +52,8 @@
47
52
  "access": "public"
48
53
  },
49
54
  "dependencies": {
50
- "zod": "^4.3.6"
55
+ "zod": "^4.3.6",
56
+ "@voyantjs/catalog-contracts": "0.99.0"
51
57
  },
52
58
  "devDependencies": {
53
59
  "typescript": "^6.0.2",