@pisell/core 1.0.57 → 1.0.58
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.
- package/es/indexDB/index.js +32 -25
- package/lib/indexDB/index.js +4 -1
- package/package.json +1 -1
- package/es/logger/index.d.ts +0 -135
- package/lib/logger/index.d.ts +0 -135
package/es/indexDB/index.js
CHANGED
|
@@ -331,7 +331,7 @@ var IndexDBManager = /*#__PURE__*/function () {
|
|
|
331
331
|
_context3.prev = 9;
|
|
332
332
|
case 10:
|
|
333
333
|
if (!(buffer.length > 0)) {
|
|
334
|
-
_context3.next =
|
|
334
|
+
_context3.next = 38;
|
|
335
335
|
break;
|
|
336
336
|
}
|
|
337
337
|
batch = buffer.splice(0, this.debouncedBatchSize);
|
|
@@ -340,55 +340,62 @@ var IndexDBManager = /*#__PURE__*/function () {
|
|
|
340
340
|
_iterator.s();
|
|
341
341
|
case 15:
|
|
342
342
|
if ((_step = _iterator.n()).done) {
|
|
343
|
-
_context3.next =
|
|
343
|
+
_context3.next = 28;
|
|
344
344
|
break;
|
|
345
345
|
}
|
|
346
346
|
item = _step.value;
|
|
347
347
|
_context3.next = 19;
|
|
348
348
|
return mockPromise({}, this.debouncedDelay);
|
|
349
349
|
case 19:
|
|
350
|
-
_context3.
|
|
350
|
+
_context3.prev = 19;
|
|
351
|
+
_context3.next = 22;
|
|
351
352
|
return this.add(storeName, item);
|
|
352
|
-
case
|
|
353
|
-
_context3.next =
|
|
353
|
+
case 22:
|
|
354
|
+
_context3.next = 26;
|
|
354
355
|
break;
|
|
355
|
-
case
|
|
356
|
-
_context3.
|
|
356
|
+
case 24:
|
|
357
|
+
_context3.prev = 24;
|
|
358
|
+
_context3.t0 = _context3["catch"](19);
|
|
359
|
+
case 26:
|
|
360
|
+
_context3.next = 15;
|
|
357
361
|
break;
|
|
358
|
-
case 25:
|
|
359
|
-
_context3.prev = 25;
|
|
360
|
-
_context3.t0 = _context3["catch"](13);
|
|
361
|
-
_iterator.e(_context3.t0);
|
|
362
362
|
case 28:
|
|
363
|
-
_context3.
|
|
363
|
+
_context3.next = 33;
|
|
364
|
+
break;
|
|
365
|
+
case 30:
|
|
366
|
+
_context3.prev = 30;
|
|
367
|
+
_context3.t1 = _context3["catch"](13);
|
|
368
|
+
_iterator.e(_context3.t1);
|
|
369
|
+
case 33:
|
|
370
|
+
_context3.prev = 33;
|
|
364
371
|
_iterator.f();
|
|
365
|
-
return _context3.finish(
|
|
366
|
-
case
|
|
372
|
+
return _context3.finish(33);
|
|
373
|
+
case 36:
|
|
367
374
|
_context3.next = 10;
|
|
368
375
|
break;
|
|
369
|
-
case
|
|
370
|
-
_context3.next =
|
|
376
|
+
case 38:
|
|
377
|
+
_context3.next = 43;
|
|
371
378
|
break;
|
|
372
|
-
case
|
|
373
|
-
_context3.prev =
|
|
374
|
-
_context3.
|
|
379
|
+
case 40:
|
|
380
|
+
_context3.prev = 40;
|
|
381
|
+
_context3.t2 = _context3["catch"](9);
|
|
375
382
|
this.app.logger.addLog({
|
|
376
383
|
type: 'error',
|
|
377
384
|
title: uuid,
|
|
378
385
|
metadata: {
|
|
379
386
|
msg: '防抖合并 add 失败',
|
|
380
|
-
error: _context3.
|
|
387
|
+
error: _context3.t2.message
|
|
381
388
|
}
|
|
382
389
|
});
|
|
383
|
-
case
|
|
384
|
-
_context3.prev =
|
|
390
|
+
case 43:
|
|
391
|
+
_context3.prev = 43;
|
|
385
392
|
this.debouncedFlushing.delete(storeName);
|
|
386
|
-
return _context3.finish(
|
|
387
|
-
case
|
|
393
|
+
return _context3.finish(43);
|
|
394
|
+
case 46:
|
|
388
395
|
case "end":
|
|
389
396
|
return _context3.stop();
|
|
390
397
|
}
|
|
391
|
-
}, _callee3, this, [[9,
|
|
398
|
+
}, _callee3, this, [[9, 40, 43, 46], [13, 30, 33, 36], [19, 24]]);
|
|
392
399
|
}));
|
|
393
400
|
function flushDebouncedAdd(_x) {
|
|
394
401
|
return _flushDebouncedAdd.apply(this, arguments);
|
package/lib/indexDB/index.js
CHANGED
|
@@ -243,7 +243,10 @@ var IndexDBManager = class _IndexDBManager {
|
|
|
243
243
|
const batch = buffer.splice(0, this.debouncedBatchSize);
|
|
244
244
|
for (const item of batch) {
|
|
245
245
|
await mockPromise({}, this.debouncedDelay);
|
|
246
|
-
|
|
246
|
+
try {
|
|
247
|
+
await this.add(storeName, item);
|
|
248
|
+
} catch (err) {
|
|
249
|
+
}
|
|
247
250
|
}
|
|
248
251
|
}
|
|
249
252
|
} catch (error) {
|
package/package.json
CHANGED
package/es/logger/index.d.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import App from "../app";
|
|
2
|
-
export declare type LogConsoleType = "info" | "warning" | "error" | "debug";
|
|
3
|
-
/**
|
|
4
|
-
* 日志项接口
|
|
5
|
-
*/
|
|
6
|
-
interface LogItem {
|
|
7
|
-
logId?: string | number;
|
|
8
|
-
type: LogConsoleType;
|
|
9
|
-
title: string;
|
|
10
|
-
date?: string;
|
|
11
|
-
metadata?: any;
|
|
12
|
-
feishu?: any;
|
|
13
|
-
}
|
|
14
|
-
interface LogFile {
|
|
15
|
-
fileName: string;
|
|
16
|
-
date: string;
|
|
17
|
-
fileContent: LogFileContent;
|
|
18
|
-
}
|
|
19
|
-
interface LogFileContent {
|
|
20
|
-
metadata: any;
|
|
21
|
-
logs: LogItem[];
|
|
22
|
-
}
|
|
23
|
-
export interface LoggerOptions {
|
|
24
|
-
prefix?: string;
|
|
25
|
-
checkInterval?: number;
|
|
26
|
-
feishuConfig?: any;
|
|
27
|
-
retentionDays?: number;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* 日志管理器类
|
|
31
|
-
*/
|
|
32
|
-
declare class LoggerManager {
|
|
33
|
-
private logBuffer;
|
|
34
|
-
private timer;
|
|
35
|
-
private checkInterval;
|
|
36
|
-
private prefix;
|
|
37
|
-
private metadata;
|
|
38
|
-
private db;
|
|
39
|
-
private app;
|
|
40
|
-
private feishuConfig;
|
|
41
|
-
private retentionDays;
|
|
42
|
-
private metadataFunction;
|
|
43
|
-
private status;
|
|
44
|
-
/**
|
|
45
|
-
* 构造函数
|
|
46
|
-
* @param prefix 日志前缀
|
|
47
|
-
* @param checkInterval 检查间隔时间,默认5分钟
|
|
48
|
-
*/
|
|
49
|
-
constructor(app: App, options?: LoggerOptions);
|
|
50
|
-
init(): Promise<void>;
|
|
51
|
-
/**
|
|
52
|
-
* 初始化 IndexDB
|
|
53
|
-
*/
|
|
54
|
-
private initDB;
|
|
55
|
-
/**
|
|
56
|
-
* 设置元数据
|
|
57
|
-
* @param metadata 元数据
|
|
58
|
-
*/
|
|
59
|
-
setMetadata(metadata: any): void;
|
|
60
|
-
setMetadataFunction(metadataFunction: () => any): void;
|
|
61
|
-
/**
|
|
62
|
-
* 初始化定时器
|
|
63
|
-
*/
|
|
64
|
-
initTimer(): void;
|
|
65
|
-
private setStatus;
|
|
66
|
-
stop(): void;
|
|
67
|
-
/**
|
|
68
|
-
* 添加日志
|
|
69
|
-
* @param log 日志项
|
|
70
|
-
*/
|
|
71
|
-
addLog(log: LogItem): void;
|
|
72
|
-
/**
|
|
73
|
-
* 发送飞书通知
|
|
74
|
-
* @param log 日志项
|
|
75
|
-
*/
|
|
76
|
-
private sendFeishuNotification;
|
|
77
|
-
/**
|
|
78
|
-
* 创建日志文件名
|
|
79
|
-
* @returns 日志文件名
|
|
80
|
-
*/
|
|
81
|
-
private createFileName;
|
|
82
|
-
/**
|
|
83
|
-
* 创建AWS日志文件名
|
|
84
|
-
* @param isManual 紧急上传
|
|
85
|
-
* @returns 日志文件名
|
|
86
|
-
*/
|
|
87
|
-
createAWSFileName(urgent?: boolean): Promise<any>;
|
|
88
|
-
/**
|
|
89
|
-
* 创建日志文件
|
|
90
|
-
* @param _fileName 文件名
|
|
91
|
-
* @returns 日志文件对象
|
|
92
|
-
*/
|
|
93
|
-
private createFile;
|
|
94
|
-
/**
|
|
95
|
-
* 存储日志到持久化存储
|
|
96
|
-
*/
|
|
97
|
-
storeLog(urgent?: boolean): Promise<void>;
|
|
98
|
-
uploadIndexDBLog(): Promise<void>;
|
|
99
|
-
private storeLogToIndexDB;
|
|
100
|
-
/**
|
|
101
|
-
* 清理旧日志,只保留最近指定天数的日志
|
|
102
|
-
*/
|
|
103
|
-
private cleanupOldLogs;
|
|
104
|
-
/**
|
|
105
|
-
* 获取日志文件列表
|
|
106
|
-
* @returns 日志文件列表
|
|
107
|
-
*/
|
|
108
|
-
getLogFiles(): Promise<LogFile[]>;
|
|
109
|
-
/**
|
|
110
|
-
* 获取指定日志文件的内容
|
|
111
|
-
* @param fileName 日志文件名
|
|
112
|
-
* @returns 日志文件内容
|
|
113
|
-
*/
|
|
114
|
-
getLogFile(fileName: string): Promise<LogFile | null>;
|
|
115
|
-
/**
|
|
116
|
-
* 清空指定日志文件
|
|
117
|
-
* @param fileName 日志文件名,不指定则清空所有日志
|
|
118
|
-
* @returns 是否成功
|
|
119
|
-
*/
|
|
120
|
-
clearLogs(fileName?: string): Promise<boolean>;
|
|
121
|
-
/**
|
|
122
|
-
* 设置日志保留天数
|
|
123
|
-
* @param days 保留天数
|
|
124
|
-
*/
|
|
125
|
-
setRetentionDays(days: number): void;
|
|
126
|
-
/**
|
|
127
|
-
* 手动触发清理旧日志
|
|
128
|
-
*/
|
|
129
|
-
manualCleanup(): Promise<void>;
|
|
130
|
-
/**
|
|
131
|
-
* 销毁实例
|
|
132
|
-
*/
|
|
133
|
-
destroy(): void;
|
|
134
|
-
}
|
|
135
|
-
export default LoggerManager;
|
package/lib/logger/index.d.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import App from "../app";
|
|
2
|
-
export declare type LogConsoleType = "info" | "warning" | "error" | "debug";
|
|
3
|
-
/**
|
|
4
|
-
* 日志项接口
|
|
5
|
-
*/
|
|
6
|
-
interface LogItem {
|
|
7
|
-
logId?: string | number;
|
|
8
|
-
type: LogConsoleType;
|
|
9
|
-
title: string;
|
|
10
|
-
date?: string;
|
|
11
|
-
metadata?: any;
|
|
12
|
-
feishu?: any;
|
|
13
|
-
}
|
|
14
|
-
interface LogFile {
|
|
15
|
-
fileName: string;
|
|
16
|
-
date: string;
|
|
17
|
-
fileContent: LogFileContent;
|
|
18
|
-
}
|
|
19
|
-
interface LogFileContent {
|
|
20
|
-
metadata: any;
|
|
21
|
-
logs: LogItem[];
|
|
22
|
-
}
|
|
23
|
-
export interface LoggerOptions {
|
|
24
|
-
prefix?: string;
|
|
25
|
-
checkInterval?: number;
|
|
26
|
-
feishuConfig?: any;
|
|
27
|
-
retentionDays?: number;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* 日志管理器类
|
|
31
|
-
*/
|
|
32
|
-
declare class LoggerManager {
|
|
33
|
-
private logBuffer;
|
|
34
|
-
private timer;
|
|
35
|
-
private checkInterval;
|
|
36
|
-
private prefix;
|
|
37
|
-
private metadata;
|
|
38
|
-
private db;
|
|
39
|
-
private app;
|
|
40
|
-
private feishuConfig;
|
|
41
|
-
private retentionDays;
|
|
42
|
-
private metadataFunction;
|
|
43
|
-
private status;
|
|
44
|
-
/**
|
|
45
|
-
* 构造函数
|
|
46
|
-
* @param prefix 日志前缀
|
|
47
|
-
* @param checkInterval 检查间隔时间,默认5分钟
|
|
48
|
-
*/
|
|
49
|
-
constructor(app: App, options?: LoggerOptions);
|
|
50
|
-
init(): Promise<void>;
|
|
51
|
-
/**
|
|
52
|
-
* 初始化 IndexDB
|
|
53
|
-
*/
|
|
54
|
-
private initDB;
|
|
55
|
-
/**
|
|
56
|
-
* 设置元数据
|
|
57
|
-
* @param metadata 元数据
|
|
58
|
-
*/
|
|
59
|
-
setMetadata(metadata: any): void;
|
|
60
|
-
setMetadataFunction(metadataFunction: () => any): void;
|
|
61
|
-
/**
|
|
62
|
-
* 初始化定时器
|
|
63
|
-
*/
|
|
64
|
-
initTimer(): void;
|
|
65
|
-
private setStatus;
|
|
66
|
-
stop(): void;
|
|
67
|
-
/**
|
|
68
|
-
* 添加日志
|
|
69
|
-
* @param log 日志项
|
|
70
|
-
*/
|
|
71
|
-
addLog(log: LogItem): void;
|
|
72
|
-
/**
|
|
73
|
-
* 发送飞书通知
|
|
74
|
-
* @param log 日志项
|
|
75
|
-
*/
|
|
76
|
-
private sendFeishuNotification;
|
|
77
|
-
/**
|
|
78
|
-
* 创建日志文件名
|
|
79
|
-
* @returns 日志文件名
|
|
80
|
-
*/
|
|
81
|
-
private createFileName;
|
|
82
|
-
/**
|
|
83
|
-
* 创建AWS日志文件名
|
|
84
|
-
* @param isManual 紧急上传
|
|
85
|
-
* @returns 日志文件名
|
|
86
|
-
*/
|
|
87
|
-
createAWSFileName(urgent?: boolean): Promise<any>;
|
|
88
|
-
/**
|
|
89
|
-
* 创建日志文件
|
|
90
|
-
* @param _fileName 文件名
|
|
91
|
-
* @returns 日志文件对象
|
|
92
|
-
*/
|
|
93
|
-
private createFile;
|
|
94
|
-
/**
|
|
95
|
-
* 存储日志到持久化存储
|
|
96
|
-
*/
|
|
97
|
-
storeLog(urgent?: boolean): Promise<void>;
|
|
98
|
-
uploadIndexDBLog(): Promise<void>;
|
|
99
|
-
private storeLogToIndexDB;
|
|
100
|
-
/**
|
|
101
|
-
* 清理旧日志,只保留最近指定天数的日志
|
|
102
|
-
*/
|
|
103
|
-
private cleanupOldLogs;
|
|
104
|
-
/**
|
|
105
|
-
* 获取日志文件列表
|
|
106
|
-
* @returns 日志文件列表
|
|
107
|
-
*/
|
|
108
|
-
getLogFiles(): Promise<LogFile[]>;
|
|
109
|
-
/**
|
|
110
|
-
* 获取指定日志文件的内容
|
|
111
|
-
* @param fileName 日志文件名
|
|
112
|
-
* @returns 日志文件内容
|
|
113
|
-
*/
|
|
114
|
-
getLogFile(fileName: string): Promise<LogFile | null>;
|
|
115
|
-
/**
|
|
116
|
-
* 清空指定日志文件
|
|
117
|
-
* @param fileName 日志文件名,不指定则清空所有日志
|
|
118
|
-
* @returns 是否成功
|
|
119
|
-
*/
|
|
120
|
-
clearLogs(fileName?: string): Promise<boolean>;
|
|
121
|
-
/**
|
|
122
|
-
* 设置日志保留天数
|
|
123
|
-
* @param days 保留天数
|
|
124
|
-
*/
|
|
125
|
-
setRetentionDays(days: number): void;
|
|
126
|
-
/**
|
|
127
|
-
* 手动触发清理旧日志
|
|
128
|
-
*/
|
|
129
|
-
manualCleanup(): Promise<void>;
|
|
130
|
-
/**
|
|
131
|
-
* 销毁实例
|
|
132
|
-
*/
|
|
133
|
-
destroy(): void;
|
|
134
|
-
}
|
|
135
|
-
export default LoggerManager;
|