@voyant-travel/charters 0.117.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 +16 -0
- package/dist/adapters/index.d.ts +254 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +16 -0
- package/dist/adapters/memoize.d.ts +28 -0
- package/dist/adapters/memoize.d.ts.map +1 -0
- package/dist/adapters/memoize.js +121 -0
- package/dist/adapters/mock.d.ts +50 -0
- package/dist/adapters/mock.d.ts.map +1 -0
- package/dist/adapters/mock.js +194 -0
- package/dist/adapters/registry.d.ts +24 -0
- package/dist/adapters/registry.d.ts.map +1 -0
- package/dist/adapters/registry.js +40 -0
- package/dist/booking-extension.d.ts +895 -0
- package/dist/booking-extension.d.ts.map +1 -0
- package/dist/booking-extension.js +339 -0
- package/dist/catalog-policy.d.ts +23 -0
- package/dist/catalog-policy.d.ts.map +1 -0
- package/dist/catalog-policy.js +400 -0
- package/dist/content-shape.d.ts +5 -0
- package/dist/content-shape.d.ts.map +1 -0
- package/dist/content-shape.js +13 -0
- package/dist/draft-shape.d.ts +29 -0
- package/dist/draft-shape.d.ts.map +1 -0
- package/dist/draft-shape.js +63 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +55 -0
- package/dist/lib/key.d.ts +22 -0
- package/dist/lib/key.d.ts.map +1 -0
- package/dist/lib/key.js +24 -0
- package/dist/routes-public.d.ts +785 -0
- package/dist/routes-public.d.ts.map +1 -0
- package/dist/routes-public.js +234 -0
- package/dist/routes.d.ts +1744 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +543 -0
- package/dist/schema-core.d.ts +815 -0
- package/dist/schema-core.d.ts.map +1 -0
- package/dist/schema-core.js +98 -0
- package/dist/schema-itinerary.d.ts +239 -0
- package/dist/schema-itinerary.d.ts.map +1 -0
- package/dist/schema-itinerary.js +30 -0
- package/dist/schema-pricing.d.ts +385 -0
- package/dist/schema-pricing.d.ts.map +1 -0
- package/dist/schema-pricing.js +62 -0
- package/dist/schema-shared.d.ts +8 -0
- package/dist/schema-shared.d.ts.map +1 -0
- package/dist/schema-shared.js +37 -0
- package/dist/schema-sourced-content.d.ts +253 -0
- package/dist/schema-sourced-content.d.ts.map +1 -0
- package/dist/schema-sourced-content.js +44 -0
- package/dist/schema-yachts.d.ts +367 -0
- package/dist/schema-yachts.d.ts.map +1 -0
- package/dist/schema-yachts.js +30 -0
- package/dist/schema.d.ts +8 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +7 -0
- package/dist/service-bookings-helpers.d.ts +20 -0
- package/dist/service-bookings-helpers.d.ts.map +1 -0
- package/dist/service-bookings-helpers.js +67 -0
- package/dist/service-bookings-local.d.ts +5 -0
- package/dist/service-bookings-local.d.ts.map +1 -0
- package/dist/service-bookings-local.js +177 -0
- package/dist/service-bookings-types.d.ts +88 -0
- package/dist/service-bookings-types.d.ts.map +1 -0
- package/dist/service-bookings-types.js +1 -0
- package/dist/service-bookings.d.ts +36 -0
- package/dist/service-bookings.d.ts.map +1 -0
- package/dist/service-bookings.js +267 -0
- package/dist/service-catalog-plane.d.ts +58 -0
- package/dist/service-catalog-plane.d.ts.map +1 -0
- package/dist/service-catalog-plane.js +145 -0
- package/dist/service-content-synthesizer.d.ts +42 -0
- package/dist/service-content-synthesizer.d.ts.map +1 -0
- package/dist/service-content-synthesizer.js +122 -0
- package/dist/service-content.d.ts +43 -0
- package/dist/service-content.d.ts.map +1 -0
- package/dist/service-content.js +248 -0
- package/dist/service-myba.d.ts +85 -0
- package/dist/service-myba.d.ts.map +1 -0
- package/dist/service-myba.js +88 -0
- package/dist/service-pricing.d.ts +64 -0
- package/dist/service-pricing.d.ts.map +1 -0
- package/dist/service-pricing.js +167 -0
- package/dist/service.d.ts +131 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +279 -0
- package/dist/validation-core.d.ts +152 -0
- package/dist/validation-core.d.ts.map +1 -0
- package/dist/validation-core.js +66 -0
- package/dist/validation-itinerary.d.ts +43 -0
- package/dist/validation-itinerary.d.ts.map +1 -0
- package/dist/validation-itinerary.js +19 -0
- package/dist/validation-pricing.d.ts +103 -0
- package/dist/validation-pricing.d.ts.map +1 -0
- package/dist/validation-pricing.js +28 -0
- package/dist/validation-shared.d.ts +61 -0
- package/dist/validation-shared.d.ts.map +1 -0
- package/dist/validation-shared.js +60 -0
- package/dist/validation-yachts.d.ts +76 -0
- package/dist/validation-yachts.d.ts.map +1 -0
- package/dist/validation-yachts.js +36 -0
- package/dist/validation.d.ts +6 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +5 -0
- package/package.json +116 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory CharterAdapter for tests and templates that need a working
|
|
3
|
+
* external source without a real upstream.
|
|
4
|
+
*
|
|
5
|
+
* Seed via the `add*` / `set*` methods; queries against the seeded data work
|
|
6
|
+
* exactly like a real adapter would. Booking commits return synthesized
|
|
7
|
+
* confirmation refs and increment per-instance counters.
|
|
8
|
+
*/
|
|
9
|
+
import type { CharterAdapter, CreateExternalPerSuiteBookingInput, CreateExternalWholeYachtBookingInput, ExternalBookingResult, ExternalCharterProduct, ExternalCharterScheduleDay, ExternalCharterSuite, ExternalCharterVoyage, ExternalCharterYacht, ListEntriesOptions, ListEntriesResult, SourceRef } from "./index.js";
|
|
10
|
+
export type MockCharterAdapterOptions = {
|
|
11
|
+
name?: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
/** Auto-fail every nth call to surface upstream-error handling in tests. */
|
|
14
|
+
failEveryNthCall?: number;
|
|
15
|
+
};
|
|
16
|
+
export declare class MockCharterAdapter implements CharterAdapter {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly version: string;
|
|
19
|
+
private readonly productsByRef;
|
|
20
|
+
private readonly yachtsByRef;
|
|
21
|
+
private readonly perSuiteBookingResults;
|
|
22
|
+
private readonly wholeYachtBookingResults;
|
|
23
|
+
callCount: number;
|
|
24
|
+
perSuiteBookingCount: number;
|
|
25
|
+
wholeYachtBookingCount: number;
|
|
26
|
+
private readonly failEveryNthCall;
|
|
27
|
+
constructor(options?: MockCharterAdapterOptions);
|
|
28
|
+
addProduct(product: ExternalCharterProduct, voyages?: ExternalCharterVoyage[]): void;
|
|
29
|
+
addVoyage(productRef: SourceRef, voyage: ExternalCharterVoyage): void;
|
|
30
|
+
addYacht(yacht: ExternalCharterYacht): void;
|
|
31
|
+
setVoyageSuites(voyageRef: SourceRef, suites: ExternalCharterSuite[]): void;
|
|
32
|
+
setVoyageSchedule(voyageRef: SourceRef, days: ExternalCharterScheduleDay[]): void;
|
|
33
|
+
/** Pre-program a per-suite booking response for the next matching commit. */
|
|
34
|
+
setPerSuiteBookingResult(voyageRef: SourceRef, suiteRef: SourceRef, result: ExternalBookingResult): void;
|
|
35
|
+
/** Pre-program a whole-yacht booking response for the next matching commit. */
|
|
36
|
+
setWholeYachtBookingResult(voyageRef: SourceRef, result: ExternalBookingResult): void;
|
|
37
|
+
private tickAndCheck;
|
|
38
|
+
private resolveYachtName;
|
|
39
|
+
private lowestSuitePriceFor;
|
|
40
|
+
listEntries(options?: ListEntriesOptions): Promise<ListEntriesResult>;
|
|
41
|
+
fetchProduct(ref: SourceRef): Promise<ExternalCharterProduct | null>;
|
|
42
|
+
fetchVoyage(ref: SourceRef): Promise<ExternalCharterVoyage | null>;
|
|
43
|
+
fetchVoyageSuites(ref: SourceRef): Promise<ExternalCharterSuite[]>;
|
|
44
|
+
fetchVoyageSchedule(ref: SourceRef): Promise<ExternalCharterScheduleDay[]>;
|
|
45
|
+
fetchYacht(ref: SourceRef): Promise<ExternalCharterYacht | null>;
|
|
46
|
+
listVoyagesForProduct(productRef: SourceRef): Promise<ExternalCharterVoyage[]>;
|
|
47
|
+
createPerSuiteBooking(input: CreateExternalPerSuiteBookingInput): Promise<ExternalBookingResult>;
|
|
48
|
+
createWholeYachtBooking(input: CreateExternalWholeYachtBookingInput): Promise<ExternalBookingResult>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=mock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/adapters/mock.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,kCAAkC,EAClC,oCAAoC,EACpC,qBAAqB,EACrB,sBAAsB,EAEtB,0BAA0B,EAC1B,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,SAAS,EACV,MAAM,YAAY,CAAA;AAEnB,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,4EAA4E;IAC5E,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B,CAAA;AAaD,qBAAa,kBAAmB,YAAW,cAAc;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAExB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAmC;IACjE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA0C;IACtE,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAA2C;IAClF,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAA2C;IAGpF,SAAS,SAAI;IACb,oBAAoB,SAAI;IACxB,sBAAsB,SAAI;IAC1B,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAQ;gBAE7B,OAAO,GAAE,yBAA8B;IAQnD,UAAU,CAAC,OAAO,EAAE,sBAAsB,EAAE,OAAO,GAAE,qBAAqB,EAAO,GAAG,IAAI;IAUxF,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,qBAAqB,GAAG,IAAI;IAMrE,QAAQ,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI;IAI3C,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,oBAAoB,EAAE,GAAG,IAAI;IAW3E,iBAAiB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,0BAA0B,EAAE,GAAG,IAAI;IAWjF,6EAA6E;IAC7E,wBAAwB,CACtB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,SAAS,EACnB,MAAM,EAAE,qBAAqB,GAC5B,IAAI;IAIP,+EAA+E;IAC/E,0BAA0B,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,qBAAqB,GAAG,IAAI;IAMrF,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,mBAAmB;IAiBrB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA4BzE,YAAY,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC;IAKpE,WAAW,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IASlE,iBAAiB,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;IASlE,mBAAmB,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,0BAA0B,EAAE,CAAC;IAS1E,UAAU,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAKhE,qBAAqB,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAK9E,qBAAqB,CACzB,KAAK,EAAE,kCAAkC,GACxC,OAAO,CAAC,qBAAqB,CAAC;IAa3B,uBAAuB,CAC3B,KAAK,EAAE,oCAAoC,GAC1C,OAAO,CAAC,qBAAqB,CAAC;CAUlC"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory CharterAdapter for tests and templates that need a working
|
|
3
|
+
* external source without a real upstream.
|
|
4
|
+
*
|
|
5
|
+
* Seed via the `add*` / `set*` methods; queries against the seeded data work
|
|
6
|
+
* exactly like a real adapter would. Booking commits return synthesized
|
|
7
|
+
* confirmation refs and increment per-instance counters.
|
|
8
|
+
*/
|
|
9
|
+
function refKey(ref) {
|
|
10
|
+
return `${ref.connectionId ?? "_"}|${ref.externalId}`;
|
|
11
|
+
}
|
|
12
|
+
export class MockCharterAdapter {
|
|
13
|
+
name;
|
|
14
|
+
version;
|
|
15
|
+
productsByRef = new Map();
|
|
16
|
+
yachtsByRef = new Map();
|
|
17
|
+
perSuiteBookingResults = new Map();
|
|
18
|
+
wholeYachtBookingResults = new Map();
|
|
19
|
+
// Telemetry — useful for assertions in tests.
|
|
20
|
+
callCount = 0;
|
|
21
|
+
perSuiteBookingCount = 0;
|
|
22
|
+
wholeYachtBookingCount = 0;
|
|
23
|
+
failEveryNthCall;
|
|
24
|
+
constructor(options = {}) {
|
|
25
|
+
this.name = options.name ?? "mock-charter";
|
|
26
|
+
this.version = options.version ?? "1.0.0";
|
|
27
|
+
this.failEveryNthCall = options.failEveryNthCall ?? 0;
|
|
28
|
+
}
|
|
29
|
+
// ---------- seeders ----------
|
|
30
|
+
addProduct(product, voyages = []) {
|
|
31
|
+
const key = refKey(product.sourceRef);
|
|
32
|
+
this.productsByRef.set(key, {
|
|
33
|
+
product,
|
|
34
|
+
voyages: [...voyages],
|
|
35
|
+
suitesByVoyage: new Map(),
|
|
36
|
+
scheduleByVoyage: new Map(),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
addVoyage(productRef, voyage) {
|
|
40
|
+
const seeded = this.productsByRef.get(refKey(productRef));
|
|
41
|
+
if (!seeded)
|
|
42
|
+
throw new Error(`MockCharterAdapter: product ${productRef.externalId} not seeded`);
|
|
43
|
+
seeded.voyages.push(voyage);
|
|
44
|
+
}
|
|
45
|
+
addYacht(yacht) {
|
|
46
|
+
this.yachtsByRef.set(refKey(yacht.sourceRef), yacht);
|
|
47
|
+
}
|
|
48
|
+
setVoyageSuites(voyageRef, suites) {
|
|
49
|
+
for (const seeded of this.productsByRef.values()) {
|
|
50
|
+
const match = seeded.voyages.find((v) => refKey(v.sourceRef) === refKey(voyageRef));
|
|
51
|
+
if (match) {
|
|
52
|
+
seeded.suitesByVoyage.set(refKey(voyageRef), suites);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
throw new Error(`MockCharterAdapter: voyage ${voyageRef.externalId} not seeded`);
|
|
57
|
+
}
|
|
58
|
+
setVoyageSchedule(voyageRef, days) {
|
|
59
|
+
for (const seeded of this.productsByRef.values()) {
|
|
60
|
+
const match = seeded.voyages.find((v) => refKey(v.sourceRef) === refKey(voyageRef));
|
|
61
|
+
if (match) {
|
|
62
|
+
seeded.scheduleByVoyage.set(refKey(voyageRef), days);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
throw new Error(`MockCharterAdapter: voyage ${voyageRef.externalId} not seeded`);
|
|
67
|
+
}
|
|
68
|
+
/** Pre-program a per-suite booking response for the next matching commit. */
|
|
69
|
+
setPerSuiteBookingResult(voyageRef, suiteRef, result) {
|
|
70
|
+
this.perSuiteBookingResults.set(`${refKey(voyageRef)}::${refKey(suiteRef)}`, result);
|
|
71
|
+
}
|
|
72
|
+
/** Pre-program a whole-yacht booking response for the next matching commit. */
|
|
73
|
+
setWholeYachtBookingResult(voyageRef, result) {
|
|
74
|
+
this.wholeYachtBookingResults.set(refKey(voyageRef), result);
|
|
75
|
+
}
|
|
76
|
+
// ---------- contract implementation ----------
|
|
77
|
+
tickAndCheck() {
|
|
78
|
+
this.callCount++;
|
|
79
|
+
if (this.failEveryNthCall > 0 && this.callCount % this.failEveryNthCall === 0) {
|
|
80
|
+
throw new Error(`MockCharterAdapter forced failure on call #${this.callCount}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
resolveYachtName(yachtRef) {
|
|
84
|
+
return this.yachtsByRef.get(refKey(yachtRef))?.name ?? null;
|
|
85
|
+
}
|
|
86
|
+
lowestSuitePriceFor(productKey, currency) {
|
|
87
|
+
const seeded = this.productsByRef.get(productKey);
|
|
88
|
+
if (!seeded)
|
|
89
|
+
return null;
|
|
90
|
+
let lowest = null;
|
|
91
|
+
for (const voyage of seeded.voyages) {
|
|
92
|
+
const suites = seeded.suitesByVoyage.get(refKey(voyage.sourceRef)) ?? [];
|
|
93
|
+
for (const suite of suites) {
|
|
94
|
+
const amount = suite.pricesByCurrency?.[currency];
|
|
95
|
+
if (!amount)
|
|
96
|
+
continue;
|
|
97
|
+
const value = Number.parseFloat(amount);
|
|
98
|
+
if (!Number.isFinite(value))
|
|
99
|
+
continue;
|
|
100
|
+
if (lowest === null || value < lowest)
|
|
101
|
+
lowest = value;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return lowest === null ? null : lowest.toFixed(2);
|
|
105
|
+
}
|
|
106
|
+
async listEntries(options = {}) {
|
|
107
|
+
this.tickAndCheck();
|
|
108
|
+
const limit = options.limit ?? 50;
|
|
109
|
+
const all = [];
|
|
110
|
+
for (const [key, seeded] of this.productsByRef.entries()) {
|
|
111
|
+
const sortedDates = seeded.voyages.map((v) => v.departureDate).sort();
|
|
112
|
+
// Mock browse currency is USD by default; real adapters can publish
|
|
113
|
+
// any currency the operator markets in.
|
|
114
|
+
const browseCurrency = "USD";
|
|
115
|
+
const lowest = this.lowestSuitePriceFor(key, browseCurrency);
|
|
116
|
+
all.push({
|
|
117
|
+
sourceRef: seeded.product.sourceRef,
|
|
118
|
+
name: seeded.product.name,
|
|
119
|
+
slug: seeded.product.slug,
|
|
120
|
+
lineName: seeded.product.lineName,
|
|
121
|
+
yachtName: seeded.product.defaultYachtRef
|
|
122
|
+
? this.resolveYachtName(seeded.product.defaultYachtRef)
|
|
123
|
+
: null,
|
|
124
|
+
earliestVoyage: sortedDates.at(0) ?? null,
|
|
125
|
+
latestVoyage: sortedDates.at(-1) ?? null,
|
|
126
|
+
lowestPriceAmount: lowest,
|
|
127
|
+
lowestPriceCurrency: lowest ? browseCurrency : null,
|
|
128
|
+
heroImageUrl: seeded.product.heroImageUrl ?? null,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return { entries: all.slice(0, limit) };
|
|
132
|
+
}
|
|
133
|
+
async fetchProduct(ref) {
|
|
134
|
+
this.tickAndCheck();
|
|
135
|
+
return this.productsByRef.get(refKey(ref))?.product ?? null;
|
|
136
|
+
}
|
|
137
|
+
async fetchVoyage(ref) {
|
|
138
|
+
this.tickAndCheck();
|
|
139
|
+
for (const seeded of this.productsByRef.values()) {
|
|
140
|
+
const match = seeded.voyages.find((v) => refKey(v.sourceRef) === refKey(ref));
|
|
141
|
+
if (match)
|
|
142
|
+
return match;
|
|
143
|
+
}
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
async fetchVoyageSuites(ref) {
|
|
147
|
+
this.tickAndCheck();
|
|
148
|
+
for (const seeded of this.productsByRef.values()) {
|
|
149
|
+
const suites = seeded.suitesByVoyage.get(refKey(ref));
|
|
150
|
+
if (suites)
|
|
151
|
+
return suites;
|
|
152
|
+
}
|
|
153
|
+
return [];
|
|
154
|
+
}
|
|
155
|
+
async fetchVoyageSchedule(ref) {
|
|
156
|
+
this.tickAndCheck();
|
|
157
|
+
for (const seeded of this.productsByRef.values()) {
|
|
158
|
+
const days = seeded.scheduleByVoyage.get(refKey(ref));
|
|
159
|
+
if (days)
|
|
160
|
+
return days;
|
|
161
|
+
}
|
|
162
|
+
return [];
|
|
163
|
+
}
|
|
164
|
+
async fetchYacht(ref) {
|
|
165
|
+
this.tickAndCheck();
|
|
166
|
+
return this.yachtsByRef.get(refKey(ref)) ?? null;
|
|
167
|
+
}
|
|
168
|
+
async listVoyagesForProduct(productRef) {
|
|
169
|
+
this.tickAndCheck();
|
|
170
|
+
return this.productsByRef.get(refKey(productRef))?.voyages ?? [];
|
|
171
|
+
}
|
|
172
|
+
async createPerSuiteBooking(input) {
|
|
173
|
+
this.tickAndCheck();
|
|
174
|
+
this.perSuiteBookingCount++;
|
|
175
|
+
const programmed = this.perSuiteBookingResults.get(`${refKey(input.voyageRef)}::${refKey(input.suiteRef)}`);
|
|
176
|
+
if (programmed)
|
|
177
|
+
return programmed;
|
|
178
|
+
return {
|
|
179
|
+
connectorBookingRef: `MOCK-CHT-${this.perSuiteBookingCount.toString().padStart(6, "0")}`,
|
|
180
|
+
connectorStatus: "confirmed",
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
async createWholeYachtBooking(input) {
|
|
184
|
+
this.tickAndCheck();
|
|
185
|
+
this.wholeYachtBookingCount++;
|
|
186
|
+
const programmed = this.wholeYachtBookingResults.get(refKey(input.voyageRef));
|
|
187
|
+
if (programmed)
|
|
188
|
+
return programmed;
|
|
189
|
+
return {
|
|
190
|
+
connectorBookingRef: `MOCK-WYC-${this.wholeYachtBookingCount.toString().padStart(6, "0")}`,
|
|
191
|
+
connectorStatus: "confirmed",
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-local registry of charter adapters.
|
|
3
|
+
*
|
|
4
|
+
* Templates register adapters at app startup:
|
|
5
|
+
*
|
|
6
|
+
* import { createConnectCharterAdapter } from "@voyant-travel/charters-adapter-connect"
|
|
7
|
+
* registerCharterAdapter(createConnectCharterAdapter({ apiKey: env.VOYANT_CONNECT_API_KEY }))
|
|
8
|
+
*
|
|
9
|
+
* The route layer resolves an adapter by `sourceProvider` (the prefix in the
|
|
10
|
+
* unified key `<provider>:<ref>`) before dispatching detail reads or external
|
|
11
|
+
* booking commits.
|
|
12
|
+
*
|
|
13
|
+
* The registry is intentionally a plain Map. There's no per-tenant scoping —
|
|
14
|
+
* each Voyant deployment is single-tenant. Tests reset state via
|
|
15
|
+
* `clearCharterAdapters()`.
|
|
16
|
+
*/
|
|
17
|
+
import type { CharterAdapter } from "./index.js";
|
|
18
|
+
export declare function registerCharterAdapter(adapter: CharterAdapter): void;
|
|
19
|
+
export declare function unregisterCharterAdapter(name: string): boolean;
|
|
20
|
+
export declare function clearCharterAdapters(): void;
|
|
21
|
+
export declare function resolveCharterAdapter(name: string): CharterAdapter | undefined;
|
|
22
|
+
export declare function listCharterAdapters(): CharterAdapter[];
|
|
23
|
+
export declare function hasCharterAdapter(name: string): boolean;
|
|
24
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/adapters/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAIhD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAQpE;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAE9E;AAED,wBAAgB,mBAAmB,IAAI,cAAc,EAAE,CAEtD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-local registry of charter adapters.
|
|
3
|
+
*
|
|
4
|
+
* Templates register adapters at app startup:
|
|
5
|
+
*
|
|
6
|
+
* import { createConnectCharterAdapter } from "@voyant-travel/charters-adapter-connect"
|
|
7
|
+
* registerCharterAdapter(createConnectCharterAdapter({ apiKey: env.VOYANT_CONNECT_API_KEY }))
|
|
8
|
+
*
|
|
9
|
+
* The route layer resolves an adapter by `sourceProvider` (the prefix in the
|
|
10
|
+
* unified key `<provider>:<ref>`) before dispatching detail reads or external
|
|
11
|
+
* booking commits.
|
|
12
|
+
*
|
|
13
|
+
* The registry is intentionally a plain Map. There's no per-tenant scoping —
|
|
14
|
+
* each Voyant deployment is single-tenant. Tests reset state via
|
|
15
|
+
* `clearCharterAdapters()`.
|
|
16
|
+
*/
|
|
17
|
+
const adapters = new Map();
|
|
18
|
+
export function registerCharterAdapter(adapter) {
|
|
19
|
+
if (!adapter.name)
|
|
20
|
+
throw new Error("Adapter must have a non-empty name");
|
|
21
|
+
if (adapters.has(adapter.name)) {
|
|
22
|
+
throw new Error(`Charter adapter '${adapter.name}' is already registered; call unregisterCharterAdapter first if you intend to replace it`);
|
|
23
|
+
}
|
|
24
|
+
adapters.set(adapter.name, adapter);
|
|
25
|
+
}
|
|
26
|
+
export function unregisterCharterAdapter(name) {
|
|
27
|
+
return adapters.delete(name);
|
|
28
|
+
}
|
|
29
|
+
export function clearCharterAdapters() {
|
|
30
|
+
adapters.clear();
|
|
31
|
+
}
|
|
32
|
+
export function resolveCharterAdapter(name) {
|
|
33
|
+
return adapters.get(name);
|
|
34
|
+
}
|
|
35
|
+
export function listCharterAdapters() {
|
|
36
|
+
return Array.from(adapters.values());
|
|
37
|
+
}
|
|
38
|
+
export function hasCharterAdapter(name) {
|
|
39
|
+
return adapters.has(name);
|
|
40
|
+
}
|