@agenzo/merchant-cli 0.9.1 → 0.9.2

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
@@ -1590,6 +1590,7 @@ var hotelCreateOrderSchema = {
1590
1590
  children: { type: "int", required: false, default: 0, description: "Children per room (match quote)", constraints: "0-10" },
1591
1591
  nationality: { type: "string", required: false, default: "CN", description: "Guest nationality (match quote)" },
1592
1592
  "guest-name": { type: "string", required: true, description: "Primary guest name", constraints: "Use the name as the user gives it. If a supplier returns NAME_FORMAT_INVALID, re-collect in Latin letters and retry" },
1593
+ "room-guests": { type: "string", required: false, description: "Per-room primary guests, listed in room order, for booking several rooms under different names. Omit it and every room reuses guest-name (backward compatible); guest-name stays required either way", constraints: "JSON array of {guest_name (non-empty string)}; room_index is optional and filled in from the array position (1-based, validated against room-num by the platform) \u2014 pass it explicitly only to override; else PARAM_INVALID" },
1593
1594
  "contact-name": { type: "string", required: true, description: "Booking contact name (may equal guest-name)" },
1594
1595
  "contact-phone": { type: "string", required: true, description: "Booking contact phone number", constraints: "Digits; collect country code separately in --contact-country-code" },
1595
1596
  "contact-country-code": { type: "string", required: false, default: "86", description: "Phone country calling code without '+'" },
@@ -4606,6 +4607,34 @@ function parsePriceItems(raw) {
4606
4607
  }
4607
4608
  return parsed;
4608
4609
  }
4610
+ function parseRoomGuests(raw) {
4611
+ const INVALID = "--room-guests must be a JSON array of {guest_name (non-empty string), room_index (optional 1-based integer)}.";
4612
+ let parsed;
4613
+ try {
4614
+ parsed = JSON.parse(raw);
4615
+ } catch {
4616
+ throw new CliError("PARAM_INVALID", INVALID);
4617
+ }
4618
+ if (!Array.isArray(parsed) || parsed.length === 0) {
4619
+ throw new CliError("PARAM_INVALID", INVALID);
4620
+ }
4621
+ return parsed.map((el, i) => {
4622
+ if (typeof el !== "object" || el === null || Array.isArray(el)) {
4623
+ throw new CliError("PARAM_INVALID", INVALID);
4624
+ }
4625
+ const item = el;
4626
+ if (typeof item.guest_name !== "string" || item.guest_name.trim() === "") {
4627
+ throw new CliError("PARAM_INVALID", INVALID);
4628
+ }
4629
+ if (item.room_index === void 0) {
4630
+ return { ...item, room_index: i + 1 };
4631
+ }
4632
+ if (!Number.isInteger(item.room_index) || item.room_index < 1) {
4633
+ throw new CliError("PARAM_INVALID", INVALID);
4634
+ }
4635
+ return item;
4636
+ });
4637
+ }
4609
4638
  function parseTips(raw) {
4610
4639
  const INVALID = "--tips must be a JSON array of {title (string, optional), text (string, optional)}.";
4611
4640
  let parsed;
@@ -4691,7 +4720,10 @@ function formatCreateOrder2(data) {
4691
4720
  return out.join("\n");
4692
4721
  }
4693
4722
  function registerHotelCreateOrderCommand(parent, deps) {
4694
- const cmd = parent.command("create-order").description("Create a hotel order without charging (lock inventory, await payment)").option("--api-key <key>", "API Key for authentication (X-Api-Key)").option("--product-token <token>", "Chosen rate token from quote (rates[].product_token)").option("--total-amount <amount>", "Total stay price in decimal currency units (not cents)").option("--currency <currency>", "ISO 4217 currency code from the chosen rate").option("--price-items <json>", "Per-night price breakdown JSON array (copied verbatim from quote)").option("--check-in <date>", "Check-in date (YYYY-MM-DD, match quote)").option("--check-out <date>", "Check-out date (YYYY-MM-DD, strictly after check-in)").option("--room-num <n>", "Number of rooms (match quote)", "1").option("--adults <n>", "Adults per room (match quote)", "2").option("--children <n>", "Children per room (match quote)", "0").option("--nationality <code>", "Guest nationality (ISO country code)", "CN").option("--guest-name <name>", "Primary guest name").option("--contact-name <name>", "Booking contact name (may equal guest-name)").option("--contact-phone <phone>", "Booking contact phone number (digits)").option("--contact-country-code <code>", "Phone country calling code without '+'", "86").option("--contact-email <email>", "Booking contact email").option("--arrive-time <time>", "Expected arrival time (HH:mm, hotel local time)").option("--special-requests <text>", "Free-text special requests (non-binding)").option(
4723
+ const cmd = parent.command("create-order").description("Create a hotel order without charging (lock inventory, await payment)").option("--api-key <key>", "API Key for authentication (X-Api-Key)").option("--product-token <token>", "Chosen rate token from quote (rates[].product_token)").option("--total-amount <amount>", "Total stay price in decimal currency units (not cents)").option("--currency <currency>", "ISO 4217 currency code from the chosen rate").option("--price-items <json>", "Per-night price breakdown JSON array (copied verbatim from quote)").option("--check-in <date>", "Check-in date (YYYY-MM-DD, match quote)").option("--check-out <date>", "Check-out date (YYYY-MM-DD, strictly after check-in)").option("--room-num <n>", "Number of rooms (match quote)", "1").option("--adults <n>", "Adults per room (match quote)", "2").option("--children <n>", "Children per room (match quote)", "0").option("--nationality <code>", "Guest nationality (ISO country code)", "CN").option("--guest-name <name>", "Primary guest name").option(
4724
+ "--room-guests <json>",
4725
+ "Optional per-room primary guests as a JSON array [{guest_name}], listed in room order, for booking several rooms under different names. room_index is filled in from the array position (1-based); pass it explicitly to override. Omit the flag and every room reuses --guest-name."
4726
+ ).option("--contact-name <name>", "Booking contact name (may equal guest-name)").option("--contact-phone <phone>", "Booking contact phone number (digits)").option("--contact-country-code <code>", "Phone country calling code without '+'", "86").option("--contact-email <email>", "Booking contact email").option("--arrive-time <time>", "Expected arrival time (HH:mm, hotel local time)").option("--special-requests <text>", "Free-text special requests (non-binding)").option(
4695
4727
  "--tips <json>",
4696
4728
  "\u5BA2\u6237\u81EA\u6D4B\u70B95 \u63D0\u793A\u4FE1\u606F: the chosen quote rate's tips as a JSON array [{title,text}]. Stored on the order for the order-detail page ONLY \u2014 platform-local, not sent upstream."
4697
4729
  ).option("--hotel-name <name>", "Hotel name (display-only, stored for order summary)").option(
@@ -4753,6 +4785,7 @@ function registerHotelCreateOrderCommand(parent, deps) {
4753
4785
  contact_phone: contactPhone,
4754
4786
  contact_country_code: opts.contactCountryCode
4755
4787
  };
4788
+ if (opts.roomGuests !== void 0) body.room_guests = parseRoomGuests(opts.roomGuests);
4756
4789
  if (opts.contactEmail !== void 0) body.contact_email = opts.contactEmail;
4757
4790
  if (opts.arriveTime !== void 0) body.arrive_time = opts.arriveTime;
4758
4791
  if (opts.specialRequests !== void 0) body.special_requests = opts.specialRequests;