@freelog/tools-lib 0.1.54 → 0.1.59

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,9 +2,16 @@ import FUtil from '../utils';
2
2
 
3
3
  // 分页查询账户交易流水
4
4
  interface DetailsParamsType {
5
- accountId: string;
6
5
  skip?: number;
7
6
  limit?: number;
7
+ accountId: string;
8
+ startCreatedDate?: string;
9
+ endCreatedDate?: string;
10
+ amountStartPoint?: number;
11
+ amountEndPoint?: number;
12
+ serialNo?: string;
13
+ status?: 1 | 2 | 3;
14
+ keywords?: string;
8
15
  }
9
16
 
10
17
  export function details({accountId, ...params}: DetailsParamsType) {
@@ -1,89 +1,89 @@
1
- import moment from 'moment';
2
- import {report} from '@freelog/resource-policy-lang/dist';
3
- import {ContractEntity} from '@freelog/resource-policy-lang/dist/tools/ContractTool';
4
-
5
- const {compile} = require('@freelog/resource-policy-lang');
6
-
7
- /**
8
- * 将对应的字节数,转换为易读单位数量
9
- * @param bytes
10
- * @return {string}
11
- */
12
- export function humanizeSize(bytes: number): string {
13
- // console.log('dddhumanizeSizesdfsd');
14
- if (bytes <= 0) {
15
- return '0 B';
16
- }
17
- const unitArr = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
18
- const index = Math.floor(Math.log(bytes) / Math.log(1024));
19
- const size = Math.round((bytes / Math.pow(1024, index)) * 100) / 100; //保留的小数位数
20
- return size + ' ' + unitArr[index];
21
- }
22
-
23
- /**
24
- * 格式化日期时间
25
- */
26
- export function formatDateTime(date: string, showTime: boolean = false) {
27
- return moment(date).format('YYYY/MM/DD' + (showTime ? ' HH:mm' : ''));
28
- }
29
-
30
- /**
31
- * 根据传入的子域名拼合成完整的适合的url
32
- * @param domain 要组合的三级域名
33
- */
34
- export function completeUrlByDomain(domain: string): string {
35
- let origin: string = `http://${domain}.testfreelog.com`;
36
-
37
- if (window.location.origin.includes('.freelog.com')) {
38
- origin = `https://${domain}.freelog.com`;
39
- }
40
-
41
- return origin;
42
- }
43
-
44
- /**
45
- * 根据策略代码和标的物类型,生成对应的翻译
46
- * @param code 策略代码
47
- * @param targetType 标的物类型
48
- */
49
- export async function policyCodeTranslationToText(code: string, targetType: string): Promise<{
50
- error: string[] | null;
51
- text?: string;
52
- }> {
53
- try {
54
- const result = await compile(
55
- code,
56
- targetType,
57
- completeUrlByDomain('qi'),
58
- window.location.origin.endsWith('.freelog.com') ? 'prod' : 'dev',
59
- );
60
- const contract: ContractEntity = {
61
- audiences: result.state_machine.audiences,
62
- fsmStates: Object.entries<any>(result.state_machine.states)
63
- .map((st) => {
64
- return {
65
- name: st[0],
66
- serviceStates: st[1].serviceStates,
67
- events: st[1].transitions.map((ts: any) => {
68
-
69
- return {
70
- id: ts.code,
71
- name: ts.name,
72
- args: ts.args,
73
- state: ts.toState,
74
- };
75
- }),
76
- };
77
- }),
78
- };
79
- const rrr = report(contract);
80
- return {
81
- error: null,
82
- text: rrr.audienceInfos[0].content + rrr.content,
83
- };
84
- } catch (err) {
85
- return {
86
- error: [err.message],
87
- };
88
- }
89
- }
1
+ import moment from 'moment';
2
+ import {report} from '@freelog/resource-policy-lang/dist';
3
+ import {ContractEntity} from '@freelog/resource-policy-lang/dist/tools/ContractTool';
4
+
5
+ const {compile} = require('@freelog/resource-policy-lang');
6
+
7
+ /**
8
+ * 将对应的字节数,转换为易读单位数量
9
+ * @param bytes
10
+ * @return {string}
11
+ */
12
+ export function humanizeSize(bytes: number): string {
13
+ // console.log('dddhumanizeSizesdfsd');
14
+ if (bytes <= 0) {
15
+ return '0 B';
16
+ }
17
+ const unitArr = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
18
+ const index = Math.floor(Math.log(bytes) / Math.log(1024));
19
+ const size = Math.round((bytes / Math.pow(1024, index)) * 100) / 100; //保留的小数位数
20
+ return size + ' ' + unitArr[index];
21
+ }
22
+
23
+ /**
24
+ * 格式化日期时间
25
+ */
26
+ export function formatDateTime(date: string, showTime: boolean = false) {
27
+ return moment(date).format('YYYY/MM/DD' + (showTime ? ' HH:mm' : ''));
28
+ }
29
+
30
+ /**
31
+ * 根据传入的子域名拼合成完整的适合的url
32
+ * @param domain 要组合的三级域名
33
+ */
34
+ export function completeUrlByDomain(domain: string): string {
35
+ let origin: string = `http://${domain}.testfreelog.com`;
36
+
37
+ if (window.location.origin.includes('.freelog.com')) {
38
+ origin = `https://${domain}.freelog.com`;
39
+ }
40
+
41
+ return origin;
42
+ }
43
+
44
+ /**
45
+ * 根据策略代码和标的物类型,生成对应的翻译
46
+ * @param code 策略代码
47
+ * @param targetType 标的物类型
48
+ */
49
+ export async function policyCodeTranslationToText(code: string, targetType: string): Promise<{
50
+ error: string[] | null;
51
+ text?: string;
52
+ }> {
53
+ try {
54
+ const result = await compile(
55
+ code,
56
+ targetType,
57
+ completeUrlByDomain('qi'),
58
+ window.location.origin.endsWith('.freelog.com') ? 'prod' : 'dev',
59
+ );
60
+ const contract: ContractEntity = {
61
+ audiences: result.state_machine.audiences,
62
+ fsmStates: Object.entries<any>(result.state_machine.states)
63
+ .map((st) => {
64
+ return {
65
+ name: st[0],
66
+ serviceStates: st[1].serviceStates,
67
+ events: st[1].transitions.map((ts: any) => {
68
+
69
+ return {
70
+ id: ts.code,
71
+ name: ts.name,
72
+ args: ts.args,
73
+ state: ts.toState,
74
+ };
75
+ }),
76
+ };
77
+ }),
78
+ };
79
+ const rrr = report(contract);
80
+ return {
81
+ error: null,
82
+ text: rrr.audienceInfos[0].content + rrr.content,
83
+ };
84
+ } catch (err) {
85
+ return {
86
+ error: [err.message],
87
+ };
88
+ }
89
+ }
@@ -1,35 +1,38 @@
1
1
  // 展品名称
2
- export const EXHIBIT_NAME: RegExp = /^(?!.*(\\|\/|:|\*|\?|"|<|>|\||\s|@|\$|#)).{1,60}$/;
2
+ export const EXHIBIT_NAME: RegExp = new RegExp(/^(?!.*(\\|\/|:|\*|\?|"|<|>|\||\s|@|\$|#)).{1,60}$/);
3
3
 
4
4
  // 资源名称
5
- export const RESOURCE_NAME: RegExp = /^(?!.*(\\|\/|:|\*|\?|"|<|>|\||\s|@|\$|#)).{1,60}$/;
5
+ export const RESOURCE_NAME: RegExp = new RegExp(/^(?!.*(\\|\/|:|\*|\?|"|<|>|\||\s|@|\$|#)).{1,60}$/);
6
6
 
7
7
  // 资源类型
8
- export const RESOURCE_TYPE: RegExp = /^(?!_)[a-z0-9_]{3,20}(?<!_)$/;
8
+ export const RESOURCE_TYPE: RegExp = new RegExp(/^(?!_)[a-z0-9_]{3,20}(?<!_)$/);
9
9
 
10
10
  // 自定义属性键
11
- export const CUSTOM_KEY: RegExp = /^[a-zA-Z0-9_]{1,20}$/;
11
+ export const CUSTOM_KEY: RegExp = new RegExp(/^[a-zA-Z0-9_]{1,20}$/);
12
12
 
13
13
  // 节点名称
14
- export const NODE_NAME: RegExp = /^[\u4E00-\u9FA5|a-zA-Z0-9]{2,24}$/;
14
+ export const NODE_NAME: RegExp = new RegExp(/^[\u4E00-\u9FA5|a-zA-Z0-9]{2,24}$/);
15
15
 
16
16
  // 节点地址
17
- export const NODE_DOMAIN = /^(?!-)[a-z0-9-]{4,24}(?<!-)$/;
17
+ export const NODE_DOMAIN: RegExp = new RegExp(/^(?!-)[a-z0-9-]{4,24}(?<!-)$/);
18
18
 
19
19
  // 支付密码
20
- export const PAY_PASSWORD = /^\d{6}$/;
20
+ export const PAY_PASSWORD: RegExp = new RegExp(/^\d{6}$/);
21
21
 
22
22
  // 手机号码
23
- export const MOBILE_PHONE_NUMBER = /^1[345789]\d{9}$/;
23
+ export const MOBILE_PHONE_NUMBER = new RegExp(/^1[345789]\d{9}$/);
24
24
  // export const TELEPHONE_NUMBER = /^((13[0-9])|(14[5-9])|(15([0-3]|[5-9]))|(16[6-7])|(17[1-8])|(18[0-9])|(19[1|3])|(19[5|6])|(19[8|9]))\d{8}$/
25
25
 
26
26
  // 邮箱地址
27
- export const EMAIL_ADDRESS = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
27
+ export const EMAIL_ADDRESS: RegExp = new RegExp(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/);
28
28
 
29
29
  // 用户名
30
30
  // export const USERNAME = /^(?!-)[A-Za-z0-9-]{1,30}(?<!-)$/;
31
- export const USERNAME = /^(?!-)[A-Za-z0-9-]{1,30}(?<!-)$/;
31
+ export const USERNAME: RegExp = new RegExp(/^(?!-)[A-Za-z0-9-]{1,30}(?<!-)$/);
32
32
 
33
33
  // 用户密码
34
34
  // export const PASSWORD = /^(?=.*[a-zA-Z])(?=.*[0-9]).{6,24}$/;
35
- export const PASSWORD = /^(?=.*[0-9])(?=.*[a-zA-Z])(.{6,24})$/;
35
+ export const PASSWORD: RegExp = new RegExp(/^(?=.*[0-9])(?=.*[a-zA-Z])(.{6,24})$/);
36
+
37
+ // 自然数
38
+ export const NATURAL_NUMBER: RegExp = new RegExp(/^[0-9]*$/);