@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.
@@ -1,97 +1,97 @@
1
- import * as Tool from '../../utils/tools';
2
- import * as Storage from '../storages';
3
-
4
- interface FileInfo {
5
- sha1: string;
6
- state: 'success' | 'fail' | 'nonentity';
7
- info: {
8
- [key: string]: any;
9
- }
10
- }
11
-
12
- interface GetFileInfosBySha1Params {
13
- sha1: string[];
14
- resourceTypeCode: string;
15
- }
16
-
17
- export async function getFilesSha1Info({
18
- sha1,
19
- resourceTypeCode
20
- }: GetFileInfosBySha1Params, cdPartially: (s: any[]) => void = () => undefined): Promise<{
21
- error: string;
22
- result: FileInfo[],
23
- }> {
24
- if (sha1.length === 0) {
25
- return {
26
- error: '',
27
- result: [],
28
- };
29
- }
30
-
31
- let delay: number = 500;
32
-
33
- let needHandleSha1: string[] = [...sha1];
34
-
35
- let allData: FileInfo[] = [];
36
-
37
- while (true) {
38
- // console.log(needHandleSha1.join(','), 'needHandleSha1.join()90ojlskdfjsdlk')
39
- const {ret, errCode, data, msg}: any = await Storage.filesListInfo({
40
- sha1: needHandleSha1.join(','),
41
- resourceTypeCode: resourceTypeCode,
42
- });
43
-
44
- if (ret !== 0 || errCode !== 0) {
45
- console.log({
46
- ret, errCode, data, msg
47
- }, '09iowksdjaklfjs;oalijflskdjflsdkjflkj');
48
- return {
49
- error: msg,
50
- result: allData,
51
- };
52
- }
53
-
54
- needHandleSha1 = data
55
- .filter((d: any) => {
56
- return d.metaAnalyzeStatus === 0 || d.metaAnalyzeStatus === 1;
57
- })
58
- .map((d: any) => {
59
- return d.sha1;
60
- });
61
- const finishedInfo: FileInfo[] = data
62
- .filter((d: any) => {
63
- return d.metaAnalyzeStatus !== 0 && d.metaAnalyzeStatus !== 1;
64
- })
65
- .map((d: any) => {
66
- let state: 'success' | 'fail' | 'nonentity' = 'fail';
67
- if (!d.metaAnalyzeStatus) {
68
- state = 'nonentity';
69
- } else if (d.metaAnalyzeStatus === 2) {
70
- state = 'success';
71
- } else if (d.metaAnalyzeStatus === 3) {
72
- state = 'fail';
73
- }
74
- // console.log(d, '90wieojiksdjf;lkasdjf;lksdjflksjdflkjsdlfkjsdlkj');
75
- return {
76
- sha1: d.sha1,
77
- state,
78
- info: d,
79
- };
80
- });
81
- cdPartially && cdPartially(finishedInfo);
82
- allData = [
83
- ...allData,
84
- ...finishedInfo,
85
- ];
86
-
87
- if (needHandleSha1.length === 0) {
88
- break;
89
- }
90
- await Tool.promiseSleep(delay);
91
- // delay += 500;
92
- }
93
- return {
94
- error: '',
95
- result: allData,
96
- };
97
- }
1
+ import * as Tool from '../../utils/tools';
2
+ import * as Storage from '../storages';
3
+
4
+ interface FileInfo {
5
+ sha1: string;
6
+ state: 'success' | 'fail' | 'nonentity';
7
+ info: {
8
+ [key: string]: any;
9
+ }
10
+ }
11
+
12
+ interface GetFileInfosBySha1Params {
13
+ sha1: string[];
14
+ resourceTypeCode: string;
15
+ }
16
+
17
+ export async function getFilesSha1Info({
18
+ sha1,
19
+ resourceTypeCode
20
+ }: GetFileInfosBySha1Params, cdPartially: (s: any[]) => void = () => undefined): Promise<{
21
+ error: string;
22
+ result: FileInfo[],
23
+ }> {
24
+ if (sha1.length === 0) {
25
+ return {
26
+ error: '',
27
+ result: [],
28
+ };
29
+ }
30
+
31
+ let delay: number = 500;
32
+
33
+ let needHandleSha1: string[] = [...sha1];
34
+
35
+ let allData: FileInfo[] = [];
36
+
37
+ while (true) {
38
+ // console.log(needHandleSha1.join(','), 'needHandleSha1.join()90ojlskdfjsdlk')
39
+ const {ret, errCode, data, msg}: any = await Storage.filesListInfo({
40
+ sha1: needHandleSha1.join(','),
41
+ resourceTypeCode: resourceTypeCode,
42
+ });
43
+
44
+ if (ret !== 0 || errCode !== 0) {
45
+ console.log({
46
+ ret, errCode, data, msg
47
+ }, '09iowksdjaklfjs;oalijflskdjflsdkjflkj');
48
+ return {
49
+ error: msg,
50
+ result: allData,
51
+ };
52
+ }
53
+
54
+ needHandleSha1 = data
55
+ .filter((d: any) => {
56
+ return d.metaAnalyzeStatus === 0 || d.metaAnalyzeStatus === 1;
57
+ })
58
+ .map((d: any) => {
59
+ return d.sha1;
60
+ });
61
+ const finishedInfo: FileInfo[] = data
62
+ .filter((d: any) => {
63
+ return d.metaAnalyzeStatus !== 0 && d.metaAnalyzeStatus !== 1;
64
+ })
65
+ .map((d: any) => {
66
+ let state: 'success' | 'fail' | 'nonentity' = 'fail';
67
+ if (!d.metaAnalyzeStatus) {
68
+ state = 'nonentity';
69
+ } else if (d.metaAnalyzeStatus === 2) {
70
+ state = 'success';
71
+ } else if (d.metaAnalyzeStatus === 3) {
72
+ state = 'fail';
73
+ }
74
+ // console.log(d, '90wieojiksdjf;lkasdjf;lksdjflksjdflkjsdlfkjsdlkj');
75
+ return {
76
+ sha1: d.sha1,
77
+ state,
78
+ info: d,
79
+ };
80
+ });
81
+ cdPartially && cdPartially(finishedInfo);
82
+ allData = [
83
+ ...allData,
84
+ ...finishedInfo,
85
+ ];
86
+
87
+ if (needHandleSha1.length === 0) {
88
+ break;
89
+ }
90
+ await Tool.promiseSleep(delay);
91
+ // delay += 500;
92
+ }
93
+ return {
94
+ error: '',
95
+ result: allData,
96
+ };
97
+ }
@@ -83,6 +83,7 @@ interface ListParamsType {
83
83
  keywords?: string;
84
84
  resourceType?: string;
85
85
  resourceTypeCode?: string;
86
+ resourceTypeCategory?: 1 | 2; // 资源类型分类,1:基础类型,2:自定义类型,其实只有2时生效,生效时,resourceTypeCode为父类类型
86
87
  omitResourceType?: string;
87
88
  isSelf?: 0 | 1;
88
89
  userId?: number;
@@ -215,6 +216,10 @@ interface CreateVersionParamsType {
215
216
  policyId: string;
216
217
  }[];
217
218
  }[];
219
+ inputAttrs: {
220
+ key: string;
221
+ value: string;
222
+ }[];
218
223
  }
219
224
 
220
225
  export function createVersion({resourceId, ...params}: CreateVersionParamsType) {
@@ -307,6 +312,10 @@ interface UpdateResourceVersionInfoParamsType {
307
312
  policyId: string;
308
313
  }[];
309
314
  }[];
315
+ inputAttrs: {
316
+ key: string;
317
+ value: string;
318
+ }[];
310
319
  }
311
320
 
312
321
  export function updateResourceVersionInfo(params: UpdateResourceVersionInfoParamsType) {
@@ -554,6 +563,8 @@ export function availableTags({...params}: AvailableTagsParamsType) {
554
563
  interface ResourceTypesParamsType {
555
564
  codeOrName?: string;
556
565
  category?: 1 | 2; // 种类 1:基础资源类型 2:自定义资源类型
566
+ isMine?: boolean;
567
+ status?: 0 | 1;
557
568
  }
558
569
 
559
570
  export function resourceTypes({...params}: ResourceTypesParamsType = {}) {
@@ -569,6 +580,8 @@ interface ListSimpleByParentCodeParamsType {
569
580
  parentCode: string;
570
581
  name?: string;
571
582
  category?: 1 | 2; // 种类 1:基础资源类型 2:自定义资源类型
583
+ excludeParentCode?: boolean;
584
+ isTerminate?: boolean;
572
585
  }
573
586
 
574
587
  export function ListSimpleByParentCode({...params}: ListSimpleByParentCodeParamsType) {
@@ -593,11 +606,11 @@ export function getResourceTypeInfoByCode({...params}: GetResourceTypeInfoByCode
593
606
  }
594
607
 
595
608
  //
596
- interface GetResourceAttrListSimple {
609
+ interface GetResourceAttrListSimpleParamsType {
597
610
 
598
611
  }
599
612
 
600
- export function getResourceAttrListSimple({...params}: GetResourceAttrListSimple) {
613
+ export function getResourceAttrListSimple({...params}: GetResourceAttrListSimpleParamsType) {
601
614
  return FUtil.Request({
602
615
  method: 'GET',
603
616
  url: `/v2/resources/attrs/listSimple`,
@@ -605,14 +618,27 @@ export function getResourceAttrListSimple({...params}: GetResourceAttrListSimple
605
618
  });
606
619
  }
607
620
 
608
- interface ListSimple4RecentlySimple {
621
+ interface ListSimple4RecentlyParamsType {
609
622
 
610
623
  }
611
624
 
612
- export function listSimple4Recently({...params}: ListSimple4RecentlySimple = {}) {
625
+ export function listSimple4Recently({...params}: ListSimple4RecentlyParamsType = {}) {
613
626
  return FUtil.Request({
614
627
  method: 'GET',
615
628
  url: `/v2/resources/types/listSimple4Recently`,
616
629
  params: params,
617
630
  });
618
631
  }
632
+
633
+ // 通过key取资源属性
634
+ interface GetAttrsInfoByKeyParamsType {
635
+ key: string;
636
+ }
637
+
638
+ export function getAttrsInfoByKey({...params}: GetAttrsInfoByKeyParamsType) {
639
+ return FUtil.Request({
640
+ method: 'GET',
641
+ url: `/v2/resources/attrs/getInfoByKey`,
642
+ params: params,
643
+ });
644
+ }