@freelog/tools-lib 0.1.152 → 0.1.154

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,8 +2,10 @@ 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';
8
+ import htmlReactParser from 'html-react-parser';
7
9
 
8
10
  // import {ContractEntity} from '@freelog/resource-policy-lang/dist/tools/ContractTool';
9
11
  // const {compile} = require('@freelog/resource-policy-lang');
@@ -152,7 +154,11 @@ var MAX_2_DECIMAL_POSITIVE_NUMBER = /*#__PURE__*/new RegExp(/^\d+(\.\d{0,2})?$/)
152
154
 
153
155
  var BUCKET_NAME = /*#__PURE__*/new RegExp(/^([a-z0-9][a-z0-9-]{0,61})?[a-z0-9]$/); // JS变量名称
154
156
 
155
- var JS_VARIABLE_NAME = /*#__PURE__*/new RegExp(/^[A-Za-z$_][\w$_]*$/);
157
+ var JS_VARIABLE_NAME = /*#__PURE__*/new RegExp(/^[A-Za-z$_][\w$_]*$/); // 日期
158
+
159
+ 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)$/); // 日期时间
160
+
161
+ var DATE_TIME = /*#__PURE__*/new RegExp(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/);
156
162
 
157
163
  var Regexp = {
158
164
  __proto__: null,
@@ -171,7 +177,9 @@ var Regexp = {
171
177
  POSITIVE_INTEGER: POSITIVE_INTEGER,
172
178
  MAX_2_DECIMAL_POSITIVE_NUMBER: MAX_2_DECIMAL_POSITIVE_NUMBER,
173
179
  BUCKET_NAME: BUCKET_NAME,
174
- JS_VARIABLE_NAME: JS_VARIABLE_NAME
180
+ JS_VARIABLE_NAME: JS_VARIABLE_NAME,
181
+ DATE: DATE,
182
+ DATE_TIME: DATE_TIME
175
183
  };
176
184
 
177
185
  function _regeneratorRuntime() {
@@ -595,7 +603,8 @@ var _excluded = ["resourceID"],
595
603
  _excluded2 = ["nodeID", "showPage"],
596
604
  _excluded3 = ["nodeID", "showPage"],
597
605
  _excluded4 = ["goTo"],
598
- _excluded5 = ["goTo"];
606
+ _excluded5 = ["goTo"],
607
+ _excluded6 = ["goTo", "returnUrl"];
599
608
  function home(_temp) {
600
609
  var _ref = _temp === void 0 ? {} : _temp;
601
610
 
@@ -777,84 +786,101 @@ function resourceFreeze(_ref29) {
777
786
  var resourceID = _ref29.resourceID;
778
787
  return "/result/resource/freeze/" + resourceID;
779
788
  }
789
+ function globalSearch(_ref30) {
790
+ var search = _ref30.search;
791
+ return "/search" + handleQuery({
792
+ search: search
793
+ });
794
+ }
780
795
  function login(_temp13) {
781
- var _ref30 = _temp13 === void 0 ? {} : _temp13,
782
- goTo = _ref30.goTo;
796
+ var _ref31 = _temp13 === void 0 ? {} : _temp13,
797
+ goTo = _ref31.goTo;
783
798
 
784
799
  return "/login" + handleQuery({
785
800
  goTo: goTo ? encodeURIComponent(goTo) : undefined
786
801
  });
787
802
  }
788
803
  function logon(_temp14) {
789
- var _ref31 = _temp14 === void 0 ? {} : _temp14,
790
- goTo = _ref31.goTo,
791
- params = _objectWithoutPropertiesLoose(_ref31, _excluded5);
804
+ var _ref32 = _temp14 === void 0 ? {} : _temp14,
805
+ goTo = _ref32.goTo,
806
+ params = _objectWithoutPropertiesLoose(_ref32, _excluded5);
792
807
 
793
808
  return "/logon" + handleQuery(_extends({
794
809
  goTo: goTo ? encodeURIComponent(goTo) : undefined
795
810
  }, params));
796
811
  }
797
- function retrieveUserPassword(_temp15) {
798
- var _ref32 = _temp15 === void 0 ? {} : _temp15,
799
- goTo = _ref32.goTo;
812
+ function bind(_temp15) {
813
+ var _ref33 = _temp15 === void 0 ? {} : _temp15,
814
+ goTo = _ref33.goTo,
815
+ returnUrl = _ref33.returnUrl,
816
+ params = _objectWithoutPropertiesLoose(_ref33, _excluded6);
817
+
818
+ return "/bind" + handleQuery(_extends({
819
+ goTo: goTo ? encodeURIComponent(goTo) : undefined,
820
+ returnUrl: returnUrl ? encodeURIComponent(returnUrl) : undefined
821
+ }, params));
822
+ }
823
+ function retrieveUserPassword(_temp16) {
824
+ var _ref34 = _temp16 === void 0 ? {} : _temp16,
825
+ goTo = _ref34.goTo;
800
826
 
801
827
  return "/retrieve" + handleQuery({
802
828
  goTo: goTo ? encodeURIComponent(goTo) : undefined
803
829
  });
804
830
  }
805
- function retrievePayPassword(_temp16) {
806
- var _ref33 = _temp16 === void 0 ? {} : _temp16;
831
+ function retrievePayPassword(_temp17) {
832
+ var _ref35 = _temp17 === void 0 ? {} : _temp17;
807
833
 
808
- _objectDestructuringEmpty(_ref33);
834
+ _objectDestructuringEmpty(_ref35);
809
835
 
810
836
  return "/retrievePayPassword";
811
837
  }
812
- function userFreeze(_temp17) {
813
- var _ref34 = _temp17 === void 0 ? {} : _temp17;
838
+ function userFreeze(_temp18) {
839
+ var _ref36 = _temp18 === void 0 ? {} : _temp18;
814
840
 
815
- _objectDestructuringEmpty(_ref34);
841
+ _objectDestructuringEmpty(_ref36);
816
842
 
817
843
  return "/freeze";
818
844
  }
819
- function wallet(_temp18) {
820
- var _ref35 = _temp18 === void 0 ? {} : _temp18;
845
+ function wallet(_temp19) {
846
+ var _ref37 = _temp19 === void 0 ? {} : _temp19;
821
847
 
822
- _objectDestructuringEmpty(_ref35);
848
+ _objectDestructuringEmpty(_ref37);
823
849
 
824
850
  return "/logged/wallet";
825
851
  }
826
- function reward(_temp19) {
827
- var _ref36 = _temp19 === void 0 ? {} : _temp19;
852
+ function reward(_temp20) {
853
+ var _ref38 = _temp20 === void 0 ? {} : _temp20;
828
854
 
829
- _objectDestructuringEmpty(_ref36);
855
+ _objectDestructuringEmpty(_ref38);
830
856
 
831
857
  return "/logged/reward";
832
858
  }
833
- function contract(_temp20) {
834
- var _ref37 = _temp20 === void 0 ? {} : _temp20;
859
+ function contract(_temp21) {
860
+ var _ref39 = _temp21 === void 0 ? {} : _temp21;
835
861
 
836
- _objectDestructuringEmpty(_ref37);
862
+ _objectDestructuringEmpty(_ref39);
837
863
 
838
864
  return "/logged/contract";
839
865
  }
840
- function setting(_temp21) {
841
- var _ref38 = _temp21 === void 0 ? {} : _temp21;
866
+ function setting(_temp22) {
867
+ var _ref40 = _temp22 === void 0 ? {} : _temp22;
842
868
 
843
- _objectDestructuringEmpty(_ref38);
869
+ _objectDestructuringEmpty(_ref40);
844
870
 
845
871
  return "/logged/setting";
846
872
  }
847
- function binding(_temp22) {
848
- var _ref39 = _temp22 === void 0 ? {} : _temp22;
873
+ function binding(_temp23) {
874
+ var _ref41 = _temp23 === void 0 ? {} : _temp23;
849
875
 
850
- _objectDestructuringEmpty(_ref39);
876
+ _objectDestructuringEmpty(_ref41);
851
877
 
852
878
  return "/logged/binding";
853
879
  }
854
- function resultBindingSuccess(_temp23) {
855
- var _ref40 = _temp23 === void 0 ? {} : _temp23;
880
+ function resultBindingSuccess(_temp24) {
881
+ var _ref42 = _temp24 === void 0 ? {} : _temp24;
856
882
 
857
- _objectDestructuringEmpty(_ref40);
883
+ _objectDestructuringEmpty(_ref42);
858
884
 
859
885
  return "/result/binding";
860
886
  }
@@ -908,8 +934,10 @@ var LinkTo = {
908
934
  exception403: exception403,
909
935
  nodeFreeze: nodeFreeze,
910
936
  resourceFreeze: resourceFreeze,
937
+ globalSearch: globalSearch,
911
938
  login: login,
912
939
  logon: logon,
940
+ bind: bind,
913
941
  retrieveUserPassword: retrieveUserPassword,
914
942
  retrievePayPassword: retrievePayPassword,
915
943
  userFreeze: userFreeze,
@@ -1024,7 +1052,7 @@ var _excluded$1 = ["presentableId"],
1024
1052
  _excluded3$1 = ["presentableId"],
1025
1053
  _excluded4$1 = ["presentableId"],
1026
1054
  _excluded5$1 = ["presentableId"],
1027
- _excluded6 = ["presentableId"],
1055
+ _excluded6$1 = ["presentableId"],
1028
1056
  _excluded7 = ["presentableId"],
1029
1057
  _excluded8 = ["presentableId"],
1030
1058
  _excluded9 = ["nodeId"],
@@ -1121,7 +1149,7 @@ function relationTree(_ref4) {
1121
1149
  }
1122
1150
  function authTree(_ref5) {
1123
1151
  var presentableId = _ref5.presentableId,
1124
- params = _objectWithoutPropertiesLoose(_ref5, _excluded6);
1152
+ params = _objectWithoutPropertiesLoose(_ref5, _excluded6$1);
1125
1153
 
1126
1154
  // return FUtil.Axios.get(`/v2/presentables/${presentableId}/authTree`, {params});
1127
1155
  return FUtil.Request({
@@ -1456,9 +1484,6 @@ function collectResource(params) {
1456
1484
  });
1457
1485
  }
1458
1486
  function collectionResources(params) {
1459
- // return FUtil.Axios.get('/v2/collections/resources', {
1460
- // params
1461
- // });
1462
1487
  return FUtil.Request({
1463
1488
  method: 'GET',
1464
1489
  url: "/v2/collections/resources",
@@ -1506,7 +1531,7 @@ var _excluded$3 = ["resourceIdOrName"],
1506
1531
  _excluded3$3 = ["resourceId"],
1507
1532
  _excluded4$3 = ["resourceId"],
1508
1533
  _excluded5$3 = ["resourceId", "version"],
1509
- _excluded6$1 = ["fileSha1"],
1534
+ _excluded6$2 = ["fileSha1"],
1510
1535
  _excluded7$1 = ["fileSha1"],
1511
1536
  _excluded8$1 = ["resourceId"],
1512
1537
  _excluded9$1 = ["resourceId"],
@@ -1605,7 +1630,7 @@ function resourceVersionInfo2(params) {
1605
1630
  }
1606
1631
  function getResourceVersionBySha1(_ref6) {
1607
1632
  var fileSha1 = _ref6.fileSha1,
1608
- params = _objectWithoutPropertiesLoose(_ref6, _excluded6$1);
1633
+ params = _objectWithoutPropertiesLoose(_ref6, _excluded6$2);
1609
1634
 
1610
1635
  // return FUtil.Axios.get(`/v2/resources/files/${fileSha1}/versions`, {
1611
1636
  // params,
@@ -1816,6 +1841,15 @@ function listSimple4Recently(_temp2) {
1816
1841
  params: params
1817
1842
  });
1818
1843
  }
1844
+ function getAttrsInfoByKey(_ref22) {
1845
+ var params = _extends({}, _ref22);
1846
+
1847
+ return FUtil.Request({
1848
+ method: 'GET',
1849
+ url: "/v2/resources/attrs/getInfoByKey",
1850
+ params: params
1851
+ });
1852
+ }
1819
1853
 
1820
1854
  var Resource = {
1821
1855
  __proto__: null,
@@ -1850,7 +1884,8 @@ var Resource = {
1850
1884
  ListSimpleByParentCode: ListSimpleByParentCode,
1851
1885
  getResourceTypeInfoByCode: getResourceTypeInfoByCode,
1852
1886
  getResourceAttrListSimple: getResourceAttrListSimple,
1853
- listSimple4Recently: listSimple4Recently
1887
+ listSimple4Recently: listSimple4Recently,
1888
+ getAttrsInfoByKey: getAttrsInfoByKey
1854
1889
  };
1855
1890
 
1856
1891
  var _excluded$4 = ["loginName"];
@@ -2063,7 +2098,7 @@ var _excluded$5 = ["nodeId"],
2063
2098
  _excluded3$4 = ["nodeId"],
2064
2099
  _excluded4$4 = ["nodeId"],
2065
2100
  _excluded5$4 = ["nodeId"],
2066
- _excluded6$2 = ["testResourceId"],
2101
+ _excluded6$3 = ["testResourceId"],
2067
2102
  _excluded7$2 = ["testResourceId"],
2068
2103
  _excluded8$2 = ["nodeId"],
2069
2104
  _excluded9$2 = ["nodeId"],
@@ -2128,7 +2163,7 @@ function testNodeRules(_ref6) {
2128
2163
  }
2129
2164
  function updateTestResourceContracts(_ref7) {
2130
2165
  var testResourceId = _ref7.testResourceId,
2131
- params = _objectWithoutPropertiesLoose(_ref7, _excluded6$2);
2166
+ params = _objectWithoutPropertiesLoose(_ref7, _excluded6$3);
2132
2167
 
2133
2168
  // return FUtil.Axios.put(`/v2/testNodes/testResources/${testResourceId}`, params);
2134
2169
  return FUtil.Request({
@@ -3221,6 +3256,30 @@ function _request() {
3221
3256
  return _request.apply(this, arguments);
3222
3257
  }
3223
3258
 
3259
+ function useGetState(initVal) {
3260
+ var _React$useState = useState(initVal),
3261
+ state = _React$useState[0],
3262
+ setState = _React$useState[1];
3263
+
3264
+ var ref = useRef(initVal);
3265
+
3266
+ function setStateCopy(newVal) {
3267
+ ref.current = newVal;
3268
+ setState(newVal);
3269
+ }
3270
+
3271
+ function getState() {
3272
+ return ref.current;
3273
+ }
3274
+
3275
+ return [state, setStateCopy, getState];
3276
+ }
3277
+
3278
+ var Hook = {
3279
+ __proto__: null,
3280
+ useGetState: useGetState
3281
+ };
3282
+
3224
3283
  var FUtil = {
3225
3284
  Format: Format,
3226
3285
  Regexp: Regexp,
@@ -3228,7 +3287,8 @@ var FUtil = {
3228
3287
  Predefined: Predefined,
3229
3288
  Axios: axios,
3230
3289
  Request: request,
3231
- Tool: Tool
3290
+ Tool: Tool,
3291
+ Hook: Hook
3232
3292
  };
3233
3293
 
3234
3294
  var ossJsonUrl = 'https://freelog-i18n.oss-cn-shenzhen.aliyuncs.com/configs/i18n.json';
@@ -3346,6 +3406,10 @@ var I18nNext = /*#__PURE__*/function () {
3346
3406
  return i18next.t(key.trim(), options);
3347
3407
  };
3348
3408
 
3409
+ _proto.tJSXElement = function tJSXElement(key, options) {
3410
+ return htmlReactParser(i18next.t(key.trim(), options));
3411
+ };
3412
+
3349
3413
  _proto.changeLanguage = function changeLanguage(lng) {
3350
3414
  // return i18next.changeLanguage(lng);
3351
3415
  // window.localStorage.setItem(localStorage_i18nextLng_key, lng)