@gojinko/cli 2.24.0 → 2.25.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 +1 -1
- package/dist/commands/get-booking.d.ts +26 -0
- package/dist/commands/get-booking.d.ts.map +1 -1
- package/dist/commands/get-booking.js +54 -2
- package/dist/commands/get-booking.js.map +1 -1
- package/dist/commands/ground-search.d.ts +2 -1
- package/dist/commands/ground-search.d.ts.map +1 -1
- package/dist/commands/ground-search.js +14 -25
- package/dist/commands/ground-search.js.map +1 -1
- package/dist/output/price-change.d.ts +8 -12
- package/dist/output/price-change.d.ts.map +1 -1
- package/dist/output/price-change.js +20 -26
- package/dist/output/price-change.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -89,7 +89,7 @@ Prod and sandbox keys are stored separately in `~/.jinko/config.yaml`. Resolutio
|
|
|
89
89
|
|
|
90
90
|
| Command | Description |
|
|
91
91
|
|---|---|
|
|
92
|
-
| `get-booking` | Retrieve the whole booking (flight + hotel) by reference (booking ref + last-name guest-auth). No subcommands. |
|
|
92
|
+
| `get-booking` | Retrieve the whole booking (flight + hotel) by reference (booking ref + last-name guest-auth). No subcommands. Carries `calendar` — the `.ics` files for the booking's flights and stays; the table format lists one line per file, `--format json` carries the contents. |
|
|
93
93
|
| `refund check` | Check refund eligibility for a booking |
|
|
94
94
|
| `refund commit` | Initiate a refund for a booking |
|
|
95
95
|
| `refund status` | Check the status of a previously committed refund |
|
|
@@ -1,3 +1,29 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import type { BookingGetResponse } from '@gojinko/api-client';
|
|
3
|
+
/**
|
|
4
|
+
* One compact line per calendar file (JIN-2176): the iTIP method and the
|
|
5
|
+
* filename the confirmation email attached that same file under.
|
|
6
|
+
*
|
|
7
|
+
* The iCalendar body itself is deliberately NOT printed — it is multi-kilobyte
|
|
8
|
+
* CRLF text, and a consumer that wants the bytes reads them from `--format
|
|
9
|
+
* json`, which carries the response untouched.
|
|
10
|
+
*
|
|
11
|
+
* Empty when the booking carries no calendar — a booking with no flight and no
|
|
12
|
+
* hotel omits it altogether — so those bookings print nothing extra. Pure —
|
|
13
|
+
* exported for tests.
|
|
14
|
+
*/
|
|
15
|
+
export declare function calendarLines(response: BookingGetResponse): string[];
|
|
16
|
+
/**
|
|
17
|
+
* Print the booking, then the calendar summary under it.
|
|
18
|
+
*
|
|
19
|
+
* JSON output gets the calendar for free — `calendar` is a response field and
|
|
20
|
+
* travels through `output` untouched — so only the human format needs anything
|
|
21
|
+
* extra. There the files are summarised INSTEAD of dumped: `output` renders a
|
|
22
|
+
* nested object by JSON.stringify-ing it into a single table cell, which for an
|
|
23
|
+
* iCalendar body means thousands of characters of escaped CRLF on one line.
|
|
24
|
+
* Swapping it for the summary keeps the table readable and leaves the bytes one
|
|
25
|
+
* `--format json` away. Exported for tests.
|
|
26
|
+
*/
|
|
27
|
+
export declare function renderGetBookingResponse(response: BookingGetResponse, format: 'json' | 'table'): void;
|
|
2
28
|
export declare function registerGetBookingCommand(program: Command): void;
|
|
3
29
|
//# sourceMappingURL=get-booking.d.ts.map
|
|
@@ -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;AAEpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG9D;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAUpE;AASD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,kBAAkB,EAC5B,MAAM,EAAE,MAAM,GAAG,OAAO,GACvB,IAAI,CAQN;AAkBD,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAYhE"}
|
|
@@ -1,4 +1,56 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
1
2
|
import { withClient, output, resolveDeprecatedFlag, userIntentOption } from './shared.js';
|
|
3
|
+
/**
|
|
4
|
+
* One compact line per calendar file (JIN-2176): the iTIP method and the
|
|
5
|
+
* filename the confirmation email attached that same file under.
|
|
6
|
+
*
|
|
7
|
+
* The iCalendar body itself is deliberately NOT printed — it is multi-kilobyte
|
|
8
|
+
* CRLF text, and a consumer that wants the bytes reads them from `--format
|
|
9
|
+
* json`, which carries the response untouched.
|
|
10
|
+
*
|
|
11
|
+
* Empty when the booking carries no calendar — a booking with no flight and no
|
|
12
|
+
* hotel omits it altogether — so those bookings print nothing extra. Pure —
|
|
13
|
+
* exported for tests.
|
|
14
|
+
*/
|
|
15
|
+
export function calendarLines(response) {
|
|
16
|
+
const files = response.booking?.calendar?.files ?? [];
|
|
17
|
+
if (files.length === 0)
|
|
18
|
+
return [];
|
|
19
|
+
const method = (file) => file.method ?? '—';
|
|
20
|
+
const width = Math.max(...files.map((file) => method(file).length));
|
|
21
|
+
return [
|
|
22
|
+
'Calendar:',
|
|
23
|
+
...files.map((file) => ` ${method(file).padEnd(width)} ${file.filename ?? '—'}`),
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
/** The same response with `booking.calendar` dropped. */
|
|
27
|
+
function withoutCalendar(response) {
|
|
28
|
+
if (!response.booking)
|
|
29
|
+
return response;
|
|
30
|
+
const { calendar: _calendar, ...booking } = response.booking;
|
|
31
|
+
return { ...response, booking };
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Print the booking, then the calendar summary under it.
|
|
35
|
+
*
|
|
36
|
+
* JSON output gets the calendar for free — `calendar` is a response field and
|
|
37
|
+
* travels through `output` untouched — so only the human format needs anything
|
|
38
|
+
* extra. There the files are summarised INSTEAD of dumped: `output` renders a
|
|
39
|
+
* nested object by JSON.stringify-ing it into a single table cell, which for an
|
|
40
|
+
* iCalendar body means thousands of characters of escaped CRLF on one line.
|
|
41
|
+
* Swapping it for the summary keeps the table readable and leaves the bytes one
|
|
42
|
+
* `--format json` away. Exported for tests.
|
|
43
|
+
*/
|
|
44
|
+
export function renderGetBookingResponse(response, format) {
|
|
45
|
+
const lines = format === 'table' ? calendarLines(response) : [];
|
|
46
|
+
output(lines.length > 0 ? withoutCalendar(response) : response, { format });
|
|
47
|
+
if (lines.length === 0)
|
|
48
|
+
return;
|
|
49
|
+
console.log('');
|
|
50
|
+
console.log(chalk.bold(lines[0]));
|
|
51
|
+
for (const line of lines.slice(1))
|
|
52
|
+
console.log(line);
|
|
53
|
+
}
|
|
2
54
|
// Commander action for `get-booking`. The canonical flag is `--booking-ref`
|
|
3
55
|
// (matches the jinko-api `booking_ref` leaf); `--ref` is kept as a deprecated
|
|
4
56
|
// alias (JIN-665).
|
|
@@ -12,13 +64,13 @@ const action = withClient(async (client, globals, opts) => {
|
|
|
12
64
|
booking_ref: bookingRef,
|
|
13
65
|
last_name: opts.lastName,
|
|
14
66
|
});
|
|
15
|
-
|
|
67
|
+
renderGetBookingResponse(response, globals.format);
|
|
16
68
|
});
|
|
17
69
|
export function registerGetBookingCommand(program) {
|
|
18
70
|
program
|
|
19
71
|
.command('get-booking')
|
|
20
72
|
.summary("Retrieve a booking using the Jinko booking reference and the traveler's last name")
|
|
21
|
-
.description(
|
|
73
|
+
.description("Anonymous retrieval for a booking the user already made. Use it when the traveler has their Jinko booking reference and last name, for example to look up the itinerary days later without signing in. Returns the full booking envelope: status, travelers, and itinerary items with confirmation numbers (PNR for flights, confirmation number for hotels), plus `calendar` — the iCalendar (.ics) files for the booking's flights and stays, the same bytes the confirmation email attaches. The human format lists one line per file; `--format json` carries the file contents.")
|
|
22
74
|
.option('--booking-ref <ref>', 'Jinko booking reference (e.g. JNK-A7B3X9) — the `booking_ref` returned by trip-status / agent-pay submit, not a supplier PNR. JSON: `booking_ref`. [required]')
|
|
23
75
|
.requiredOption('--last-name <name>', 'Last name of the primary traveler. JSON: `last_name`. [required]')
|
|
24
76
|
.addOption(userIntentOption())
|
|
@@ -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,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1F,4EAA4E;AAC5E,8EAA8E;AAC9E,mBAAmB;AACnB,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,
|
|
1
|
+
{"version":3,"file":"get-booking.js","sourceRoot":"","sources":["../../src/commands/get-booking.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1F;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAAC,QAA4B;IACxD,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,IAAI,EA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AAC,CAAC;AACpB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import type
|
|
2
|
+
import { type GroundSearchRequest } from "@gojinko/api-client";
|
|
3
3
|
/** Resolved, validated inputs for a ground_search request. */
|
|
4
4
|
export interface GroundSearchInputs {
|
|
5
5
|
departureCity?: string;
|
|
@@ -49,6 +49,7 @@ interface ConnectionLike {
|
|
|
49
49
|
value?: number;
|
|
50
50
|
currency?: string;
|
|
51
51
|
decimal_places?: number;
|
|
52
|
+
display?: string;
|
|
52
53
|
};
|
|
53
54
|
}>;
|
|
54
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ground-search.d.ts","sourceRoot":"","sources":["../../src/commands/ground-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"ground-search.d.ts","sourceRoot":"","sources":["../../src/commands/ground-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAgB,KAAK,mBAAmB,EAAqB,MAAM,qBAAqB,CAAC;AAoBhG,8DAA8D;AAC9D,MAAM,WAAW,kBAAkB;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,kBAAkB,GACxB,mBAAmB,CA+BrB;AAED,UAAU,cAAc;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,eAAe,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,iBAAiB,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3D,KAAK,CAAC,EAAE,KAAK,CAAC;QACZ,WAAW,CAAC,EAAE;YAAE,KAAK,CAAC,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;YAAC,cAAc,CAAC,EAAE,MAAM,CAAC;YAAC,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KAChG,CAAC,CAAC;CACJ;AAsDD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,cAAc,EAAE,GAAG,MAAM,EAAE,CAiCzE;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA2HlE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { tryReadMoney } from "@gojinko/api-client";
|
|
1
2
|
import { withClient, output, userIntentOption } from "./shared.js";
|
|
2
3
|
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
3
4
|
/**
|
|
@@ -92,36 +93,24 @@ function dayOffsetSuffix(departure, arrival) {
|
|
|
92
93
|
return `+${days}d`;
|
|
93
94
|
}
|
|
94
95
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
96
|
+
* The cheapest fare, read through the api-client money reader: the fare's own
|
|
97
|
+
* `display` string when it carries one, else "GBP 18.00" built from the reading.
|
|
98
|
+
*
|
|
99
|
+
* Fares are compared by major amount, not by the raw figure, so a scale is
|
|
100
|
+
* always applied before comparing. The reader honours an explicit
|
|
101
|
+
* `decimal_places: 0` and, when the field is genuinely absent, the currency's
|
|
102
|
+
* ISO digits — assuming 2 would print a JPY fare of {value: 3200} as
|
|
103
|
+
* "JPY 32.00". A fare whose money cannot be read is skipped rather than
|
|
104
|
+
* printed wrong.
|
|
100
105
|
*/
|
|
101
|
-
function isoFractionDigits(currency) {
|
|
102
|
-
if (!currency)
|
|
103
|
-
return 2;
|
|
104
|
-
try {
|
|
105
|
-
return (new Intl.NumberFormat("en-US", { style: "currency", currency })
|
|
106
|
-
.resolvedOptions().maximumFractionDigits ?? 2);
|
|
107
|
-
}
|
|
108
|
-
catch {
|
|
109
|
-
return 2;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
106
|
function cheapestFare(c) {
|
|
113
107
|
const prices = (c.fares ?? [])
|
|
114
|
-
.map((f) => f.total_price)
|
|
115
|
-
.filter((p) =>
|
|
108
|
+
.map((f) => tryReadMoney(f.total_price))
|
|
109
|
+
.filter((p) => p !== undefined);
|
|
116
110
|
if (!prices.length)
|
|
117
111
|
return "";
|
|
118
|
-
const cheapest = prices.reduce((a, b) => (
|
|
119
|
-
|
|
120
|
-
// "unset" — hence `??` — and a genuinely absent field falls back to the
|
|
121
|
-
// currency's own ISO digits rather than assuming 2.
|
|
122
|
-
const places = cheapest.decimal_places ?? isoFractionDigits(cheapest.currency);
|
|
123
|
-
const amount = (cheapest.value ?? 0) / 10 ** places;
|
|
124
|
-
return `${amount.toFixed(places)} ${cheapest.currency ?? ""}`.trim();
|
|
112
|
+
const cheapest = prices.reduce((a, b) => (a.amount <= b.amount ? a : b));
|
|
113
|
+
return cheapest.display ?? `${cheapest.currency} ${cheapest.text}`;
|
|
125
114
|
}
|
|
126
115
|
/**
|
|
127
116
|
* Table view. The connection id is printed in full and never truncated: it is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ground-search.js","sourceRoot":"","sources":["../../src/commands/ground-search.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ground-search.js","sourceRoot":"","sources":["../../src/commands/ground-search.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAA+C,MAAM,qBAAqB,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEnE,MAAM,OAAO,GAAG,qBAAqB,CAAC;AAEtC;;;;;;;;;GASG;AACH,SAAS,UAAU,CAAC,GAAW;IAC7B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QAAE,OAAO,SAAS,CAAC;IAChD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC;AAiBD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAyB;IAEzB,MAAM,IAAI,GAAwB,EAAE,cAAc,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;IAEjE,uEAAuE;IACvE,+DAA+D;IAC/D,IAAI,KAAK,CAAC,iBAAiB,EAAE,MAAM,EAAE,CAAC;QACpC,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC,iBAAiB,CAAC;IACpD,CAAC;SAAM,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,aAAa,CAAC;IAC5C,CAAC;IACD,IAAI,KAAK,CAAC,eAAe,EAAE,MAAM,EAAE,CAAC;QAClC,IAAI,CAAC,gBAA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I,CAAC,IAAI,CAAC;YACd,OAAO,CAAC,GAAG,CAAC,yBAAyB,KAAK,KAAK,IAAI,KAAK,CAAC,CAAC;YAC1D,KAAK,MAAM,IAAI,IAAI,iBAAiB,CAClC,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAqB,CAC7C,EAAE,CAAC;gBACF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACpB,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,OAAO;QACT,CAAC;QAED,MAAM,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3C,CAAC,CAAC,CACH,CAAC;AACN,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type MoneyReading } from '@gojinko/api-client';
|
|
1
2
|
/**
|
|
2
3
|
* Price-change notices for trip and checkout responses (JIN-2086 S2).
|
|
3
4
|
*
|
|
@@ -11,27 +12,23 @@
|
|
|
11
12
|
* They go to STDERR, like the deprecation notices: stdout stays exactly the
|
|
12
13
|
* response body so `jinko checkout | jq` keeps working.
|
|
13
14
|
*/
|
|
14
|
-
interface Money {
|
|
15
|
-
readonly amount: number;
|
|
16
|
-
readonly currency: string;
|
|
17
|
-
readonly decimal_places?: number;
|
|
18
|
-
}
|
|
19
15
|
export interface ItemPriceChange {
|
|
20
16
|
/** The item the move belongs to, when the response named one. */
|
|
21
17
|
readonly itemId?: string;
|
|
22
|
-
readonly original:
|
|
23
|
-
readonly current:
|
|
18
|
+
readonly original: MoneyReading;
|
|
19
|
+
readonly current: MoneyReading;
|
|
24
20
|
/** `current` minus `original`, SIGNED: negative when the price fell. */
|
|
25
|
-
readonly delta:
|
|
21
|
+
readonly delta: MoneyReading;
|
|
26
22
|
}
|
|
27
23
|
/**
|
|
28
24
|
* Reads every stated price move off a response body.
|
|
29
25
|
*
|
|
30
26
|
* Defensive on purpose: the CLI talks to whatever the deployed API is, and the
|
|
31
27
|
* item arrays it reads are typed `unknown[]` on two of the four responses. A
|
|
32
|
-
* block missing any of the three figures
|
|
33
|
-
* — "changed from 100.00 to
|
|
34
|
-
* own `price` is still in
|
|
28
|
+
* block missing any of the three figures, or carrying one the money reader
|
|
29
|
+
* rejects, is dropped rather than half-reported — "changed from 100.00 to
|
|
30
|
+
* (unknown)" says less than nothing, and the item's own `price` is still in
|
|
31
|
+
* the body.
|
|
35
32
|
*/
|
|
36
33
|
export declare function readPriceChanges(response: unknown): ItemPriceChange[];
|
|
37
34
|
/** One line per moved item; an empty array when no price moved. */
|
|
@@ -41,5 +38,4 @@ export declare function priceChangeNotices(response: unknown): string[];
|
|
|
41
38
|
* is already on stdout and the notices are the last thing a human reads.
|
|
42
39
|
*/
|
|
43
40
|
export declare function printPriceChangeNotices(response: unknown, write?: (line: string) => void): void;
|
|
44
|
-
export {};
|
|
45
41
|
//# sourceMappingURL=price-change.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"price-change.d.ts","sourceRoot":"","sources":["../../src/output/price-change.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"price-change.d.ts","sourceRoot":"","sources":["../../src/output/price-change.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEtE;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,eAAe;IAC9B,iEAAiE;IACjE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,wEAAwE;IACxE,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;CAC9B;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,eAAe,EAAE,CAyBrE;AAsBD,mEAAmE;AACnE,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,EAAE,CAU9D;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,OAAO,EACjB,KAAK,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAA2C,GACnE,IAAI,CAIN"}
|
|
@@ -1,26 +1,14 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
|
|
3
|
-
if (!value || typeof value !== 'object')
|
|
4
|
-
return undefined;
|
|
5
|
-
const money = value;
|
|
6
|
-
if (typeof money.amount !== 'number' || !Number.isFinite(money.amount))
|
|
7
|
-
return undefined;
|
|
8
|
-
if (typeof money.currency !== 'string' || money.currency === '')
|
|
9
|
-
return undefined;
|
|
10
|
-
return {
|
|
11
|
-
amount: money.amount,
|
|
12
|
-
currency: money.currency,
|
|
13
|
-
...(typeof money.decimal_places === 'number' ? { decimal_places: money.decimal_places } : {}),
|
|
14
|
-
};
|
|
15
|
-
}
|
|
2
|
+
import { tryReadMoney } from '@gojinko/api-client';
|
|
16
3
|
/**
|
|
17
4
|
* Reads every stated price move off a response body.
|
|
18
5
|
*
|
|
19
6
|
* Defensive on purpose: the CLI talks to whatever the deployed API is, and the
|
|
20
7
|
* item arrays it reads are typed `unknown[]` on two of the four responses. A
|
|
21
|
-
* block missing any of the three figures
|
|
22
|
-
* — "changed from 100.00 to
|
|
23
|
-
* own `price` is still in
|
|
8
|
+
* block missing any of the three figures, or carrying one the money reader
|
|
9
|
+
* rejects, is dropped rather than half-reported — "changed from 100.00 to
|
|
10
|
+
* (unknown)" says less than nothing, and the item's own `price` is still in
|
|
11
|
+
* the body.
|
|
24
12
|
*/
|
|
25
13
|
export function readPriceChanges(response) {
|
|
26
14
|
if (!response || typeof response !== 'object')
|
|
@@ -37,9 +25,9 @@ export function readPriceChanges(response) {
|
|
|
37
25
|
if (!block || typeof block !== 'object')
|
|
38
26
|
continue;
|
|
39
27
|
const change = block;
|
|
40
|
-
const original =
|
|
41
|
-
const current =
|
|
42
|
-
const delta =
|
|
28
|
+
const original = tryReadMoney(change.original);
|
|
29
|
+
const current = tryReadMoney(change.current);
|
|
30
|
+
const delta = tryReadMoney(change.delta);
|
|
43
31
|
if (!original || !current || !delta)
|
|
44
32
|
continue;
|
|
45
33
|
const itemId = record.item_id;
|
|
@@ -53,16 +41,22 @@ export function readPriceChanges(response) {
|
|
|
53
41
|
return changes;
|
|
54
42
|
}
|
|
55
43
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
44
|
+
* One amount as the server wrote it when the object carries `display`, else the
|
|
45
|
+
* same shape built from the reading: ISO code first, then the major amount —
|
|
46
|
+
* "USD 159.77". The reader applies the published money rule, so a scaled figure
|
|
47
|
+
* is divided into major units and an unscaled amount is printed at the
|
|
48
|
+
* currency's own ISO digits.
|
|
58
49
|
*/
|
|
59
50
|
function formatMoney(money) {
|
|
60
|
-
|
|
61
|
-
return `${money.amount.toFixed(digits)} ${money.currency}`;
|
|
51
|
+
return money.display ?? `${money.currency} ${money.text}`;
|
|
62
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* A difference prints like any amount, with "+" in front when the price rose.
|
|
55
|
+
* A fall needs nothing added: `display` and the reader's text both put the
|
|
56
|
+
* minus after the code ("USD -10.00"), so either source gives the same line.
|
|
57
|
+
*/
|
|
63
58
|
function formatDelta(delta) {
|
|
64
|
-
|
|
65
|
-
return `${delta.amount > 0 ? '+' : ''}${delta.amount.toFixed(digits)} ${delta.currency}`;
|
|
59
|
+
return `${delta.amount > 0 ? '+' : ''}${formatMoney(delta)}`;
|
|
66
60
|
}
|
|
67
61
|
/** One line per moved item; an empty array when no price moved. */
|
|
68
62
|
export function priceChangeNotices(response) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"price-change.js","sourceRoot":"","sources":["../../src/output/price-change.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"price-change.js","sourceRoot":"","sources":["../../src/output/price-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AM,IAAI,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC;QAClD,KAAK,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gojinko/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.25.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"jinko": "./dist/bin/jinko.js"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"docs:gen": "tsx scripts/gen-cli-docs.ts"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@gojinko/api-client": "2.
|
|
20
|
+
"@gojinko/api-client": "2.25.0",
|
|
21
21
|
"commander": "^12.1.0",
|
|
22
22
|
"chalk": "^5.4.1"
|
|
23
23
|
},
|