@agenzo/merchant-cli 0.9.3 → 0.9.4

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/dist/index.js CHANGED
@@ -62,6 +62,7 @@ var CODE_NUM = {
62
62
  BOOKING_RESTRICTED: 4310,
63
63
  PAYORDER_FAILED: 4311,
64
64
  PAYORDER_FAILED_AFTER_PAYMENT: 4312,
65
+ OFFER_UNAVAILABLE: 4401,
65
66
  RATE_LIMITED: 5001,
66
67
  UPSTREAM_ERROR: 5101,
67
68
  INTERNAL_ERROR: 5201,
@@ -249,6 +250,7 @@ var STABLE_MESSAGE = {
249
250
  BOOKING_RESTRICTED: "This room has a booking condition that your request doesn't meet. Please check the room's booking rules and adjust your request.",
250
251
  PAYORDER_FAILED: "The hotel order was created, but payment failed. Retry payment for the existing order.",
251
252
  PAYORDER_FAILED_AFTER_PAYMENT: "Payment was received, but hotel confirmation failed. Contact support for reconciliation.",
253
+ OFFER_UNAVAILABLE: "The selected flight is no longer available. Please search again and pick another flight.",
252
254
  NOT_IMPLEMENTED: "This operation is not implemented yet."
253
255
  };
254
256
  function errorDetailLines(envelope) {
@@ -2457,13 +2459,21 @@ var flightMoreOffersSchema = flightSchema(
2457
2459
  );
2458
2460
  var flightVerifySchema = flightSchema(
2459
2461
  "verify",
2460
- "Pre-booking price verification. Returns the authoritative product_token and a price_changed flag; pass the returned token to create-order.",
2461
- { "product-token": { type: "string", required: true, description: "Opaque token from search." } },
2462
+ "Pre-booking price verification. Returns the authoritative product_token and a price_changed flag; pass the returned token to create-order. With --previous-total-price set, supplier 1002/1950 no longer dead-ends: the platform re-searches the SAME flight from the token and returns the refreshed fare; if that flight can no longer be found it fails with OFFER_UNAVAILABLE (pick another flight).",
2463
+ {
2464
+ "product-token": { type: "string", required: true, description: "Opaque token from search." },
2465
+ "previous-total-price": { type: "int", required: false, description: "Total price of the selected offer; enables the one-shot re-search refresh on supplier 1002/1950. Omit to keep the legacy behavior (error surfaces as-is)." },
2466
+ "cabin-class": { type: "string", required: false, description: "Cabin class to re-search with when refreshing (economy | premium_economy | business | first). Omitted falls back to economy." },
2467
+ "adult-num": { type: "int", required: false, description: "Adults to re-search with when refreshing (1-9)." },
2468
+ "child-num": { type: "int", required: false, description: "Children to re-search with when refreshing (0-9)." },
2469
+ "infant-num": { type: "int", required: false, description: "Infants to re-search with when refreshing (0-9)." }
2470
+ },
2462
2471
  {
2463
2472
  product_token: { type: "string", description: "Authoritative token to pass to create-order." },
2464
2473
  total_price: { type: "int", description: "Verified total price (integer)." },
2465
2474
  currency: { type: "string", description: "Currency code." },
2466
2475
  price_changed: { type: "bool", description: "True if the price changed since search; re-confirm with the user." },
2476
+ previous_total_price: { type: "int", description: "The selected offer\u2019s price at pick time; present when the request carried previous-total-price. If it differs from total_price the fare was refreshed by a re-search (show the user the old \u2192 new price)." },
2467
2477
  journeys: { type: "array", description: "The COMPLETE itinerary being priced \u2014 every leg, not just the last one relayed. Use it to show the full trip on a confirmation screen." }
2468
2478
  },
2469
2479
  { command: "agenzo-merchant-cli flight-flink verify --product-token pt_...", output_summary: "Returns the authoritative product_token + price_changed." }
@@ -6350,18 +6360,26 @@ function registerMoreOffersCommand(parent, deps) {
6350
6360
 
6351
6361
  // src/flight-flink/verify.ts
6352
6362
  function registerVerifyCommand(parent, deps) {
6353
- const cmd = parent.command("verify").description("Verify the latest price before booking; returns the authoritative product_token").option("--api-key <key>", "API Key for authentication (X-Api-Key)").option("--product-token <token>", "Opaque token from search");
6363
+ const cmd = parent.command("verify").description("Verify the latest price before booking; returns the authoritative product_token").option("--api-key <key>", "API Key for authentication (X-Api-Key)").option("--product-token <token>", "Opaque token from search").option("--previous-total-price <n>", "Total price of the selected offer; enables the one-shot re-search refresh on supplier 1002/1950").option("--cabin-class <c>", "Cabin class to re-search with (economy | premium_economy | business | first)").option("--adult-num <n>", "Adults to re-search with (1-9)").option("--child-num <n>", "Children to re-search with (0-9)").option("--infant-num <n>", "Infants to re-search with (0-9)");
6354
6364
  attachSchemaHelp(cmd, flightVerifySchema);
6355
6365
  cmd.action(async () => {
6356
6366
  const opts = cmd.optsWithGlobals();
6357
6367
  const format = resolveFormat(opts.format);
6358
6368
  const apiKey = await resolveApiKey(opts.apiKey);
6359
6369
  const productToken = need21(opts.productToken, "product-token");
6370
+ const body = { product_token: productToken };
6371
+ if (opts.previousTotalPrice !== void 0) {
6372
+ body.previous_total_price = num10(opts.previousTotalPrice, "previous-total-price");
6373
+ }
6374
+ if (opts.cabinClass !== void 0) body.cabin_class = opts.cabinClass;
6375
+ if (opts.adultNum !== void 0) body.adult_num = num10(opts.adultNum, "adult-num");
6376
+ if (opts.childNum !== void 0) body.child_num = num10(opts.childNum, "child-num");
6377
+ if (opts.infantNum !== void 0) body.infant_num = num10(opts.infantNum, "infant-num");
6360
6378
  const spinner = format === "json" ? null : createSpinner("Verifying price...");
6361
6379
  const result = await deps.apiClient.post(
6362
6380
  "/flight/verify",
6363
6381
  { type: "api-key", key: apiKey },
6364
- { product_token: productToken }
6382
+ body
6365
6383
  );
6366
6384
  spinner?.stop();
6367
6385
  if (!result.success) throw CliError.fromApi(result, { auth: "api-key" });
@@ -6371,7 +6389,9 @@ function registerVerifyCommand(parent, deps) {
6371
6389
  (d) => Formatter.keyValue([
6372
6390
  ["Product token", String(d.product_token ?? "-")],
6373
6391
  ["Total price", `${d.total_price ?? "-"} ${d.currency ?? ""}`.trim()],
6374
- ["Price changed", String(d.price_changed)]
6392
+ ["Price changed", String(d.price_changed)],
6393
+ // 刷新路径:平台带回选中时的原价,人读 output 里直接看出 原价 → 新价。
6394
+ ...d.previous_total_price != null ? [["Previous total price", String(d.previous_total_price)]] : []
6375
6395
  ])
6376
6396
  );
6377
6397
  });