@ywfe/fe-tools 1.2.1-beta.30 → 1.2.1-beta.32

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.
@@ -4,9 +4,5 @@ interface userInput {
4
4
  }
5
5
  declare function userInputToJson({ input }: {
6
6
  input: userInput;
7
- }): Promise<{
8
- message: string;
9
- success: boolean;
10
- data: any;
11
- }>;
7
+ }): Promise<any>;
12
8
  export default userInputToJson;
@@ -8723,13 +8723,8 @@ function request(_a) {
8723
8723
  return basePathMap.get(env);
8724
8724
  };
8725
8725
  isValidURL = function (url) {
8726
- var pattern = new RegExp("^(https?:\/\/)?" + // protocol
8727
- "((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|" + // domain name
8728
- "((\d{1,3}\.){3}\d{1,3}))" + // OR ip (v4) address
8729
- "(\:\d+)?(\/[-a-z\d%_.&#126;+]*)*" + // port and path
8730
- "(\?[;&a-z\d%_.&#126;+=-]*)?" + // query string
8731
- "(\#[-a-z\d_]*)?$", "i"); // fragment locator
8732
- return !!pattern.test(url);
8726
+ var regex = /^https?:\/\//;
8727
+ return regex.test(url);
8733
8728
  };
8734
8729
  prefix = getBasePath();
8735
8730
  requestUrl = isValidURL(input.url) ? input.url : "".concat(prefix).concat(input.url);
@@ -8751,11 +8746,13 @@ function request(_a) {
8751
8746
  response = _c.sent();
8752
8747
  if (!response.ok) {
8753
8748
  message = "An error has occured: ".concat(response.status);
8749
+ console.log('req result', message);
8754
8750
  return [2 /*return*/, { success: false, message: message }];
8755
8751
  }
8756
8752
  return [4 /*yield*/, response.json()];
8757
8753
  case 2:
8758
8754
  result = _c.sent();
8755
+ console.log('req result', result);
8759
8756
  return [2 /*return*/, result];
8760
8757
  }
8761
8758
  });
@@ -8764,20 +8761,28 @@ function request(_a) {
8764
8761
 
8765
8762
  function userInputToJson(_a) {
8766
8763
  return __awaiter(this, arguments, void 0, function (_b) {
8767
- var res;
8764
+ var res, result;
8768
8765
  var input = _b.input;
8769
8766
  return __generator(this, function (_c) {
8770
8767
  switch (_c.label) {
8771
- case 0: return [4 /*yield*/, request({
8772
- input: {
8773
- url: "https://fc-typechat.ywwl.com/userInputToJson",
8774
- method: "GET",
8775
- params: input,
8776
- },
8777
- })];
8768
+ case 0:
8769
+ console.log("input", input);
8770
+ return [4 /*yield*/, request({
8771
+ input: {
8772
+ url: "https://fc-typechat.ywwl.com/userInputToJson",
8773
+ method: "GET",
8774
+ params: input,
8775
+ },
8776
+ })];
8778
8777
  case 1:
8779
8778
  res = _c.sent();
8780
- return [2 /*return*/, res];
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
+ }
8781
8786
  }
8782
8787
  });
8783
8788
  });