@agenzo/merchant-cli 0.8.5 → 0.8.7

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
@@ -60,6 +60,8 @@ var CODE_NUM = {
60
60
  PAY_PER_CALL_NOT_AVAILABLE: 4308,
61
61
  HOTEL_NOT_FOUND: 4309,
62
62
  BOOKING_RESTRICTED: 4310,
63
+ PAYORDER_FAILED: 4311,
64
+ PAYORDER_FAILED_AFTER_PAYMENT: 4312,
63
65
  RATE_LIMITED: 5001,
64
66
  UPSTREAM_ERROR: 5101,
65
67
  INTERNAL_ERROR: 5201,
@@ -77,13 +79,14 @@ function codeNum(code) {
77
79
  return CODE_NUM[code];
78
80
  }
79
81
  var CliError = class _CliError extends Error {
80
- constructor(code, message, statusCode, requestId, upstream, backendMessage) {
82
+ constructor(code, message, statusCode, requestId, upstream, backendMessage, data) {
81
83
  super(message);
82
84
  this.code = code;
83
85
  this.statusCode = statusCode;
84
86
  this.requestId = requestId;
85
87
  this.upstream = upstream;
86
88
  this.backendMessage = backendMessage;
89
+ this.data = data;
87
90
  this.name = "CliError";
88
91
  }
89
92
  code;
@@ -91,6 +94,7 @@ var CliError = class _CliError extends Error {
91
94
  requestId;
92
95
  upstream;
93
96
  backendMessage;
97
+ data;
94
98
  /**
95
99
  * Map a backend ApiError to a CLI-facing code (§8.5 transitional mapping).
96
100
  * Backend numeric codes / HTTP status are translated to §8.4 string codes.
@@ -124,7 +128,8 @@ var CliError = class _CliError extends Error {
124
128
  error.statusCode,
125
129
  error.requestId,
126
130
  error.upstream,
127
- error.errorMessage
131
+ error.errorMessage,
132
+ error.data
128
133
  );
129
134
  }
130
135
  const status = error.statusCode;
@@ -142,7 +147,8 @@ var CliError = class _CliError extends Error {
142
147
  status,
143
148
  error.requestId,
144
149
  error.upstream,
145
- error.errorMessage
150
+ error.errorMessage,
151
+ error.data
146
152
  );
147
153
  }
148
154
  };
@@ -241,8 +247,15 @@ var STABLE_MESSAGE = {
241
247
  PAY_PER_CALL_NOT_AVAILABLE: "Pay-per-call billing is not available; use monthly_settlement.",
242
248
  HOTEL_NOT_FOUND: "This hotel is no longer available from the supplier.",
243
249
  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
+ PAYORDER_FAILED: "The hotel order was created, but payment failed. Retry payment for the existing order.",
251
+ PAYORDER_FAILED_AFTER_PAYMENT: "Payment was received, but hotel confirmation failed. Contact support for reconciliation.",
244
252
  NOT_IMPLEMENTED: "This operation is not implemented yet."
245
253
  };
254
+ function errorDetailLines(envelope) {
255
+ const orderId = envelope.error.data?.order_id;
256
+ if (typeof orderId !== "string" || orderId.length === 0) return [];
257
+ return [` Order: ${orderId}`];
258
+ }
246
259
  function toErrorEnvelope(error) {
247
260
  if (error instanceof CliError) {
248
261
  const stableMessage = error.message || "Unknown error";
@@ -254,7 +267,8 @@ function toErrorEnvelope(error) {
254
267
  message: stableMessage,
255
268
  ...error.requestId ? { request_id: error.requestId } : {},
256
269
  ...error.upstream ? { upstream: error.upstream } : {},
257
- ...backendMessage ? { backend_message: backendMessage } : {}
270
+ ...backendMessage ? { backend_message: backendMessage } : {},
271
+ ...error.data ? { data: error.data } : {}
258
272
  }
259
273
  };
260
274
  }
@@ -472,7 +486,8 @@ var ApiClient = class {
472
486
  }
473
487
  }
474
488
  const errorCodeStr = responseBody.error_code;
475
- const rawData = responseBody.data;
489
+ const dataValue = responseBody.data;
490
+ const rawData = dataValue && typeof dataValue === "object" && !Array.isArray(dataValue) ? dataValue : void 0;
476
491
  const upstream = rawData?.upstream && typeof rawData.upstream === "object" ? rawData.upstream : void 0;
477
492
  return {
478
493
  success: false,
@@ -481,6 +496,7 @@ var ApiClient = class {
481
496
  statusCode: response.status,
482
497
  ...errorCodeStr ? { code: errorCodeStr } : typeof code === "string" && code ? { code } : {},
483
498
  requestId: responseBody.request_id ?? responseBody.requestId,
499
+ ...rawData ? { data: rawData } : {},
484
500
  ...upstream ? { upstream } : {}
485
501
  };
486
502
  } catch (error) {
@@ -529,12 +545,12 @@ var DEFAULT_API_PATH = "/api/admin/v1";
529
545
  var DEFAULT_CONFIG = {
530
546
  active_org: null,
531
547
  active_developer_id: null,
532
- api_host: "https://agent.everonet.com",
548
+ api_host: "https://agent.agenzo.com",
533
549
  api_path: DEFAULT_API_PATH
534
550
  };
535
551
  var BUILTIN_PROFILES = {
536
- production: "https://agent.everonet.com",
537
- testing: "https://agent-test.everonet.com"
552
+ production: "https://agent.agenzo.com",
553
+ testing: "https://agent-dev.agenzo.com"
538
554
  };
539
555
  function resolveApiHost(host) {
540
556
  if (BUILTIN_PROFILES[host]) {
@@ -1332,6 +1348,17 @@ var hotelCreateOrderSchema = {
1332
1348
  "arrive-time": { type: "string", required: false, description: "Expected arrival time", constraints: "HH:mm, hotel local time" },
1333
1349
  "special-requests": { type: "string", required: false, description: "Free-text special requests (non-binding)" },
1334
1350
  tips: { type: "string", required: false, description: "FCG \u5BA2\u6237\u81EA\u6D4B\u70B95 \u63D0\u793A\u4FE1\u606F: the chosen quote rate's tips (tips[].tipsDetails[]) as a JSON array [{title,text}], captured at booking. Stored on the order for the order-detail page only; platform-local, not sent upstream", constraints: "JSON array of {title (string, optional), text (string, optional)}; else PARAM_INVALID" },
1351
+ cancellation: {
1352
+ type: "string",
1353
+ required: false,
1354
+ description: "Cancellation policy snapshot copied from the selected quote rate and stored on the order.",
1355
+ constraints: "JSON object; else PARAM_INVALID"
1356
+ },
1357
+ "hotel-timezone": {
1358
+ type: "string",
1359
+ required: false,
1360
+ description: "Hotel timezone from quote (for example 'UTC+8'), used to evaluate cancellation deadlines."
1361
+ },
1335
1362
  "bed-type": {
1336
1363
  type: "string",
1337
1364
  required: false,
@@ -2836,6 +2863,7 @@ var SERVICE_REGISTRY = [
2836
2863
  "change-search",
2837
2864
  "change-apply",
2838
2865
  "change-detail",
2866
+ "change-pay",
2839
2867
  "change-cancel",
2840
2868
  "refund-apply",
2841
2869
  "refund-detail",
@@ -2857,6 +2885,7 @@ var SERVICE_REGISTRY = [
2857
2885
  "change-search": "Search rebook-eligible flights.",
2858
2886
  "change-apply": "Submit a change request (pending review).",
2859
2887
  "change-detail": "Change request detail.",
2888
+ "change-pay": "Pay the change fee and trigger change ticketing.",
2860
2889
  "change-cancel": "Cancel a change request (immediate terminal).",
2861
2890
  "refund-apply": "Submit a refund request (pending review).",
2862
2891
  "refund-detail": "Refund request detail.",
@@ -3431,6 +3460,19 @@ function parseTips(raw) {
3431
3460
  }
3432
3461
  return parsed;
3433
3462
  }
3463
+ function parseCancellation(raw) {
3464
+ const invalid = "--cancellation must be a JSON object.";
3465
+ let parsed;
3466
+ try {
3467
+ parsed = JSON.parse(raw);
3468
+ } catch {
3469
+ throw new CliError("PARAM_INVALID", invalid);
3470
+ }
3471
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
3472
+ throw new CliError("PARAM_INVALID", invalid);
3473
+ }
3474
+ return parsed;
3475
+ }
3434
3476
  function need7(value, flag) {
3435
3477
  if (value === void 0) {
3436
3478
  throw new CliError("PARAM_INVALID", `Missing required --${flag}.`);
@@ -3485,6 +3527,12 @@ function registerHotelCreateOrderCommand(parent, deps) {
3485
3527
  "--tips <json>",
3486
3528
  "\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."
3487
3529
  ).option("--hotel-name <name>", "Hotel name (display-only, stored for order summary)").option(
3530
+ "--cancellation <json>",
3531
+ "Cancellation policy JSON from the chosen rate; stored on the order for cancellation gating and deadline display."
3532
+ ).option(
3533
+ "--hotel-timezone <tz>",
3534
+ "Hotel timezone from quote (for example 'UTC+8'); stored to evaluate cancellation deadlines in hotel-local time."
3535
+ ).option(
3488
3536
  "--bed-type <code>",
3489
3537
  "Product bed-type code from the chosen quote rate's beds[].code (e.g. 'L000000' King / '1000000' Queen); forwarded verbatim to upstream createOrder bedType."
3490
3538
  ).option(
@@ -3538,6 +3586,8 @@ function registerHotelCreateOrderCommand(parent, deps) {
3538
3586
  if (opts.arriveTime !== void 0) body.arrive_time = opts.arriveTime;
3539
3587
  if (opts.specialRequests !== void 0) body.special_requests = opts.specialRequests;
3540
3588
  if (opts.tips !== void 0) body.tips = parseTips(opts.tips);
3589
+ if (opts.cancellation !== void 0) body.cancellation = parseCancellation(opts.cancellation);
3590
+ if (opts.hotelTimezone !== void 0) body.hotel_timezone = opts.hotelTimezone;
3541
3591
  if (opts.hotelName !== void 0) body.hotel_name = opts.hotelName;
3542
3592
  if (opts.bedType !== void 0) body.bed_type = opts.bedType;
3543
3593
  if (opts.paymentMethodId !== void 0) body.payment_method_id = opts.paymentMethodId;
@@ -5831,6 +5881,9 @@ function reportError(error) {
5831
5881
  console.error(
5832
5882
  Formatter.status("error", `[${envelope.error.code_num}] ${envelope.error.message}`)
5833
5883
  );
5884
+ for (const line of errorDetailLines(envelope)) {
5885
+ console.error(line);
5886
+ }
5834
5887
  if (envelope.error.upstream) {
5835
5888
  console.error(` \u21B3 [${envelope.error.upstream.code}] ${envelope.error.upstream.message}`);
5836
5889
  }