@freelog/tools-lib 0.1.106 → 0.1.109

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.
@@ -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 {};
@@ -13,6 +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 combination from './combinations';
16
17
  declare const FServiceAPI: {
17
18
  Node: typeof Node;
18
19
  Exhibit: typeof Exhibit;
@@ -29,5 +30,6 @@ declare const FServiceAPI: {
29
30
  TestQualification: typeof TestQualification;
30
31
  Statistic: typeof Statistic;
31
32
  I18n: typeof I18n;
33
+ combination: typeof combination;
32
34
  };
33
35
  export default FServiceAPI;
@@ -15,7 +15,7 @@ interface IResourceInfo {
15
15
  }[];
16
16
  resourceId: string;
17
17
  resourceName: string;
18
- resourceType: string;
18
+ resourceType: string[];
19
19
  resourceVersions: {
20
20
  createDate: string;
21
21
  version: string;
@@ -29,7 +29,7 @@ interface IResourceInfo {
29
29
  }
30
30
  export interface CreateParamsType {
31
31
  name: string;
32
- resourceType: string;
32
+ resourceType: string[];
33
33
  policies?: any[];
34
34
  coverImages?: string[];
35
35
  intro?: string;
@@ -90,7 +90,7 @@ interface UpdateObjectParamsType {
90
90
  type: string;
91
91
  versionRange?: string;
92
92
  }[];
93
- resourceType?: string;
93
+ resourceType?: string[];
94
94
  }
95
95
  export declare function updateObject({ objectIdOrName, ...params }: UpdateObjectParamsType): Promise<any>;
96
96
  interface BatchObjectListParamsType {
@@ -101,7 +101,6 @@ interface BatchObjectListParamsType {
101
101
  export declare function batchObjectList(params: BatchObjectListParamsType): Promise<any>;
102
102
  interface FilePropertyParamsType {
103
103
  sha1: string;
104
- resourceType: string;
105
104
  }
106
105
  export declare function fileProperty({ sha1, ...params }: FilePropertyParamsType): Promise<any>;
107
106
  interface CycleDependencyCheckParamsType {
@@ -118,4 +117,8 @@ interface ClearUserNodeDataParamsType {
118
117
  nodeDomains?: string[];
119
118
  }
120
119
  export declare function clearUserNodeData({ ...params }: ClearUserNodeDataParamsType): Promise<any>;
120
+ interface FilesListInfoParamsType {
121
+ sha1: string[];
122
+ }
123
+ export declare function filesListInfo({ ...params }: FilesListInfoParamsType): Promise<any>;
121
124
  export {};
@@ -62,4 +62,10 @@ interface UpdateMobileOrEmailParamsType {
62
62
  newLoginName: string;
63
63
  }
64
64
  export declare function updateMobileOrEmail(params: UpdateMobileOrEmailParamsType): Promise<any>;
65
+ interface RegisterOrBindParamsType {
66
+ loginName: string;
67
+ password: string;
68
+ identityId: string;
69
+ }
70
+ export declare function registerOrBind(params: RegisterOrBindParamsType): Promise<any>;
65
71
  export {};
@@ -896,6 +896,10 @@ function completeUrlByDomain(domain) {
896
896
  function policyCodeTranslationToText(_x, _x2) {
897
897
  return _policyCodeTranslationToText.apply(this, arguments);
898
898
  }
899
+ /**
900
+ * 将资源类型关键字数组,转换成标准展示文字
901
+ * @param arr 关键字数组
902
+ */
899
903
 
900
904
  function _policyCodeTranslationToText() {
901
905
  _policyCodeTranslationToText = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(code, targetType) {
@@ -950,12 +954,17 @@ function _policyCodeTranslationToText() {
950
954
  return _policyCodeTranslationToText.apply(this, arguments);
951
955
  }
952
956
 
957
+ function resourceTypeKeyArrToResourceType(arr) {
958
+ return arr.join(' / ');
959
+ }
960
+
953
961
  var Format = {
954
962
  __proto__: null,
955
963
  humanizeSize: humanizeSize,
956
964
  formatDateTime: formatDateTime,
957
965
  completeUrlByDomain: completeUrlByDomain,
958
- policyCodeTranslationToText: policyCodeTranslationToText
966
+ policyCodeTranslationToText: policyCodeTranslationToText,
967
+ resourceTypeKeyArrToResourceType: resourceTypeKeyArrToResourceType
959
968
  };
960
969
 
961
970
  // 展品名称
@@ -1734,7 +1743,7 @@ function updateObject(_ref5) {
1734
1743
 
1735
1744
  return FUtil.Request({
1736
1745
  method: 'PUT',
1737
- url: "/v1/storages/objects/" + objectIdOrName,
1746
+ url: "/v2/storages/objects/" + objectIdOrName,
1738
1747
  data: params
1739
1748
  });
1740
1749
  }
@@ -1774,6 +1783,15 @@ function clearUserNodeData(_ref8) {
1774
1783
  data: params
1775
1784
  });
1776
1785
  }
1786
+ function filesListInfo(_ref9) {
1787
+ var params = _extends({}, _ref9);
1788
+
1789
+ return FUtil.Request({
1790
+ method: 'GET',
1791
+ url: "/v2/storages/files/list/info",
1792
+ params: params
1793
+ });
1794
+ }
1777
1795
 
1778
1796
  var Storage = {
1779
1797
  __proto__: null,
@@ -1796,7 +1814,8 @@ var Storage = {
1796
1814
  batchObjectList: batchObjectList,
1797
1815
  fileProperty: fileProperty,
1798
1816
  cycleDependencyCheck: cycleDependencyCheck,
1799
- clearUserNodeData: clearUserNodeData
1817
+ clearUserNodeData: clearUserNodeData,
1818
+ filesListInfo: filesListInfo
1800
1819
  };
1801
1820
 
1802
1821
  function collectResource(params) {
@@ -2240,6 +2259,15 @@ function updateMobileOrEmail(params) {
2240
2259
  data: params
2241
2260
  });
2242
2261
  }
2262
+ function registerOrBind(params) {
2263
+ return FUtil.Request({
2264
+ method: 'POST',
2265
+ url: "/v2/thirdParty/registerOrBind",
2266
+ data: params
2267
+ }, {
2268
+ noRedirect: true
2269
+ });
2270
+ }
2243
2271
 
2244
2272
  var User = {
2245
2273
  __proto__: null,
@@ -2254,7 +2282,8 @@ var User = {
2254
2282
  updateDetailInfo: updateDetailInfo,
2255
2283
  verifyLoginPassword: verifyLoginPassword,
2256
2284
  areasProvinces: areasProvinces,
2257
- updateMobileOrEmail: updateMobileOrEmail
2285
+ updateMobileOrEmail: updateMobileOrEmail,
2286
+ registerOrBind: registerOrBind
2258
2287
  };
2259
2288
 
2260
2289
  var _excluded$5 = ["nodeId"],
@@ -2722,6 +2751,207 @@ var I18n = {
2722
2751
  configsList: configsList
2723
2752
  };
2724
2753
 
2754
+ /**
2755
+ * 根据 File 获取 SHA1 Hash 字符串
2756
+ * @param file
2757
+ * @return {Promise<string>}
2758
+ */
2759
+
2760
+ function getSHA1Hash(file) {
2761
+ return new Promise(function (resolve) {
2762
+ var reader = new FileReader();
2763
+
2764
+ reader.onload = function () {
2765
+ var wordArray = CryptoJS.lib.WordArray.create(reader.result);
2766
+ var hash = CryptoJS.SHA1(wordArray).toString();
2767
+ resolve(hash);
2768
+ };
2769
+
2770
+ reader.readAsArrayBuffer(file);
2771
+ });
2772
+ }
2773
+ /**
2774
+ * 生成随机码
2775
+ */
2776
+
2777
+ function generateRandomCode(strLen) {
2778
+ if (strLen === void 0) {
2779
+ strLen = 5;
2780
+ }
2781
+
2782
+ var allStr = 'ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
2783
+ var newStrArr = [];
2784
+
2785
+ for (var i = 0; i < strLen; i++) {
2786
+ newStrArr.push(allStr[Math.floor(Math.random() * 61)]);
2787
+ }
2788
+
2789
+ return newStrArr.join('');
2790
+ }
2791
+ /**
2792
+ * 通过读取 cookies 获取用户 ID
2793
+ */
2794
+
2795
+ function getUserIDByCookies() {
2796
+ var uid = document.cookie.split('; ').find(function (co) {
2797
+ return co.startsWith('uid=');
2798
+ });
2799
+
2800
+ if (!uid) {
2801
+ return -1;
2802
+ }
2803
+
2804
+ return Number(uid.replace('uid=', ''));
2805
+ }
2806
+ function transformServerAPIContractState(_ref) {
2807
+ var status = _ref.status,
2808
+ authStatus = _ref.authStatus;
2809
+
2810
+ if (status === 0) {
2811
+ if (authStatus === 1 || authStatus === 3) {
2812
+ return 'active';
2813
+ }
2814
+
2815
+ if (authStatus === 2) {
2816
+ return 'testActive';
2817
+ }
2818
+
2819
+ if (authStatus === 128) {
2820
+ return 'inactive';
2821
+ }
2822
+ }
2823
+
2824
+ if (status === 1) {
2825
+ return 'terminal';
2826
+ }
2827
+
2828
+ return 'exception';
2829
+ }
2830
+ /**
2831
+ * 暂时休眠
2832
+ * @param ms 休眠时常(毫秒)
2833
+ */
2834
+
2835
+ function promiseSleep(ms) {
2836
+ if (ms === void 0) {
2837
+ ms = 300;
2838
+ }
2839
+
2840
+ return new Promise(function (resolve) {
2841
+ setTimeout(function () {
2842
+ resolve();
2843
+ }, ms);
2844
+ });
2845
+ }
2846
+
2847
+ var Tool = {
2848
+ __proto__: null,
2849
+ getSHA1Hash: getSHA1Hash,
2850
+ generateRandomCode: generateRandomCode,
2851
+ getUserIDByCookies: getUserIDByCookies,
2852
+ transformServerAPIContractState: transformServerAPIContractState,
2853
+ promiseSleep: promiseSleep
2854
+ };
2855
+
2856
+ function getFilesSha1Info(_x, _x2) {
2857
+ return _getFilesSha1Info.apply(this, arguments);
2858
+ }
2859
+
2860
+ function _getFilesSha1Info() {
2861
+ _getFilesSha1Info = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref, cdPartially) {
2862
+ var sha1, needHandleSha1, allData, _yield$Storage$filesL, data, finishedInfo;
2863
+
2864
+ return runtime_1.wrap(function _callee$(_context) {
2865
+ while (1) {
2866
+ switch (_context.prev = _context.next) {
2867
+ case 0:
2868
+ sha1 = _ref.sha1;
2869
+
2870
+ if (cdPartially === void 0) {
2871
+ cdPartially = function cdPartially() {
2872
+ return undefined;
2873
+ };
2874
+ }
2875
+
2876
+ if (!(sha1.length === 0)) {
2877
+ _context.next = 4;
2878
+ break;
2879
+ }
2880
+
2881
+ return _context.abrupt("return", []);
2882
+
2883
+ case 4:
2884
+ needHandleSha1 = [].concat(sha1);
2885
+ allData = [];
2886
+
2887
+ case 6:
2888
+
2889
+ _context.next = 9;
2890
+ return filesListInfo({
2891
+ sha1: needHandleSha1
2892
+ });
2893
+
2894
+ case 9:
2895
+ _yield$Storage$filesL = _context.sent;
2896
+ data = _yield$Storage$filesL.data;
2897
+ needHandleSha1 = data.filter(function (d) {
2898
+ return d.metaAnalyzeStatus && d.metaAnalyzeStatus === 1;
2899
+ }).map(function (d) {
2900
+ return d.sha1;
2901
+ });
2902
+ finishedInfo = data.filter(function (d) {
2903
+ return !d.metaAnalyzeStatus || d.metaAnalyzeStatus !== 1;
2904
+ }).map(function (d) {
2905
+ var state = 'fail';
2906
+
2907
+ if (!d.metaAnalyzeStatus) {
2908
+ state = 'nonentity';
2909
+ } else if (d.metaAnalyzeStatus === 2) {
2910
+ state = 'success';
2911
+ }
2912
+
2913
+ return {
2914
+ sha1: d.sha1,
2915
+ state: state,
2916
+ info: d
2917
+ };
2918
+ });
2919
+ cdPartially && cdPartially(finishedInfo);
2920
+ allData = [].concat(allData, finishedInfo);
2921
+
2922
+ if (!(needHandleSha1.length === 0)) {
2923
+ _context.next = 17;
2924
+ break;
2925
+ }
2926
+
2927
+ return _context.abrupt("break", 21);
2928
+
2929
+ case 17:
2930
+ _context.next = 19;
2931
+ return promiseSleep(3000);
2932
+
2933
+ case 19:
2934
+ _context.next = 6;
2935
+ break;
2936
+
2937
+ case 21:
2938
+ return _context.abrupt("return", allData);
2939
+
2940
+ case 22:
2941
+ case "end":
2942
+ return _context.stop();
2943
+ }
2944
+ }
2945
+ }, _callee);
2946
+ }));
2947
+ return _getFilesSha1Info.apply(this, arguments);
2948
+ }
2949
+
2950
+ var combination = {
2951
+ __proto__: null,
2952
+ getFilesSha1Info: getFilesSha1Info
2953
+ };
2954
+
2725
2955
  var FServiceAPI = {
2726
2956
  Node: Node,
2727
2957
  Exhibit: Exhibit,
@@ -2737,7 +2967,8 @@ var FServiceAPI = {
2737
2967
  Activity: Activity,
2738
2968
  TestQualification: TestQualification,
2739
2969
  Statistic: Statistic,
2740
- I18n: I18n
2970
+ I18n: I18n,
2971
+ combination: combination
2741
2972
  };
2742
2973
 
2743
2974
  var codeMessage = {
@@ -2895,91 +3126,6 @@ function _request() {
2895
3126
  return _request.apply(this, arguments);
2896
3127
  }
2897
3128
 
2898
- /**
2899
- * 根据 File 获取 SHA1 Hash 字符串
2900
- * @param file
2901
- * @return {Promise<string>}
2902
- */
2903
-
2904
- function getSHA1Hash(file) {
2905
- return new Promise(function (resolve) {
2906
- var reader = new FileReader();
2907
-
2908
- reader.onload = function () {
2909
- var wordArray = CryptoJS.lib.WordArray.create(reader.result);
2910
- var hash = CryptoJS.SHA1(wordArray).toString();
2911
- resolve(hash);
2912
- };
2913
-
2914
- reader.readAsArrayBuffer(file);
2915
- });
2916
- }
2917
- /**
2918
- * 生成随机码
2919
- */
2920
-
2921
- function generateRandomCode(strLen) {
2922
- if (strLen === void 0) {
2923
- strLen = 5;
2924
- }
2925
-
2926
- var allStr = 'ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
2927
- var newStrArr = [];
2928
-
2929
- for (var i = 0; i < strLen; i++) {
2930
- newStrArr.push(allStr[Math.floor(Math.random() * 61)]);
2931
- }
2932
-
2933
- return newStrArr.join('');
2934
- }
2935
- /**
2936
- * 通过读取 cookies 获取用户 ID
2937
- */
2938
-
2939
- function getUserIDByCookies() {
2940
- var uid = document.cookie.split('; ').find(function (co) {
2941
- return co.startsWith('uid=');
2942
- });
2943
-
2944
- if (!uid) {
2945
- return -1;
2946
- }
2947
-
2948
- return Number(uid.replace('uid=', ''));
2949
- }
2950
- function transformServerAPIContractState(_ref) {
2951
- var status = _ref.status,
2952
- authStatus = _ref.authStatus;
2953
-
2954
- if (status === 0) {
2955
- if (authStatus === 1 || authStatus === 3) {
2956
- return 'active';
2957
- }
2958
-
2959
- if (authStatus === 2) {
2960
- return 'testActive';
2961
- }
2962
-
2963
- if (authStatus === 128) {
2964
- return 'inactive';
2965
- }
2966
- }
2967
-
2968
- if (status === 1) {
2969
- return 'terminal';
2970
- }
2971
-
2972
- return 'exception';
2973
- }
2974
-
2975
- var Tool = {
2976
- __proto__: null,
2977
- getSHA1Hash: getSHA1Hash,
2978
- generateRandomCode: generateRandomCode,
2979
- getUserIDByCookies: getUserIDByCookies,
2980
- transformServerAPIContractState: transformServerAPIContractState
2981
- };
2982
-
2983
3129
  var FUtil = {
2984
3130
  Format: Format,
2985
3131
  Regexp: Regexp,