@domain.js/main 0.3.21 → 0.3.24
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/.vscode/settings.json +5 -1
- package/dist/deps/logger/index.d.ts +1 -1
- package/dist/deps/logger/index.js +38 -34
- package/dist/deps/rest/stats.d.ts +1 -1
- package/dist/deps/rest/stats.js +1 -1
- package/dist/deps/sequelize/index.d.ts +1 -1
- package/dist/http/socket.js +1 -4
- package/package.json +1 -1
package/.vscode/settings.json
CHANGED
|
@@ -1,34 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
4
|
};
|
|
21
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
6
|
exports.Deps = exports.Main = void 0;
|
|
23
|
-
const
|
|
24
|
-
const
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const util_1 = require("util");
|
|
25
10
|
const date = (offset = 0) => new Date(Date.now() + (offset | 0)).toISOString();
|
|
26
11
|
function Main(cnf, deps) {
|
|
27
12
|
const { logger: { errorLogPath, infoLogPath, ignoreErrors, clientId }, } = cnf;
|
|
28
13
|
const { _, uuid: { v4: uuid }, } = deps;
|
|
29
14
|
const makeDir = _.memoize((dir) => {
|
|
30
|
-
if (!
|
|
31
|
-
|
|
15
|
+
if (!fs_1.default.existsSync(dir))
|
|
16
|
+
fs_1.default.mkdirSync(dir);
|
|
32
17
|
});
|
|
33
18
|
const ignores = new Set(ignoreErrors);
|
|
34
19
|
const error = (e, extra) => {
|
|
@@ -42,18 +27,30 @@ function Main(cnf, deps) {
|
|
|
42
27
|
// 忽略某些错误
|
|
43
28
|
if (ignores.has(code))
|
|
44
29
|
return;
|
|
45
|
-
const dir =
|
|
30
|
+
const dir = path_1.default.resolve(errorLogPath, today);
|
|
46
31
|
makeDir(dir);
|
|
47
|
-
const file =
|
|
32
|
+
const file = path_1.default.resolve(dir, `${code}.err`);
|
|
48
33
|
const content = [time, clientId, e.message];
|
|
49
|
-
if (e.data)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
34
|
+
if (e.data) {
|
|
35
|
+
try {
|
|
36
|
+
content.push(JSON.stringify(e.data));
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
content.push((0, util_1.format)(e.data));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (extra !== null || extra !== undefined) {
|
|
43
|
+
try {
|
|
44
|
+
content.push(JSON.stringify(extra));
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
content.push((0, util_1.format)(extra));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
53
50
|
if (e.stack)
|
|
54
51
|
content.push(JSON.stringify(e.stack));
|
|
55
52
|
try {
|
|
56
|
-
|
|
53
|
+
fs_1.default.appendFileSync(file, `${content.join("\t")}\n`);
|
|
57
54
|
}
|
|
58
55
|
catch (err) {
|
|
59
56
|
console.error("Logger.error appendFileSync faid: %o", err);
|
|
@@ -62,14 +59,21 @@ function Main(cnf, deps) {
|
|
|
62
59
|
const info = (message, extra) => {
|
|
63
60
|
const time = date();
|
|
64
61
|
const today = time.split("T")[0];
|
|
65
|
-
const dir =
|
|
62
|
+
const dir = path_1.default.resolve(infoLogPath, today);
|
|
66
63
|
makeDir(dir);
|
|
67
|
-
const file =
|
|
64
|
+
const file = path_1.default.resolve(dir, "info.log");
|
|
68
65
|
const content = [time, clientId, message];
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
// eslint-disable-next-line no-eq-null
|
|
67
|
+
if (extra !== null || extra !== undefined) {
|
|
68
|
+
try {
|
|
69
|
+
content.push(JSON.stringify(extra));
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
content.push((0, util_1.format)(extra));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
71
75
|
try {
|
|
72
|
-
|
|
76
|
+
fs_1.default.appendFileSync(file, `${content.join("\t")}\n`);
|
|
73
77
|
}
|
|
74
78
|
catch (e) {
|
|
75
79
|
console.error("Logger.info appendFileSync faid: %o", e);
|
|
@@ -6,7 +6,7 @@ interface Deps {
|
|
|
6
6
|
_: typeof _;
|
|
7
7
|
Sequelize: Pick<typeof Sequelize, "literal" | "and" | "fn">;
|
|
8
8
|
}
|
|
9
|
-
export declare function Stats(
|
|
9
|
+
export declare function Stats(_cnf: any, deps: Deps, utils: ReturnType<typeof Utils>): <T extends ModelBase<any, any>>(Model: ModelStatic<T>, params: Record<string, any>, where?: any, conf?: {
|
|
10
10
|
dimensions?: Record<string, string> | undefined;
|
|
11
11
|
metrics: Record<string, string>;
|
|
12
12
|
pagination?: {
|
package/dist/deps/rest/stats.js
CHANGED
|
@@ -26,7 +26,7 @@ export interface ModelSort<Fields extends string> {
|
|
|
26
26
|
}
|
|
27
27
|
/** Model 上的 stats 设定类型 */
|
|
28
28
|
export interface ModelStats<Fields extends string> {
|
|
29
|
-
dimensions?: Record<
|
|
29
|
+
dimensions?: Record<string, Fields>;
|
|
30
30
|
metrics: Record<string, string>;
|
|
31
31
|
pagination?: {
|
|
32
32
|
maxResults: number;
|
package/dist/http/socket.js
CHANGED
|
@@ -116,15 +116,12 @@ function BridgeSocket(io, domain) {
|
|
|
116
116
|
try {
|
|
117
117
|
if (!client.profile || !client.inited)
|
|
118
118
|
return;
|
|
119
|
-
const res = await entrance({
|
|
119
|
+
const res = await entrance({ ...client.profile, roomId }, client);
|
|
120
120
|
client.profile.roomId = roomId;
|
|
121
121
|
client.roomId = roomId;
|
|
122
122
|
client.emit("entranced", res);
|
|
123
123
|
}
|
|
124
124
|
catch (e) {
|
|
125
|
-
client.roomId = undefined;
|
|
126
|
-
if (client.profile)
|
|
127
|
-
client.profile.roomId = undefined;
|
|
128
125
|
if (e instanceof MyError) {
|
|
129
126
|
client.emit("internalError", e.message, e.code || "unknown");
|
|
130
127
|
return;
|