@freelog/tools-lib 0.1.108 → 0.1.111

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.
@@ -13,7 +13,7 @@ import * as Activity from './activities';
13
13
  import * as TestQualification from './testQualifications';
14
14
  import * as Statistic from './statistics';
15
15
  import * as I18n from './i18n';
16
- import * as C from './combinations';
16
+ import * as recombination from './recombinations';
17
17
  declare const FServiceAPI: {
18
18
  Node: typeof Node;
19
19
  Exhibit: typeof Exhibit;
@@ -30,6 +30,6 @@ declare const FServiceAPI: {
30
30
  TestQualification: typeof TestQualification;
31
31
  Statistic: typeof Statistic;
32
32
  I18n: typeof I18n;
33
- C: typeof C;
33
+ recombination: typeof recombination;
34
34
  };
35
35
  export default FServiceAPI;
@@ -0,0 +1,12 @@
1
+ interface FileInfo {
2
+ sha1: string;
3
+ state: 'success' | 'fail' | 'nonentity';
4
+ info: {
5
+ [key: string]: any;
6
+ };
7
+ }
8
+ interface GetFileInfosBySha1Params {
9
+ sha1: string[];
10
+ }
11
+ export declare function getFilesSha1Info({ sha1 }: GetFileInfosBySha1Params, cdPartially?: (s: any[]) => void): Promise<FileInfo[]>;
12
+ export {};
@@ -253,4 +253,8 @@ interface BatchAuthParamsType {
253
253
  versionRanges?: string;
254
254
  }
255
255
  export declare function batchAuth({ ...params }: BatchAuthParamsType): Promise<any>;
256
+ interface ResourcesRecommendParamsType {
257
+ recommendType: 1 | 2;
258
+ }
259
+ export declare function resourcesRecommend({ ...params }: ResourcesRecommendParamsType): Promise<any>;
256
260
  export {};
@@ -68,4 +68,12 @@ interface RegisterOrBindParamsType {
68
68
  identityId: string;
69
69
  }
70
70
  export declare function registerOrBind(params: RegisterOrBindParamsType): Promise<any>;
71
+ interface ThirdPartyUnbindParamsType {
72
+ thirdPartyType: string;
73
+ password: string;
74
+ }
75
+ export declare function thirdPartyUnbind(params: ThirdPartyUnbindParamsType): Promise<any>;
76
+ interface ThirdPartyListParamsType {
77
+ }
78
+ export declare function thirdPartyList(params?: ThirdPartyListParamsType): Promise<any>;
71
79
  export {};
@@ -1026,7 +1026,8 @@ var Regexp = {
1026
1026
  };
1027
1027
 
1028
1028
  var _excluded = ["resourceID"],
1029
- _excluded2 = ["nodeID", "showPage"];
1029
+ _excluded2 = ["nodeID", "showPage"],
1030
+ _excluded3 = ["nodeID", "showPage"];
1030
1031
  function home(_temp) {
1031
1032
  var _ref = _temp === void 0 ? {} : _temp;
1032
1033
 
@@ -1053,11 +1054,10 @@ function dashboard(_temp3) {
1053
1054
  return "/dashboard";
1054
1055
  }
1055
1056
  function market(_temp4) {
1056
- var _ref5 = _temp4 === void 0 ? {} : _temp4;
1057
+ var _ref5 = _temp4 === void 0 ? {} : _temp4,
1058
+ params = _extends({}, _ref5);
1057
1059
 
1058
- _objectDestructuringEmpty(_ref5);
1059
-
1060
- return "/market";
1060
+ return "/market" + handleQuery(params);
1061
1061
  }
1062
1062
  function exampleNodes(_temp5) {
1063
1063
  var _ref6 = _temp5 === void 0 ? {} : _temp5;
@@ -1118,8 +1118,14 @@ function nodeCreator(_temp9) {
1118
1118
  return "/node/creator";
1119
1119
  }
1120
1120
  function nodeManagement(_ref16) {
1121
- var nodeID = _ref16.nodeID;
1122
- return "/node/formal/" + nodeID;
1121
+ var nodeID = _ref16.nodeID,
1122
+ _ref16$showPage = _ref16.showPage,
1123
+ showPage = _ref16$showPage === void 0 ? 'exhibit' : _ref16$showPage,
1124
+ params = _objectWithoutPropertiesLoose(_ref16, _excluded2);
1125
+
1126
+ return "/node/formal/" + nodeID + handleQuery(_extends({
1127
+ showPage: showPage
1128
+ }, params));
1123
1129
  }
1124
1130
  function exhibitManagement(_ref17) {
1125
1131
  var exhibitID = _ref17.exhibitID;
@@ -1129,7 +1135,7 @@ function informNodeManagement(_ref18) {
1129
1135
  var nodeID = _ref18.nodeID,
1130
1136
  _ref18$showPage = _ref18.showPage,
1131
1137
  showPage = _ref18$showPage === void 0 ? 'exhibit' : _ref18$showPage,
1132
- params = _objectWithoutPropertiesLoose(_ref18, _excluded2);
1138
+ params = _objectWithoutPropertiesLoose(_ref18, _excluded3);
1133
1139
 
1134
1140
  return "/node/informal/" + nodeID + handleQuery(_extends({
1135
1141
  showPage: showPage
@@ -1392,7 +1398,7 @@ var Node = {
1392
1398
 
1393
1399
  var _excluded$1 = ["presentableId"],
1394
1400
  _excluded2$1 = ["presentableId"],
1395
- _excluded3 = ["presentableId"],
1401
+ _excluded3$1 = ["presentableId"],
1396
1402
  _excluded4 = ["presentableId"],
1397
1403
  _excluded5 = ["presentableId"],
1398
1404
  _excluded6 = ["presentableId"],
@@ -1443,7 +1449,7 @@ function presentableDetails(params) {
1443
1449
  }
1444
1450
 
1445
1451
  var presentableId = params.presentableId,
1446
- p = _objectWithoutPropertiesLoose(params, _excluded3); // return FUtil.Axios.get(`/v2/presentables/${presentableId}`, {
1452
+ p = _objectWithoutPropertiesLoose(params, _excluded3$1); // return FUtil.Axios.get(`/v2/presentables/${presentableId}`, {
1447
1453
  // params: p,
1448
1454
  // });
1449
1455
 
@@ -1569,7 +1575,7 @@ var Exhibit = {
1569
1575
 
1570
1576
  var _excluded$2 = ["bucketName"],
1571
1577
  _excluded2$2 = ["bucketName"],
1572
- _excluded3$1 = ["objectIdOrName"],
1578
+ _excluded3$2 = ["objectIdOrName"],
1573
1579
  _excluded4$1 = ["sha1"],
1574
1580
  _excluded5$1 = ["objectIdOrName"];
1575
1581
  function createBucket(params) {
@@ -1739,7 +1745,7 @@ function uploadImage(params, config) {
1739
1745
  }
1740
1746
  function updateObject(_ref5) {
1741
1747
  var objectIdOrName = _ref5.objectIdOrName,
1742
- params = _objectWithoutPropertiesLoose(_ref5, _excluded3$1);
1748
+ params = _objectWithoutPropertiesLoose(_ref5, _excluded3$2);
1743
1749
 
1744
1750
  return FUtil.Request({
1745
1751
  method: 'PUT',
@@ -1874,7 +1880,7 @@ var Collection = {
1874
1880
 
1875
1881
  var _excluded$3 = ["resourceIdOrName"],
1876
1882
  _excluded2$3 = ["resourceId"],
1877
- _excluded3$2 = ["resourceId"],
1883
+ _excluded3$3 = ["resourceId"],
1878
1884
  _excluded4$2 = ["resourceId"],
1879
1885
  _excluded5$2 = ["resourceId", "version"],
1880
1886
  _excluded6$1 = ["fileSha1"],
@@ -1934,7 +1940,7 @@ function dependencyTree$1(_ref2) {
1934
1940
  }
1935
1941
  function authTree$1(_ref3) {
1936
1942
  var resourceId = _ref3.resourceId,
1937
- params = _objectWithoutPropertiesLoose(_ref3, _excluded3$2);
1943
+ params = _objectWithoutPropertiesLoose(_ref3, _excluded3$3);
1938
1944
 
1939
1945
  return FUtil.Request({
1940
1946
  method: 'GET',
@@ -2110,6 +2116,15 @@ function batchAuth$1(_ref13) {
2110
2116
  params: params
2111
2117
  });
2112
2118
  }
2119
+ function resourcesRecommend(_ref14) {
2120
+ var params = _extends({}, _ref14);
2121
+
2122
+ return FUtil.Request({
2123
+ method: 'GET',
2124
+ url: "/v2/resources/recommend?recommendType=2",
2125
+ params: params
2126
+ });
2127
+ }
2113
2128
 
2114
2129
  var Resource = {
2115
2130
  __proto__: null,
@@ -2136,7 +2151,8 @@ var Resource = {
2136
2151
  cycleDependencyCheck: cycleDependencyCheck$1,
2137
2152
  relationTree: relationTree$1,
2138
2153
  relationTreeAuth: relationTreeAuth,
2139
- batchAuth: batchAuth$1
2154
+ batchAuth: batchAuth$1,
2155
+ resourcesRecommend: resourcesRecommend
2140
2156
  };
2141
2157
 
2142
2158
  var _excluded$4 = ["loginName"];
@@ -2264,6 +2280,26 @@ function registerOrBind(params) {
2264
2280
  method: 'POST',
2265
2281
  url: "/v2/thirdParty/registerOrBind",
2266
2282
  data: params
2283
+ }, {
2284
+ noRedirect: true
2285
+ });
2286
+ }
2287
+ function thirdPartyUnbind(params) {
2288
+ return FUtil.Request({
2289
+ method: 'PUT',
2290
+ url: "/v2/thirdParty/unbind",
2291
+ data: params
2292
+ });
2293
+ }
2294
+ function thirdPartyList(params) {
2295
+ if (params === void 0) {
2296
+ params = {};
2297
+ }
2298
+
2299
+ return FUtil.Request({
2300
+ method: 'GET',
2301
+ url: "/v2/thirdParty/list",
2302
+ data: params
2267
2303
  });
2268
2304
  }
2269
2305
 
@@ -2281,12 +2317,14 @@ var User = {
2281
2317
  verifyLoginPassword: verifyLoginPassword,
2282
2318
  areasProvinces: areasProvinces,
2283
2319
  updateMobileOrEmail: updateMobileOrEmail,
2284
- registerOrBind: registerOrBind
2320
+ registerOrBind: registerOrBind,
2321
+ thirdPartyUnbind: thirdPartyUnbind,
2322
+ thirdPartyList: thirdPartyList
2285
2323
  };
2286
2324
 
2287
2325
  var _excluded$5 = ["nodeId"],
2288
2326
  _excluded2$4 = ["nodeId"],
2289
- _excluded3$3 = ["nodeId"],
2327
+ _excluded3$4 = ["nodeId"],
2290
2328
  _excluded4$3 = ["nodeId"],
2291
2329
  _excluded5$3 = ["nodeId"],
2292
2330
  _excluded6$2 = ["testResourceId"],
@@ -2317,7 +2355,7 @@ function createRules(_ref2) {
2317
2355
  }
2318
2356
  function batchTestResources(_ref3) {
2319
2357
  var nodeId = _ref3.nodeId,
2320
- params = _objectWithoutPropertiesLoose(_ref3, _excluded3$3);
2358
+ params = _objectWithoutPropertiesLoose(_ref3, _excluded3$4);
2321
2359
 
2322
2360
  return FUtil.Request({
2323
2361
  method: 'GET',
@@ -2749,33 +2787,193 @@ var I18n = {
2749
2787
  configsList: configsList
2750
2788
  };
2751
2789
 
2752
- function getFilesSha1Info(_x) {
2790
+ /**
2791
+ * 根据 File 获取 SHA1 Hash 字符串
2792
+ * @param file
2793
+ * @return {Promise<string>}
2794
+ */
2795
+
2796
+ function getSHA1Hash(file) {
2797
+ return new Promise(function (resolve) {
2798
+ var reader = new FileReader();
2799
+
2800
+ reader.onload = function () {
2801
+ var wordArray = CryptoJS.lib.WordArray.create(reader.result);
2802
+ var hash = CryptoJS.SHA1(wordArray).toString();
2803
+ resolve(hash);
2804
+ };
2805
+
2806
+ reader.readAsArrayBuffer(file);
2807
+ });
2808
+ }
2809
+ /**
2810
+ * 生成随机码
2811
+ */
2812
+
2813
+ function generateRandomCode(strLen) {
2814
+ if (strLen === void 0) {
2815
+ strLen = 5;
2816
+ }
2817
+
2818
+ var allStr = 'ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
2819
+ var newStrArr = [];
2820
+
2821
+ for (var i = 0; i < strLen; i++) {
2822
+ newStrArr.push(allStr[Math.floor(Math.random() * 61)]);
2823
+ }
2824
+
2825
+ return newStrArr.join('');
2826
+ }
2827
+ /**
2828
+ * 通过读取 cookies 获取用户 ID
2829
+ */
2830
+
2831
+ function getUserIDByCookies() {
2832
+ var uid = document.cookie.split('; ').find(function (co) {
2833
+ return co.startsWith('uid=');
2834
+ });
2835
+
2836
+ if (!uid) {
2837
+ return -1;
2838
+ }
2839
+
2840
+ return Number(uid.replace('uid=', ''));
2841
+ }
2842
+ function transformServerAPIContractState(_ref) {
2843
+ var status = _ref.status,
2844
+ authStatus = _ref.authStatus;
2845
+
2846
+ if (status === 0) {
2847
+ if (authStatus === 1 || authStatus === 3) {
2848
+ return 'active';
2849
+ }
2850
+
2851
+ if (authStatus === 2) {
2852
+ return 'testActive';
2853
+ }
2854
+
2855
+ if (authStatus === 128) {
2856
+ return 'inactive';
2857
+ }
2858
+ }
2859
+
2860
+ if (status === 1) {
2861
+ return 'terminal';
2862
+ }
2863
+
2864
+ return 'exception';
2865
+ }
2866
+ /**
2867
+ * 暂时休眠
2868
+ * @param ms 休眠时常(毫秒)
2869
+ */
2870
+
2871
+ function promiseSleep(ms) {
2872
+ if (ms === void 0) {
2873
+ ms = 300;
2874
+ }
2875
+
2876
+ return new Promise(function (resolve) {
2877
+ setTimeout(function () {
2878
+ resolve();
2879
+ }, ms);
2880
+ });
2881
+ }
2882
+
2883
+ var Tool = {
2884
+ __proto__: null,
2885
+ getSHA1Hash: getSHA1Hash,
2886
+ generateRandomCode: generateRandomCode,
2887
+ getUserIDByCookies: getUserIDByCookies,
2888
+ transformServerAPIContractState: transformServerAPIContractState,
2889
+ promiseSleep: promiseSleep
2890
+ };
2891
+
2892
+ function getFilesSha1Info(_x, _x2) {
2753
2893
  return _getFilesSha1Info.apply(this, arguments);
2754
2894
  }
2755
2895
 
2756
2896
  function _getFilesSha1Info() {
2757
- _getFilesSha1Info = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref) {
2758
- var sha1, cdPartiallySuccess, cdPartiallyFail, _yield$Storage$filesL, data, all, success, fail;
2897
+ _getFilesSha1Info = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref, cdPartially) {
2898
+ var sha1, needHandleSha1, allData, _yield$Storage$filesL, data, finishedInfo;
2759
2899
 
2760
2900
  return runtime_1.wrap(function _callee$(_context) {
2761
2901
  while (1) {
2762
2902
  switch (_context.prev = _context.next) {
2763
2903
  case 0:
2764
- sha1 = _ref.sha1, cdPartiallySuccess = _ref.cdPartiallySuccess, cdPartiallyFail = _ref.cdPartiallyFail;
2765
- _context.next = 3;
2904
+ sha1 = _ref.sha1;
2905
+
2906
+ if (cdPartially === void 0) {
2907
+ cdPartially = function cdPartially() {
2908
+ return undefined;
2909
+ };
2910
+ }
2911
+
2912
+ if (!(sha1.length === 0)) {
2913
+ _context.next = 4;
2914
+ break;
2915
+ }
2916
+
2917
+ return _context.abrupt("return", []);
2918
+
2919
+ case 4:
2920
+ needHandleSha1 = [].concat(sha1);
2921
+ allData = [];
2922
+
2923
+ case 6:
2924
+
2925
+ _context.next = 9;
2766
2926
  return filesListInfo({
2767
- sha1: sha1
2927
+ sha1: needHandleSha1
2768
2928
  });
2769
2929
 
2770
- case 3:
2930
+ case 9:
2771
2931
  _yield$Storage$filesL = _context.sent;
2772
2932
  data = _yield$Storage$filesL.data;
2773
- all = [];
2774
- success = [];
2775
- fail = [];
2776
- console.log(data, all, success, fail, cdPartiallySuccess, cdPartiallyFail, '093oijsdlkfsjdl');
2933
+ needHandleSha1 = data.filter(function (d) {
2934
+ return d.metaAnalyzeStatus && d.metaAnalyzeStatus === 1;
2935
+ }).map(function (d) {
2936
+ return d.sha1;
2937
+ });
2938
+ finishedInfo = data.filter(function (d) {
2939
+ return !d.metaAnalyzeStatus || d.metaAnalyzeStatus !== 1;
2940
+ }).map(function (d) {
2941
+ var state = 'fail';
2942
+
2943
+ if (!d.metaAnalyzeStatus) {
2944
+ state = 'nonentity';
2945
+ } else if (d.metaAnalyzeStatus === 2) {
2946
+ state = 'success';
2947
+ }
2777
2948
 
2778
- case 9:
2949
+ return {
2950
+ sha1: d.sha1,
2951
+ state: state,
2952
+ info: d
2953
+ };
2954
+ });
2955
+ cdPartially && cdPartially(finishedInfo);
2956
+ allData = [].concat(allData, finishedInfo);
2957
+
2958
+ if (!(needHandleSha1.length === 0)) {
2959
+ _context.next = 17;
2960
+ break;
2961
+ }
2962
+
2963
+ return _context.abrupt("break", 21);
2964
+
2965
+ case 17:
2966
+ _context.next = 19;
2967
+ return promiseSleep(3000);
2968
+
2969
+ case 19:
2970
+ _context.next = 6;
2971
+ break;
2972
+
2973
+ case 21:
2974
+ return _context.abrupt("return", allData);
2975
+
2976
+ case 22:
2779
2977
  case "end":
2780
2978
  return _context.stop();
2781
2979
  }
@@ -2785,7 +2983,7 @@ function _getFilesSha1Info() {
2785
2983
  return _getFilesSha1Info.apply(this, arguments);
2786
2984
  }
2787
2985
 
2788
- var C = {
2986
+ var recombination = {
2789
2987
  __proto__: null,
2790
2988
  getFilesSha1Info: getFilesSha1Info
2791
2989
  };
@@ -2806,7 +3004,7 @@ var FServiceAPI = {
2806
3004
  TestQualification: TestQualification,
2807
3005
  Statistic: Statistic,
2808
3006
  I18n: I18n,
2809
- C: C
3007
+ recombination: recombination
2810
3008
  };
2811
3009
 
2812
3010
  var codeMessage = {
@@ -2964,91 +3162,6 @@ function _request() {
2964
3162
  return _request.apply(this, arguments);
2965
3163
  }
2966
3164
 
2967
- /**
2968
- * 根据 File 获取 SHA1 Hash 字符串
2969
- * @param file
2970
- * @return {Promise<string>}
2971
- */
2972
-
2973
- function getSHA1Hash(file) {
2974
- return new Promise(function (resolve) {
2975
- var reader = new FileReader();
2976
-
2977
- reader.onload = function () {
2978
- var wordArray = CryptoJS.lib.WordArray.create(reader.result);
2979
- var hash = CryptoJS.SHA1(wordArray).toString();
2980
- resolve(hash);
2981
- };
2982
-
2983
- reader.readAsArrayBuffer(file);
2984
- });
2985
- }
2986
- /**
2987
- * 生成随机码
2988
- */
2989
-
2990
- function generateRandomCode(strLen) {
2991
- if (strLen === void 0) {
2992
- strLen = 5;
2993
- }
2994
-
2995
- var allStr = 'ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
2996
- var newStrArr = [];
2997
-
2998
- for (var i = 0; i < strLen; i++) {
2999
- newStrArr.push(allStr[Math.floor(Math.random() * 61)]);
3000
- }
3001
-
3002
- return newStrArr.join('');
3003
- }
3004
- /**
3005
- * 通过读取 cookies 获取用户 ID
3006
- */
3007
-
3008
- function getUserIDByCookies() {
3009
- var uid = document.cookie.split('; ').find(function (co) {
3010
- return co.startsWith('uid=');
3011
- });
3012
-
3013
- if (!uid) {
3014
- return -1;
3015
- }
3016
-
3017
- return Number(uid.replace('uid=', ''));
3018
- }
3019
- function transformServerAPIContractState(_ref) {
3020
- var status = _ref.status,
3021
- authStatus = _ref.authStatus;
3022
-
3023
- if (status === 0) {
3024
- if (authStatus === 1 || authStatus === 3) {
3025
- return 'active';
3026
- }
3027
-
3028
- if (authStatus === 2) {
3029
- return 'testActive';
3030
- }
3031
-
3032
- if (authStatus === 128) {
3033
- return 'inactive';
3034
- }
3035
- }
3036
-
3037
- if (status === 1) {
3038
- return 'terminal';
3039
- }
3040
-
3041
- return 'exception';
3042
- }
3043
-
3044
- var Tool = {
3045
- __proto__: null,
3046
- getSHA1Hash: getSHA1Hash,
3047
- generateRandomCode: generateRandomCode,
3048
- getUserIDByCookies: getUserIDByCookies,
3049
- transformServerAPIContractState: transformServerAPIContractState
3050
- };
3051
-
3052
3165
  var FUtil = {
3053
3166
  Format: Format,
3054
3167
  Regexp: Regexp,