@voyant-travel/flights 0.119.2
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 +116 -0
- package/dist/contract/adapter.d.ts +2 -0
- package/dist/contract/adapter.d.ts.map +1 -0
- package/dist/contract/adapter.js +1 -0
- package/dist/contract/adapter.test.d.ts +2 -0
- package/dist/contract/adapter.test.d.ts.map +1 -0
- package/dist/contract/adapter.test.js +171 -0
- package/dist/contract/post-book-types.d.ts +2 -0
- package/dist/contract/post-book-types.d.ts.map +1 -0
- package/dist/contract/post-book-types.js +1 -0
- package/dist/contract/schemas.d.ts +2 -0
- package/dist/contract/schemas.d.ts.map +1 -0
- package/dist/contract/schemas.js +1 -0
- package/dist/contract/schemas.test.d.ts +2 -0
- package/dist/contract/schemas.test.d.ts.map +1 -0
- package/dist/contract/schemas.test.js +360 -0
- package/dist/contract/types.d.ts +2 -0
- package/dist/contract/types.d.ts.map +1 -0
- package/dist/contract/types.js +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -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 +271 -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 +2 -0
- package/dist/reference/contract.d.ts.map +1 -0
- package/dist/reference/contract.js +1 -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 +2 -0
- package/dist/reference/static-bundle.d.ts.map +1 -0
- package/dist/reference/static-bundle.js +1 -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 +2 -0
- package/dist/snapshot.d.ts.map +1 -0
- package/dist/snapshot.js +1 -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 +96 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.test.d.ts","sourceRoot":"","sources":["../src/snapshot.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { buildFlightSnapshotInput } from "./snapshot.js";
|
|
3
|
+
const sampleOffer = {
|
|
4
|
+
offerId: "ofr_abc",
|
|
5
|
+
source: "amadeus",
|
|
6
|
+
itineraries: [
|
|
7
|
+
{
|
|
8
|
+
segments: [
|
|
9
|
+
{
|
|
10
|
+
segmentId: "s1",
|
|
11
|
+
carrierCode: "BA",
|
|
12
|
+
flightNumber: "177",
|
|
13
|
+
departure: { iataCode: "LHR", at: "2026-10-15T11:00:00+00:00" },
|
|
14
|
+
arrival: { iataCode: "JFK", at: "2026-10-15T14:00:00-04:00" },
|
|
15
|
+
cabin: "economy",
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
fareBreakdowns: [
|
|
21
|
+
{
|
|
22
|
+
passengerType: "adult",
|
|
23
|
+
passengerCount: 1,
|
|
24
|
+
baseFare: { amount: "500", currency: "USD" },
|
|
25
|
+
taxes: { amount: "100", currency: "USD" },
|
|
26
|
+
total: { amount: "600", currency: "USD" },
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
totalPrice: { amount: "600", currency: "USD" },
|
|
30
|
+
};
|
|
31
|
+
const sampleOrder = {
|
|
32
|
+
orderId: "ord_xyz",
|
|
33
|
+
pnr: "ABCDEF",
|
|
34
|
+
status: "ticketed",
|
|
35
|
+
offer: sampleOffer,
|
|
36
|
+
passengers: [],
|
|
37
|
+
totalPrice: { amount: "600", currency: "USD" },
|
|
38
|
+
createdAt: "2026-09-01T12:00:00Z",
|
|
39
|
+
};
|
|
40
|
+
describe("buildFlightSnapshotInput", () => {
|
|
41
|
+
it("composes a CaptureSnapshotInput with frozen offer + order", () => {
|
|
42
|
+
const input = buildFlightSnapshotInput({
|
|
43
|
+
offer: sampleOffer,
|
|
44
|
+
order: sampleOrder,
|
|
45
|
+
sourceKind: "voyant-connect",
|
|
46
|
+
sourceProvider: "amadeus",
|
|
47
|
+
sourceConnectionId: "conn_xyz",
|
|
48
|
+
});
|
|
49
|
+
expect(input.entityModule).toBe("flights");
|
|
50
|
+
expect(input.entityId).toBe("ord_xyz");
|
|
51
|
+
expect(input.sourceKind).toBe("voyant-connect");
|
|
52
|
+
expect(input.sourceProvider).toBe("amadeus");
|
|
53
|
+
expect(input.sourceConnectionId).toBe("conn_xyz");
|
|
54
|
+
// sourceRef defaults to PNR when present
|
|
55
|
+
expect(input.sourceRef).toBe("ABCDEF");
|
|
56
|
+
});
|
|
57
|
+
it("falls back to orderId for sourceRef when PNR is missing", () => {
|
|
58
|
+
const orderNoPnr = { ...sampleOrder, pnr: undefined };
|
|
59
|
+
const input = buildFlightSnapshotInput({
|
|
60
|
+
offer: sampleOffer,
|
|
61
|
+
order: orderNoPnr,
|
|
62
|
+
sourceKind: "direct:hisky",
|
|
63
|
+
});
|
|
64
|
+
expect(input.sourceRef).toBe("ord_xyz");
|
|
65
|
+
});
|
|
66
|
+
it("populates structured pricing columns from offer.totalPrice", () => {
|
|
67
|
+
const input = buildFlightSnapshotInput({
|
|
68
|
+
offer: sampleOffer,
|
|
69
|
+
order: sampleOrder,
|
|
70
|
+
sourceKind: "owned",
|
|
71
|
+
});
|
|
72
|
+
expect(input.pricingBasis).toBeDefined();
|
|
73
|
+
expect(input.pricingBasis?.base_amount).toBe(600);
|
|
74
|
+
expect(input.pricingBasis?.currency).toBe("USD");
|
|
75
|
+
expect(input.pricingBasis?.breakdown).toEqual({
|
|
76
|
+
fareBreakdowns: sampleOffer.fareBreakdowns,
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
it("frozen_payload contains the full offer + order pair", () => {
|
|
80
|
+
const input = buildFlightSnapshotInput({
|
|
81
|
+
offer: sampleOffer,
|
|
82
|
+
order: sampleOrder,
|
|
83
|
+
sourceKind: "owned",
|
|
84
|
+
});
|
|
85
|
+
expect(input.frozenPayload).toEqual({ offer: sampleOffer, order: sampleOrder });
|
|
86
|
+
});
|
|
87
|
+
it("entityId can be overridden (e.g. for tour-package composite bookings)", () => {
|
|
88
|
+
const input = buildFlightSnapshotInput({
|
|
89
|
+
offer: sampleOffer,
|
|
90
|
+
order: sampleOrder,
|
|
91
|
+
sourceKind: "voyant-connect",
|
|
92
|
+
entityId: "custom_entity_xyz",
|
|
93
|
+
});
|
|
94
|
+
expect(input.entityId).toBe("custom_entity_xyz");
|
|
95
|
+
});
|
|
96
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voyant-travel/flights",
|
|
3
|
+
"version": "0.119.2",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./contract/types": {
|
|
13
|
+
"types": "./dist/contract/types.d.ts",
|
|
14
|
+
"import": "./dist/contract/types.js",
|
|
15
|
+
"default": "./dist/contract/types.js"
|
|
16
|
+
},
|
|
17
|
+
"./contract/adapter": {
|
|
18
|
+
"types": "./dist/contract/adapter.d.ts",
|
|
19
|
+
"import": "./dist/contract/adapter.js",
|
|
20
|
+
"default": "./dist/contract/adapter.js"
|
|
21
|
+
},
|
|
22
|
+
"./contract/schemas": {
|
|
23
|
+
"types": "./dist/contract/schemas.d.ts",
|
|
24
|
+
"import": "./dist/contract/schemas.js",
|
|
25
|
+
"default": "./dist/contract/schemas.js"
|
|
26
|
+
},
|
|
27
|
+
"./orchestration/fingerprint": {
|
|
28
|
+
"types": "./dist/orchestration/fingerprint.d.ts",
|
|
29
|
+
"import": "./dist/orchestration/fingerprint.js",
|
|
30
|
+
"default": "./dist/orchestration/fingerprint.js"
|
|
31
|
+
},
|
|
32
|
+
"./orchestration/fan-out": {
|
|
33
|
+
"types": "./dist/orchestration/fan-out.d.ts",
|
|
34
|
+
"import": "./dist/orchestration/fan-out.js",
|
|
35
|
+
"default": "./dist/orchestration/fan-out.js"
|
|
36
|
+
},
|
|
37
|
+
"./snapshot": {
|
|
38
|
+
"types": "./dist/snapshot.d.ts",
|
|
39
|
+
"import": "./dist/snapshot.js",
|
|
40
|
+
"default": "./dist/snapshot.js"
|
|
41
|
+
},
|
|
42
|
+
"./reference/contract": {
|
|
43
|
+
"types": "./dist/reference/contract.d.ts",
|
|
44
|
+
"import": "./dist/reference/contract.js",
|
|
45
|
+
"default": "./dist/reference/contract.js"
|
|
46
|
+
},
|
|
47
|
+
"./reference/local-postgres": {
|
|
48
|
+
"types": "./dist/reference/local-postgres.d.ts",
|
|
49
|
+
"import": "./dist/reference/local-postgres.js",
|
|
50
|
+
"default": "./dist/reference/local-postgres.js"
|
|
51
|
+
},
|
|
52
|
+
"./reference/static-bundle": {
|
|
53
|
+
"types": "./dist/reference/static-bundle.d.ts",
|
|
54
|
+
"import": "./dist/reference/static-bundle.js",
|
|
55
|
+
"default": "./dist/reference/static-bundle.js"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"voyant": {
|
|
59
|
+
"schema": "./reference/local-postgres",
|
|
60
|
+
"requiresSchemas": [
|
|
61
|
+
"@voyant-travel/db"
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
"files": [
|
|
65
|
+
"dist"
|
|
66
|
+
],
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"access": "public"
|
|
69
|
+
},
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"drizzle-orm": "^0.45.2",
|
|
72
|
+
"zod": "^4.3.6",
|
|
73
|
+
"@voyant-travel/db": "^0.108.0",
|
|
74
|
+
"@voyant-travel/flights-contracts": "^0.104.4",
|
|
75
|
+
"@voyant-travel/catalog": "^0.117.2"
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"typescript": "^6.0.2",
|
|
79
|
+
"vitest": "^4.1.2",
|
|
80
|
+
"@voyant-travel/voyant-typescript-config": "^0.1.0"
|
|
81
|
+
},
|
|
82
|
+
"repository": {
|
|
83
|
+
"type": "git",
|
|
84
|
+
"url": "https://github.com/voyant-travel/voyant.git",
|
|
85
|
+
"directory": "packages/flights"
|
|
86
|
+
},
|
|
87
|
+
"scripts": {
|
|
88
|
+
"typecheck": "tsc --noEmit",
|
|
89
|
+
"lint": "biome check src/",
|
|
90
|
+
"test": "vitest run",
|
|
91
|
+
"build": "tsc -p tsconfig.json",
|
|
92
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo"
|
|
93
|
+
},
|
|
94
|
+
"main": "./dist/index.js",
|
|
95
|
+
"types": "./dist/index.d.ts"
|
|
96
|
+
}
|