@gojinko/cli 2.14.0 → 2.16.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 +11 -5
- package/SKILL.md +10 -6
- package/dist/commands/agent-pay.d.ts +3 -0
- package/dist/commands/agent-pay.d.ts.map +1 -0
- package/dist/commands/agent-pay.js +18 -0
- package/dist/commands/agent-pay.js.map +1 -0
- package/dist/commands/checkout.d.ts +1 -1
- package/dist/commands/checkout.d.ts.map +1 -1
- package/dist/commands/checkout.js +14 -4
- package/dist/commands/checkout.js.map +1 -1
- package/dist/commands/schema.d.ts.map +1 -1
- package/dist/commands/schema.js +23 -3
- package/dist/commands/schema.js.map +1 -1
- package/dist/commands/shared.d.ts +15 -0
- package/dist/commands/shared.d.ts.map +1 -1
- package/dist/commands/shared.js +34 -0
- package/dist/commands/shared.js.map +1 -1
- package/dist/commands/travel-demand/demand-shared.d.ts +31 -0
- package/dist/commands/travel-demand/demand-shared.d.ts.map +1 -0
- package/dist/commands/travel-demand/demand-shared.js +141 -0
- package/dist/commands/travel-demand/demand-shared.js.map +1 -0
- package/dist/commands/travel-demand/index.d.ts +10 -0
- package/dist/commands/travel-demand/index.d.ts.map +1 -0
- package/dist/commands/travel-demand/index.js +35 -0
- package/dist/commands/travel-demand/index.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/output/formatter.d.ts.map +1 -1
- package/dist/output/formatter.js +39 -16
- package/dist/output/formatter.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -49,6 +49,8 @@ Prod and sandbox keys are stored separately in `~/.jinko/config.yaml`. Resolutio
|
|
|
49
49
|
|---|---|
|
|
50
50
|
| `find-destination` | Discover destinations from an origin |
|
|
51
51
|
| `flight-calendar` | Cheapest prices across a date range for a known route |
|
|
52
|
+
| `find-dates` | Best date options for a known route — up to ten cheapest itineraries, one per date-pair, spread across the month |
|
|
53
|
+
| `lowest-fare` | Cheapest fares for a fixed route + date — up to ten itineraries, cheapest first |
|
|
52
54
|
|
|
53
55
|
### Live pricing & trip building
|
|
54
56
|
|
|
@@ -69,7 +71,9 @@ Prod and sandbox keys are stored separately in `~/.jinko/config.yaml`. Resolutio
|
|
|
69
71
|
|
|
70
72
|
| Command | Description |
|
|
71
73
|
|---|---|
|
|
72
|
-
| `
|
|
74
|
+
| `checkout` | Finalize a trip → returns `checkout_url` (human pays in a browser) + `agent_spt_params` (agent pays programmatically) + items + total. (`book` is a deprecated alias.) |
|
|
75
|
+
| `agent-pay submit` | Pay programmatically with a Shared Payment Token: present `--trip-id` + `--token`; the BFF schedules the agent fulfillment and redeems the SPT. Falls back to `checkout_url` on a 3DS step-up. |
|
|
76
|
+
| `get-ancillaries` | List a trip's purchasable ancillaries (bags / seats / meals) without generating a checkout URL |
|
|
73
77
|
| `select-ancillaries` | Optional: preselect bags / seats / meals before handoff |
|
|
74
78
|
| `trip-status` | Full lifecycle state: cart, quote, fulfillment, bookings |
|
|
75
79
|
|
|
@@ -97,10 +101,11 @@ Prod and sandbox keys are stored separately in `~/.jinko/config.yaml`. Resolutio
|
|
|
97
101
|
## Canonical Flow
|
|
98
102
|
|
|
99
103
|
```
|
|
100
|
-
flight-search → trip →
|
|
104
|
+
flight-search → trip → checkout → user pays on checkout_url → trip-status
|
|
105
|
+
↘ agent-pay submit (programmatic, Shared Payment Token) → trip-status
|
|
101
106
|
```
|
|
102
107
|
|
|
103
|
-
Quote is automatic — `
|
|
108
|
+
Quote is automatic — `checkout` handles it internally. A human pays on the returned `checkout_url` (the Jinko web page, not in the CLI); an agent can instead mint a Shared Payment Token from `agent_spt_params` and call `agent-pay submit` to pay programmatically.
|
|
104
109
|
|
|
105
110
|
## Examples
|
|
106
111
|
|
|
@@ -124,8 +129,8 @@ jinko trip \
|
|
|
124
129
|
--travelers '[{"first_name":"Jane","last_name":"Doe","date_of_birth":"1990-01-15","gender":"FEMALE","passenger_type":"ADULT"}]' \
|
|
125
130
|
--contact '{"email":"jane@example.com","phone":"+33612345678"}'
|
|
126
131
|
|
|
127
|
-
#
|
|
128
|
-
jinko
|
|
132
|
+
# Finalize → returns checkout_url (human) + agent_spt_params (agent)
|
|
133
|
+
jinko checkout --trip-id <trip_id>
|
|
129
134
|
|
|
130
135
|
# Optional: add baggage/seats/meals before handoff
|
|
131
136
|
jinko select-ancillaries \
|
|
@@ -177,6 +182,7 @@ JSON output stays parseable) and will be removed in the next major release.
|
|
|
177
182
|
| `flight-search`, `price-monitoring` | `--cabin-class` | `--cabin` |
|
|
178
183
|
| `flight-search`, `price-monitoring` | `--adults` | `--passengers` |
|
|
179
184
|
| `flight-calendar` | `--origins` / `--destinations` | `--from` / `--to` |
|
|
185
|
+
| `find-dates`, `lowest-fare` | `--origins` / `--destinations` | `--from` / `--to` |
|
|
180
186
|
| `find-destination` | `--origins` / `--departure-dates` / `--max-total` / `--sort-by` … | `--from` / `--date` / `--max-price` / `--sort` … |
|
|
181
187
|
| `hotel-search` | `--city-name` / `--country-code` | `--city` / `--country` |
|
|
182
188
|
| `hotel-search` | `--latitude` / `--longitude` / `--radius-km` | `--lat` / `--lng` / `--radius` |
|
package/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Jinko CLI — Agent Skill Guide
|
|
2
2
|
|
|
3
|
-
You are using `jinko`, a CLI for the Jinko developer platform.
|
|
3
|
+
You are using `jinko`, a CLI for the Jinko developer platform. A trip can be paid two ways: a human opens the Jinko-hosted `checkout_url` in a browser, OR an agent pays programmatically with a Shared Payment Token via `agent-pay submit` (no browser, no checkout page).
|
|
4
4
|
|
|
5
5
|
## Authentication
|
|
6
6
|
|
|
@@ -33,8 +33,9 @@ Opens a browser for WorkOS device flow login. Token is stored in `~/.jinko/confi
|
|
|
33
33
|
- `trip` — create/update a trip (add items, set travelers + contact). Returns `trip_id`.
|
|
34
34
|
|
|
35
35
|
### Checkout
|
|
36
|
-
- `checkout` —
|
|
37
|
-
- `
|
|
36
|
+
- `checkout` — finalize a trip; returns BOTH `checkout_url` (a human opens it to pay) AND `agent_spt_params` (an agent uses them to pay programmatically), plus items + ancillaries + total. (`book` is a deprecated alias.)
|
|
37
|
+
- `agent-pay submit --trip-id <id> --token <spt>` — pay programmatically: mint a Shared Payment Token scoped to `checkout`'s `agent_spt_params`, then submit it; the BFF schedules the agent fulfillment and redeems the token. A 3DS step-up / decline falls back to a `checkout_url`.
|
|
38
|
+
- `select-ancillaries` — (optional) preselect bags/seats/meals before checkout.
|
|
38
39
|
|
|
39
40
|
### Status
|
|
40
41
|
- `trip-status` — full lifecycle state: cart, quote, fulfillment, bookings (PNRs).
|
|
@@ -58,12 +59,15 @@ Opens a browser for WorkOS device flow login. Token is stored in `~/.jinko/confi
|
|
|
58
59
|
→ returns trip_id
|
|
59
60
|
|
|
60
61
|
3. jinko checkout --trip-id <trip_id>
|
|
61
|
-
→ returns { checkout_url, items, available_ancillaries, total_amount }
|
|
62
|
+
→ returns { checkout_url, agent_spt_params, items, available_ancillaries, total_amount }
|
|
62
63
|
|
|
63
64
|
4. (optional) jinko select-ancillaries --trip-id <id> --item-id <id> --select <offer_ids>
|
|
64
65
|
→ apply bag/seat selections
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
5a. Human path: send the user to checkout_url — they complete payment on the Jinko web page.
|
|
68
|
+
5b. Agent path: mint a Shared Payment Token scoped to agent_spt_params, then
|
|
69
|
+
jinko agent-pay submit --trip-id <trip_id> --token <spt>
|
|
70
|
+
→ { status: "processing", payment_verified: true } (or a checkout_url fallback on 3DS)
|
|
67
71
|
|
|
68
72
|
6. jinko trip-status --trip-id <trip_id>
|
|
69
73
|
→ poll until status = "fulfilled" (or "partially_fulfilled") to get PNRs.
|
|
@@ -72,7 +76,7 @@ Opens a browser for WorkOS device flow login. Token is stored in `~/.jinko/confi
|
|
|
72
76
|
## Important Notes
|
|
73
77
|
|
|
74
78
|
- Quote is automatic — you never call it explicitly. `checkout` handles it internally.
|
|
75
|
-
- Payment happens on the Jinko web page
|
|
79
|
+
- Payment happens either on the Jinko web page (`checkout_url`) or programmatically via `agent-pay submit` (Shared Payment Token).
|
|
76
80
|
- Ancillary selection CAN happen via the CLI before handoff, or on the web page.
|
|
77
81
|
- Airport codes: IATA (PAR, NYC, JFK).
|
|
78
82
|
- Dates: YYYY-MM-DD.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-pay.d.ts","sourceRoot":"","sources":["../../src/commands/agent-pay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAsBnE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { withClient, output } from './shared.js';
|
|
2
|
+
export function registerAgentPaymentCommands(program) {
|
|
3
|
+
const agent = program
|
|
4
|
+
.command('agent-pay')
|
|
5
|
+
.summary('Pay for a trip programmatically with a Shared Payment Token (no checkout page)')
|
|
6
|
+
.description('Programmatic agent payment (JIN-1109). First call `checkout` to get the trip\'s `agent_spt_params`, mint a Shared Payment Token scoped to them, then `submit` it here. In one call the BFF schedules the agent fulfillment and redeems the token to authorize the booking server-side — no browser, no hosted checkout page. On a 3DS step-up or decline, `submit` returns a checkout_url the user can complete instead.');
|
|
7
|
+
agent
|
|
8
|
+
.command('submit')
|
|
9
|
+
.summary('Submit a Shared Payment Token to schedule + authorize the booking')
|
|
10
|
+
.description('Present a trip ID and a Shared Payment Token: the BFF schedules the agent fulfillment and redeems the token to authorize the booking server-side, advancing it to fulfillment. If the issuer requires customer action (3DS) the response carries a checkout_url fallback instead of confirming.')
|
|
11
|
+
.requiredOption('--trip-id <id>', 'trip ID (from the trip command) [required]')
|
|
12
|
+
.requiredOption('--token <spt>', 'Shared Payment Token (spt_...) [required]')
|
|
13
|
+
.action(withClient(async (client, globals, opts) => {
|
|
14
|
+
const response = await client.submitAgentPayment(opts.tripId, opts.token);
|
|
15
|
+
output(response, { format: globals.format });
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=agent-pay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-pay.js","sourceRoot":"","sources":["../../src/commands/agent-pay.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,UAAU,4BAA4B,CAAC,OAAgB;IAC3D,MAAM,KAAK,GAAG,OAAO;SAClB,OAAO,CAAC,WAAW,CAAC;SACpB,OAAO,CAAC,gFAAgF,CAAC;SACzF,WAAW,CACV,0ZAA0Z,CAC3Z,CAAC;IAEJ,KAAK;SACF,OAAO,CAAC,QAAQ,CAAC;SACjB,OAAO,CAAC,mEAAmE,CAAC;SAC5E,WAAW,CACV,iSAAiS,CAClS;SACA,cAAc,CAAC,gBAAgB,EAAE,4CAA4C,CAAC;SAC9E,cAAc,CAAC,eAAe,EAAE,2CAA2C,CAAC;SAC5E,MAAM,CACL,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QACzC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1E,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":"checkout.d.ts","sourceRoot":"","sources":["../../src/commands/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,wBAAgB,
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/commands/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuB9D"}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { withClient, output } from './shared.js';
|
|
2
|
-
export function
|
|
2
|
+
export function registerCheckoutCommand(program) {
|
|
3
3
|
program
|
|
4
|
-
.command('
|
|
5
|
-
.summary('
|
|
6
|
-
.description('
|
|
4
|
+
.command('checkout')
|
|
5
|
+
.summary('Checkout a trip — returns a checkout URL the user opens to pay, plus agent payment params')
|
|
6
|
+
.description('Finalize a finalized trip. Use it once the trip is set and traveler details are filled in, for example after the user picks a Paris to Tokyo round trip and adds a hotel for the stay. The response carries two payment paths: `checkout_url` is what a human opens in a browser to pay, and `agent_spt_params` (max amount, currency, profile) is what an agent uses to mint a Shared Payment Token and pay programmatically via `agent-pay submit`.')
|
|
7
|
+
.requiredOption('--trip-id <id>', 'trip ID (from trip command) [required]')
|
|
8
|
+
.action(withClient(async (client, globals, opts) => {
|
|
9
|
+
const response = await client.checkout(opts.tripId);
|
|
10
|
+
output(response, { format: globals.format });
|
|
11
|
+
}));
|
|
12
|
+
// DEPRECATED alias — `book` was renamed to `checkout` (JIN-1131). Kept so
|
|
13
|
+
// existing scripts keep working; mcp-apps still exposes `book`.
|
|
14
|
+
program
|
|
15
|
+
.command('book', { hidden: true })
|
|
16
|
+
.summary('DEPRECATED — use `checkout`. Alias retained for backward compatibility.')
|
|
7
17
|
.requiredOption('--trip-id <id>', 'trip ID (from trip command) [required]')
|
|
8
18
|
.action(withClient(async (client, globals, opts) => {
|
|
9
19
|
const response = await client.book(opts.tripId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../src/commands/checkout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../src/commands/checkout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACtD,OAAO;SACJ,OAAO,CAAC,UAAU,CAAC;SACnB,OAAO,CAAC,2FAA2F,CAAC;SACpG,WAAW,CACV,ubAAub,CACxb;SACA,cAAc,CAAC,gBAAgB,EAAE,wCAAwC,CAAC;SAC1E,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QACjD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACpD,MAAM,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC,CAAC;IAEN,0EAA0E;IAC1E,gEAAgE;IAChE,OAAO;SACJ,OAAO,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;SACjC,OAAO,CAAC,yEAAyE,CAAC;SAClF,cAAc,CAAC,gBAAgB,EAAE,wCAAwC,CAAC;SAC1E,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QACjD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAChD,MAAM,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC,CAAC;AACR,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/commands/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/commands/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgMpC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmC5D"}
|
package/dist/commands/schema.js
CHANGED
|
@@ -80,17 +80,18 @@ const SCHEMAS = {
|
|
|
80
80
|
actions_performed: "string[]",
|
|
81
81
|
},
|
|
82
82
|
},
|
|
83
|
-
|
|
84
|
-
description: "
|
|
83
|
+
checkout: {
|
|
84
|
+
description: "Checkout a trip — returns the web checkout_url a human opens to pay, the agent_spt_params an agent uses to pay programmatically, plus cart items and ancillaries (POST /shop/sync/checkout). `book` is a deprecated alias.",
|
|
85
85
|
request: {
|
|
86
86
|
trip_id: "string (from trip command)",
|
|
87
87
|
},
|
|
88
88
|
response: {
|
|
89
89
|
session_id: "string",
|
|
90
|
-
checkout_url: "string",
|
|
90
|
+
checkout_url: "string (human payment URL)",
|
|
91
91
|
expires_at: "string? (ISO datetime)",
|
|
92
92
|
status: "ready | pending | failed",
|
|
93
93
|
total_amount: "{ amount: number, currency: string }?",
|
|
94
|
+
agent_spt_params: "{ max_amount: number, currency: string, stripe_profile?: string, expires_at?: string }? (mint an SPT scoped to these, then call agent-pay submit)",
|
|
94
95
|
items: "[{ item_id, kind, price, pax_count, available_ancillaries: [...], selected_ancillaries: [...] }]",
|
|
95
96
|
},
|
|
96
97
|
},
|
|
@@ -139,6 +140,25 @@ const SCHEMAS = {
|
|
|
139
140
|
items: "[...]",
|
|
140
141
|
},
|
|
141
142
|
},
|
|
143
|
+
"agent-pay": {
|
|
144
|
+
description: "One-call programmatic payment with a Shared Payment Token — the alternative to opening `checkout`'s checkout URL. Get `agent_spt_params` from `checkout`, mint an SPT scoped to them, then `agent-pay submit` presents trip_id + the SPT: the BFF schedules the agent fulfillment and redeems the token (POST /v1/agent_payment/submit).",
|
|
145
|
+
request: {
|
|
146
|
+
submit: {
|
|
147
|
+
trip_id: "string (from trip command)",
|
|
148
|
+
shared_payment_token: "string (SPT minted for the checkout agent_spt_params)",
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
response: {
|
|
152
|
+
submit: {
|
|
153
|
+
fulfillment_cart_id: "number",
|
|
154
|
+
status: "string",
|
|
155
|
+
payment_verified: "boolean",
|
|
156
|
+
message: "string?",
|
|
157
|
+
checkout_url: "string? (hosted-checkout fallback, present only on a 3DS step-up / decline)",
|
|
158
|
+
recap_token: "string?",
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
142
162
|
};
|
|
143
163
|
export function registerSchemaCommand(program) {
|
|
144
164
|
program
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/commands/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;GAEG;AACH,MAAM,OAAO,GAOT;IACF,kBAAkB,EAAE;QAClB,WAAW,EACT,gFAAgF;QAClF,OAAO,EAAE;YACP,UAAU,EAAE,iBAAiB;YAC7B,OAAO,EAAE;gBACP,SAAS,EAAE,uBAAuB;gBAClC,KAAK,EAAE,0DAA0D;gBACjE,SAAS,EAAE,oBAAoB;aAChC;YACD,uBAAuB,EAAE,qBAAqB;YAC9C,KAAK,EAAE,sBAAsB;YAC7B,iBAAiB,EAAE,yBAAyB;SAC7C;QACD,QAAQ,EAAE;YACR,MAAM,EAAE,wCAAwC;YAChD,YAAY,EAAE,yDAAyD;YACvE,UAAU,EAAE,qBAAqB;YACjC,KAAK,EAAE,QAAQ;SAChB;KACF;IACD,eAAe,EAAE;QACf,WAAW,EACT,0EAA0E;QAC5E,OAAO,EAAE;YACP,aAAa,EAAE;gBACb,MAAM,EAAE,oBAAoB;gBAC5B,WAAW,EAAE,oBAAoB;gBACjC,cAAc,EAAE,qBAAqB;gBACrC,WAAW,EAAE,sBAAsB;gBACnC,SAAS,EAAE,oBAAoB;gBAC/B,WAAW,EAAE,8CAA8C;gBAC3D,WAAW,EAAE,UAAU;gBACvB,SAAS,EAAE,SAAS;gBACpB,UAAU,EAAE,0DAA0D;aACvE;YACD,kBAAkB,EAAE;gBAClB,WAAW,EAAE,wDAAwD;gBACrE,UAAU,EAAE,0DAA0D;aACvE;SACF;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,sBAAsB;YAC5B,OAAO,EACL,8FAA8F;YAChG,KAAK,EACH,oGAAoG;SACvG;KACF;IACD,iBAAiB,EAAE;QACjB,WAAW,EACT,6EAA6E;QAC/E,OAAO,EAAE;YACP,IAAI,EAAE,4BAA4B;YAClC,EAAE,EAAE,iCAAiC;YACrC,KAAK,EAAE,kBAAkB;YACzB,WAAW,EAAE,2BAA2B;YACxC,WAAW,EAAE,UAAU;SACxB;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,qCAAqC;SACnD;KACF;IACD,IAAI,EAAE;QACJ,WAAW,EACT,kFAAkF;QACpF,OAAO,EAAE;YACP,OAAO,EAAE,8BAA8B;YACvC,QAAQ,EAAE,mDAAmD;YAC7D,WAAW,EACT,8IAA8I;YAChJ,gBAAgB,EACd,8TAA8T;SACjU;QACD,QAAQ,EAAE;YACR,OAAO,EAAE,QAAQ;YACjB,MAAM,EAAE,QAAQ;YAChB,KAAK,EAAE,mDAAmD;YAC1D,SAAS,EAAE,OAAO;YAClB,OAAO,EAAE,kBAAkB;YAC3B,MAAM,EAAE,qBAAqB;YAC7B,iBAAiB,EAAE,UAAU;SAC9B;KACF;IACD,
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/commands/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;GAEG;A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,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YACzC,OAAO;QACT,CAAC;QAED,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClD,OAAO,CAAC,KAAK,CACX,oBAAoB,WAAW,gBAAgB,SAAS,EAAE,CAC3D,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,MAAM,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1E,CAAC,CACF,CAAC;AACN,CAAC"}
|
|
@@ -4,6 +4,21 @@ import { type GlobalOptions } from '../config/config.js';
|
|
|
4
4
|
import { output, outputError } from '../output/formatter.js';
|
|
5
5
|
export { output, outputError };
|
|
6
6
|
export type { GlobalOptions };
|
|
7
|
+
/** Thrown by command input validation; mapped to exit code 3. */
|
|
8
|
+
export declare class UsageError extends Error {
|
|
9
|
+
readonly code: string;
|
|
10
|
+
constructor(message: string, code?: string);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Map a thrown error to a stderr message + process exit:
|
|
14
|
+
* 3 = bad input (UsageError) · 2 = auth required (AuthError) · 1 = API/other.
|
|
15
|
+
*
|
|
16
|
+
* Input validation is checked first so a missing flag never masquerades as an
|
|
17
|
+
* auth error. AuthError is checked before ApiError because it extends it. This
|
|
18
|
+
* mirrors withClient's mapping but adds the exit-3 path and lets commands that
|
|
19
|
+
* must validate BEFORE creating a client (e.g. travel-demand) reuse it.
|
|
20
|
+
*/
|
|
21
|
+
export declare function exitWithError(err: unknown, globals: GlobalOptions): never;
|
|
7
22
|
/**
|
|
8
23
|
* Promote a deprecated flag onto its canonical counterpart (JIN-665).
|
|
9
24
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/commands/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAA0C,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AAC/B,YAAY,EAAE,aAAa,EAAE,CAAC;AAE9B;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,SAAS,EAAE,CAAC,GAAG,SAAS,EACxB,UAAU,EAAE,CAAC,GAAG,SAAS,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,CAAC,GAAG,SAAS,CAMf;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,CACP,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,aAAa,EAEtB,OAAO,CAAC,EAAE,GAAG,EACb,GAAG,CAAC,EAAE,OAAO,KACV,OAAO,CAAC,IAAI,CAAC,IAGK,MAAM,OAAO,EAAE,GAAG,MAAM,GAAG,EAAE,mBA4BrD"}
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/commands/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAA0C,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AAC/B,YAAY,EAAE,aAAa,EAAE,CAAC;AAE9B,iEAAiE;AACjE,qBAAa,UAAW,SAAQ,KAAK;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBACV,OAAO,EAAE,MAAM,EAAE,IAAI,SAAkB;CAKpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,GAAG,KAAK,CAezE;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,SAAS,EAAE,CAAC,GAAG,SAAS,EACxB,UAAU,EAAE,CAAC,GAAG,SAAS,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,CAAC,GAAG,SAAS,CAMf;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,CACP,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,aAAa,EAEtB,OAAO,CAAC,EAAE,GAAG,EACb,GAAG,CAAC,EAAE,OAAO,KACV,OAAO,CAAC,IAAI,CAAC,IAGK,MAAM,OAAO,EAAE,GAAG,MAAM,GAAG,EAAE,mBA4BrD"}
|
package/dist/commands/shared.js
CHANGED
|
@@ -2,6 +2,40 @@ import { createJinkoClient, ApiError, AuthError } from '@gojinko/api-client';
|
|
|
2
2
|
import { getGlobalOptions } from '../config/config.js';
|
|
3
3
|
import { output, outputError } from '../output/formatter.js';
|
|
4
4
|
export { output, outputError };
|
|
5
|
+
/** Thrown by command input validation; mapped to exit code 3. */
|
|
6
|
+
export class UsageError extends Error {
|
|
7
|
+
code;
|
|
8
|
+
constructor(message, code = 'INVALID_INPUT') {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = 'UsageError';
|
|
11
|
+
this.code = code;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Map a thrown error to a stderr message + process exit:
|
|
16
|
+
* 3 = bad input (UsageError) · 2 = auth required (AuthError) · 1 = API/other.
|
|
17
|
+
*
|
|
18
|
+
* Input validation is checked first so a missing flag never masquerades as an
|
|
19
|
+
* auth error. AuthError is checked before ApiError because it extends it. This
|
|
20
|
+
* mirrors withClient's mapping but adds the exit-3 path and lets commands that
|
|
21
|
+
* must validate BEFORE creating a client (e.g. travel-demand) reuse it.
|
|
22
|
+
*/
|
|
23
|
+
export function exitWithError(err, globals) {
|
|
24
|
+
if (err instanceof UsageError) {
|
|
25
|
+
outputError({ code: err.code, message: err.message }, globals);
|
|
26
|
+
process.exit(3);
|
|
27
|
+
}
|
|
28
|
+
if (err instanceof AuthError) {
|
|
29
|
+
outputError({ code: err.code, message: err.message, doc_url: err.docUrl }, globals);
|
|
30
|
+
process.exit(2);
|
|
31
|
+
}
|
|
32
|
+
if (err instanceof ApiError) {
|
|
33
|
+
outputError({ code: err.code, message: err.message, doc_url: err.docUrl }, globals);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
outputError({ message: err instanceof Error ? err.message : String(err) }, globals);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
5
39
|
/**
|
|
6
40
|
* Promote a deprecated flag onto its canonical counterpart (JIN-665).
|
|
7
41
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/commands/shared.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,SAAS,EAAoB,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAsB,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AAG/B;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CACnC,SAAwB,EACxB,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CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;YACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Shared option registration + request building for the three travel-demand commands. */
|
|
2
|
+
import type { Command } from 'commander';
|
|
3
|
+
import { type DemandQuery, type JinkoClient } from '@gojinko/api-client';
|
|
4
|
+
/** Raw option bag as parsed by Commander (camelCased flags). */
|
|
5
|
+
export interface DemandCliOpts {
|
|
6
|
+
analysis?: string;
|
|
7
|
+
originMarket?: string;
|
|
8
|
+
destination?: string;
|
|
9
|
+
travelPeriod?: string;
|
|
10
|
+
departureDateFrom?: string;
|
|
11
|
+
departureDateTo?: string;
|
|
12
|
+
travelerType?: string;
|
|
13
|
+
tripType?: string;
|
|
14
|
+
limit?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface BuildOpts {
|
|
17
|
+
requireDestination?: boolean;
|
|
18
|
+
allowTravelerType?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** Validate CLI options and build the wire query. Throws UsageError (exit 3) on bad input. */
|
|
21
|
+
export declare function buildDemandQuery(opts: DemandCliOpts, build?: BuildOpts): DemandQuery;
|
|
22
|
+
/**
|
|
23
|
+
* Build a Commander action for a demand command. Order matters: validate input FIRST
|
|
24
|
+
* (UsageError -> exit 3), THEN construct the client (AuthError -> exit 2), THEN call the
|
|
25
|
+
* API — so a missing required flag is never reported as an auth error. (This is why these
|
|
26
|
+
* commands don't use the generic withClient wrapper, which creates the client first.)
|
|
27
|
+
*/
|
|
28
|
+
export declare function demandAction(build: BuildOpts, call: (client: JinkoClient, query: DemandQuery) => Promise<unknown>): (this: Command, ...args: unknown[]) => Promise<void>;
|
|
29
|
+
/** Register the query options shared by all three demand commands. */
|
|
30
|
+
export declare function addCommonDemandOptions(cmd: Command): Command;
|
|
31
|
+
//# sourceMappingURL=demand-shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demand-shared.d.ts","sourceRoot":"","sources":["../../../src/commands/travel-demand/demand-shared.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,WAAW,EAIjB,MAAM,qBAAqB,CAAC;AAmB7B,gEAAgE;AAChE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAgDD,8FAA8F;AAC9F,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,GAAE,SAAc,GAAG,WAAW,CA2CxF;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC,OAAO,CAAC,IAE5C,MAAM,OAAO,EAAE,GAAG,MAAM,OAAO,EAAE,KAAG,OAAO,CAAC,IAAI,CAAC,CAezE;AAED,sEAAsE;AACtE,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAY5D"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { createJinkoClient, } from '@gojinko/api-client';
|
|
2
|
+
import { getGlobalOptions } from '../../config/config.js';
|
|
3
|
+
import { exitWithError, output, UsageError } from '../shared.js';
|
|
4
|
+
const ANALYSIS = ['snapshot', 'trend'];
|
|
5
|
+
const TRAVEL_PERIODS = [
|
|
6
|
+
'Summer',
|
|
7
|
+
'Winter',
|
|
8
|
+
'Christmas',
|
|
9
|
+
'Easter',
|
|
10
|
+
'Next30Days',
|
|
11
|
+
'Next90Days',
|
|
12
|
+
'Custom',
|
|
13
|
+
];
|
|
14
|
+
const TRAVELER_TYPES = ['Solo', 'Couple', 'Group', 'Family'];
|
|
15
|
+
const TRIP_TYPES = ['One-Way', 'Round-Trip'];
|
|
16
|
+
const LEVELS = ['City', 'Country'];
|
|
17
|
+
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
18
|
+
function checkEnum(value, allowed, flag) {
|
|
19
|
+
if (value === undefined)
|
|
20
|
+
return undefined;
|
|
21
|
+
if (!allowed.includes(value)) {
|
|
22
|
+
throw new UsageError(`${flag} must be one of: ${allowed.join(', ')} (got "${value}")`);
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
function checkLocation(value, flag) {
|
|
27
|
+
if (value === undefined)
|
|
28
|
+
return undefined;
|
|
29
|
+
const parts = value.split(':');
|
|
30
|
+
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
31
|
+
throw new UsageError(`${flag} must be "<Level>:<Code>", e.g. Country:US or City:NYC (got "${value}")`);
|
|
32
|
+
}
|
|
33
|
+
if (!LEVELS.includes(parts[0])) {
|
|
34
|
+
throw new UsageError(`${flag} level must be one of: ${LEVELS.join(', ')} (got "${parts[0]}")`);
|
|
35
|
+
}
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
function checkDate(value, flag) {
|
|
39
|
+
if (value === undefined)
|
|
40
|
+
return undefined;
|
|
41
|
+
if (DATE_RE.test(value)) {
|
|
42
|
+
// Date.parse normalizes overflow (2026-02-30 -> Mar 2), so round-trip to reject it.
|
|
43
|
+
const [y, mo, d] = value.split('-').map(Number);
|
|
44
|
+
const dt = new Date(Date.UTC(y, mo - 1, d));
|
|
45
|
+
if (dt.getUTCFullYear() === y && dt.getUTCMonth() === mo - 1 && dt.getUTCDate() === d) {
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
throw new UsageError(`${flag} must be a valid date YYYY-MM-DD (got "${value}")`);
|
|
50
|
+
}
|
|
51
|
+
function checkLimit(value) {
|
|
52
|
+
if (value === undefined)
|
|
53
|
+
return undefined;
|
|
54
|
+
const n = Number(value);
|
|
55
|
+
if (!Number.isInteger(n) || n < 1 || n > 200) {
|
|
56
|
+
throw new UsageError(`--limit must be a positive integer (1-200) (got "${value}")`);
|
|
57
|
+
}
|
|
58
|
+
return n;
|
|
59
|
+
}
|
|
60
|
+
/** Validate CLI options and build the wire query. Throws UsageError (exit 3) on bad input. */
|
|
61
|
+
export function buildDemandQuery(opts, build = {}) {
|
|
62
|
+
const analysis = checkEnum(opts.analysis, ANALYSIS, '--analysis') ?? 'snapshot';
|
|
63
|
+
const travelPeriod = checkEnum(opts.travelPeriod, TRAVEL_PERIODS, '--travel-period');
|
|
64
|
+
const from = checkDate(opts.departureDateFrom, '--departure-date-from');
|
|
65
|
+
const to = checkDate(opts.departureDateTo, '--departure-date-to');
|
|
66
|
+
if (travelPeriod === 'Custom') {
|
|
67
|
+
if (!from || !to) {
|
|
68
|
+
throw new UsageError('--travel-period Custom requires both --departure-date-from and --departure-date-to');
|
|
69
|
+
}
|
|
70
|
+
if (to < from) {
|
|
71
|
+
throw new UsageError('--departure-date-to must be on or after --departure-date-from');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else if (from || to) {
|
|
75
|
+
throw new UsageError('--departure-date-from/--departure-date-to are only valid with --travel-period Custom');
|
|
76
|
+
}
|
|
77
|
+
const destination = checkLocation(opts.destination, '--destination');
|
|
78
|
+
if (build.requireDestination && !destination) {
|
|
79
|
+
throw new UsageError('--destination is required for this command (e.g. --destination Country:TH)');
|
|
80
|
+
}
|
|
81
|
+
const originMarket = checkLocation(opts.originMarket, '--origin-market');
|
|
82
|
+
const travelerType = build.allowTravelerType
|
|
83
|
+
? checkEnum(opts.travelerType, TRAVELER_TYPES, '--traveler-type')
|
|
84
|
+
: undefined;
|
|
85
|
+
const tripType = checkEnum(opts.tripType, TRIP_TYPES, '--trip-type');
|
|
86
|
+
const limit = checkLimit(opts.limit);
|
|
87
|
+
const query = { analysis };
|
|
88
|
+
if (originMarket)
|
|
89
|
+
query.origin_market = originMarket;
|
|
90
|
+
if (destination)
|
|
91
|
+
query.destination = destination;
|
|
92
|
+
if (travelPeriod)
|
|
93
|
+
query.travel_period = travelPeriod;
|
|
94
|
+
if (from)
|
|
95
|
+
query.departure_date_from = from;
|
|
96
|
+
if (to)
|
|
97
|
+
query.departure_date_to = to;
|
|
98
|
+
if (travelerType)
|
|
99
|
+
query.traveler_type = travelerType;
|
|
100
|
+
if (tripType)
|
|
101
|
+
query.trip_type = tripType;
|
|
102
|
+
if (limit !== undefined)
|
|
103
|
+
query.limit = limit;
|
|
104
|
+
return query;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Build a Commander action for a demand command. Order matters: validate input FIRST
|
|
108
|
+
* (UsageError -> exit 3), THEN construct the client (AuthError -> exit 2), THEN call the
|
|
109
|
+
* API — so a missing required flag is never reported as an auth error. (This is why these
|
|
110
|
+
* commands don't use the generic withClient wrapper, which creates the client first.)
|
|
111
|
+
*/
|
|
112
|
+
export function demandAction(build, call) {
|
|
113
|
+
return async function (...args) {
|
|
114
|
+
const command = args[args.length - 1];
|
|
115
|
+
const opts = args[args.length - 2] ?? {};
|
|
116
|
+
const globals = getGlobalOptions(command);
|
|
117
|
+
try {
|
|
118
|
+
const query = buildDemandQuery(opts, build);
|
|
119
|
+
const client = await createJinkoClient({
|
|
120
|
+
apiKey: globals.apiKey,
|
|
121
|
+
environment: globals.environment,
|
|
122
|
+
});
|
|
123
|
+
output(await call(client, query), { format: globals.format });
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
exitWithError(err, globals);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/** Register the query options shared by all three demand commands. */
|
|
131
|
+
export function addCommonDemandOptions(cmd) {
|
|
132
|
+
return cmd
|
|
133
|
+
.option('--analysis <mode>', 'analysis mode: snapshot (default) or trend', 'snapshot')
|
|
134
|
+
.option('--origin-market <level:code>', 'origin market filter, e.g. Country:US or City:NYC')
|
|
135
|
+
.option('--travel-period <period>', 'Summer|Winter|Christmas|Easter|Next30Days|Next90Days|Custom (default Next90Days)')
|
|
136
|
+
.option('--departure-date-from <YYYY-MM-DD>', 'start of departure window (requires --travel-period Custom)')
|
|
137
|
+
.option('--departure-date-to <YYYY-MM-DD>', 'end of departure window (requires --travel-period Custom)')
|
|
138
|
+
.option('--trip-type <type>', 'One-Way|Round-Trip')
|
|
139
|
+
.option('--limit <n>', 'max rows, 1-200 (default 20)');
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=demand-shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demand-shared.js","sourceRoot":"","sources":["../../../src/commands/travel-demand/demand-shared.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,iBAAiB,GAOlB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEjE,MAAM,QAAQ,GAA4B,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAChE,MAAM,cAAc,GAA4B;IAC9C,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,QAAQ;IACR,YAAY;IACZ,YAAY;IACZ,QAAQ;CACT,CAAC;A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K,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAChE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,sBAAsB,CAAC,GAAY;IACjD,OAAO,GAAG;SACP,MAAM,CAAC,mBAAmB,EAAE,4CAA4C,EAAE,UAAU,CAAC;SACrF,MAAM,CAAC,8BAA8B,EAAE,mDAAmD,CAAC;SAC3F,MAAM,CACL,0BAA0B,EAC1B,kFAAkF,CACnF;SACA,MAAM,CAAC,oCAAoC,EAAE,6DAA6D,CAAC;SAC3G,MAAM,CAAC,kCAAkC,EAAE,2DAA2D,CAAC;SACvG,MAAM,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;SAClD,MAAM,CAAC,aAAa,EAAE,8BAA8B,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* `jinko travel-demand <operation>` — Travel Demand Intelligence (JIN-1378).
|
|
4
|
+
*
|
|
5
|
+
* A second-level command group (like `auth`/`config`) whose three operations
|
|
6
|
+
* mirror the SDK/MCP names 1:1: demand-destination / demand-market / demand-audience.
|
|
7
|
+
* Registration is purely additive — see createProgram() in ../../index.ts.
|
|
8
|
+
*/
|
|
9
|
+
export declare function registerTravelDemandCommands(program: Command): void;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/travel-demand/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkDnE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { addCommonDemandOptions, demandAction } from './demand-shared.js';
|
|
2
|
+
/**
|
|
3
|
+
* `jinko travel-demand <operation>` — Travel Demand Intelligence (JIN-1378).
|
|
4
|
+
*
|
|
5
|
+
* A second-level command group (like `auth`/`config`) whose three operations
|
|
6
|
+
* mirror the SDK/MCP names 1:1: demand-destination / demand-market / demand-audience.
|
|
7
|
+
* Registration is purely additive — see createProgram() in ../../index.ts.
|
|
8
|
+
*/
|
|
9
|
+
export function registerTravelDemandCommands(program) {
|
|
10
|
+
const td = program
|
|
11
|
+
.command('travel-demand')
|
|
12
|
+
.summary('Travel Demand Intelligence — top destinations, source markets, audience mix')
|
|
13
|
+
.description('Query de-sampled search-demand analytics (JIN-1378): the most-searched destinations, ' +
|
|
14
|
+
'the source markets driving demand for a destination, and the traveler-type mix.');
|
|
15
|
+
addCommonDemandOptions(td
|
|
16
|
+
.command('demand-destination')
|
|
17
|
+
.summary('Top destinations by search demand')
|
|
18
|
+
.description('Most-searched destinations by de-sampled request share. Optionally scope to an origin ' +
|
|
19
|
+
'market with --origin-market, or filter to a single destination with --destination.')
|
|
20
|
+
.option('--destination <level:code>', 'optional destination filter, e.g. Country:TH')
|
|
21
|
+
.option('--traveler-type <type>', 'Solo|Couple|Group|Family')).action(demandAction({ allowTravelerType: true }, (client, query) => client.demandDestination(query)));
|
|
22
|
+
addCommonDemandOptions(td
|
|
23
|
+
.command('demand-market')
|
|
24
|
+
.summary('Top source markets for a destination')
|
|
25
|
+
.description('Which source markets generate the most demand for a destination. --destination is required.')
|
|
26
|
+
.option('--destination <level:code>', 'destination, e.g. Country:TH (required)')
|
|
27
|
+
.option('--traveler-type <type>', 'Solo|Couple|Group|Family')).action(demandAction({ requireDestination: true, allowTravelerType: true }, (client, query) => client.demandMarket(query)));
|
|
28
|
+
addCommonDemandOptions(td
|
|
29
|
+
.command('demand-audience')
|
|
30
|
+
.summary('Traveler-type mix for a destination')
|
|
31
|
+
.description('Traveler-type composition (Solo/Couple/Family/Group) of demand for a destination. ' +
|
|
32
|
+
'--destination is required. (traveler_type is not a filter here — it is the dimension.)')
|
|
33
|
+
.option('--destination <level:code>', 'destination, e.g. Country:JP (required)')).action(demandAction({ requireDestination: true }, (client, query) => client.demandAudience(query)));
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/travel-demand/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE1E;;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B,CAAC,OAAgB;IAC3D,MAAM,EAAE,GAAG,OAAO;SACf,OAAO,CAAC,eAAe,CAAC;SACxB,OAAO,CAAC,6EAA6E,CAAC;SACtF,WAAW,CACV,uFAAuF;QACrF,iFAAiF,CACpF,CAAC;IAEJ,sBAAsB,CACpB,EAAE;SACC,OAAO,CAAC,oBAAoB,CAAC;SAC7B,OAAO,CAAC,mCAAmC,CAAC;SAC5C,WAAW,CACV,wFAAwF;QACtF,oFAAoF,CACvF;SACA,MAAM,CAAC,4BAA4B,EAAE,8CAA8C,CAAC;SACpF,MAAM,CAAC,wBAAwB,EAAE,0BAA0B,CAAC,CAChE,CAAC,MAAM,CACN,YAAY,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAC9F,CAAC;IAEF,sBAAsB,CACpB,EAAE;SACC,OAAO,CAAC,eAAe,CAAC;SACxB,OAAO,CAAC,sCAAsC,CAAC;SAC/C,WAAW,CACV,6FAA6F,CAC9F;SACA,MAAM,CAAC,4BAA4B,EAAE,yCAAyC,CAAC;SAC/E,MAAM,CAAC,wBAAwB,EAAE,0BAA0B,CAAC,CAChE,CAAC,MAAM,CACN,YAAY,CAAC,EAAE,kBAAkB,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CACpF,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAC3B,CACF,CAAC;IAEF,sBAAsB,CACpB,EAAE;SACC,OAAO,CAAC,iBAAiB,CAAC;SAC1B,OAAO,CAAC,qCAAqC,CAAC;SAC9C,WAAW,CACV,oFAAoF;QAClF,wFAAwF,CAC3F;SACA,MAAM,CAAC,4BAA4B,EAAE,yCAAyC,CAAC,CACnF,CAAC,MAAM,CACN,YAAY,CAAC,EAAE,kBAAkB,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAC5F,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiCpC,wBAAgB,aAAa,IAAI,OAAO,CAqDvC"}
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,8 @@ import { registerPriceMonitoringCommand } from "./commands/price-monitoring.js";
|
|
|
11
11
|
import { registerHotelSearchCommand } from "./commands/hotel-search.js";
|
|
12
12
|
import { registerHotelDetailsCommand } from "./commands/hotel-details.js";
|
|
13
13
|
import { registerTripCommand } from "./commands/trip.js";
|
|
14
|
-
import {
|
|
14
|
+
import { registerCheckoutCommand } from "./commands/checkout.js";
|
|
15
|
+
import { registerAgentPaymentCommands } from "./commands/agent-pay.js";
|
|
15
16
|
import { registerTripStatusCommand } from "./commands/trip-status.js";
|
|
16
17
|
import { registerGetAncillariesCommand } from "./commands/get-ancillaries.js";
|
|
17
18
|
import { registerSelectAncillariesCommand } from "./commands/select-ancillaries.js";
|
|
@@ -22,6 +23,7 @@ import { registerHotelCancelCommand } from "./commands/hotel-cancel.js";
|
|
|
22
23
|
import { registerAuthCommands } from "./commands/auth/index.js";
|
|
23
24
|
import { registerSchemaCommand } from "./commands/schema.js";
|
|
24
25
|
import { registerConfigCommands } from "./commands/config/index.js";
|
|
26
|
+
import { registerTravelDemandCommands } from "./commands/travel-demand/index.js";
|
|
25
27
|
// Read version dynamically from package.json so it never drifts.
|
|
26
28
|
// Compiled file lives at dist/index.js; package.json is one level up.
|
|
27
29
|
const pkg = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), "..", "package.json"), "utf-8"));
|
|
@@ -45,7 +47,8 @@ export function createProgram() {
|
|
|
45
47
|
registerHotelDetailsCommand(program);
|
|
46
48
|
// Trip building + checkout
|
|
47
49
|
registerTripCommand(program);
|
|
48
|
-
|
|
50
|
+
registerCheckoutCommand(program);
|
|
51
|
+
registerAgentPaymentCommands(program);
|
|
49
52
|
registerGetAncillariesCommand(program);
|
|
50
53
|
registerSelectAncillariesCommand(program);
|
|
51
54
|
registerTripStatusCommand(program);
|
|
@@ -54,6 +57,8 @@ export function createProgram() {
|
|
|
54
57
|
registerHotelCancelCommand(program);
|
|
55
58
|
registerRefundCommand(program);
|
|
56
59
|
registerExchangeCommand(program);
|
|
60
|
+
// Travel Demand Intelligence
|
|
61
|
+
registerTravelDemandCommands(program);
|
|
57
62
|
// Utility commands
|
|
58
63
|
registerAuthCommands(program);
|
|
59
64
|
registerConfigCommands(program);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,S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formatter.d.ts","sourceRoot":"","sources":["../../src/output/formatter.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5C,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAMlE;
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../src/output/formatter.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5C,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAMlE;AAgFD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CASrH"}
|
package/dist/output/formatter.js
CHANGED
|
@@ -16,29 +16,52 @@ function outputJson(data) {
|
|
|
16
16
|
}
|
|
17
17
|
function outputTable(data) {
|
|
18
18
|
if (Array.isArray(data)) {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
printRows(data);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (data !== null && typeof data === 'object') {
|
|
23
|
+
const entries = Object.entries(data);
|
|
24
|
+
const arrayEntry = entries.find(([, v]) => Array.isArray(v));
|
|
25
|
+
if (arrayEntry) {
|
|
26
|
+
// Object wrapping a list (e.g. { analysis_type, rows }): show the scalar
|
|
27
|
+
// fields, then tabulate the rows — instead of collapsing the array into a
|
|
28
|
+
// single key/value cell. Used by the travel-demand responses.
|
|
29
|
+
const scalars = entries.filter(([, v]) => !Array.isArray(v) && (v === null || typeof v !== 'object'));
|
|
30
|
+
for (const [key, value] of scalars) {
|
|
31
|
+
console.log(`${chalk.bold(key)}: ${formatCell(value)}`);
|
|
32
|
+
}
|
|
33
|
+
if (scalars.length > 0)
|
|
34
|
+
console.log('');
|
|
35
|
+
printRows(arrayEntry[1]);
|
|
21
36
|
return;
|
|
22
37
|
}
|
|
23
|
-
// Extract columns from first row keys.
|
|
24
|
-
const columns = Object.keys(data[0]);
|
|
25
|
-
const rows = data.map((row) => {
|
|
26
|
-
const record = row;
|
|
27
|
-
return columns.map((col) => formatCell(record[col]));
|
|
28
|
-
});
|
|
29
|
-
printTable(columns, rows);
|
|
30
|
-
}
|
|
31
|
-
else if (data !== null && typeof data === 'object') {
|
|
32
38
|
// Single object — print key/value pairs.
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
for (const [key, value] of Object.entries(record)) {
|
|
39
|
+
const maxKeyLen = Math.max(...entries.map(([k]) => k.length));
|
|
40
|
+
for (const [key, value] of entries) {
|
|
36
41
|
console.log(`${chalk.bold(key.padEnd(maxKeyLen))} ${formatCell(value)}`);
|
|
37
42
|
}
|
|
43
|
+
return;
|
|
38
44
|
}
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
console.log(String(data));
|
|
46
|
+
}
|
|
47
|
+
/** Render an array of records (or primitives) as a table. */
|
|
48
|
+
function printRows(rows) {
|
|
49
|
+
if (rows.length === 0) {
|
|
50
|
+
console.log(chalk.dim('No results.'));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (rows[0] === null || typeof rows[0] !== 'object') {
|
|
54
|
+
for (const row of rows)
|
|
55
|
+
console.log(String(row));
|
|
56
|
+
return;
|
|
41
57
|
}
|
|
58
|
+
// Extract columns from first row keys.
|
|
59
|
+
const columns = Object.keys(rows[0]);
|
|
60
|
+
const tableRows = rows.map((row) => {
|
|
61
|
+
const record = row;
|
|
62
|
+
return columns.map((col) => formatCell(record[col]));
|
|
63
|
+
});
|
|
64
|
+
printTable(columns, tableRows);
|
|
42
65
|
}
|
|
43
66
|
function formatCell(value) {
|
|
44
67
|
if (value === null || value === undefined)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../src/output/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,IAAa,EAAE,OAAsB;IAC1D,IAAI,OAAO,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;QAC/B,WAAW,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,IAAa;IAC/B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,WAAW,CAAC,IAAa;IAChC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,
|
|
1
|
+
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../src/output/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,IAAa,EAAE,OAAsB;IAC1D,IAAI,OAAO,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;QAC/B,WAAW,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,IAAa;IAC/B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,I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AE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAA2D,EAAE,OAAsB;IAC7G,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC9B,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACpD,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gojinko/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.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.16.0",
|
|
21
21
|
"commander": "^12.1.0",
|
|
22
22
|
"chalk": "^5.4.1",
|
|
23
23
|
"open": "^10.0.0"
|