@gojinko/cli 1.3.0 → 2.0.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 +30 -5
- package/dist/commands/checkout.d.ts.map +1 -1
- package/dist/commands/checkout.js +2 -4
- package/dist/commands/checkout.js.map +1 -1
- package/dist/commands/exchange.d.ts.map +1 -1
- package/dist/commands/exchange.js +2 -0
- package/dist/commands/exchange.js.map +1 -1
- package/dist/commands/find-destination.d.ts +5 -0
- package/dist/commands/find-destination.d.ts.map +1 -1
- package/dist/commands/find-destination.js +89 -90
- package/dist/commands/find-destination.js.map +1 -1
- package/dist/commands/find-flight.d.ts.map +1 -1
- package/dist/commands/find-flight.js +45 -33
- package/dist/commands/find-flight.js.map +1 -1
- package/dist/commands/flight-calendar.d.ts.map +1 -1
- package/dist/commands/flight-calendar.js +31 -25
- package/dist/commands/flight-calendar.js.map +1 -1
- package/dist/commands/flight-search.d.ts.map +1 -1
- package/dist/commands/flight-search.js +52 -48
- package/dist/commands/flight-search.js.map +1 -1
- package/dist/commands/get-booking.d.ts.map +1 -1
- package/dist/commands/get-booking.js +16 -7
- package/dist/commands/get-booking.js.map +1 -1
- package/dist/commands/hotel-cancel.d.ts +4 -2
- package/dist/commands/hotel-cancel.d.ts.map +1 -1
- package/dist/commands/hotel-cancel.js +18 -14
- package/dist/commands/hotel-cancel.js.map +1 -1
- package/dist/commands/hotel-search.d.ts.map +1 -1
- package/dist/commands/hotel-search.js +65 -46
- package/dist/commands/hotel-search.js.map +1 -1
- package/dist/commands/price-monitoring.d.ts.map +1 -1
- package/dist/commands/price-monitoring.js +48 -33
- package/dist/commands/price-monitoring.js.map +1 -1
- package/dist/commands/select-ancillaries.d.ts.map +1 -1
- package/dist/commands/select-ancillaries.js +5 -7
- package/dist/commands/select-ancillaries.js.map +1 -1
- package/dist/commands/shared.d.ts +11 -0
- package/dist/commands/shared.d.ts.map +1 -1
- package/dist/commands/shared.js +17 -0
- package/dist/commands/shared.js.map +1 -1
- package/dist/commands/trip-status.d.ts.map +1 -1
- package/dist/commands/trip-status.js +2 -4
- package/dist/commands/trip-status.js.map +1 -1
- package/dist/commands/trip.d.ts.map +1 -1
- package/dist/commands/trip.js +2 -4
- package/dist/commands/trip.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/commands/hotel-lookup-booking.d.ts +0 -7
- package/dist/commands/hotel-lookup-booking.d.ts.map +0 -1
- package/dist/commands/hotel-lookup-booking.js +0 -20
- package/dist/commands/hotel-lookup-booking.js.map +0 -1
|
@@ -1,14 +1,28 @@
|
|
|
1
|
-
import { withClient, output } from './shared.js';
|
|
1
|
+
import { withClient, output, resolveDeprecatedFlag } from './shared.js';
|
|
2
2
|
export function registerFlightCalendarCommand(program) {
|
|
3
3
|
program
|
|
4
4
|
.command('flight-calendar')
|
|
5
5
|
.description('Show cheapest prices across a date range for a route.')
|
|
6
|
-
|
|
7
|
-
.
|
|
6
|
+
// Canonical flat discovery flags — match jinko-api FlightDiscoveryRequest.
|
|
7
|
+
.option('--origins <codes...>', 'origin IATA airport/city codes. JSON: `origins[]`.')
|
|
8
|
+
.option('--destinations <codes...>', 'destination IATA airport/city codes. JSON: `destinations[]`.')
|
|
8
9
|
.option('--month <month>', 'month to display (YYYY-MM), defaults to current month')
|
|
9
|
-
.option('--cabin <class>', 'cabin class
|
|
10
|
-
.option('--direct-only', 'only direct flights')
|
|
10
|
+
.option('--cabin-class <class>', 'cabin class: economy, premium_economy, business, first (default: economy). JSON: `cabin_class`.')
|
|
11
|
+
.option('--direct-only', 'only direct flights. JSON: `direct_only`.')
|
|
12
|
+
// Deprecated aliases — Phase 1 transition (JIN-665), remove in next major.
|
|
13
|
+
.option('--from <origin>', 'DEPRECATED: use --origins.')
|
|
14
|
+
.option('--to <destination>', 'DEPRECATED: use --destinations.')
|
|
15
|
+
.option('--cabin <class>', 'DEPRECATED: use --cabin-class.')
|
|
11
16
|
.action(withClient(async (client, globals, opts) => {
|
|
17
|
+
// Resolve deprecated aliases onto canonical flags. --from/--to are
|
|
18
|
+
// singular; wrap them into the canonical arrays.
|
|
19
|
+
const origins = resolveDeprecatedFlag(opts.origins, opts.from ? [opts.from] : undefined, '--from', '--origins');
|
|
20
|
+
const destinations = resolveDeprecatedFlag(opts.destinations, opts.to ? [opts.to] : undefined, '--to', '--destinations');
|
|
21
|
+
const cabinClass = resolveDeprecatedFlag(opts.cabinClass, opts.cabin, '--cabin', '--cabin-class') ?? 'economy';
|
|
22
|
+
if (!origins?.length || !destinations?.length) {
|
|
23
|
+
console.error('Error: --origins and --destinations are required.');
|
|
24
|
+
process.exit(3);
|
|
25
|
+
}
|
|
12
26
|
const month = opts.month ?? new Date().toISOString().slice(0, 7);
|
|
13
27
|
const [year, mon] = month.split('-').map(Number);
|
|
14
28
|
if (!year || !mon) {
|
|
@@ -18,28 +32,20 @@ export function registerFlightCalendarCommand(program) {
|
|
|
18
32
|
const startDate = `${month}-01`;
|
|
19
33
|
const lastDay = new Date(year, mon, 0).getDate();
|
|
20
34
|
const endDate = `${month}-${String(lastDay).padStart(2, '0')}`;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
trip_type: 'oneway',
|
|
32
|
-
cabin_class: opts.cabin,
|
|
33
|
-
direct_only: opts.directOnly ?? false,
|
|
34
|
-
},
|
|
35
|
-
sort: 'lowest',
|
|
35
|
+
// Canonical FLAT discovery body — jinko-api POST /v1/flight_calendar.
|
|
36
|
+
const request = {
|
|
37
|
+
origins,
|
|
38
|
+
destinations,
|
|
39
|
+
departure_date_ranges: [{ start: startDate, end: endDate }],
|
|
40
|
+
trip_type: 'oneway',
|
|
41
|
+
cabin_class: cabinClass,
|
|
42
|
+
direct_only: opts.directOnly ?? false,
|
|
43
|
+
adults: 1,
|
|
44
|
+
sort_by: 'lowest',
|
|
36
45
|
};
|
|
37
|
-
const
|
|
38
|
-
body,
|
|
39
|
-
});
|
|
40
|
-
const data = response.data;
|
|
46
|
+
const data = await client.flightCalendar(request);
|
|
41
47
|
if (globals.format === 'table') {
|
|
42
|
-
console.log(`\nFlight calendar: ${
|
|
48
|
+
console.log(`\nFlight calendar: ${origins.join(',')} → ${destinations.join(',')} (${month})`);
|
|
43
49
|
console.log(`Date range: ${startDate} to ${endDate}\n`);
|
|
44
50
|
}
|
|
45
51
|
output(data, { format: globals.format });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flight-calendar.js","sourceRoot":"","sources":["../../src/commands/flight-calendar.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"flight-calendar.js","sourceRoot":"","sources":["../../src/commands/flight-calendar.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAExE,MAAM,UAAU,6BAA6B,CAAC,OAAgB;IAC5D,OAAO;SACJ,OAAO,CAAC,iBAAiB,CAAC;SAC1B,WAAW,CAAC,uDAAuD,CAAC;QACrE,2EAA2E;SAC1E,MAAM,CAAC,sBAAsB,EAAE,oDAAoD,CAAC;SACpF,MAAM,CAAC,2BAA2B,EAAE,8DAA8D,CAAC;SACnG,MAAM,CAAC,iBAAiB,EAAE,uDAAuD,CAAC;SAClF,MAAM,CAAC,uBAAuB,EAAE,iGAAiG,CAAC;SAClI,MAAM,CAAC,eAAe,EAAE,2CAA2C,CAAC;QACrE,2EAA2E;SAC1E,MAAM,CAAC,iBAAiB,EAAE,4BAA4B,CAAC;SACvD,MAAM,CAAC,oBAAoB,EAAE,iCAAiC,CAAC;SAC/D,MAAM,CAAC,iBAAiB,EAAE,gCAAgC,CAAC;SAC3D,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE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AC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QACjD,MAAM,OAAO,GAAG,GAAG,KAAK,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;QAE/D,sEAAsE;QACtE,MAAM,OAAO,GAAsB;YACjC,OAAO;YACP,YAAY;YACZ,qBAAqB,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;YAC3D,SAAS,EAAE,QAAQ;YACnB,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,IAAI,CAAC,UAAU,IAAI,KAAK;YACrC,MAAM,EAAE,CAAC;YACT,OAAO,EAAE,QAAQ;SAClB,CAAC;QAEF,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAElD,IAAI,OAAO,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;YAC/B,OAAO,CAAC,GAAG,CAAC,sBAAsB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC,CAAC;YAC9F,OAAO,CAAC,GAAG,CAAC,eAAe,SAAS,OAAO,OAAO,IAAI,CAAC,CAAC;QAC1D,CAAC;QAED,MAAM,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC,CAAC;AACR,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flight-search.d.ts","sourceRoot":"","sources":["../../src/commands/flight-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"flight-search.d.ts","sourceRoot":"","sources":["../../src/commands/flight-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA0ElE"}
|
|
@@ -1,67 +1,71 @@
|
|
|
1
|
-
import { withClient, output } from './shared.js';
|
|
1
|
+
import { withClient, output, resolveDeprecatedFlag } from './shared.js';
|
|
2
2
|
export function registerFlightSearchCommand(program) {
|
|
3
3
|
program
|
|
4
4
|
.command('flight-search')
|
|
5
5
|
.description('Live flight search or price-check a specific offer.')
|
|
6
|
-
|
|
7
|
-
.option('--origin
|
|
8
|
-
.option('--
|
|
9
|
-
.option('--
|
|
10
|
-
.option('--date <date>', '
|
|
11
|
-
.option('--
|
|
12
|
-
.option('--
|
|
13
|
-
.option('--
|
|
14
|
-
.option('--
|
|
15
|
-
.option('--
|
|
16
|
-
.option('--
|
|
17
|
-
.option('--
|
|
18
|
-
|
|
6
|
+
// Canonical flat flags — match jinko-api FlightSearchRequest leaf names.
|
|
7
|
+
.option('--origin <code>', 'origin IATA code (e.g. PAR for city, JFK for airport). JSON: `origin`.')
|
|
8
|
+
.option('--destination <code>', 'destination IATA code (e.g. NYC for city, LAX for airport). JSON: `destination`.')
|
|
9
|
+
.option('--departure-date <date>', 'departure date (YYYY-MM-DD). JSON: `departure_date`.')
|
|
10
|
+
.option('--return-date <date>', 'return date for round-trip (YYYY-MM-DD). JSON: `return_date`.')
|
|
11
|
+
.option('--cabin-class <class>', 'cabin class: economy, premium_economy, business, first (default: economy). JSON: `cabin_class`.')
|
|
12
|
+
.option('--adults <n>', 'number of adult passengers (default: 1). JSON: `adults`.')
|
|
13
|
+
.option('--direct-only', 'only show direct flights. JSON: `direct_only`.')
|
|
14
|
+
.option('--max-price <amount>', 'maximum price filter. JSON: `max_price`.')
|
|
15
|
+
.option('--include-carriers <codes...>', 'include only these IATA 2-letter carrier codes (e.g. AF KL). JSON: `include_carriers`.')
|
|
16
|
+
.option('--exclude-carriers <codes...>', 'exclude these IATA 2-letter carrier codes (e.g. FR U2). JSON: `exclude_carriers`.')
|
|
17
|
+
.option('--offer-token <token>', 'price-check a specific offer (live pricing). JSON: `offer_token`.')
|
|
18
|
+
// Deprecated aliases — Phase 1 transition (JIN-665), remove in next major.
|
|
19
|
+
.option('--from <origin>', 'DEPRECATED: use --origin.')
|
|
20
|
+
.option('--to <destination>', 'DEPRECATED: use --destination.')
|
|
21
|
+
.option('--date <date>', 'DEPRECATED: use --departure-date.')
|
|
22
|
+
.option('--return <date>', 'DEPRECATED: use --return-date.')
|
|
23
|
+
.option('--cabin <class>', 'DEPRECATED: use --cabin-class.')
|
|
24
|
+
.option('--passengers <n>', 'DEPRECATED: use --adults.')
|
|
25
|
+
// Deprecated no-ops — dropped from the public flat contract.
|
|
26
|
+
.option('--origin-type <type>', 'DEPRECATED: ignored by the public contract (no longer sent).')
|
|
27
|
+
.option('--destination-type <type>', 'DEPRECATED: ignored by the public contract (no longer sent).')
|
|
19
28
|
.action(withClient(async (client, globals, opts) => {
|
|
29
|
+
// Resolve deprecated aliases onto canonical flags.
|
|
30
|
+
const origin = resolveDeprecatedFlag(opts.origin, opts.from, '--from', '--origin');
|
|
31
|
+
const destination = resolveDeprecatedFlag(opts.destination, opts.to, '--to', '--destination');
|
|
32
|
+
const departureDate = resolveDeprecatedFlag(opts.departureDate, opts.date, '--date', '--departure-date');
|
|
33
|
+
const returnDate = resolveDeprecatedFlag(opts.returnDate, opts.return, '--return', '--return-date');
|
|
34
|
+
const cabinClass = resolveDeprecatedFlag(opts.cabinClass, opts.cabin, '--cabin', '--cabin-class') ?? 'economy';
|
|
35
|
+
const adults = resolveDeprecatedFlag(opts.adults, opts.passengers, '--passengers', '--adults') ?? '1';
|
|
20
36
|
const isOfferCheck = Boolean(opts.offerToken);
|
|
21
37
|
if (isOfferCheck) {
|
|
22
|
-
// Price-check mode
|
|
23
|
-
const response = await client.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
passengers: {
|
|
27
|
-
adults: Number(opts.passengers) || 1,
|
|
28
|
-
},
|
|
29
|
-
},
|
|
38
|
+
// Price-check mode — canonical flat body, jinko-api POST /v1/flight_search.
|
|
39
|
+
const response = await client.flightSearch({
|
|
40
|
+
offer_token: opts.offerToken,
|
|
41
|
+
adults: Number(adults) || 1,
|
|
30
42
|
});
|
|
31
|
-
output(response
|
|
43
|
+
output(response, { format: globals.format });
|
|
32
44
|
}
|
|
33
45
|
else {
|
|
34
46
|
// Search mode
|
|
35
|
-
if (!
|
|
36
|
-
console.error('Error: --
|
|
47
|
+
if (!origin || !destination || !departureDate) {
|
|
48
|
+
console.error('Error: --origin, --destination, and --departure-date are required for search mode.');
|
|
37
49
|
console.error(' Or provide --offer-token for price-check mode.');
|
|
38
50
|
process.exit(3);
|
|
39
51
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
departure_date:
|
|
46
|
-
trip_type:
|
|
47
|
-
cabin_class:
|
|
52
|
+
// Canonical FLAT body — adults at top level (no `passengers` wrapper);
|
|
53
|
+
// the public surface drops origin_type/destination_type.
|
|
54
|
+
const request = {
|
|
55
|
+
origin,
|
|
56
|
+
destination,
|
|
57
|
+
departure_date: departureDate,
|
|
58
|
+
trip_type: returnDate ? 'roundtrip' : 'oneway',
|
|
59
|
+
cabin_class: cabinClass,
|
|
48
60
|
direct_only: opts.directOnly ?? false,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
},
|
|
61
|
+
adults: Number(adults) || 1,
|
|
62
|
+
...(returnDate ? { return_date: returnDate } : {}),
|
|
63
|
+
...(opts.maxPrice ? { max_price: Number(opts.maxPrice) } : {}),
|
|
64
|
+
...(opts.includeCarriers ? { include_carriers: opts.includeCarriers } : {}),
|
|
65
|
+
...(opts.excludeCarriers ? { exclude_carriers: opts.excludeCarriers } : {}),
|
|
52
66
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (opts.maxPrice)
|
|
56
|
-
body['max_price'] = Number(opts.maxPrice);
|
|
57
|
-
if (opts.includeCarriers)
|
|
58
|
-
body['include_carriers'] = opts.includeCarriers;
|
|
59
|
-
if (opts.excludeCarriers)
|
|
60
|
-
body['exclude_carriers'] = opts.excludeCarriers;
|
|
61
|
-
const response = await client.raw.POST('/api/v1/flights/shop', {
|
|
62
|
-
body,
|
|
63
|
-
});
|
|
64
|
-
output(response.data, { format: globals.format });
|
|
67
|
+
const response = await client.flightSearch(request);
|
|
68
|
+
output(response, { format: globals.format });
|
|
65
69
|
}
|
|
66
70
|
}));
|
|
67
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flight-search.js","sourceRoot":"","sources":["../../src/commands/flight-search.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"flight-search.js","sourceRoot":"","sources":["../../src/commands/flight-search.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAExE,MAAM,UAAU,2BAA2B,CAAC,OAAgB;IAC1D,OAAO;SACJ,OAAO,CAAC,eAAe,CAAC;SACxB,WAAW,CAAC,qDAAqD,CAAC;QACnE,yEAAyE;SACxE,MAAM,CAAC,iBAAiB,EAAE,wEAAwE,CAAC;SACnG,MAAM,CAAC,sBAAsB,EAAE,kFAAkF,CAAC;SAClH,MAAM,CAAC,yBAAyB,EAAE,sDAAsD,CAAC;SACzF,MAAM,CAAC,sBAAsB,EAAE,+DAA+D,CAAC;SAC/F,MAAM,CAAC,uBAAuB,EAAE,iGAAiG,CAAC;SAClI,MAAM,CAAC,cAAc,EAAE,0DAA0D,CAAC;SAClF,MAAM,CAAC,eAAe,EAAE,gDAAgD,CAAC;SACzE,MAAM,CAAC,sBAAsB,EAAE,0CAA0C,CAAC;SAC1E,MAAM,CAAC,+BAA+B,EAAE,wFAAwF,CAAC;SACjI,MAAM,CAAC,+BAA+B,EAAE,mFAAmF,CAAC;SAC5H,MAAM,CAAC,uBAAuB,EAAE,mEA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,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC3E,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC5E,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YACpD,MAAM,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC,CAAC,CAAC,CAAC;AACR,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-booking.d.ts","sourceRoot":"","sources":["../../src/commands/get-booking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"get-booking.d.ts","sourceRoot":"","sources":["../../src/commands/get-booking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoBpC,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA0BhE"}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import { withClient, output } from './shared.js';
|
|
1
|
+
import { withClient, output, resolveDeprecatedFlag } from './shared.js';
|
|
2
2
|
// Shared commander action used by both the canonical `get-booking` command
|
|
3
|
-
// and its deprecated `lookup-booking` alias (JIN-663).
|
|
3
|
+
// and its deprecated `lookup-booking` alias (JIN-663). The canonical flag is
|
|
4
|
+
// `--booking-ref` (matches the jinko-api `booking_ref` leaf); `--ref` is kept
|
|
5
|
+
// as a deprecated alias (JIN-665).
|
|
4
6
|
const action = withClient(async (client, globals, opts) => {
|
|
7
|
+
const bookingRef = resolveDeprecatedFlag(opts.bookingRef, opts.ref, '--ref', '--booking-ref');
|
|
8
|
+
if (!bookingRef) {
|
|
9
|
+
console.error('Error: --booking-ref is required.');
|
|
10
|
+
process.exit(3);
|
|
11
|
+
}
|
|
5
12
|
const response = await client.getBooking({
|
|
6
|
-
booking_ref:
|
|
13
|
+
booking_ref: bookingRef,
|
|
7
14
|
last_name: opts.lastName,
|
|
8
15
|
});
|
|
9
16
|
output(response, { format: globals.format });
|
|
@@ -12,8 +19,9 @@ export function registerGetBookingCommand(program) {
|
|
|
12
19
|
program
|
|
13
20
|
.command('get-booking')
|
|
14
21
|
.description('Retrieve a booking by Jinko reference + last name (guest access).')
|
|
15
|
-
.
|
|
16
|
-
.requiredOption('--last-name <name>', 'Last name of the primary traveler')
|
|
22
|
+
.option('--booking-ref <ref>', 'Jinko booking reference (e.g. JNK-A7B3X9). JSON: `booking_ref`.')
|
|
23
|
+
.requiredOption('--last-name <name>', 'Last name of the primary traveler. JSON: `last_name`.')
|
|
24
|
+
.option('--ref <ref>', 'DEPRECATED: use --booking-ref.')
|
|
17
25
|
.action(action);
|
|
18
26
|
// Deprecated alias (JIN-663) — hidden from `--help`, emits a one-line
|
|
19
27
|
// deprecation warning to stderr, then runs the same action. Remove once
|
|
@@ -21,8 +29,9 @@ export function registerGetBookingCommand(program) {
|
|
|
21
29
|
program
|
|
22
30
|
.command('lookup-booking', { hidden: true })
|
|
23
31
|
.description('[DEPRECATED] Alias for `get-booking`. Use `get-booking` instead.')
|
|
24
|
-
.
|
|
25
|
-
.requiredOption('--last-name <name>', 'Last name of the primary traveler')
|
|
32
|
+
.option('--booking-ref <ref>', 'Jinko booking reference (e.g. JNK-A7B3X9). JSON: `booking_ref`.')
|
|
33
|
+
.requiredOption('--last-name <name>', 'Last name of the primary traveler. JSON: `last_name`.')
|
|
34
|
+
.option('--ref <ref>', 'DEPRECATED: use --booking-ref.')
|
|
26
35
|
.action(function deprecatedLookupBookingAction(...args) {
|
|
27
36
|
// eslint-disable-next-line no-console
|
|
28
37
|
console.error('[DEPRECATED] `jinko lookup-booking` is renamed to `jinko get-booking`. ' +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-booking.js","sourceRoot":"","sources":["../../src/commands/get-booking.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"get-booking.js","sourceRoot":"","sources":["../../src/commands/get-booking.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAExE,2EAA2E;AAC3E,6EAA6E;AAC7E,8EAA8E;AAC9E,mCAAmC;AACnC,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACxD,MAAM,UAAU,GAAG,qBAAqB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;IAC9F,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACnD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC;QACvC,WAAW,EAAE,UAAU;QACvB,SAAS,EAAE,IAAI,CAAC,QAAQ;KACzB,CAAC,CAAC;IACH,MAAM,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC;AAEH,MAAM,UAAU,yBAAyB,CAAC,OAAgB;IACxD,OAAO;SACJ,OAAO,CAAC,aAAa,CAAC;SACtB,WAAW,CAAC,mEAAmE,CAAC;SAChF,MAAM,CAAC,qBAAqB,EAAE,iEAAiE,CAAC;SAChG,cAAc,CAAC,oBAAoB,EAAE,uDAAuD,CAAC;SAC7F,MAAM,CAAC,aAAa,EAAE,gCAAgC,CAAC;SACvD,MAAM,CAAC,MAAM,CAAC,CAAC;IAElB,sEAAsE;IACtE,wEAAwE;IACxE,yDAAyD;IACzD,OAAO;SACJ,OAAO,CAAC,gBAAgB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;SAC3C,WAAW,CAAC,kEAAkE,CAAC;SAC/E,MAAM,CAAC,qBAAqB,EAAE,iEAAiE,CAAC;SAChG,cAAc,CAAC,oBAAoB,EAAE,uDAAuD,CAAC;SAC7F,MAAM,CAAC,aAAa,EAAE,gCAAgC,CAAC;SACvD,MAAM,CAAC,SAAS,6BAA6B,CAAgB,GAAG,IAAe;QAC9E,sCAAsC;QACtC,OAAO,CAAC,KAAK,CACX,yEAAyE;YACvE,mDAAmD,CACtD,CAAC;QACF,OAAQ,MAA6C,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -3,14 +3,16 @@ import { Command } from 'commander';
|
|
|
3
3
|
* `gojinko hotel-cancel` — hotel cancellation, idempotent.
|
|
4
4
|
*
|
|
5
5
|
* Dual-auth (JIN-281, mirrors flight_refund):
|
|
6
|
-
* - Guest: --ref + --last-name (must be provided together)
|
|
6
|
+
* - Guest: --booking-ref + --last-name (must be provided together)
|
|
7
7
|
* - Authenticated: --provider-booking-id [+ --provider]
|
|
8
8
|
*
|
|
9
9
|
* The two modes are mutually exclusive at the BFF. Idempotent: the BFF
|
|
10
10
|
* persists the cancellation result and re-serves the stored response on
|
|
11
11
|
* subsequent calls (with `idempotent: true`). Safe to retry.
|
|
12
12
|
*
|
|
13
|
-
* Wraps
|
|
13
|
+
* Wraps jinko-api POST /v1/hotel_cancel. The canonical guest flag is
|
|
14
|
+
* `--booking-ref` (matches the `booking_ref` leaf); `--ref` is kept as a
|
|
15
|
+
* deprecated alias (JIN-665).
|
|
14
16
|
*/
|
|
15
17
|
export declare function registerHotelCancelCommand(program: Command): void;
|
|
16
18
|
//# sourceMappingURL=hotel-cancel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hotel-cancel.d.ts","sourceRoot":"","sources":["../../src/commands/hotel-cancel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC
|
|
1
|
+
{"version":3,"file":"hotel-cancel.d.ts","sourceRoot":"","sources":["../../src/commands/hotel-cancel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAgDjE"}
|
|
@@ -1,43 +1,47 @@
|
|
|
1
|
-
import { withClient, output } from './shared.js';
|
|
1
|
+
import { withClient, output, resolveDeprecatedFlag } from './shared.js';
|
|
2
2
|
/**
|
|
3
3
|
* `gojinko hotel-cancel` — hotel cancellation, idempotent.
|
|
4
4
|
*
|
|
5
5
|
* Dual-auth (JIN-281, mirrors flight_refund):
|
|
6
|
-
* - Guest: --ref + --last-name (must be provided together)
|
|
6
|
+
* - Guest: --booking-ref + --last-name (must be provided together)
|
|
7
7
|
* - Authenticated: --provider-booking-id [+ --provider]
|
|
8
8
|
*
|
|
9
9
|
* The two modes are mutually exclusive at the BFF. Idempotent: the BFF
|
|
10
10
|
* persists the cancellation result and re-serves the stored response on
|
|
11
11
|
* subsequent calls (with `idempotent: true`). Safe to retry.
|
|
12
12
|
*
|
|
13
|
-
* Wraps
|
|
13
|
+
* Wraps jinko-api POST /v1/hotel_cancel. The canonical guest flag is
|
|
14
|
+
* `--booking-ref` (matches the `booking_ref` leaf); `--ref` is kept as a
|
|
15
|
+
* deprecated alias (JIN-665).
|
|
14
16
|
*/
|
|
15
17
|
export function registerHotelCancelCommand(program) {
|
|
16
18
|
program
|
|
17
19
|
.command('hotel-cancel')
|
|
18
|
-
.description('Cancel a hotel booking. Idempotent — safe to retry. Use either guest auth (--ref + --last-name) OR the authenticated shortcut (--provider-booking-id).')
|
|
19
|
-
.option('--ref <ref>', 'Jinko booking reference (e.g. JNK-A7B3X9). Guest path — pair with --last-name.')
|
|
20
|
-
.option('--last-name <name>', 'Last name of the lead guest. Guest path — pair with --ref.')
|
|
21
|
-
.option('--provider-booking-id <id>', 'Provider booking ID (authenticated shortcut). Mutually exclusive with --ref + --last-name.')
|
|
22
|
-
.option('--provider <code>', 'Provider code (e.g. "nuitee"). Optional, only meaningful with --provider-booking-id.')
|
|
20
|
+
.description('Cancel a hotel booking. Idempotent — safe to retry. Use either guest auth (--booking-ref + --last-name) OR the authenticated shortcut (--provider-booking-id).')
|
|
21
|
+
.option('--booking-ref <ref>', 'Jinko booking reference (e.g. JNK-A7B3X9). Guest path — pair with --last-name. JSON: `booking_ref`.')
|
|
22
|
+
.option('--last-name <name>', 'Last name of the lead guest. Guest path — pair with --booking-ref. JSON: `last_name`.')
|
|
23
|
+
.option('--provider-booking-id <id>', 'Provider booking ID (authenticated shortcut). Mutually exclusive with --booking-ref + --last-name. JSON: `provider_booking_id`.')
|
|
24
|
+
.option('--provider <code>', 'Provider code (e.g. "nuitee"). Optional, only meaningful with --provider-booking-id. JSON: `provider`.')
|
|
25
|
+
.option('--ref <ref>', 'DEPRECATED: use --booking-ref.')
|
|
23
26
|
.action(withClient(async (client, globals, opts) => {
|
|
24
|
-
const
|
|
25
|
-
const
|
|
27
|
+
const bookingRef = resolveDeprecatedFlag(opts.bookingRef, opts.ref, '--ref', '--booking-ref');
|
|
28
|
+
const hasGuest = Boolean(bookingRef) && Boolean(opts.lastName);
|
|
29
|
+
const guestPartial = (Boolean(bookingRef) && !opts.lastName) || (!bookingRef && Boolean(opts.lastName));
|
|
26
30
|
const hasProviderId = Boolean(opts.providerBookingId);
|
|
27
31
|
if (guestPartial) {
|
|
28
|
-
console.error('Error: --ref and --last-name must be provided together.');
|
|
32
|
+
console.error('Error: --booking-ref and --last-name must be provided together.');
|
|
29
33
|
process.exit(3);
|
|
30
34
|
}
|
|
31
35
|
if (hasGuest && hasProviderId) {
|
|
32
|
-
console.error('Error: --ref + --last-name and --provider-booking-id are mutually exclusive. Pass one mode.');
|
|
36
|
+
console.error('Error: --booking-ref + --last-name and --provider-booking-id are mutually exclusive. Pass one mode.');
|
|
33
37
|
process.exit(3);
|
|
34
38
|
}
|
|
35
39
|
if (!hasGuest && !hasProviderId) {
|
|
36
|
-
console.error('Error: provide either --ref + --last-name (guest) or --provider-booking-id (authenticated).');
|
|
40
|
+
console.error('Error: provide either --booking-ref + --last-name (guest) or --provider-booking-id (authenticated).');
|
|
37
41
|
process.exit(3);
|
|
38
42
|
}
|
|
39
43
|
const response = await client.hotelCancelBooking({
|
|
40
|
-
booking_ref:
|
|
44
|
+
booking_ref: bookingRef,
|
|
41
45
|
last_name: opts.lastName,
|
|
42
46
|
provider_booking_id: opts.providerBookingId,
|
|
43
47
|
provider: opts.provider,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hotel-cancel.js","sourceRoot":"","sources":["../../src/commands/hotel-cancel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"hotel-cancel.js","sourceRoot":"","sources":["../../src/commands/hotel-cancel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAExE;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,0BAA0B,CAAC,OAAgB;IACzD,OAAO;SACJ,OAAO,CAAC,cAAc,CAAC;SACvB,WAAW,CACV,gKAAgK,CACjK;SACA,MAAM,CAAC,qBAAqB,EAAE,qGAAqG,CAAC;SACpI,MAAM,CAAC,oBAAoB,EAAE,uFAAuF,CAAC;SACrH,MAAM,CACL,4BAA4B,EAC5B,iIAAiI,C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AAI,CAAC,iBAAiB;YAC3C,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAC;QACH,MAAM,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC,CAAC,CACH,CAAC;AACN,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hotel-search.d.ts","sourceRoot":"","sources":["../../src/commands/hotel-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"hotel-search.d.ts","sourceRoot":"","sources":["../../src/commands/hotel-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAwEpC,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAiIjE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import { withClient, output } from './shared.js';
|
|
2
|
+
import { withClient, output, resolveDeprecatedFlag } from './shared.js';
|
|
3
3
|
function isLowConfidenceError(body) {
|
|
4
4
|
if (!body || typeof body !== 'object')
|
|
5
5
|
return false;
|
|
@@ -33,43 +33,61 @@ function formatLowConfidenceError(body, format) {
|
|
|
33
33
|
console.error(` ${chalk.cyan('destination=')}${dest}`);
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
|
-
console.error(chalk.dim('No suggested_retry — provide --city and --country to narrow the lookup, or try a different name.'));
|
|
36
|
+
console.error(chalk.dim('No suggested_retry — provide --city-name and --country-code to narrow the lookup, or try a different name.'));
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
export function registerHotelSearchCommand(program) {
|
|
40
40
|
program
|
|
41
41
|
.command('hotel-search')
|
|
42
42
|
.description('Search live hotel inventory and rates by destination, dates, and occupancy.')
|
|
43
|
-
.option('--query <text>', 'free-text destination (city, region, POI) — Mode B')
|
|
44
|
-
.option('--city <name>', 'city name (e.g. "Paris") — Mode B destination, or Mode A lookup scope when combined with --hotel-name')
|
|
45
|
-
.option('--country <code>', 'ISO 3166-1 alpha-2 country code (e.g. fr) — Mode B destination, or Mode A lookup scope when combined with --hotel-name')
|
|
46
|
-
.option('--
|
|
47
|
-
.option('--
|
|
48
|
-
.option('--radius <km>', 'search radius in km (default 5, max 50) — Mode B')
|
|
49
|
-
.option('--place-id <id>', 'Google Places ID or upstream place identifier — Mode B')
|
|
50
|
-
.option('--hotel-ids <ids...>', 're-shop specific hotel IDs — Mode A')
|
|
51
|
-
.option('--hotel-name <name>', 'look up a specific hotel by name — Mode A. Pair with --city and --country to narrow the lookup scope.')
|
|
52
|
-
.option('--checkin <date>', 'check-in date (YYYY-MM-DD)', undefined)
|
|
53
|
-
.option('--checkout <date>', 'check-out date (YYYY-MM-DD)', undefined)
|
|
54
|
-
.option('--adults <n>', 'number of adults (shorthand)', '2')
|
|
55
|
-
.option('--children <ages...>', 'children ages (shorthand, e.g. 5 7)')
|
|
56
|
-
.option('--rooms <n>', 'number of rooms (shorthand)')
|
|
57
|
-
.option('--currency <code>', 'ISO 4217 currency code (default USD)')
|
|
58
|
-
.option('--nationality <code>', 'guest nationality (ISO 3166-1 alpha-2)')
|
|
59
|
-
.option('--min-rating <n>', 'minimum guest review rating (0-10)')
|
|
60
|
-
.option('--
|
|
61
|
-
.option('--max-
|
|
62
|
-
.option('--min-reviews <n>', 'minimum number of reviews')
|
|
63
|
-
.option('--max-results <n>', 'maximum hotels to return (default 50)')
|
|
43
|
+
.option('--query <text>', 'free-text destination (city, region, POI) — Mode B. JSON: `query`.')
|
|
44
|
+
.option('--city-name <name>', 'city name (e.g. "Paris") — Mode B destination, or Mode A lookup scope when combined with --hotel-name. JSON: `city_name`.')
|
|
45
|
+
.option('--country-code <code>', 'ISO 3166-1 alpha-2 country code (e.g. fr) — Mode B destination, or Mode A lookup scope when combined with --hotel-name. JSON: `country_code`.')
|
|
46
|
+
.option('--latitude <latitude>', 'latitude for geo-radius search — Mode B. JSON: `latitude`.')
|
|
47
|
+
.option('--longitude <longitude>', 'longitude for geo-radius search — Mode B. JSON: `longitude`.')
|
|
48
|
+
.option('--radius-km <km>', 'search radius in km (default 5, max 50) — Mode B. JSON: `radius_km`.')
|
|
49
|
+
.option('--place-id <id>', 'Google Places ID or upstream place identifier — Mode B. JSON: `place_id`.')
|
|
50
|
+
.option('--hotel-ids <ids...>', 're-shop specific hotel IDs — Mode A. JSON: `hotel_ids`.')
|
|
51
|
+
.option('--hotel-name <name>', 'look up a specific hotel by name — Mode A. Pair with --city-name and --country-code to narrow the lookup scope.')
|
|
52
|
+
.option('--checkin <date>', 'check-in date (YYYY-MM-DD). JSON: `checkin`.', undefined)
|
|
53
|
+
.option('--checkout <date>', 'check-out date (YYYY-MM-DD). JSON: `checkout`.', undefined)
|
|
54
|
+
.option('--adults <n>', 'number of adults (shorthand). JSON: `adults`.', '2')
|
|
55
|
+
.option('--children <ages...>', 'children ages (shorthand, e.g. 5 7). JSON: `children`.')
|
|
56
|
+
.option('--rooms <n>', 'number of rooms (shorthand). JSON: `rooms`.')
|
|
57
|
+
.option('--currency <code>', 'ISO 4217 currency code (default USD). JSON: `currency`.')
|
|
58
|
+
.option('--guest-nationality <code>', 'guest nationality (ISO 3166-1 alpha-2). JSON: `guest_nationality`.')
|
|
59
|
+
.option('--min-rating <n>', 'minimum guest review rating (0-10). JSON: `min_rating`.')
|
|
60
|
+
.option('--star-rating <n>', 'minimum star rating (1-5). JSON: `min_star_rating`.')
|
|
61
|
+
.option('--max-star-rating <n>', 'maximum star rating (1-5). JSON: `max_star_rating`.')
|
|
62
|
+
.option('--min-reviews <n>', 'minimum number of reviews. JSON: `min_reviews`.')
|
|
63
|
+
.option('--max-results <n>', 'maximum hotels to return (default 50). JSON: `max_results`.')
|
|
64
|
+
// Deprecated aliases — Phase 1 transition (JIN-665), remove in next major.
|
|
65
|
+
.option('--city <name>', 'DEPRECATED: use --city-name.')
|
|
66
|
+
.option('--country <code>', 'DEPRECATED: use --country-code.')
|
|
67
|
+
.option('--lat <latitude>', 'DEPRECATED: use --latitude.')
|
|
68
|
+
.option('--lng <longitude>', 'DEPRECATED: use --longitude.')
|
|
69
|
+
.option('--radius <km>', 'DEPRECATED: use --radius-km.')
|
|
70
|
+
.option('--nationality <code>', 'DEPRECATED: use --guest-nationality.')
|
|
71
|
+
.option('--stars <n>', 'DEPRECATED: use --star-rating.')
|
|
72
|
+
.option('--max-stars <n>', 'DEPRECATED: use --max-star-rating.')
|
|
64
73
|
.action(withClient(async (client, globals, opts) => {
|
|
74
|
+
// Resolve deprecated aliases onto canonical flags.
|
|
75
|
+
const cityName = resolveDeprecatedFlag(opts.cityName, opts.city, '--city', '--city-name');
|
|
76
|
+
const countryCode = resolveDeprecatedFlag(opts.countryCode, opts.country, '--country', '--country-code');
|
|
77
|
+
const latitude = resolveDeprecatedFlag(opts.latitude, opts.lat, '--lat', '--latitude');
|
|
78
|
+
const longitude = resolveDeprecatedFlag(opts.longitude, opts.lng, '--lng', '--longitude');
|
|
79
|
+
const radiusKm = resolveDeprecatedFlag(opts.radiusKm, opts.radius, '--radius', '--radius-km');
|
|
80
|
+
const guestNationality = resolveDeprecatedFlag(opts.guestNationality, opts.nationality, '--nationality', '--guest-nationality');
|
|
81
|
+
const starRating = resolveDeprecatedFlag(opts.starRating, opts.stars, '--stars', '--star-rating');
|
|
82
|
+
const maxStarRating = resolveDeprecatedFlag(opts.maxStarRating, opts.maxStars, '--max-stars', '--max-star-rating');
|
|
65
83
|
if (!opts.checkin || !opts.checkout) {
|
|
66
84
|
console.error('Error: --checkin and --checkout are required.');
|
|
67
85
|
process.exit(3);
|
|
68
86
|
}
|
|
69
|
-
const hasDestination = opts.query ||
|
|
87
|
+
const hasDestination = opts.query || cityName || latitude || opts.placeId || opts.hotelIds || opts.hotelName;
|
|
70
88
|
if (!hasDestination) {
|
|
71
|
-
console.error('Error: provide a destination — Mode A: --hotel-name (optionally + --city/--country) or --hotel-ids; ' +
|
|
72
|
-
'Mode B: --query, --city, --
|
|
89
|
+
console.error('Error: provide a destination — Mode A: --hotel-name (optionally + --city-name/--country-code) or --hotel-ids; ' +
|
|
90
|
+
'Mode B: --query, --city-name, --latitude+--longitude, or --place-id.');
|
|
73
91
|
process.exit(3);
|
|
74
92
|
}
|
|
75
93
|
// Mode A signal: --hotel-name or --hotel-ids. In Mode A the server
|
|
@@ -77,9 +95,9 @@ export function registerHotelSearchCommand(program) {
|
|
|
77
95
|
// happen (server-side behavior is lenient-with-warnings for now per
|
|
78
96
|
// JIN-639 Phase 4 plan; may become a 422 in a future version).
|
|
79
97
|
const isModeA = Boolean(opts.hotelName || opts.hotelIds);
|
|
80
|
-
const hasFilters = Boolean(opts.minRating ||
|
|
98
|
+
const hasFilters = Boolean(opts.minRating || starRating || maxStarRating || opts.minReviews || opts.maxResults);
|
|
81
99
|
if (isModeA && hasFilters) {
|
|
82
|
-
console.warn('Warning: filters (--min-rating / --
|
|
100
|
+
console.warn('Warning: filters (--min-rating / --star-rating / --max-star-rating / --min-reviews / --max-results) ' +
|
|
83
101
|
'are ignored when --hotel-name or --hotel-ids is set (rate-lookup mode). ' +
|
|
84
102
|
'The server will return a warnings entry in the response.');
|
|
85
103
|
}
|
|
@@ -91,16 +109,16 @@ export function registerHotelSearchCommand(program) {
|
|
|
91
109
|
// Destination
|
|
92
110
|
if (opts.query)
|
|
93
111
|
body.query = opts.query;
|
|
94
|
-
if (
|
|
95
|
-
body.city_name =
|
|
96
|
-
if (
|
|
97
|
-
body.country_code =
|
|
98
|
-
if (
|
|
99
|
-
body.latitude = Number(
|
|
100
|
-
if (
|
|
101
|
-
body.longitude = Number(
|
|
102
|
-
if (
|
|
103
|
-
body.radius_km = Number(
|
|
112
|
+
if (cityName)
|
|
113
|
+
body.city_name = cityName;
|
|
114
|
+
if (countryCode)
|
|
115
|
+
body.country_code = countryCode;
|
|
116
|
+
if (latitude)
|
|
117
|
+
body.latitude = Number(latitude);
|
|
118
|
+
if (longitude)
|
|
119
|
+
body.longitude = Number(longitude);
|
|
120
|
+
if (radiusKm)
|
|
121
|
+
body.radius_km = Number(radiusKm);
|
|
104
122
|
if (opts.placeId)
|
|
105
123
|
body.place_id = opts.placeId;
|
|
106
124
|
if (opts.hotelIds)
|
|
@@ -115,20 +133,21 @@ export function registerHotelSearchCommand(program) {
|
|
|
115
133
|
// Context
|
|
116
134
|
if (opts.currency)
|
|
117
135
|
body.currency = opts.currency;
|
|
118
|
-
if (
|
|
119
|
-
body.guest_nationality =
|
|
120
|
-
// Filters (Mode B only — Mode A warned above)
|
|
136
|
+
if (guestNationality)
|
|
137
|
+
body.guest_nationality = guestNationality;
|
|
138
|
+
// Filters (Mode B only — Mode A warned above). `--star-rating` maps to
|
|
139
|
+
// the canonical `min_star_rating` leaf (minimum-stars semantics).
|
|
121
140
|
if (opts.minRating)
|
|
122
141
|
body.min_rating = Number(opts.minRating);
|
|
123
|
-
if (
|
|
124
|
-
body.min_star_rating = Number(
|
|
125
|
-
if (
|
|
126
|
-
body.max_star_rating = Number(
|
|
142
|
+
if (starRating)
|
|
143
|
+
body.min_star_rating = Number(starRating);
|
|
144
|
+
if (maxStarRating)
|
|
145
|
+
body.max_star_rating = Number(maxStarRating);
|
|
127
146
|
if (opts.minReviews)
|
|
128
147
|
body.min_reviews = Number(opts.minReviews);
|
|
129
148
|
if (opts.maxResults)
|
|
130
149
|
body.max_results = Number(opts.maxResults);
|
|
131
|
-
const response = await client.raw.POST('/
|
|
150
|
+
const response = await client.raw.POST('/v1/hotel_search', {
|
|
132
151
|
body,
|
|
133
152
|
});
|
|
134
153
|
// 422 HOTEL_NAME_LOW_CONFIDENCE is actionable, not fatal — pretty-print
|