@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.
Files changed (41) hide show
  1. package/README.md +98 -0
  2. package/dist/contract/adapter.d.ts +121 -0
  3. package/dist/contract/adapter.d.ts.map +1 -0
  4. package/dist/contract/adapter.js +43 -0
  5. package/dist/contract/types.d.ts +222 -0
  6. package/dist/contract/types.d.ts.map +1 -0
  7. package/dist/contract/types.js +33 -0
  8. package/dist/index.d.ts +9 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +13 -0
  11. package/dist/orchestration/fan-out.d.ts +81 -0
  12. package/dist/orchestration/fan-out.d.ts.map +1 -0
  13. package/dist/orchestration/fan-out.js +132 -0
  14. package/dist/orchestration/fan-out.test.d.ts +2 -0
  15. package/dist/orchestration/fan-out.test.d.ts.map +1 -0
  16. package/dist/orchestration/fan-out.test.js +237 -0
  17. package/dist/orchestration/fingerprint.d.ts +20 -0
  18. package/dist/orchestration/fingerprint.d.ts.map +1 -0
  19. package/dist/orchestration/fingerprint.js +22 -0
  20. package/dist/orchestration/fingerprint.test.d.ts +2 -0
  21. package/dist/orchestration/fingerprint.test.d.ts.map +1 -0
  22. package/dist/orchestration/fingerprint.test.js +91 -0
  23. package/dist/reference/contract.d.ts +90 -0
  24. package/dist/reference/contract.d.ts.map +1 -0
  25. package/dist/reference/contract.js +26 -0
  26. package/dist/reference/local-postgres.d.ts +390 -0
  27. package/dist/reference/local-postgres.d.ts.map +1 -0
  28. package/dist/reference/local-postgres.js +194 -0
  29. package/dist/reference/static-bundle.d.ts +29 -0
  30. package/dist/reference/static-bundle.d.ts.map +1 -0
  31. package/dist/reference/static-bundle.js +83 -0
  32. package/dist/reference/static-bundle.test.d.ts +2 -0
  33. package/dist/reference/static-bundle.test.d.ts.map +1 -0
  34. package/dist/reference/static-bundle.test.js +75 -0
  35. package/dist/snapshot.d.ts +50 -0
  36. package/dist/snapshot.d.ts.map +1 -0
  37. package/dist/snapshot.js +65 -0
  38. package/dist/snapshot.test.d.ts +2 -0
  39. package/dist/snapshot.test.d.ts.map +1 -0
  40. package/dist/snapshot.test.js +96 -0
  41. package/package.json +95 -0
@@ -0,0 +1,390 @@
1
+ /**
2
+ * In-deployment local-Postgres `ReferenceDataProvider`.
3
+ *
4
+ * The simplest possible implementation: reference data lives as ordinary
5
+ * tables in the operator's own Voyant Postgres database. Population is
6
+ * a one-time seed migration / weekly batch refresh / CSV import — whatever
7
+ * suits the deployment. **No external service, no network call.**
8
+ *
9
+ * This is a fully valid first-party implementation, not a fallback. For
10
+ * many tour operators / DMCs, this is the right choice — they don't want
11
+ * a hosted dependency just for IATA lookups.
12
+ *
13
+ * The schema below is exposed as drizzle table definitions; operators can
14
+ * pull them into their `drizzle.config.ts` schema list to generate
15
+ * migrations, or apply the SQL directly.
16
+ *
17
+ * See `docs/architecture/catalog-flights-architecture.md` §6.2.
18
+ */
19
+ import type { AnyDrizzleDb } from "@voyantjs/db";
20
+ import type { ReferenceDataCapabilities, ReferenceDataProvider } from "./contract.js";
21
+ /**
22
+ * `reference_airlines` — IATA-code-keyed airline catalog. Populate from a
23
+ * public IATA dataset, a CSV import, or curated by the operator.
24
+ */
25
+ export declare const referenceAirlines: import("drizzle-orm/pg-core").PgTableWithColumns<{
26
+ name: "reference_airlines";
27
+ schema: undefined;
28
+ columns: {
29
+ iataCode: import("drizzle-orm/pg-core").PgColumn<{
30
+ name: "iata_code";
31
+ tableName: "reference_airlines";
32
+ dataType: "string";
33
+ columnType: "PgText";
34
+ data: string;
35
+ driverParam: string;
36
+ notNull: true;
37
+ hasDefault: false;
38
+ isPrimaryKey: true;
39
+ isAutoincrement: false;
40
+ hasRuntimeDefault: false;
41
+ enumValues: [string, ...string[]];
42
+ baseColumn: never;
43
+ identity: undefined;
44
+ generated: undefined;
45
+ }, {}, {}>;
46
+ icaoCode: import("drizzle-orm/pg-core").PgColumn<{
47
+ name: "icao_code";
48
+ tableName: "reference_airlines";
49
+ dataType: "string";
50
+ columnType: "PgText";
51
+ data: string;
52
+ driverParam: string;
53
+ notNull: false;
54
+ hasDefault: false;
55
+ isPrimaryKey: false;
56
+ isAutoincrement: false;
57
+ hasRuntimeDefault: false;
58
+ enumValues: [string, ...string[]];
59
+ baseColumn: never;
60
+ identity: undefined;
61
+ generated: undefined;
62
+ }, {}, {}>;
63
+ name: import("drizzle-orm/pg-core").PgColumn<{
64
+ name: "name";
65
+ tableName: "reference_airlines";
66
+ dataType: "string";
67
+ columnType: "PgText";
68
+ data: string;
69
+ driverParam: string;
70
+ notNull: true;
71
+ hasDefault: false;
72
+ isPrimaryKey: false;
73
+ isAutoincrement: false;
74
+ hasRuntimeDefault: false;
75
+ enumValues: [string, ...string[]];
76
+ baseColumn: never;
77
+ identity: undefined;
78
+ generated: undefined;
79
+ }, {}, {}>;
80
+ country: import("drizzle-orm/pg-core").PgColumn<{
81
+ name: "country";
82
+ tableName: "reference_airlines";
83
+ dataType: "string";
84
+ columnType: "PgText";
85
+ data: string;
86
+ driverParam: string;
87
+ notNull: false;
88
+ hasDefault: false;
89
+ isPrimaryKey: false;
90
+ isAutoincrement: false;
91
+ hasRuntimeDefault: false;
92
+ enumValues: [string, ...string[]];
93
+ baseColumn: never;
94
+ identity: undefined;
95
+ generated: undefined;
96
+ }, {}, {}>;
97
+ logoUrl: import("drizzle-orm/pg-core").PgColumn<{
98
+ name: "logo_url";
99
+ tableName: "reference_airlines";
100
+ dataType: "string";
101
+ columnType: "PgText";
102
+ data: string;
103
+ driverParam: string;
104
+ notNull: false;
105
+ hasDefault: false;
106
+ isPrimaryKey: false;
107
+ isAutoincrement: false;
108
+ hasRuntimeDefault: false;
109
+ enumValues: [string, ...string[]];
110
+ baseColumn: never;
111
+ identity: undefined;
112
+ generated: undefined;
113
+ }, {}, {}>;
114
+ alliance: import("drizzle-orm/pg-core").PgColumn<{
115
+ name: "alliance";
116
+ tableName: "reference_airlines";
117
+ dataType: "string";
118
+ columnType: "PgText";
119
+ data: string;
120
+ driverParam: string;
121
+ notNull: false;
122
+ hasDefault: false;
123
+ isPrimaryKey: false;
124
+ isAutoincrement: false;
125
+ hasRuntimeDefault: false;
126
+ enumValues: [string, ...string[]];
127
+ baseColumn: never;
128
+ identity: undefined;
129
+ generated: undefined;
130
+ }, {}, {}>;
131
+ };
132
+ dialect: "pg";
133
+ }>;
134
+ /**
135
+ * `reference_airports` — IATA-code-keyed airport catalog with geo + tz.
136
+ */
137
+ export declare const referenceAirports: import("drizzle-orm/pg-core").PgTableWithColumns<{
138
+ name: "reference_airports";
139
+ schema: undefined;
140
+ columns: {
141
+ iataCode: import("drizzle-orm/pg-core").PgColumn<{
142
+ name: "iata_code";
143
+ tableName: "reference_airports";
144
+ dataType: "string";
145
+ columnType: "PgText";
146
+ data: string;
147
+ driverParam: string;
148
+ notNull: true;
149
+ hasDefault: false;
150
+ isPrimaryKey: true;
151
+ isAutoincrement: false;
152
+ hasRuntimeDefault: false;
153
+ enumValues: [string, ...string[]];
154
+ baseColumn: never;
155
+ identity: undefined;
156
+ generated: undefined;
157
+ }, {}, {}>;
158
+ icaoCode: import("drizzle-orm/pg-core").PgColumn<{
159
+ name: "icao_code";
160
+ tableName: "reference_airports";
161
+ dataType: "string";
162
+ columnType: "PgText";
163
+ data: string;
164
+ driverParam: string;
165
+ notNull: false;
166
+ hasDefault: false;
167
+ isPrimaryKey: false;
168
+ isAutoincrement: false;
169
+ hasRuntimeDefault: false;
170
+ enumValues: [string, ...string[]];
171
+ baseColumn: never;
172
+ identity: undefined;
173
+ generated: undefined;
174
+ }, {}, {}>;
175
+ name: import("drizzle-orm/pg-core").PgColumn<{
176
+ name: "name";
177
+ tableName: "reference_airports";
178
+ dataType: "string";
179
+ columnType: "PgText";
180
+ data: string;
181
+ driverParam: string;
182
+ notNull: true;
183
+ hasDefault: false;
184
+ isPrimaryKey: false;
185
+ isAutoincrement: false;
186
+ hasRuntimeDefault: false;
187
+ enumValues: [string, ...string[]];
188
+ baseColumn: never;
189
+ identity: undefined;
190
+ generated: undefined;
191
+ }, {}, {}>;
192
+ city: import("drizzle-orm/pg-core").PgColumn<{
193
+ name: "city";
194
+ tableName: "reference_airports";
195
+ dataType: "string";
196
+ columnType: "PgText";
197
+ data: string;
198
+ driverParam: string;
199
+ notNull: true;
200
+ hasDefault: false;
201
+ isPrimaryKey: false;
202
+ isAutoincrement: false;
203
+ hasRuntimeDefault: false;
204
+ enumValues: [string, ...string[]];
205
+ baseColumn: never;
206
+ identity: undefined;
207
+ generated: undefined;
208
+ }, {}, {}>;
209
+ country: import("drizzle-orm/pg-core").PgColumn<{
210
+ name: "country";
211
+ tableName: "reference_airports";
212
+ dataType: "string";
213
+ columnType: "PgText";
214
+ data: string;
215
+ driverParam: string;
216
+ notNull: true;
217
+ hasDefault: false;
218
+ isPrimaryKey: false;
219
+ isAutoincrement: false;
220
+ hasRuntimeDefault: false;
221
+ enumValues: [string, ...string[]];
222
+ baseColumn: never;
223
+ identity: undefined;
224
+ generated: undefined;
225
+ }, {}, {}>;
226
+ timezone: import("drizzle-orm/pg-core").PgColumn<{
227
+ name: "timezone";
228
+ tableName: "reference_airports";
229
+ dataType: "string";
230
+ columnType: "PgText";
231
+ data: string;
232
+ driverParam: string;
233
+ notNull: false;
234
+ hasDefault: false;
235
+ isPrimaryKey: false;
236
+ isAutoincrement: false;
237
+ hasRuntimeDefault: false;
238
+ enumValues: [string, ...string[]];
239
+ baseColumn: never;
240
+ identity: undefined;
241
+ generated: undefined;
242
+ }, {}, {}>;
243
+ latitude: import("drizzle-orm/pg-core").PgColumn<{
244
+ name: "latitude";
245
+ tableName: "reference_airports";
246
+ dataType: "number";
247
+ columnType: "PgReal";
248
+ data: number;
249
+ driverParam: string | number;
250
+ notNull: false;
251
+ hasDefault: false;
252
+ isPrimaryKey: false;
253
+ isAutoincrement: false;
254
+ hasRuntimeDefault: false;
255
+ enumValues: undefined;
256
+ baseColumn: never;
257
+ identity: undefined;
258
+ generated: undefined;
259
+ }, {}, {}>;
260
+ longitude: import("drizzle-orm/pg-core").PgColumn<{
261
+ name: "longitude";
262
+ tableName: "reference_airports";
263
+ dataType: "number";
264
+ columnType: "PgReal";
265
+ data: number;
266
+ driverParam: string | number;
267
+ notNull: false;
268
+ hasDefault: false;
269
+ isPrimaryKey: false;
270
+ isAutoincrement: false;
271
+ hasRuntimeDefault: false;
272
+ enumValues: undefined;
273
+ baseColumn: never;
274
+ identity: undefined;
275
+ generated: undefined;
276
+ }, {}, {}>;
277
+ };
278
+ dialect: "pg";
279
+ }>;
280
+ /**
281
+ * `reference_aircraft` — IATA-code-keyed aircraft type catalog.
282
+ */
283
+ export declare const referenceAircraft: import("drizzle-orm/pg-core").PgTableWithColumns<{
284
+ name: "reference_aircraft";
285
+ schema: undefined;
286
+ columns: {
287
+ iataCode: import("drizzle-orm/pg-core").PgColumn<{
288
+ name: "iata_code";
289
+ tableName: "reference_aircraft";
290
+ dataType: "string";
291
+ columnType: "PgText";
292
+ data: string;
293
+ driverParam: string;
294
+ notNull: true;
295
+ hasDefault: false;
296
+ isPrimaryKey: true;
297
+ isAutoincrement: false;
298
+ hasRuntimeDefault: false;
299
+ enumValues: [string, ...string[]];
300
+ baseColumn: never;
301
+ identity: undefined;
302
+ generated: undefined;
303
+ }, {}, {}>;
304
+ icaoCode: import("drizzle-orm/pg-core").PgColumn<{
305
+ name: "icao_code";
306
+ tableName: "reference_aircraft";
307
+ dataType: "string";
308
+ columnType: "PgText";
309
+ data: string;
310
+ driverParam: string;
311
+ notNull: false;
312
+ hasDefault: false;
313
+ isPrimaryKey: false;
314
+ isAutoincrement: false;
315
+ hasRuntimeDefault: false;
316
+ enumValues: [string, ...string[]];
317
+ baseColumn: never;
318
+ identity: undefined;
319
+ generated: undefined;
320
+ }, {}, {}>;
321
+ name: import("drizzle-orm/pg-core").PgColumn<{
322
+ name: "name";
323
+ tableName: "reference_aircraft";
324
+ dataType: "string";
325
+ columnType: "PgText";
326
+ data: string;
327
+ driverParam: string;
328
+ notNull: true;
329
+ hasDefault: false;
330
+ isPrimaryKey: false;
331
+ isAutoincrement: false;
332
+ hasRuntimeDefault: false;
333
+ enumValues: [string, ...string[]];
334
+ baseColumn: never;
335
+ identity: undefined;
336
+ generated: undefined;
337
+ }, {}, {}>;
338
+ manufacturer: import("drizzle-orm/pg-core").PgColumn<{
339
+ name: "manufacturer";
340
+ tableName: "reference_aircraft";
341
+ dataType: "string";
342
+ columnType: "PgText";
343
+ data: string;
344
+ driverParam: string;
345
+ notNull: false;
346
+ hasDefault: false;
347
+ isPrimaryKey: false;
348
+ isAutoincrement: false;
349
+ hasRuntimeDefault: false;
350
+ enumValues: [string, ...string[]];
351
+ baseColumn: never;
352
+ identity: undefined;
353
+ generated: undefined;
354
+ }, {}, {}>;
355
+ typicalSeats: import("drizzle-orm/pg-core").PgColumn<{
356
+ name: "typical_seats";
357
+ tableName: "reference_aircraft";
358
+ dataType: "number";
359
+ columnType: "PgInteger";
360
+ data: number;
361
+ driverParam: string | number;
362
+ notNull: false;
363
+ hasDefault: false;
364
+ isPrimaryKey: false;
365
+ isAutoincrement: false;
366
+ hasRuntimeDefault: false;
367
+ enumValues: undefined;
368
+ baseColumn: never;
369
+ identity: undefined;
370
+ generated: undefined;
371
+ }, {}, {}>;
372
+ };
373
+ dialect: "pg";
374
+ }>;
375
+ export interface LocalPostgresReferenceProviderOptions {
376
+ db: AnyDrizzleDb;
377
+ /**
378
+ * Override capabilities — operators that don't populate aircraft data
379
+ * can declare `coversAircraft: false` to fail fast on aircraft lookups.
380
+ * Default: covers airlines + airports + aircraft, read-only at the
381
+ * provider layer (operators write directly to the tables out-of-band).
382
+ */
383
+ capabilities?: Partial<ReferenceDataCapabilities>;
384
+ }
385
+ /**
386
+ * Build a `ReferenceDataProvider` backed by ordinary Postgres tables in
387
+ * the operator's own Voyant database. No external service.
388
+ */
389
+ export declare function createLocalPostgresReferenceProvider(options: LocalPostgresReferenceProviderOptions): ReferenceDataProvider;
390
+ //# sourceMappingURL=local-postgres.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-postgres.d.ts","sourceRoot":"","sources":["../../src/reference/local-postgres.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAIhD,OAAO,KAAK,EAIV,yBAAyB,EACzB,qBAAqB,EACtB,MAAM,eAAe,CAAA;AAOtB;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAO5B,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS5B,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAM5B,CAAA;AAMF,MAAM,WAAW,qCAAqC;IACpD,EAAE,EAAE,YAAY,CAAA;IAChB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,CAAA;CAClD;AAYD;;;GAGG;AACH,wBAAgB,oCAAoC,CAClD,OAAO,EAAE,qCAAqC,GAC7C,qBAAqB,CAwFvB"}
@@ -0,0 +1,194 @@
1
+ /**
2
+ * In-deployment local-Postgres `ReferenceDataProvider`.
3
+ *
4
+ * The simplest possible implementation: reference data lives as ordinary
5
+ * tables in the operator's own Voyant Postgres database. Population is
6
+ * a one-time seed migration / weekly batch refresh / CSV import — whatever
7
+ * suits the deployment. **No external service, no network call.**
8
+ *
9
+ * This is a fully valid first-party implementation, not a fallback. For
10
+ * many tour operators / DMCs, this is the right choice — they don't want
11
+ * a hosted dependency just for IATA lookups.
12
+ *
13
+ * The schema below is exposed as drizzle table definitions; operators can
14
+ * pull them into their `drizzle.config.ts` schema list to generate
15
+ * migrations, or apply the SQL directly.
16
+ *
17
+ * See `docs/architecture/catalog-flights-architecture.md` §6.2.
18
+ */
19
+ import { eq, inArray } from "drizzle-orm";
20
+ import { integer, pgTable, real, text } from "drizzle-orm/pg-core";
21
+ import { dedupeCodes } from "./contract.js";
22
+ // ─────────────────────────────────────────────────────────────────────────────
23
+ // Drizzle table schemas
24
+ // ─────────────────────────────────────────────────────────────────────────────
25
+ /**
26
+ * `reference_airlines` — IATA-code-keyed airline catalog. Populate from a
27
+ * public IATA dataset, a CSV import, or curated by the operator.
28
+ */
29
+ export const referenceAirlines = pgTable("reference_airlines", {
30
+ iataCode: text("iata_code").primaryKey(),
31
+ icaoCode: text("icao_code"),
32
+ name: text("name").notNull(),
33
+ country: text("country"),
34
+ logoUrl: text("logo_url"),
35
+ alliance: text("alliance"),
36
+ });
37
+ /**
38
+ * `reference_airports` — IATA-code-keyed airport catalog with geo + tz.
39
+ */
40
+ export const referenceAirports = pgTable("reference_airports", {
41
+ iataCode: text("iata_code").primaryKey(),
42
+ icaoCode: text("icao_code"),
43
+ name: text("name").notNull(),
44
+ city: text("city").notNull(),
45
+ country: text("country").notNull(),
46
+ timezone: text("timezone"),
47
+ latitude: real("latitude"),
48
+ longitude: real("longitude"),
49
+ });
50
+ /**
51
+ * `reference_aircraft` — IATA-code-keyed aircraft type catalog.
52
+ */
53
+ export const referenceAircraft = pgTable("reference_aircraft", {
54
+ iataCode: text("iata_code").primaryKey(),
55
+ icaoCode: text("icao_code"),
56
+ name: text("name").notNull(),
57
+ manufacturer: text("manufacturer"),
58
+ typicalSeats: integer("typical_seats"),
59
+ });
60
+ const DEFAULT_CAPABILITIES = {
61
+ coversAirlines: true,
62
+ coversAirports: true,
63
+ coversAircraft: true,
64
+ coversCurrencies: false,
65
+ coversCountries: false,
66
+ isReadOnly: true, // provider doesn't expose writes; operator manages tables out-of-band
67
+ refreshCadence: "weekly", // operator-driven cadence; static if seeded once
68
+ };
69
+ /**
70
+ * Build a `ReferenceDataProvider` backed by ordinary Postgres tables in
71
+ * the operator's own Voyant database. No external service.
72
+ */
73
+ export function createLocalPostgresReferenceProvider(options) {
74
+ const { db } = options;
75
+ const capabilities = {
76
+ ...DEFAULT_CAPABILITIES,
77
+ ...options.capabilities,
78
+ };
79
+ return {
80
+ capabilities,
81
+ async getAirline(iataCode) {
82
+ if (!capabilities.coversAirlines)
83
+ return null;
84
+ const rows = await db
85
+ .select()
86
+ .from(referenceAirlines)
87
+ .where(eq(referenceAirlines.iataCode, iataCode))
88
+ .limit(1);
89
+ const row = rows[0];
90
+ return row ? rowToAirline(row) : null;
91
+ },
92
+ async getAirport(iataCode) {
93
+ if (!capabilities.coversAirports)
94
+ return null;
95
+ const rows = await db
96
+ .select()
97
+ .from(referenceAirports)
98
+ .where(eq(referenceAirports.iataCode, iataCode))
99
+ .limit(1);
100
+ const row = rows[0];
101
+ return row ? rowToAirport(row) : null;
102
+ },
103
+ async getAircraft(iataCode) {
104
+ if (!capabilities.coversAircraft)
105
+ return null;
106
+ const rows = await db
107
+ .select()
108
+ .from(referenceAircraft)
109
+ .where(eq(referenceAircraft.iataCode, iataCode))
110
+ .limit(1);
111
+ const row = rows[0];
112
+ return row ? rowToAircraft(row) : null;
113
+ },
114
+ async getAirlines(iataCodes) {
115
+ if (!capabilities.coversAirlines)
116
+ return new Map();
117
+ const codes = dedupeCodes(iataCodes);
118
+ if (codes.length === 0)
119
+ return new Map();
120
+ const rows = await db
121
+ .select()
122
+ .from(referenceAirlines)
123
+ .where(inArray(referenceAirlines.iataCode, codes));
124
+ const result = new Map();
125
+ for (const row of rows) {
126
+ result.set(row.iataCode, rowToAirline(row));
127
+ }
128
+ return result;
129
+ },
130
+ async getAirports(iataCodes) {
131
+ if (!capabilities.coversAirports)
132
+ return new Map();
133
+ const codes = dedupeCodes(iataCodes);
134
+ if (codes.length === 0)
135
+ return new Map();
136
+ const rows = await db
137
+ .select()
138
+ .from(referenceAirports)
139
+ .where(inArray(referenceAirports.iataCode, codes));
140
+ const result = new Map();
141
+ for (const row of rows) {
142
+ result.set(row.iataCode, rowToAirport(row));
143
+ }
144
+ return result;
145
+ },
146
+ async getAircraftBatch(iataCodes) {
147
+ if (!capabilities.coversAircraft)
148
+ return new Map();
149
+ const codes = dedupeCodes(iataCodes);
150
+ if (codes.length === 0)
151
+ return new Map();
152
+ const rows = await db
153
+ .select()
154
+ .from(referenceAircraft)
155
+ .where(inArray(referenceAircraft.iataCode, codes));
156
+ const result = new Map();
157
+ for (const row of rows) {
158
+ result.set(row.iataCode, rowToAircraft(row));
159
+ }
160
+ return result;
161
+ },
162
+ };
163
+ }
164
+ function rowToAirline(row) {
165
+ return {
166
+ iataCode: row.iataCode,
167
+ icaoCode: row.icaoCode ?? undefined,
168
+ name: row.name,
169
+ country: row.country ?? undefined,
170
+ logoUrl: row.logoUrl ?? undefined,
171
+ alliance: row.alliance ?? undefined,
172
+ };
173
+ }
174
+ function rowToAirport(row) {
175
+ return {
176
+ iataCode: row.iataCode,
177
+ icaoCode: row.icaoCode ?? undefined,
178
+ name: row.name,
179
+ city: row.city,
180
+ country: row.country,
181
+ timezone: row.timezone ?? undefined,
182
+ latitude: row.latitude ?? undefined,
183
+ longitude: row.longitude ?? undefined,
184
+ };
185
+ }
186
+ function rowToAircraft(row) {
187
+ return {
188
+ iataCode: row.iataCode,
189
+ icaoCode: row.icaoCode ?? undefined,
190
+ name: row.name,
191
+ manufacturer: row.manufacturer ?? undefined,
192
+ typicalSeats: row.typicalSeats ?? undefined,
193
+ };
194
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Static-bundle `ReferenceDataProvider`.
3
+ *
4
+ * Even simpler than a local-Postgres provider — ship a JSON / CSV bundle
5
+ * with the deployment, load it into memory at startup, serve from a `Map`.
6
+ * Appropriate for small operators with stable, narrow geographic scope and
7
+ * no need for refresh.
8
+ *
9
+ * No DB, no external service, no network call.
10
+ *
11
+ * See `docs/architecture/catalog-flights-architecture.md` §6.2.
12
+ */
13
+ import type { Aircraft, Airline, Airport, ReferenceDataCapabilities, ReferenceDataProvider } from "./contract.js";
14
+ export interface StaticBundleReferenceData {
15
+ airlines?: Airline[];
16
+ airports?: Airport[];
17
+ aircraft?: Aircraft[];
18
+ }
19
+ export interface StaticBundleProviderOptions {
20
+ data: StaticBundleReferenceData;
21
+ /** Override capabilities; defaults are inferred from which arrays are populated. */
22
+ capabilities?: Partial<ReferenceDataCapabilities>;
23
+ }
24
+ /**
25
+ * Build a `ReferenceDataProvider` from in-memory bundles. Maps are built
26
+ * once at construction; lookups are O(1).
27
+ */
28
+ export declare function createStaticBundleReferenceProvider(options: StaticBundleProviderOptions): ReferenceDataProvider;
29
+ //# sourceMappingURL=static-bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static-bundle.d.ts","sourceRoot":"","sources":["../../src/reference/static-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,OAAO,EACP,OAAO,EACP,yBAAyB,EACzB,qBAAqB,EACtB,MAAM,eAAe,CAAA;AAGtB,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;IACpB,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAA;CACtB;AAED,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,yBAAyB,CAAA;IAC/B,oFAAoF;IACpF,YAAY,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,CAAA;CAClD;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CACjD,OAAO,EAAE,2BAA2B,GACnC,qBAAqB,CAuEvB"}