@ywfe/fe-tools 1.2.1-beta.29 → 1.2.1-beta.3

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.
@@ -8704,28 +8704,29 @@ var require$$1 = /*@__PURE__*/getAugmentedNamespace(empty$1);
8704
8704
 
8705
8705
  function request(_a) {
8706
8706
  return __awaiter(this, arguments, void 0, function (_b) {
8707
- var method, basePathMap, getBasePath, isValidURL, prefix, requestUrl, fetchOption, response, message, result;
8707
+ var method, basePathMap, getBasePath, isValidURL, prefix, requestUrl, fetchOption, res;
8708
8708
  var input = _b.input;
8709
8709
  return __generator(this, function (_c) {
8710
8710
  switch (_c.label) {
8711
8711
  case 0:
8712
- method = input.method || "GET";
8712
+ method = input.method || 'GET';
8713
8713
  basePathMap = new Map([
8714
- ["prod", "https://gateway.ywwl.com"],
8715
- ["test", "https://test-gateway.ywwl.com"],
8716
- ["test2", "https://test2-gateway.ywwl.com"],
8717
- ["dev", "https://dev-gateway.ywwl.com"],
8714
+ ['prod', 'https://gateway.ywwl.com'],
8715
+ ['test', 'https://test-gateway.ywwl.com'],
8716
+ ['test2', 'https://test2-gateway.ywwl.com'],
8717
+ ['dev', 'https://dev-gateway.ywwl.com'],
8718
8718
  ]);
8719
8719
  getBasePath = function () {
8720
- var env = "{{env}}";
8720
+ var env = '{{env}}';
8721
8721
  return basePathMap.get(env);
8722
8722
  };
8723
8723
  isValidURL = function (url) {
8724
- var pattern = new RegExp("^(https?:\/\/)?" + // protocol
8725
- "((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|" + // domain name
8726
- "((\d{1,3}\.){3}\d{1,3}))" + // OR ip (v4) address
8727
- "(\:\d+)?(\/[-a-z\d%_.~+]*)*" + // port and path
8728
- "(\#[-a-z\d_]*)?$", "i"); // fragment locator
8724
+ var pattern = new RegExp('^(https?:\\/\\/)?' + // protocol
8725
+ '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name
8726
+ '((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address
8727
+ '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path
8728
+ '(\\?[;&a-z\\d%_.~+=-]*)?' + // query string
8729
+ '(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator
8729
8730
  return !!pattern.test(url);
8730
8731
  };
8731
8732
  prefix = getBasePath();
@@ -8733,27 +8734,20 @@ function request(_a) {
8733
8734
  fetchOption = {
8734
8735
  method: method,
8735
8736
  headers: {
8736
- "Content-type": "application/json",
8737
- "x-token": "{{token}}",
8737
+ 'Content-type': 'application/json',
8738
+ 'x-token': '{{token}}',
8738
8739
  },
8739
8740
  };
8740
- if (method.toUpperCase() === "POST") {
8741
+ if (method.toUpperCase() === 'POST') {
8741
8742
  fetchOption.body = JSON.stringify(input.params);
8742
8743
  }
8743
- else if (method.toUpperCase() === "GET") {
8744
+ else if (method.toUpperCase() === 'GET') {
8744
8745
  requestUrl = "".concat(requestUrl, "?").concat(ywfeUtils_esm.querystring.stringify(input.params || {}));
8745
8746
  }
8746
8747
  return [4 /*yield*/, fetch(requestUrl, fetchOption)];
8747
8748
  case 1:
8748
- response = _c.sent();
8749
- if (!response.ok) {
8750
- message = "An error has occured: ".concat(response.status);
8751
- return [2 /*return*/, { success: false, message: message }];
8752
- }
8753
- return [4 /*yield*/, response.json()];
8754
- case 2:
8755
- result = _c.sent();
8756
- return [2 /*return*/, result];
8749
+ res = _c.sent();
8750
+ return [2 /*return*/, res.json()];
8757
8751
  }
8758
8752
  });
8759
8753
  });
@@ -8761,48 +8755,24 @@ function request(_a) {
8761
8755
 
8762
8756
  function userInputToJson(_a) {
8763
8757
  return __awaiter(this, arguments, void 0, function (_b) {
8764
- var res, result;
8765
8758
  var input = _b.input;
8766
8759
  return __generator(this, function (_c) {
8767
8760
  switch (_c.label) {
8768
8761
  case 0:
8769
- console.log("input", input);
8762
+ input.userInput, input.rules;
8770
8763
  return [4 /*yield*/, request({
8771
8764
  input: {
8772
8765
  url: "https://fc-typechat.ywwl.com/userInputToJson",
8773
- method: "GET",
8774
- params: input,
8775
- },
8766
+ method: "GET"
8767
+ }
8776
8768
  })];
8777
8769
  case 1:
8778
- res = _c.sent();
8779
- if (res.success) {
8780
- result = res.data;
8781
- return [2 /*return*/, result.success ? result.data : result];
8782
- }
8783
- else {
8784
- return [2 /*return*/, res.success ? res.data : res];
8785
- }
8770
+ _c.sent();
8771
+ return [2 /*return*/, "2"];
8786
8772
  }
8787
8773
  });
8788
8774
  });
8789
8775
  }
8790
8776
 
8791
- // Ctrl-S保存代码
8792
- function JSON2String(_a) {
8793
- var input = _a.input;
8794
- var data = input.data;
8795
- var result = { content: '' };
8796
- try {
8797
- var str = JSON.stringify(data);
8798
- result.content = '```json' + str + 'json```';
8799
- return result;
8800
- }
8801
- catch (error) {
8802
- result.content = '```json' + '{}' + 'json```';
8803
- return result;
8804
- }
8805
- }
8806
-
8807
- export { JSON2String, request, userInputToJson };
8777
+ export { request, userInputToJson };
8808
8778
  //# sourceMappingURL=ywfe-tools.esm.js.map