@freelog/tools-lib 0.1.148 → 0.1.151

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,92 +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
- }
15
-
16
- export async function getFilesSha1Info({sha1}: GetFileInfosBySha1Params, cdPartially: (s: any[]) => void = () => undefined): Promise<{
17
- error: string;
18
- result: FileInfo[],
19
- }> {
20
- if (sha1.length === 0) {
21
- return {
22
- error: '',
23
- result: [],
24
- };
25
- }
26
-
27
- let delay: number = 500;
28
-
29
- let needHandleSha1: string[] = [...sha1];
30
-
31
- let allData: FileInfo[] = [];
32
-
33
- while (true) {
34
- // console.log(needHandleSha1.join(','), 'needHandleSha1.join()90ojlskdfjsdlk')
35
- const {ret, errCode, data, msg}: any = await Storage.filesListInfo({
36
- sha1: needHandleSha1.join(','),
37
- });
38
-
39
- if (ret !== 0 || errCode !== 0) {
40
- console.log({
41
- ret, errCode, data, msg
42
- }, '09iowksdjaklfjs;oalijflskdjflsdkjflkj');
43
- return {
44
- error: msg,
45
- result: allData,
46
- };
47
- }
48
-
49
- needHandleSha1 = data
50
- .filter((d: any) => {
51
- return d.metaAnalyzeStatus === 0 || d.metaAnalyzeStatus === 1;
52
- })
53
- .map((d: any) => {
54
- return d.sha1;
55
- });
56
- const finishedInfo: FileInfo[] = data
57
- .filter((d: any) => {
58
- return d.metaAnalyzeStatus !== 0 && d.metaAnalyzeStatus !== 1;
59
- })
60
- .map((d: any) => {
61
- let state: 'success' | 'fail' | 'nonentity' = 'fail';
62
- if (!d.metaAnalyzeStatus) {
63
- state = 'nonentity';
64
- } else if (d.metaAnalyzeStatus === 2) {
65
- state = 'success';
66
- } else if (d.metaAnalyzeStatus === 3) {
67
- state = 'fail';
68
- }
69
- console.log(d, '90wieojiksdjf;lkasdjf;lksdjflksjdflkjsdlfkjsdlkj');
70
- return {
71
- sha1: d.sha1,
72
- state,
73
- info: d,
74
- };
75
- });
76
- cdPartially && cdPartially(finishedInfo);
77
- allData = [
78
- ...allData,
79
- ...finishedInfo,
80
- ];
81
-
82
- if (needHandleSha1.length === 0) {
83
- break;
84
- }
85
- await Tool.promiseSleep(delay);
86
- // delay += 500;
87
- }
88
- return {
89
- error: '',
90
- result: allData,
91
- };
92
- }
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
+ }
@@ -33,7 +33,9 @@ interface IResourceInfo {
33
33
  // 创建资源
34
34
  export interface CreateParamsType {
35
35
  name: string;
36
- resourceType: string[]
36
+ // resourceType: string[]
37
+ resourceTypeCode: string;
38
+ resourceTypeName?: string;
37
39
  policies?: any[];
38
40
  coverImages?: string[];
39
41
  intro?: string;
@@ -80,6 +82,7 @@ interface ListParamsType {
80
82
  limit?: number;
81
83
  keywords?: string;
82
84
  resourceType?: string;
85
+ resourceTypeCode?: string;
83
86
  omitResourceType?: string;
84
87
  isSelf?: 0 | 1;
85
88
  userId?: number;
@@ -93,6 +96,7 @@ interface ListParamsType {
93
96
  tags?: string;
94
97
  sort?: string;
95
98
  // startResourceId?: string;
99
+ operationCategoryCode?: string;
96
100
  }
97
101
 
98
102
  // interface ListReturnType extends CommonReturn {
@@ -196,6 +200,7 @@ interface CreateVersionParamsType {
196
200
  }[];
197
201
  customPropertyDescriptors?: {
198
202
  key: string;
203
+ name: string;
199
204
  defaultValue: string;
200
205
  type: 'editableText' | 'readonlyText' | 'radio' | 'checkbox' | 'select';
201
206
  candidateItems?: string[];
@@ -290,6 +295,7 @@ interface UpdateResourceVersionInfoParamsType {
290
295
  description?: string;
291
296
  customPropertyDescriptors?: {
292
297
  key: string;
298
+ name: string;
293
299
  defaultValue: string;
294
300
  type: 'editableText' | 'readonlyText' | 'radio' | 'checkbox' | 'select';
295
301
  candidateItems?: string[];
@@ -543,3 +549,70 @@ export function availableTags({...params}: AvailableTagsParamsType) {
543
549
  params: params,
544
550
  });
545
551
  }
552
+
553
+ // 列出资源类型分组排序
554
+ interface ResourceTypesParamsType {
555
+ codeOrName?: string;
556
+ category?: 1 | 2; // 种类 1:基础资源类型 2:自定义资源类型
557
+ }
558
+
559
+ export function resourceTypes({...params}: ResourceTypesParamsType = {}) {
560
+ return FUtil.Request({
561
+ method: 'GET',
562
+ url: `/v2/resources/types/listSimpleByGroup`,
563
+ params: params,
564
+ });
565
+ }
566
+
567
+ // 简单根据父类型列出资源类型
568
+ interface ListSimpleByParentCodeParamsType {
569
+ parentCode: string;
570
+ name?: string;
571
+ category?: 1 | 2; // 种类 1:基础资源类型 2:自定义资源类型
572
+ }
573
+
574
+ export function ListSimpleByParentCode({...params}: ListSimpleByParentCodeParamsType) {
575
+ return FUtil.Request({
576
+ method: 'GET',
577
+ url: `/v2/resources/types/listSimpleByParentCode`,
578
+ params: params,
579
+ });
580
+ }
581
+
582
+ // 根据编号取资源类型
583
+ interface GetResourceTypeInfoByCodeParamsType {
584
+ code: string;
585
+ }
586
+
587
+ export function getResourceTypeInfoByCode({...params}: GetResourceTypeInfoByCodeParamsType) {
588
+ return FUtil.Request({
589
+ method: 'GET',
590
+ url: `/v2/resources/types/getInfoByCode`,
591
+ params: params,
592
+ });
593
+ }
594
+
595
+ //
596
+ interface GetResourceAttrListSimple {
597
+
598
+ }
599
+
600
+ export function getResourceAttrListSimple({...params}: GetResourceAttrListSimple) {
601
+ return FUtil.Request({
602
+ method: 'GET',
603
+ url: `/v2/resources/attrs/listSimple`,
604
+ params: params,
605
+ });
606
+ }
607
+
608
+ interface ListSimple4RecentlySimple {
609
+
610
+ }
611
+
612
+ export function listSimple4Recently({...params}: ListSimple4RecentlySimple = {}) {
613
+ return FUtil.Request({
614
+ method: 'GET',
615
+ url: `/v2/resources/types/listSimple4Recently`,
616
+ params: params,
617
+ });
618
+ }