@wix/mcp 1.0.17 → 1.0.19

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.
@@ -4928,7 +4928,7 @@ var require_error = __commonJS({
4928
4928
  "toJSON",
4929
4929
  "__CANCEL__"
4930
4930
  ];
4931
- var HttpError = class _HttpError extends Error {
4931
+ var HttpError2 = class _HttpError extends Error {
4932
4932
  constructor(error) {
4933
4933
  super(error.message);
4934
4934
  this.isWixHttpError = true;
@@ -4941,9 +4941,9 @@ var require_error = __commonJS({
4941
4941
  return (0, headers_1.requestIdOrEmptyString)(this.response);
4942
4942
  }
4943
4943
  };
4944
- exports2.HttpError = HttpError;
4944
+ exports2.HttpError = HttpError2;
4945
4945
  function createHttpError(...args) {
4946
- return new HttpError(...args);
4946
+ return new HttpError2(...args);
4947
4947
  }
4948
4948
  exports2.createHttpError = createHttpError;
4949
4949
  }
@@ -7905,7 +7905,7 @@ var require_http_client = __commonJS({
7905
7905
  var headers_1 = require_headers();
7906
7906
  var options_1 = require_options();
7907
7907
  var utils_1 = require_utils4();
7908
- var HttpClient2 = class {
7908
+ var HttpClient3 = class {
7909
7909
  constructor(opts = {}) {
7910
7910
  this.opts = opts;
7911
7911
  this.opts = defaultClientOptions(this.opts);
@@ -8037,9 +8037,9 @@ var require_http_client = __commonJS({
8037
8037
  });
8038
8038
  }
8039
8039
  };
8040
- exports2.HttpClient = HttpClient2;
8041
- HttpClient2.CancelToken = axios_1.default.CancelToken;
8042
- HttpClient2.isCancel = axios_1.default.isCancel;
8040
+ exports2.HttpClient = HttpClient3;
8041
+ HttpClient3.CancelToken = axios_1.default.CancelToken;
8042
+ HttpClient3.isCancel = axios_1.default.isCancel;
8043
8043
  function defaultClientOptions(opts) {
8044
8044
  let adapter = opts.adapter;
8045
8045
  if (!adapter) {
@@ -8109,7 +8109,7 @@ var require_http_client = __commonJS({
8109
8109
  }
8110
8110
  }
8111
8111
  function createHttpClient(...args) {
8112
- return new HttpClient2(...args);
8112
+ return new HttpClient3(...args);
8113
8113
  }
8114
8114
  exports2.createHttpClient = createHttpClient;
8115
8115
  }
@@ -9877,7 +9877,7 @@ var require_error2 = __commonJS({
9877
9877
  "toJSON",
9878
9878
  "__CANCEL__"
9879
9879
  ];
9880
- var HttpError = class _HttpError extends Error {
9880
+ var HttpError2 = class _HttpError extends Error {
9881
9881
  constructor(error) {
9882
9882
  super(error.message);
9883
9883
  this.isWixHttpError = true;
@@ -9890,9 +9890,9 @@ var require_error2 = __commonJS({
9890
9890
  return (0, headers_1.requestIdOrEmptyString)(this.response);
9891
9891
  }
9892
9892
  };
9893
- exports2.HttpError = HttpError;
9893
+ exports2.HttpError = HttpError2;
9894
9894
  function createHttpError(...args) {
9895
- return new HttpError(...args);
9895
+ return new HttpError2(...args);
9896
9896
  }
9897
9897
  exports2.createHttpError = createHttpError;
9898
9898
  }
@@ -11581,7 +11581,7 @@ var require_http_client2 = __commonJS({
11581
11581
  var headers_1 = require_headers2();
11582
11582
  var options_1 = require_options2();
11583
11583
  var utils_1 = require_utils7();
11584
- var HttpClient2 = class {
11584
+ var HttpClient3 = class {
11585
11585
  constructor(opts = {}) {
11586
11586
  this.opts = opts;
11587
11587
  this.opts = defaultClientOptions(this.opts);
@@ -11713,9 +11713,9 @@ var require_http_client2 = __commonJS({
11713
11713
  });
11714
11714
  }
11715
11715
  };
11716
- exports2.HttpClient = HttpClient2;
11717
- HttpClient2.CancelToken = axios_1.default.CancelToken;
11718
- HttpClient2.isCancel = axios_1.default.isCancel;
11716
+ exports2.HttpClient = HttpClient3;
11717
+ HttpClient3.CancelToken = axios_1.default.CancelToken;
11718
+ HttpClient3.isCancel = axios_1.default.isCancel;
11719
11719
  function defaultClientOptions(opts) {
11720
11720
  let adapter = opts.adapter;
11721
11721
  if (!adapter) {
@@ -11785,7 +11785,7 @@ var require_http_client2 = __commonJS({
11785
11785
  }
11786
11786
  }
11787
11787
  function createHttpClient(...args) {
11788
- return new HttpClient2(...args);
11788
+ return new HttpClient3(...args);
11789
11789
  }
11790
11790
  exports2.createHttpClient = createHttpClient;
11791
11791
  }
@@ -12521,22 +12521,26 @@ var require_error3 = __commonJS({
12521
12521
  "toJSON",
12522
12522
  "__CANCEL__"
12523
12523
  ];
12524
- var HttpError = class _HttpError extends Error {
12524
+ var HttpError2 = class _HttpError extends Error {
12525
12525
  constructor(error) {
12526
+ var _a;
12526
12527
  super(error.message);
12527
12528
  this.isWixHttpError = true;
12528
12529
  Object.setPrototypeOf(this, _HttpError.prototype);
12529
12530
  exports2.axiosErrorFields.forEach((key) => {
12530
12531
  this[key] = error[key];
12531
12532
  });
12533
+ if ((_a = this.response) === null || _a === void 0 ? void 0 : _a.headers) {
12534
+ this.response.requestId = (0, headers_1.requestIdOrEmptyString)(this.response);
12535
+ }
12532
12536
  }
12533
12537
  get requestId() {
12534
12538
  return (0, headers_1.requestIdOrEmptyString)(this.response);
12535
12539
  }
12536
12540
  };
12537
- exports2.HttpError = HttpError;
12541
+ exports2.HttpError = HttpError2;
12538
12542
  function createHttpError(...args) {
12539
- return new HttpError(...args);
12543
+ return new HttpError2(...args);
12540
12544
  }
12541
12545
  exports2.createHttpError = createHttpError;
12542
12546
  }
@@ -14853,7 +14857,7 @@ var require_http_client3 = __commonJS({
14853
14857
  var headers_1 = require_headers3();
14854
14858
  var options_1 = require_options3();
14855
14859
  var utils_1 = require_utils10();
14856
- var HttpClient2 = class {
14860
+ var HttpClient3 = class {
14857
14861
  constructor(opts = {}) {
14858
14862
  this.opts = opts;
14859
14863
  this.opts = defaultClientOptions(this.opts);
@@ -14994,9 +14998,9 @@ var require_http_client3 = __commonJS({
14994
14998
  });
14995
14999
  }
14996
15000
  };
14997
- exports2.HttpClient = HttpClient2;
14998
- HttpClient2.CancelToken = axios_1.default.CancelToken;
14999
- HttpClient2.isCancel = axios_1.default.isCancel;
15001
+ exports2.HttpClient = HttpClient3;
15002
+ HttpClient3.CancelToken = axios_1.default.CancelToken;
15003
+ HttpClient3.isCancel = axios_1.default.isCancel;
15000
15004
  function defaultClientOptions(opts) {
15001
15005
  let adapter = opts.adapter;
15002
15006
  if (!adapter) {
@@ -15066,7 +15070,7 @@ var require_http_client3 = __commonJS({
15066
15070
  }
15067
15071
  }
15068
15072
  function createHttpClient(...args) {
15069
- return new HttpClient2(...args);
15073
+ return new HttpClient3(...args);
15070
15074
  }
15071
15075
  exports2.createHttpClient = createHttpClient;
15072
15076
  }
@@ -24216,7 +24220,7 @@ var addDocsTools = (server, allowedTools = [
24216
24220
  getToKnowWixEnabled ? WixREADME_DEPENDENT_DESCRIPTION : ""
24217
24221
  ].join("\n"),
24218
24222
  {
24219
- articleUrl: external_exports.string().url().startsWith("https://dev.wix.com/").describe(
24223
+ articleUrl: external_exports.string().url().describe(
24220
24224
  "The URL of the docs article or method article to fetch. Should be something like https://dev.wix.com/docs/.../.../..."
24221
24225
  )
24222
24226
  },
@@ -24267,7 +24271,7 @@ var addDocsTools = (server, allowedTools = [
24267
24271
  "This will give you the entire request/response schema with all the fields and their descriptions."
24268
24272
  ].join("\n"),
24269
24273
  {
24270
- articleUrl: external_exports.string().url().startsWith("https://dev.wix.com/").describe(
24274
+ articleUrl: external_exports.string().url().describe(
24271
24275
  "The URL of the documentation to fetch. Should be something like https://dev.wix.com/docs/.../.../..."
24272
24276
  )
24273
24277
  },
@@ -24306,6 +24310,9 @@ var addDocsTools = (server, allowedTools = [
24306
24310
  );
24307
24311
  };
24308
24312
 
24313
+ // src/api-call/index.ts
24314
+ var import_http_client2 = __toESM(require_index_node3(), 1);
24315
+
24309
24316
  // src/tool-utils.ts
24310
24317
  var safeParseJSON = (text) => {
24311
24318
  try {
@@ -24330,7 +24337,7 @@ var buildErrorMessage = ({
24330
24337
  ].filter((str) => !!str).join("\n");
24331
24338
  };
24332
24339
  var handleWixAPIResponse = async (response) => {
24333
- const requestId = response.headers.get?.("x-wix-request-id");
24340
+ const requestId = response.headers?.["x-wix-request-id"];
24334
24341
  if (!response.status.toString().startsWith("2")) {
24335
24342
  const errorMessage = buildErrorMessage({
24336
24343
  status: response.status,
@@ -24438,10 +24445,15 @@ function addApiCallTool(server, strategy, allowedTools = ["CallWixSiteAPI", "Lis
24438
24445
  ]
24439
24446
  };
24440
24447
  } catch (error) {
24441
- logger2.error(`Failed to call Wix Site API: ${error}`);
24448
+ let requestId;
24449
+ if (import_http_client2.HttpClient.isHttpError(error)) {
24450
+ requestId = error.requestId;
24451
+ }
24452
+ const errorMessage = `Failed to call Wix Site API: ${error} Request ID: ${requestId ? `Request ID: ${requestId}` : ""}`;
24453
+ logger2.error(errorMessage);
24442
24454
  const response = error.response;
24443
24455
  if (!response) {
24444
- throw new Error(`Failed to call Wix Site API: ${error}`);
24456
+ throw new Error(errorMessage);
24445
24457
  }
24446
24458
  return handleWixAPIResponse(response);
24447
24459
  }