@pisell/core 1.0.10 → 1.0.11

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/app/app.d.ts CHANGED
@@ -8,6 +8,8 @@ import { MenuManager } from '../menuManager';
8
8
  import LoggerManager, { LoggerOptions } from '../logger';
9
9
  import { TasksManager } from '../tasks';
10
10
  import IndexDBManager, { DBOptions } from '../indexDB';
11
+ import CMD from "../cmd";
12
+ import AWS from "../aws";
11
13
  declare global {
12
14
  interface Window {
13
15
  app: App;
@@ -61,6 +63,8 @@ declare class App {
61
63
  };
62
64
  logger: LoggerManager;
63
65
  pubsub: import("../pubsub").PubSub;
66
+ cmd: CMD;
67
+ aws: AWS;
64
68
  tasksManager: TasksManager;
65
69
  dbManager: IndexDBManager | null;
66
70
  constants: {
package/es/app/app.js CHANGED
@@ -24,6 +24,8 @@ import { TasksManager } from "../tasks";
24
24
  import IndexDBManager from "../indexDB";
25
25
  import pubsub from "../pubsub";
26
26
  import { APPEvent } from "./const";
27
+ import CMD from "../cmd";
28
+ import AWS from "../aws";
27
29
  var App = /*#__PURE__*/function () {
28
30
  function App(options) {
29
31
  _classCallCheck(this, App);
@@ -59,6 +61,10 @@ var App = /*#__PURE__*/function () {
59
61
  _defineProperty(this, "logger", void 0);
60
62
  // 发布订阅
61
63
  _defineProperty(this, "pubsub", pubsub);
64
+ // cmd
65
+ _defineProperty(this, "cmd", void 0);
66
+ // aws
67
+ _defineProperty(this, "aws", void 0);
62
68
  // 任务管理
63
69
  _defineProperty(this, "tasksManager", void 0);
64
70
  _defineProperty(this, "dbManager", null);
@@ -79,6 +85,8 @@ var App = /*#__PURE__*/function () {
79
85
  }
80
86
  this.logger = new LoggerManager(this, options === null || options === void 0 ? void 0 : options.logger);
81
87
  this.tasksManager = new TasksManager(this);
88
+ this.cmd = new CMD(this, options === null || options === void 0 ? void 0 : options.cmd);
89
+ this.aws = new AWS(this, options === null || options === void 0 ? void 0 : options.aws);
82
90
  if (options !== null && options !== void 0 && options.constants) {
83
91
  this.constants = options.constants || {};
84
92
  }
@@ -0,0 +1,16 @@
1
+ import { S3ClientConfig, PutObjectCommandInput } from '@aws-sdk/client-s3';
2
+ import App from '../app';
3
+ export interface AWSOptions extends S3ClientConfig {
4
+ s3Config: S3ClientConfig;
5
+ bucketName?: string;
6
+ }
7
+ export interface UploadParams extends PutObjectCommandInput {
8
+ }
9
+ declare class AWS {
10
+ private s3Client?;
11
+ private app;
12
+ private config?;
13
+ constructor(app: App, options?: AWSOptions);
14
+ upload(params: UploadParams): Promise<import("@aws-sdk/client-s3").PutObjectCommandOutput | undefined>;
15
+ }
16
+ export default AWS;
@@ -0,0 +1,76 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
9
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
+ import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3';
14
+ ;
15
+ var defaultUploadParams = {
16
+ Bucket: '',
17
+ Key: '',
18
+ ContentType: 'application/json',
19
+ ContentDisposition: 'inline',
20
+ ACL: 'public-read' // 设置ACL权限为公共读取
21
+ };
22
+ var AWS = /*#__PURE__*/function () {
23
+ function AWS(app, options) {
24
+ _classCallCheck(this, AWS);
25
+ _defineProperty(this, "s3Client", void 0);
26
+ _defineProperty(this, "app", void 0);
27
+ _defineProperty(this, "config", void 0);
28
+ this.app = app;
29
+ if (options) {
30
+ // 配置S3客户端,支持自定义上传地址和CORS
31
+ var clientConfig = _objectSpread({}, options.s3Config);
32
+ this.s3Client = new S3Client(clientConfig);
33
+ this.config = options;
34
+ }
35
+ }
36
+ _createClass(AWS, [{
37
+ key: "upload",
38
+ value: function () {
39
+ var _upload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
40
+ var _this$config, _this$s3Client, _params, command, response;
41
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
42
+ while (1) switch (_context.prev = _context.next) {
43
+ case 0:
44
+ _context.prev = 0;
45
+ // Key: "logs/kds/9/2025-01-01/00:01.json",
46
+ _params = _objectSpread(_objectSpread(_objectSpread({}, defaultUploadParams), params), {}, {
47
+ Bucket: params.Bucket || ((_this$config = this.config) === null || _this$config === void 0 ? void 0 : _this$config.bucketName)
48
+ });
49
+ console.log("\u4E0A\u4F20\u53C2\u6570", _params);
50
+ command = new PutObjectCommand(_params);
51
+ _context.next = 6;
52
+ return (_this$s3Client = this.s3Client) === null || _this$s3Client === void 0 ? void 0 : _this$s3Client.send(command);
53
+ case 6:
54
+ response = _context.sent;
55
+ console.log("\u4E0A\u4F20\u6210\u529F");
56
+ return _context.abrupt("return", response);
57
+ case 11:
58
+ _context.prev = 11;
59
+ _context.t0 = _context["catch"](0);
60
+ console.error("\u4E0A\u4F20\u5931\u8D25", _context.t0);
61
+ throw _context.t0;
62
+ case 15:
63
+ case "end":
64
+ return _context.stop();
65
+ }
66
+ }, _callee, this, [[0, 11]]);
67
+ }));
68
+ function upload(_x) {
69
+ return _upload.apply(this, arguments);
70
+ }
71
+ return upload;
72
+ }()
73
+ }]);
74
+ return AWS;
75
+ }();
76
+ export default AWS;
@@ -0,0 +1,11 @@
1
+ export declare enum CMDCoreEnum {
2
+ CMD_CONNECT,
3
+ CMD_DISCONNECT,
4
+ CMD_RECONNECT,
5
+ CMD_MESSAGE,
6
+ CMD_ERROR
7
+ }
8
+ declare const _default: {
9
+ CMDCoreEnum: typeof CMDCoreEnum;
10
+ };
11
+ export default _default;
@@ -0,0 +1,13 @@
1
+ var prefix = 'cmd'; // 前缀
2
+ // 定义枚举
3
+ export var CMDCoreEnum = /*#__PURE__*/function (CMDCoreEnum) {
4
+ CMDCoreEnum["CMD_CONNECT"] = "cmd.connect";
5
+ CMDCoreEnum["CMD_DISCONNECT"] = "cmd.disconnect";
6
+ CMDCoreEnum["CMD_RECONNECT"] = "cmd.reconnect";
7
+ CMDCoreEnum["CMD_MESSAGE"] = "cmd.message";
8
+ CMDCoreEnum["CMD_ERROR"] = "cmd.error";
9
+ return CMDCoreEnum;
10
+ }({});
11
+ export default {
12
+ CMDCoreEnum: CMDCoreEnum
13
+ };
@@ -0,0 +1,13 @@
1
+ import App from "../app";
2
+ import { CMDCoreEnum } from "./const";
3
+ export interface CMDOptions {
4
+ socketUrl?: string;
5
+ }
6
+ declare class CMD {
7
+ private app;
8
+ private options?;
9
+ constructor(app: App, options?: CMDOptions);
10
+ init(): void;
11
+ }
12
+ export { CMDCoreEnum };
13
+ export default CMD;
@@ -0,0 +1,91 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
4
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ import socket from "../socket";
9
+ import { CMDCoreEnum } from "./const";
10
+ var CMD = /*#__PURE__*/function () {
11
+ function CMD(app, options) {
12
+ _classCallCheck(this, CMD);
13
+ _defineProperty(this, "app", void 0);
14
+ _defineProperty(this, "options", void 0);
15
+ this.app = app;
16
+ this.options = options;
17
+ }
18
+ _createClass(CMD, [{
19
+ key: "init",
20
+ value: function init() {
21
+ var _this$options,
22
+ _this$options2,
23
+ _this = this;
24
+ if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.socketUrl)) {
25
+ return;
26
+ }
27
+ var cmdSocket = socket.create((_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.socketUrl, {
28
+ autoConnect: false,
29
+ // 自动连接
30
+ reconnection: true,
31
+ // 启用断线重连
32
+ heartbeat: true,
33
+ // 启用心跳检测
34
+ heartbeatInterval: 30000,
35
+ // 心跳间隔(毫秒)
36
+ heartbeatTimeout: 50000 // 请求超时时间(毫秒)
37
+ }, "front_cmd" // Socket标识键
38
+ );
39
+ cmdSocket.on("connect", function (res) {
40
+ _this.app.pubsub.publish(CMDCoreEnum.CMD_CONNECT, res);
41
+ _this.app.logger.addLog({
42
+ type: "info",
43
+ title: "cmdSocket连接成功",
44
+ metadata: res
45
+ });
46
+ });
47
+ cmdSocket.on("disconnect", function (res) {
48
+ _this.app.pubsub.publish(CMDCoreEnum.CMD_DISCONNECT, res);
49
+ _this.app.logger.addLog({
50
+ type: "info",
51
+ title: "cmdSocket连接断开",
52
+ metadata: res
53
+ });
54
+ });
55
+ cmdSocket.on("reconnect", function (res) {
56
+ _this.app.pubsub.publish(CMDCoreEnum.CMD_RECONNECT, res);
57
+ _this.app.logger.addLog({
58
+ type: "info",
59
+ title: "cmdSocket重连",
60
+ metadata: res
61
+ });
62
+ });
63
+ cmdSocket.on("message", function (res) {
64
+ _this.app.pubsub.publish(CMDCoreEnum.CMD_MESSAGE, res);
65
+ _this.app.logger.addLog({
66
+ type: "info",
67
+ title: "cmdSocket收到消息",
68
+ metadata: res
69
+ });
70
+ });
71
+ cmdSocket.on("error", function (res) {
72
+ _this.app.pubsub.publish(CMDCoreEnum.CMD_ERROR, res);
73
+ _this.app.logger.addLog({
74
+ type: "info",
75
+ title: "cmdSocket连接错误",
76
+ metadata: res
77
+ });
78
+ });
79
+ cmdSocket.connect().catch(function (error) {
80
+ _this.app.logger.addLog({
81
+ type: "info",
82
+ title: "cmdSocket连接失败",
83
+ metadata: error
84
+ });
85
+ });
86
+ }
87
+ }]);
88
+ return CMD;
89
+ }();
90
+ export { CMDCoreEnum };
91
+ export default CMD;
@@ -0,0 +1,5 @@
1
+ export interface CDMItem {
2
+ key: string;
3
+ code: string;
4
+ [key: string]: any;
5
+ }
package/es/cmd/type.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -4,10 +4,12 @@ export declare type LogConsoleType = "info" | "warning" | "error" | "debug";
4
4
  * 日志项接口
5
5
  */
6
6
  interface LogItem {
7
+ logId?: string | number;
7
8
  type: LogConsoleType;
8
9
  title: string;
9
10
  date?: string;
10
11
  metadata?: any;
12
+ feishu?: any;
11
13
  }
12
14
  interface LogFile {
13
15
  fileName: string;
@@ -38,6 +40,7 @@ declare class LoggerManager {
38
40
  private feishuConfig;
39
41
  private retentionDays;
40
42
  private metadataFunction;
43
+ private status;
41
44
  /**
42
45
  * 构造函数
43
46
  * @param prefix 日志前缀
@@ -59,6 +62,8 @@ declare class LoggerManager {
59
62
  * 初始化定时器
60
63
  */
61
64
  initTimer(): void;
65
+ private setStatus;
66
+ stop(): void;
62
67
  /**
63
68
  * 添加日志
64
69
  * @param log 日志项
@@ -74,6 +79,12 @@ declare class LoggerManager {
74
79
  * @returns 日志文件名
75
80
  */
76
81
  private createFileName;
82
+ /**
83
+ * 创建AWS日志文件名
84
+ * @param isManual 是否手动上传
85
+ * @returns 日志文件名
86
+ */
87
+ createAWSFileName(isManual?: boolean): Promise<any>;
77
88
  /**
78
89
  * 创建日志文件
79
90
  * @param _fileName 文件名
@@ -83,7 +94,8 @@ declare class LoggerManager {
83
94
  /**
84
95
  * 存储日志到持久化存储
85
96
  */
86
- private storeLog;
97
+ storeLog(): Promise<void>;
98
+ private storeLogToIndexDB;
87
99
  /**
88
100
  * 清理旧日志,只保留最近指定天数的日志
89
101
  */