@freelog/tools-lib 0.1.106 → 0.1.109

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.
@@ -22,3 +22,8 @@ export declare function policyCodeTranslationToText(code: string, targetType: st
22
22
  error: string[] | null;
23
23
  text?: string;
24
24
  }>;
25
+ /**
26
+ * 将资源类型关键字数组,转换成标准展示文字
27
+ * @param arr 关键字数组
28
+ */
29
+ export declare function resourceTypeKeyArrToResourceType(arr: string[]): string;
@@ -20,4 +20,9 @@ interface TransformServerAPIContractStateParams {
20
20
  authStatus: 1 | 2 | 128 | number;
21
21
  }
22
22
  export declare function transformServerAPIContractState({ status, authStatus, }: TransformServerAPIContractStateParams): 'active' | 'testActive' | 'inactive' | 'terminal' | 'exception';
23
+ /**
24
+ * 暂时休眠
25
+ * @param ms 休眠时常(毫秒)
26
+ */
27
+ export declare function promiseSleep(ms?: number): Promise<void>;
23
28
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freelog/tools-lib",
3
- "version": "0.1.106",
3
+ "version": "0.1.109",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -0,0 +1,65 @@
1
+ import * as FUtil 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<FileInfo[]> {
17
+ if (sha1.length === 0) {
18
+ return [];
19
+ }
20
+
21
+ let needHandleSha1: string[] = [...sha1];
22
+
23
+ let allData: FileInfo[] = [];
24
+
25
+ while (true) {
26
+ const {data} = await Storage.filesListInfo({
27
+ sha1: needHandleSha1,
28
+ });
29
+ needHandleSha1 = data
30
+ .filter((d: any) => {
31
+ return d.metaAnalyzeStatus && d.metaAnalyzeStatus === 1;
32
+ })
33
+ .map((d: any) => {
34
+ return d.sha1;
35
+ });
36
+ const finishedInfo: FileInfo[] = data
37
+ .filter((d: any) => {
38
+ return !d.metaAnalyzeStatus || d.metaAnalyzeStatus !== 1;
39
+ })
40
+ .map((d: any) => {
41
+ let state: 'success' | 'fail' | 'nonentity' = 'fail';
42
+ if (!d.metaAnalyzeStatus) {
43
+ state = 'nonentity';
44
+ } else if (d.metaAnalyzeStatus === 2) {
45
+ state = 'success';
46
+ }
47
+ return {
48
+ sha1: d.sha1,
49
+ state,
50
+ info: d,
51
+ };
52
+ });
53
+ cdPartially && cdPartially(finishedInfo);
54
+ allData = [
55
+ ...allData,
56
+ ...finishedInfo,
57
+ ];
58
+
59
+ if (needHandleSha1.length === 0) {
60
+ break;
61
+ }
62
+ await FUtil.promiseSleep(3000)
63
+ }
64
+ return allData;
65
+ }
@@ -1,35 +1,37 @@
1
- import * as Node from './nodes';
2
- import * as Exhibit from './presentables';
3
- import * as Storage from './storages';
4
- import * as Collection from './collections';
5
- import * as Resource from './resources';
6
- import * as User from './user';
7
- import * as InformalNode from './informalNodes';
8
- import * as Contract from './contracts';
9
- import * as Transaction from './transactions';
10
- import * as Captcha from './captcha';
11
- import * as Event from './events';
12
- import * as Activity from './activities';
13
- import * as TestQualification from './testQualifications';
14
- import * as Statistic from './statistics';
15
- import * as I18n from './i18n';
16
-
17
- const FServiceAPI = {
18
- Node,
19
- Exhibit,
20
- Storage,
21
- Collection,
22
- Resource,
23
- User,
24
- InformalNode,
25
- Contract,
26
- Transaction,
27
- Captcha,
28
- Event,
29
- Activity,
30
- TestQualification,
31
- Statistic,
32
- I18n,
33
- };
34
-
35
- export default FServiceAPI;
1
+ import * as Node from './nodes';
2
+ import * as Exhibit from './presentables';
3
+ import * as Storage from './storages';
4
+ import * as Collection from './collections';
5
+ import * as Resource from './resources';
6
+ import * as User from './user';
7
+ import * as InformalNode from './informalNodes';
8
+ import * as Contract from './contracts';
9
+ import * as Transaction from './transactions';
10
+ import * as Captcha from './captcha';
11
+ import * as Event from './events';
12
+ import * as Activity from './activities';
13
+ import * as TestQualification from './testQualifications';
14
+ import * as Statistic from './statistics';
15
+ import * as I18n from './i18n';
16
+ import * as combination from './combinations';
17
+
18
+ const FServiceAPI = {
19
+ Node,
20
+ Exhibit,
21
+ Storage,
22
+ Collection,
23
+ Resource,
24
+ User,
25
+ InformalNode,
26
+ Contract,
27
+ Transaction,
28
+ Captcha,
29
+ Event,
30
+ Activity,
31
+ TestQualification,
32
+ Statistic,
33
+ I18n,
34
+ combination,
35
+ };
36
+
37
+ export default FServiceAPI;
@@ -17,7 +17,7 @@ interface IResourceInfo {
17
17
  }[];
18
18
  resourceId: string;
19
19
  resourceName: string;
20
- resourceType: string;
20
+ resourceType: string[];
21
21
  resourceVersions: {
22
22
  createDate: string;
23
23
  version: string;
@@ -33,7 +33,7 @@ interface IResourceInfo {
33
33
  // 创建资源
34
34
  export interface CreateParamsType {
35
35
  name: string;
36
- resourceType: string;
36
+ resourceType: string[]
37
37
  policies?: any[];
38
38
  coverImages?: string[];
39
39
  intro?: string;