@freelog/tools-lib 0.1.151 → 0.1.153

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.
@@ -2,6 +2,7 @@ import moment from 'moment';
2
2
  import { stringify } from 'querystring';
3
3
  import axios from 'axios';
4
4
  import { lib, SHA1 } from 'crypto-js';
5
+ import { useState, useRef } from 'react';
5
6
  import i18next from 'i18next';
6
7
  import Cookies from 'js-cookie';
7
8
 
@@ -119,12 +120,11 @@ var Format = {
119
120
  var EXHIBIT_NAME = /*#__PURE__*/new RegExp(/^(?!.*(\\|\/|:|\*|\?|"|<|>|\||\s|@|\$|#)).{1,60}$/); // 资源名称
120
121
 
121
122
  var RESOURCE_NAME = /*#__PURE__*/new RegExp(/^(?!.*(\\|\/|:|\*|\?|"|<|>|\||\s|@|\$|#)).{1,60}$/); // 资源类型
122
- // export const RESOURCE_TYPE: RegExp = new RegExp(/^(?!_)[a-z0-9_]{3,20}(?<!_)$/);
123
123
 
124
- var RESOURCE_TYPE = /*#__PURE__*/new RegExp(/^[a-z0-9][a-z0-9_]{1,18}[a-z0-9]$/); // 自定义属性键
125
- // export const CUSTOM_KEY: RegExp = new RegExp(/^[a-zA-Z0-9_]{1,20}$/);
124
+ var RESOURCE_TYPE = /*#__PURE__*/new RegExp("^[\u4E00-\u9FEFa-zA-Z0-9\\-&.,]{1,40}$"); // 自定义属性键
125
+ // export const CUSTOM_KEY: RegExp = new RegExp(/^[a-zA-Z_]([a-zA-Z0-9_]{1,19})?$/);
126
126
 
127
- var CUSTOM_KEY = /*#__PURE__*/new RegExp(/^[a-zA-Z_][a-zA-Z0-9_]{1,19}$/); // 节点名称
127
+ var CUSTOM_KEY = /*#__PURE__*/new RegExp('^[a-zA-Z]([a-zA-Z0-9_]{1,19})?$'); // 节点名称
128
128
 
129
129
  var NODE_NAME = /*#__PURE__*/new RegExp(/^[\u4E00-\u9FA5|a-zA-Z0-9]{2,24}$/); // 节点地址
130
130
  // export const NODE_DOMAIN: RegExp = new RegExp(/^(?!-)[a-z0-9-]{4,24}(?<!-)$/);
@@ -147,12 +147,17 @@ var PASSWORD = /*#__PURE__*/new RegExp(/^(?=.*[0-9])(?=.*[a-zA-Z])(.{6,24})$/);
147
147
  var NATURAL_NUMBER = /*#__PURE__*/new RegExp(/^[0-9]*$/); // 正整数
148
148
 
149
149
  var POSITIVE_INTEGER = /*#__PURE__*/new RegExp(/^[1-9]\d*$/); // 最多两位小数的正数
150
+ // export const MAX_2_DECIMAL_POSITIVE_NUMBER = new RegExp(/^\d+(.\d{1,2})?$/);
150
151
 
151
- var MAX_2_DECIMAL_POSITIVE_NUMBER = /*#__PURE__*/new RegExp(/^\d+(.\d{1,2})?$/); // 对象的Bucket名称
152
+ var MAX_2_DECIMAL_POSITIVE_NUMBER = /*#__PURE__*/new RegExp(/^\d+(\.\d{0,2})?$/); // 对象的Bucket名称
152
153
 
153
154
  var BUCKET_NAME = /*#__PURE__*/new RegExp(/^([a-z0-9][a-z0-9-]{0,61})?[a-z0-9]$/); // JS变量名称
154
155
 
155
- var JS_VARIABLE_NAME = /*#__PURE__*/new RegExp(/^[A-Za-z$_][\w$_]*$/);
156
+ var JS_VARIABLE_NAME = /*#__PURE__*/new RegExp(/^[A-Za-z$_][\w$_]*$/); // 日期
157
+
158
+ var DATE = /*#__PURE__*/new RegExp(/(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29)$/); // 日期时间
159
+
160
+ var DATE_TIME = /*#__PURE__*/new RegExp(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/);
156
161
 
157
162
  var Regexp = {
158
163
  __proto__: null,
@@ -171,7 +176,9 @@ var Regexp = {
171
176
  POSITIVE_INTEGER: POSITIVE_INTEGER,
172
177
  MAX_2_DECIMAL_POSITIVE_NUMBER: MAX_2_DECIMAL_POSITIVE_NUMBER,
173
178
  BUCKET_NAME: BUCKET_NAME,
174
- JS_VARIABLE_NAME: JS_VARIABLE_NAME
179
+ JS_VARIABLE_NAME: JS_VARIABLE_NAME,
180
+ DATE: DATE,
181
+ DATE_TIME: DATE_TIME
175
182
  };
176
183
 
177
184
  function _regeneratorRuntime() {
@@ -595,7 +602,8 @@ var _excluded = ["resourceID"],
595
602
  _excluded2 = ["nodeID", "showPage"],
596
603
  _excluded3 = ["nodeID", "showPage"],
597
604
  _excluded4 = ["goTo"],
598
- _excluded5 = ["goTo"];
605
+ _excluded5 = ["goTo"],
606
+ _excluded6 = ["goTo", "returnUrl"];
599
607
  function home(_temp) {
600
608
  var _ref = _temp === void 0 ? {} : _temp;
601
609
 
@@ -777,84 +785,101 @@ function resourceFreeze(_ref29) {
777
785
  var resourceID = _ref29.resourceID;
778
786
  return "/result/resource/freeze/" + resourceID;
779
787
  }
788
+ function globalSearch(_ref30) {
789
+ var search = _ref30.search;
790
+ return "/search" + handleQuery({
791
+ search: search
792
+ });
793
+ }
780
794
  function login(_temp13) {
781
- var _ref30 = _temp13 === void 0 ? {} : _temp13,
782
- goTo = _ref30.goTo;
795
+ var _ref31 = _temp13 === void 0 ? {} : _temp13,
796
+ goTo = _ref31.goTo;
783
797
 
784
798
  return "/login" + handleQuery({
785
799
  goTo: goTo ? encodeURIComponent(goTo) : undefined
786
800
  });
787
801
  }
788
802
  function logon(_temp14) {
789
- var _ref31 = _temp14 === void 0 ? {} : _temp14,
790
- goTo = _ref31.goTo,
791
- params = _objectWithoutPropertiesLoose(_ref31, _excluded5);
803
+ var _ref32 = _temp14 === void 0 ? {} : _temp14,
804
+ goTo = _ref32.goTo,
805
+ params = _objectWithoutPropertiesLoose(_ref32, _excluded5);
792
806
 
793
807
  return "/logon" + handleQuery(_extends({
794
808
  goTo: goTo ? encodeURIComponent(goTo) : undefined
795
809
  }, params));
796
810
  }
797
- function retrieveUserPassword(_temp15) {
798
- var _ref32 = _temp15 === void 0 ? {} : _temp15,
799
- goTo = _ref32.goTo;
811
+ function bind(_temp15) {
812
+ var _ref33 = _temp15 === void 0 ? {} : _temp15,
813
+ goTo = _ref33.goTo,
814
+ returnUrl = _ref33.returnUrl,
815
+ params = _objectWithoutPropertiesLoose(_ref33, _excluded6);
816
+
817
+ return "/bind" + handleQuery(_extends({
818
+ goTo: goTo ? encodeURIComponent(goTo) : undefined,
819
+ returnUrl: returnUrl ? encodeURIComponent(returnUrl) : undefined
820
+ }, params));
821
+ }
822
+ function retrieveUserPassword(_temp16) {
823
+ var _ref34 = _temp16 === void 0 ? {} : _temp16,
824
+ goTo = _ref34.goTo;
800
825
 
801
826
  return "/retrieve" + handleQuery({
802
827
  goTo: goTo ? encodeURIComponent(goTo) : undefined
803
828
  });
804
829
  }
805
- function retrievePayPassword(_temp16) {
806
- var _ref33 = _temp16 === void 0 ? {} : _temp16;
830
+ function retrievePayPassword(_temp17) {
831
+ var _ref35 = _temp17 === void 0 ? {} : _temp17;
807
832
 
808
- _objectDestructuringEmpty(_ref33);
833
+ _objectDestructuringEmpty(_ref35);
809
834
 
810
835
  return "/retrievePayPassword";
811
836
  }
812
- function userFreeze(_temp17) {
813
- var _ref34 = _temp17 === void 0 ? {} : _temp17;
837
+ function userFreeze(_temp18) {
838
+ var _ref36 = _temp18 === void 0 ? {} : _temp18;
814
839
 
815
- _objectDestructuringEmpty(_ref34);
840
+ _objectDestructuringEmpty(_ref36);
816
841
 
817
842
  return "/freeze";
818
843
  }
819
- function wallet(_temp18) {
820
- var _ref35 = _temp18 === void 0 ? {} : _temp18;
844
+ function wallet(_temp19) {
845
+ var _ref37 = _temp19 === void 0 ? {} : _temp19;
821
846
 
822
- _objectDestructuringEmpty(_ref35);
847
+ _objectDestructuringEmpty(_ref37);
823
848
 
824
849
  return "/logged/wallet";
825
850
  }
826
- function reward(_temp19) {
827
- var _ref36 = _temp19 === void 0 ? {} : _temp19;
851
+ function reward(_temp20) {
852
+ var _ref38 = _temp20 === void 0 ? {} : _temp20;
828
853
 
829
- _objectDestructuringEmpty(_ref36);
854
+ _objectDestructuringEmpty(_ref38);
830
855
 
831
856
  return "/logged/reward";
832
857
  }
833
- function contract(_temp20) {
834
- var _ref37 = _temp20 === void 0 ? {} : _temp20;
858
+ function contract(_temp21) {
859
+ var _ref39 = _temp21 === void 0 ? {} : _temp21;
835
860
 
836
- _objectDestructuringEmpty(_ref37);
861
+ _objectDestructuringEmpty(_ref39);
837
862
 
838
863
  return "/logged/contract";
839
864
  }
840
- function setting(_temp21) {
841
- var _ref38 = _temp21 === void 0 ? {} : _temp21;
865
+ function setting(_temp22) {
866
+ var _ref40 = _temp22 === void 0 ? {} : _temp22;
842
867
 
843
- _objectDestructuringEmpty(_ref38);
868
+ _objectDestructuringEmpty(_ref40);
844
869
 
845
870
  return "/logged/setting";
846
871
  }
847
- function binding(_temp22) {
848
- var _ref39 = _temp22 === void 0 ? {} : _temp22;
872
+ function binding(_temp23) {
873
+ var _ref41 = _temp23 === void 0 ? {} : _temp23;
849
874
 
850
- _objectDestructuringEmpty(_ref39);
875
+ _objectDestructuringEmpty(_ref41);
851
876
 
852
877
  return "/logged/binding";
853
878
  }
854
- function resultBindingSuccess(_temp23) {
855
- var _ref40 = _temp23 === void 0 ? {} : _temp23;
879
+ function resultBindingSuccess(_temp24) {
880
+ var _ref42 = _temp24 === void 0 ? {} : _temp24;
856
881
 
857
- _objectDestructuringEmpty(_ref40);
882
+ _objectDestructuringEmpty(_ref42);
858
883
 
859
884
  return "/result/binding";
860
885
  }
@@ -908,8 +933,10 @@ var LinkTo = {
908
933
  exception403: exception403,
909
934
  nodeFreeze: nodeFreeze,
910
935
  resourceFreeze: resourceFreeze,
936
+ globalSearch: globalSearch,
911
937
  login: login,
912
938
  logon: logon,
939
+ bind: bind,
913
940
  retrieveUserPassword: retrieveUserPassword,
914
941
  retrievePayPassword: retrievePayPassword,
915
942
  userFreeze: userFreeze,
@@ -1024,7 +1051,7 @@ var _excluded$1 = ["presentableId"],
1024
1051
  _excluded3$1 = ["presentableId"],
1025
1052
  _excluded4$1 = ["presentableId"],
1026
1053
  _excluded5$1 = ["presentableId"],
1027
- _excluded6 = ["presentableId"],
1054
+ _excluded6$1 = ["presentableId"],
1028
1055
  _excluded7 = ["presentableId"],
1029
1056
  _excluded8 = ["presentableId"],
1030
1057
  _excluded9 = ["nodeId"],
@@ -1121,7 +1148,7 @@ function relationTree(_ref4) {
1121
1148
  }
1122
1149
  function authTree(_ref5) {
1123
1150
  var presentableId = _ref5.presentableId,
1124
- params = _objectWithoutPropertiesLoose(_ref5, _excluded6);
1151
+ params = _objectWithoutPropertiesLoose(_ref5, _excluded6$1);
1125
1152
 
1126
1153
  // return FUtil.Axios.get(`/v2/presentables/${presentableId}/authTree`, {params});
1127
1154
  return FUtil.Request({
@@ -1456,9 +1483,6 @@ function collectResource(params) {
1456
1483
  });
1457
1484
  }
1458
1485
  function collectionResources(params) {
1459
- // return FUtil.Axios.get('/v2/collections/resources', {
1460
- // params
1461
- // });
1462
1486
  return FUtil.Request({
1463
1487
  method: 'GET',
1464
1488
  url: "/v2/collections/resources",
@@ -1506,7 +1530,7 @@ var _excluded$3 = ["resourceIdOrName"],
1506
1530
  _excluded3$3 = ["resourceId"],
1507
1531
  _excluded4$3 = ["resourceId"],
1508
1532
  _excluded5$3 = ["resourceId", "version"],
1509
- _excluded6$1 = ["fileSha1"],
1533
+ _excluded6$2 = ["fileSha1"],
1510
1534
  _excluded7$1 = ["fileSha1"],
1511
1535
  _excluded8$1 = ["resourceId"],
1512
1536
  _excluded9$1 = ["resourceId"],
@@ -1605,7 +1629,7 @@ function resourceVersionInfo2(params) {
1605
1629
  }
1606
1630
  function getResourceVersionBySha1(_ref6) {
1607
1631
  var fileSha1 = _ref6.fileSha1,
1608
- params = _objectWithoutPropertiesLoose(_ref6, _excluded6$1);
1632
+ params = _objectWithoutPropertiesLoose(_ref6, _excluded6$2);
1609
1633
 
1610
1634
  // return FUtil.Axios.get(`/v2/resources/files/${fileSha1}/versions`, {
1611
1635
  // params,
@@ -1816,6 +1840,15 @@ function listSimple4Recently(_temp2) {
1816
1840
  params: params
1817
1841
  });
1818
1842
  }
1843
+ function getAttrsInfoByKey(_ref22) {
1844
+ var params = _extends({}, _ref22);
1845
+
1846
+ return FUtil.Request({
1847
+ method: 'GET',
1848
+ url: "/v2/resources/attrs/getInfoByKey",
1849
+ params: params
1850
+ });
1851
+ }
1819
1852
 
1820
1853
  var Resource = {
1821
1854
  __proto__: null,
@@ -1850,7 +1883,8 @@ var Resource = {
1850
1883
  ListSimpleByParentCode: ListSimpleByParentCode,
1851
1884
  getResourceTypeInfoByCode: getResourceTypeInfoByCode,
1852
1885
  getResourceAttrListSimple: getResourceAttrListSimple,
1853
- listSimple4Recently: listSimple4Recently
1886
+ listSimple4Recently: listSimple4Recently,
1887
+ getAttrsInfoByKey: getAttrsInfoByKey
1854
1888
  };
1855
1889
 
1856
1890
  var _excluded$4 = ["loginName"];
@@ -2063,7 +2097,7 @@ var _excluded$5 = ["nodeId"],
2063
2097
  _excluded3$4 = ["nodeId"],
2064
2098
  _excluded4$4 = ["nodeId"],
2065
2099
  _excluded5$4 = ["nodeId"],
2066
- _excluded6$2 = ["testResourceId"],
2100
+ _excluded6$3 = ["testResourceId"],
2067
2101
  _excluded7$2 = ["testResourceId"],
2068
2102
  _excluded8$2 = ["nodeId"],
2069
2103
  _excluded9$2 = ["nodeId"],
@@ -2128,7 +2162,7 @@ function testNodeRules(_ref6) {
2128
2162
  }
2129
2163
  function updateTestResourceContracts(_ref7) {
2130
2164
  var testResourceId = _ref7.testResourceId,
2131
- params = _objectWithoutPropertiesLoose(_ref7, _excluded6$2);
2165
+ params = _objectWithoutPropertiesLoose(_ref7, _excluded6$3);
2132
2166
 
2133
2167
  // return FUtil.Axios.put(`/v2/testNodes/testResources/${testResourceId}`, params);
2134
2168
  return FUtil.Request({
@@ -3221,6 +3255,30 @@ function _request() {
3221
3255
  return _request.apply(this, arguments);
3222
3256
  }
3223
3257
 
3258
+ function useGetState(initVal) {
3259
+ var _React$useState = useState(initVal),
3260
+ state = _React$useState[0],
3261
+ setState = _React$useState[1];
3262
+
3263
+ var ref = useRef(initVal);
3264
+
3265
+ function setStateCopy(newVal) {
3266
+ ref.current = newVal;
3267
+ setState(newVal);
3268
+ }
3269
+
3270
+ function getState() {
3271
+ return ref.current;
3272
+ }
3273
+
3274
+ return [state, setStateCopy, getState];
3275
+ }
3276
+
3277
+ var Hook = {
3278
+ __proto__: null,
3279
+ useGetState: useGetState
3280
+ };
3281
+
3224
3282
  var FUtil = {
3225
3283
  Format: Format,
3226
3284
  Regexp: Regexp,
@@ -3228,7 +3286,8 @@ var FUtil = {
3228
3286
  Predefined: Predefined,
3229
3287
  Axios: axios,
3230
3288
  Request: request,
3231
- Tool: Tool
3289
+ Tool: Tool,
3290
+ Hook: Hook
3232
3291
  };
3233
3292
 
3234
3293
  var ossJsonUrl = 'https://freelog-i18n.oss-cn-shenzhen.aliyuncs.com/configs/i18n.json';