@pisell/core 1.0.60 → 1.0.61

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.
@@ -20,4 +20,7 @@ export declare class History {
20
20
  reloadTo: (path: string) => void;
21
21
  externalPage: (path: string) => void;
22
22
  goLogin: () => any;
23
+ getQuery: () => {
24
+ [k: string]: string;
25
+ };
23
26
  }
@@ -55,6 +55,23 @@ export var History = /*#__PURE__*/_createClass(function History(app, options) {
55
55
  var _this$app$application, _this$app$application2;
56
56
  return (_this$app$application = _this.app.applicationManager.get("login")) === null || _this$app$application === void 0 || (_this$app$application2 = _this$app$application.runFunction) === null || _this$app$application2 === void 0 ? void 0 : _this$app$application2.call(_this$app$application, "goLogin");
57
57
  });
58
+ _defineProperty(this, "getQuery", function () {
59
+ try {
60
+ var search = _this.instance.location.search;
61
+ var params = new URLSearchParams(search);
62
+ var obj = Object.fromEntries(params.entries());
63
+ return obj;
64
+ } catch (err) {
65
+ _this.app.logger.addLog({
66
+ type: "error",
67
+ title: "获取query参数失败",
68
+ metadata: {
69
+ data: err
70
+ }
71
+ });
72
+ }
73
+ return {};
74
+ });
58
75
  this.app = app;
59
76
  this.instance = createBrowserHistory({
60
77
  basename: (options === null || options === void 0 ? void 0 : options.basename) || "/"
@@ -0,0 +1,135 @@
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;
@@ -108,7 +108,7 @@ export declare class TasksManager {
108
108
  */
109
109
  getQueueStatus(module: string, queueId: string): {
110
110
  isRunning: boolean;
111
- status: "completed" | "uncompleted";
111
+ status: "uncompleted" | "completed";
112
112
  progress: {
113
113
  total: number;
114
114
  completed: number;
@@ -20,4 +20,7 @@ export declare class History {
20
20
  reloadTo: (path: string) => void;
21
21
  externalPage: (path: string) => void;
22
22
  goLogin: () => any;
23
+ getQuery: () => {
24
+ [k: string]: string;
25
+ };
23
26
  }
@@ -75,6 +75,23 @@ var History = class {
75
75
  var _a, _b;
76
76
  return (_b = (_a = this.app.applicationManager.get("login")) == null ? void 0 : _a.runFunction) == null ? void 0 : _b.call(_a, "goLogin");
77
77
  };
78
+ getQuery = () => {
79
+ try {
80
+ const search = this.instance.location.search;
81
+ const params = new URLSearchParams(search);
82
+ const obj = Object.fromEntries(params.entries());
83
+ return obj;
84
+ } catch (err) {
85
+ this.app.logger.addLog({
86
+ type: "error",
87
+ title: "获取query参数失败",
88
+ metadata: {
89
+ data: err
90
+ }
91
+ });
92
+ }
93
+ return {};
94
+ };
78
95
  };
79
96
  // Annotate the CommonJS export names for ESM import in node:
80
97
  0 && (module.exports = {
@@ -0,0 +1,135 @@
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;
@@ -108,7 +108,7 @@ export declare class TasksManager {
108
108
  */
109
109
  getQueueStatus(module: string, queueId: string): {
110
110
  isRunning: boolean;
111
- status: "completed" | "uncompleted";
111
+ status: "uncompleted" | "completed";
112
112
  progress: {
113
113
  total: number;
114
114
  completed: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/core",
3
- "version": "1.0.60",
3
+ "version": "1.0.61",
4
4
  "sideEffects": false,
5
5
  "main": "./lib/index.js",
6
6
  "module": "./es/index.js",