node-nim 10.9.30-beta.90 → 10.9.31
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/dist/v2/v2_nim_statistics_service.js +9 -0
- package/dist/v2/v2_nim_statistics_service.js.map +1 -1
- package/dist/v2_def/v2_nim_struct_def.js.map +1 -1
- package/node-nim-tester.js +36 -36
- package/package.json +1 -1
- package/types/v2/v2_nim_statistics_service.d.ts +2 -1
- package/types/v2_def/v2_nim_struct_def.d.ts +13 -2
|
@@ -11,6 +11,15 @@ class V2NIMStatisticsService extends eventemitter3_1.EventEmitter {
|
|
|
11
11
|
super();
|
|
12
12
|
this.instance = new loader_1.default.V2NIMStatisticsService({ emit: this.emit.bind(this) });
|
|
13
13
|
}
|
|
14
|
+
getDatabaseInfos() {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
this.instance.getDatabaseInfos((result) => {
|
|
17
|
+
resolve(result);
|
|
18
|
+
}, (error) => {
|
|
19
|
+
reject(error);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
14
23
|
}
|
|
15
24
|
exports.V2NIMStatisticsService = V2NIMStatisticsService;
|
|
16
25
|
//# sourceMappingURL=v2_nim_statistics_service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v2_nim_statistics_service.js","sourceRoot":"","sources":["../../ts/v2/v2_nim_statistics_service.ts"],"names":[],"mappings":";;;;;;AAGA,iDAA4C;AAC5C,uDAA2B;AAO3B,MAAa,sBAAuB,SAAQ,4BAAqC;IAG/E;QACE,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAG,CAAC,sBAAsB,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAChF,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"v2_nim_statistics_service.js","sourceRoot":"","sources":["../../ts/v2/v2_nim_statistics_service.ts"],"names":[],"mappings":";;;;;;AAGA,iDAA4C;AAC5C,uDAA2B;AAO3B,MAAa,sBAAuB,SAAQ,4BAAqC;IAG/E;QACE,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAG,CAAC,sBAAsB,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAChF,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAC5B,CAAC,MAAiC,EAAE,EAAE;gBACpC,OAAO,CAAC,MAAM,CAAC,CAAA;YACjB,CAAC,EACD,CAAC,KAAiB,EAAE,EAAE;gBACpB,MAAM,CAAC,KAAK,CAAC,CAAA;YACf,CAAC,CACF,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AApBD,wDAoBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v2_nim_struct_def.js","sourceRoot":"","sources":["../../ts/v2_def/v2_nim_struct_def.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"v2_nim_struct_def.js","sourceRoot":"","sources":["../../ts/v2_def/v2_nim_struct_def.ts"],"names":[],"mappings":";;AAwMC,CAAC;AAgeD,CAAC;AAy4BD,CAAC"}
|
package/node-nim-tester.js
CHANGED
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
const { Command } = require('commander')
|
|
4
4
|
const WebAT = require('hawk-web')
|
|
5
5
|
const program = new Command()
|
|
6
|
-
const os = require('os')
|
|
7
|
-
const path = require('path')
|
|
8
|
-
const fs = require('fs')
|
|
9
|
-
const v8 = require('v8')
|
|
10
|
-
const { createLogger, format, transports } = require('winston')
|
|
11
|
-
const { combine, timestamp, label, printf } = format
|
|
6
|
+
const os = require('os')
|
|
7
|
+
const path = require('path')
|
|
8
|
+
const fs = require('fs')
|
|
9
|
+
const v8 = require('v8')
|
|
10
|
+
const { createLogger, format, transports } = require('winston')
|
|
11
|
+
const { combine, timestamp, label, printf } = format
|
|
12
12
|
const downloadSDK = require('./script/download-sdk.js').downloadSDK
|
|
13
13
|
|
|
14
14
|
const loggerFormat = printf(({ level, message, label, timestamp }) => {
|
|
15
|
-
return `${timestamp} [${label}] ${level}: ${message}
|
|
16
|
-
})
|
|
15
|
+
return `${timestamp} [${label}] ${level}: ${message}`
|
|
16
|
+
})
|
|
17
17
|
|
|
18
18
|
const logger = createLogger({
|
|
19
19
|
level: 'info',
|
|
@@ -21,10 +21,10 @@ const logger = createLogger({
|
|
|
21
21
|
label({ label: 'right meow!' }),
|
|
22
22
|
timestamp({
|
|
23
23
|
format: () => {
|
|
24
|
-
const now = new Date()
|
|
25
|
-
const dateStr = now.toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' })
|
|
26
|
-
const ms = now.getMilliseconds().toString().padStart(3, '0')
|
|
27
|
-
return `${dateStr}.${ms}
|
|
24
|
+
const now = new Date()
|
|
25
|
+
const dateStr = now.toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' })
|
|
26
|
+
const ms = now.getMilliseconds().toString().padStart(3, '0')
|
|
27
|
+
return `${dateStr}.${ms}`
|
|
28
28
|
}
|
|
29
29
|
}),
|
|
30
30
|
loggerFormat
|
|
@@ -33,44 +33,44 @@ const logger = createLogger({
|
|
|
33
33
|
transports: [
|
|
34
34
|
new transports.File({
|
|
35
35
|
filename: (() => {
|
|
36
|
-
const logDir = path.join(os.homedir(), 'Downloads', 'node-nim')
|
|
36
|
+
const logDir = path.join(os.homedir(), 'Downloads', 'node-nim')
|
|
37
37
|
// 如果文件夹不存在则创建
|
|
38
38
|
if (!fs.existsSync(logDir)) {
|
|
39
|
-
fs.mkdirSync(logDir, { recursive: true })
|
|
39
|
+
fs.mkdirSync(logDir, { recursive: true })
|
|
40
40
|
}
|
|
41
|
-
return path.join(logDir, `node-memory-${new Date().toISOString().split('T')[0]}-${process.pid}.log`)
|
|
41
|
+
return path.join(logDir, `node-memory-${new Date().toISOString().split('T')[0]}-${process.pid}.log`)
|
|
42
42
|
})()
|
|
43
43
|
}),
|
|
44
44
|
],
|
|
45
|
-
})
|
|
45
|
+
})
|
|
46
46
|
|
|
47
|
-
function getSystemMemoryInfo() {
|
|
48
|
-
const totalMemory = os.totalmem()
|
|
49
|
-
const freeMemory = os.freemem()
|
|
50
|
-
const usedMemory = totalMemory - freeMemory
|
|
47
|
+
function getSystemMemoryInfo () {
|
|
48
|
+
const totalMemory = os.totalmem()
|
|
49
|
+
const freeMemory = os.freemem()
|
|
50
|
+
const usedMemory = totalMemory - freeMemory
|
|
51
51
|
|
|
52
52
|
return {
|
|
53
53
|
total: Math.round(totalMemory / 1024 / 1024), // MB
|
|
54
54
|
free: Math.round(freeMemory / 1024 / 1024), // MB
|
|
55
55
|
used: Math.round(usedMemory / 1024 / 1024), // MB
|
|
56
56
|
usagePercent: Math.round((usedMemory / totalMemory) * 100) // 百分比
|
|
57
|
-
}
|
|
57
|
+
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
function getProcessMemoryInfo() {
|
|
61
|
-
const usage = process.memoryUsage()
|
|
60
|
+
function getProcessMemoryInfo () {
|
|
61
|
+
const usage = process.memoryUsage()
|
|
62
62
|
return {
|
|
63
63
|
rss: Math.round(usage.rss / 1024 / 1024), // 常驻内存大小
|
|
64
|
-
heapTotal: Math.round(usage.heapTotal / 1024 / 1024), //
|
|
64
|
+
heapTotal: Math.round(usage.heapTotal / 1024 / 1024), // 堆总大小ß
|
|
65
65
|
heapUsed: Math.round(usage.heapUsed / 1024 / 1024), // 堆已使用
|
|
66
66
|
external: Math.round(usage.external / 1024 / 1024), // V8 外部内存
|
|
67
67
|
arrayBuffers: Math.round((usage.arrayBuffers || 0) / 1024 / 1024) // ArrayBuffer 大小
|
|
68
|
-
}
|
|
68
|
+
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
function getV8HeapDetails() {
|
|
72
|
-
const heapStats = v8.getHeapStatistics()
|
|
73
|
-
const heapSpaceStats = v8.getHeapSpaceStatistics()
|
|
71
|
+
function getV8HeapDetails () {
|
|
72
|
+
const heapStats = v8.getHeapStatistics()
|
|
73
|
+
const heapSpaceStats = v8.getHeapSpaceStatistics()
|
|
74
74
|
|
|
75
75
|
return {
|
|
76
76
|
heap: {
|
|
@@ -105,24 +105,24 @@ program
|
|
|
105
105
|
.option('--nimSdkUrl <nimSdkUrl>', 'nim native sdk download url')
|
|
106
106
|
.allowUnknownOption(true)
|
|
107
107
|
.action(async (options) => {
|
|
108
|
-
logger.info(`run node-nim tester, options: ${JSON.stringify(options)}`)
|
|
109
|
-
const heapStats = v8.getHeapStatistics()
|
|
110
|
-
logger.info(`V8 heap limit (max-old-space-size): ${Math.round(heapStats.heap_size_limit / 1024 / 1024)} MB`)
|
|
108
|
+
logger.info(`run node-nim tester, options: ${JSON.stringify(options)}`)
|
|
109
|
+
const heapStats = v8.getHeapStatistics()
|
|
110
|
+
logger.info(`V8 heap limit (max-old-space-size): ${Math.round(heapStats.heap_size_limit / 1024 / 1024)} MB`)
|
|
111
111
|
setInterval(() => {
|
|
112
112
|
const processMemoryUsage = getProcessMemoryInfo()
|
|
113
113
|
logger.info(`System memory usage: ${JSON.stringify(getSystemMemoryInfo(), null, 2)}`)
|
|
114
114
|
logger.info(`Process memory usage: ${JSON.stringify(getProcessMemoryInfo(), null, 2)}`)
|
|
115
115
|
logger.info(`V8 heap details: ${JSON.stringify(getV8HeapDetails())}`)
|
|
116
116
|
if (processMemoryUsage.heapTotal > 1000) {
|
|
117
|
-
const logDir = path.join(os.homedir(), 'Downloads', 'node-nim')
|
|
117
|
+
const logDir = path.join(os.homedir(), 'Downloads', 'node-nim')
|
|
118
118
|
// 如果文件夹不存在则创建
|
|
119
119
|
if (!fs.existsSync(logDir)) {
|
|
120
|
-
fs.mkdirSync(logDir, { recursive: true })
|
|
120
|
+
fs.mkdirSync(logDir, { recursive: true })
|
|
121
121
|
}
|
|
122
|
-
const heapSnapshotFile = path.join(logDir, `node-heap-snapshot-${new Date().toISOString().split('T')[0]}-${process.pid}.log`)
|
|
122
|
+
const heapSnapshotFile = path.join(logDir, `node-heap-snapshot-${new Date().toISOString().split('T')[0]}-${process.pid}.log`)
|
|
123
123
|
if (!fs.existsSync(heapSnapshotFile)) {
|
|
124
|
-
logger.info(`Writing heap snapshot to ${heapSnapshotFile}`)
|
|
125
|
-
require('v8').writeHeapSnapshot(heapSnapshotFile)
|
|
124
|
+
logger.info(`Writing heap snapshot to ${heapSnapshotFile}`)
|
|
125
|
+
require('v8').writeHeapSnapshot(heapSnapshotFile)
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
}, 5 * 1000)
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { V2NIMError } from 'ts/v2_def/v2_nim_struct_def';
|
|
1
|
+
import { V2NIMError, V2NIMSignallingCallResult } from 'ts/v2_def/v2_nim_struct_def';
|
|
2
2
|
import { EventEmitter } from 'eventemitter3';
|
|
3
3
|
export declare interface V2NIMStatisticsListener {
|
|
4
4
|
/** 数据库异常 */
|
|
@@ -7,4 +7,5 @@ export declare interface V2NIMStatisticsListener {
|
|
|
7
7
|
export declare class V2NIMStatisticsService extends EventEmitter<V2NIMStatisticsListener> {
|
|
8
8
|
instance: any;
|
|
9
9
|
constructor();
|
|
10
|
+
getDatabaseInfos(): Promise<V2NIMSignallingCallResult>;
|
|
10
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { V2NIMAIModelType, V2NIMMessageAIStatus, V2NIMAsymmetricEncryptionAlgorithm, V2NIMChatroomKickedReason, V2NIMChatroomMemberRole, V2NIMChatroomMessageNotificationType, V2NIMChatroomQueueChangeType, V2NIMChatroomQueueLevelMode, V2NIMClientAntispamOperateType, V2NIMClientAntispamThesaurusMatchType, V2NIMConversationType, V2NIMDataSyncType, V2NIMDownloadAttachmentType, V2NIMFCSAuthType, V2NIMFriendAddApplicationStatus, V2NIMFriendAddMode, V2NIMIPProtocolVersion, V2NIMLoginAuthType, V2NIMLoginClientType, V2NIMMessageAttachmentUploadState, V2NIMMessageClientAntispamOperatorType, V2NIMMessageNotificationType, V2NIMMessagePinState, V2NIMMessageRevokeType, V2NIMMessageSendingState, V2NIMMessageType, V2NIMProxyRequestMethod, V2NIMQueryDirection, V2NIMSDKLogLevel, V2NIMSignallingChannelType, V2NIMSignallingEventType, V2NIMSortOrder, V2NIMSQLCipherVersion, V2NIMHandShakeType, V2NIMSymmetricEncryptionAlgorithm, V2NIMTeamAgreeMode, V2NIMTeamChatBannedMode, V2NIMTeamInviteMode, V2NIMTeamJoinActionStatus, V2NIMTeamJoinActionType, V2NIMTeamJoinMode, V2NIMTeamMemberRole, V2NIMTeamMemberRoleQueryType, V2NIMTeamType, V2NIMTeamUpdateExtensionMode, V2NIMTeamUpdateInfoMode, V2NIMSearchKeywordMathType, V2NIMClearHistoryMode, V2NIMAIModelRoleType, V2NIMMessageAIStreamStatus, V2NIMAIModelStreamCallStatus, V2NIMMessageAIStreamStopOpType, V2NIMMessageAIRegenOpType, V2NIMKickedOfflineReason, V2NIMSearchDirection, V2NIMSearchStrategy, V2NIMMessageStreamStatus } from './v2_nim_enum_def';
|
|
1
|
+
import { V2NIMAIModelType, V2NIMMessageAIStatus, V2NIMAsymmetricEncryptionAlgorithm, V2NIMChatroomKickedReason, V2NIMChatroomMemberRole, V2NIMChatroomMessageNotificationType, V2NIMChatroomQueueChangeType, V2NIMChatroomQueueLevelMode, V2NIMClientAntispamOperateType, V2NIMClientAntispamThesaurusMatchType, V2NIMConversationType, V2NIMDataSyncType, V2NIMDownloadAttachmentType, V2NIMFCSAuthType, V2NIMFriendAddApplicationStatus, V2NIMFriendAddMode, V2NIMIPProtocolVersion, V2NIMLoginAuthType, V2NIMLoginClientType, V2NIMMessageAttachmentUploadState, V2NIMMessageClientAntispamOperatorType, V2NIMMessageNotificationType, V2NIMMessagePinState, V2NIMMessageRevokeType, V2NIMMessageSendingState, V2NIMMessageType, V2NIMProxyRequestMethod, V2NIMQueryDirection, V2NIMSDKLogLevel, V2NIMSignallingChannelType, V2NIMSignallingEventType, V2NIMSortOrder, V2NIMSQLCipherVersion, V2NIMHandShakeType, V2NIMSymmetricEncryptionAlgorithm, V2NIMTeamAgreeMode, V2NIMTeamChatBannedMode, V2NIMTeamInviteMode, V2NIMTeamJoinActionStatus, V2NIMTeamJoinActionType, V2NIMTeamJoinMode, V2NIMTeamMemberRole, V2NIMTeamMemberRoleQueryType, V2NIMTeamType, V2NIMTeamUpdateExtensionMode, V2NIMTeamUpdateInfoMode, V2NIMSearchKeywordMathType, V2NIMClearHistoryMode, V2NIMAIModelRoleType, V2NIMMessageAIStreamStatus, V2NIMAIModelStreamCallStatus, V2NIMMessageAIStreamStopOpType, V2NIMMessageAIRegenOpType, V2NIMKickedOfflineReason, V2NIMSearchDirection, V2NIMSearchStrategy, V2NIMMessageStreamStatus, V2NIMDataSyncLevel } from './v2_nim_enum_def';
|
|
2
2
|
export interface V2NIMError {
|
|
3
3
|
/** 错误码, 详见 V2NIMErrorCode */
|
|
4
4
|
code?: number;
|
|
@@ -144,6 +144,8 @@ export interface V2NIMInitOption {
|
|
|
144
144
|
databaseOption?: V2NIMDatabaseOption;
|
|
145
145
|
/** 融合存储配置 */
|
|
146
146
|
fcsOption?: V2NIMFCSOption;
|
|
147
|
+
/** 登录路由(抄送)配置 */
|
|
148
|
+
routeConfig?: V2NIMRouteConfig;
|
|
147
149
|
/** 私有化配置 */
|
|
148
150
|
privateServerOption?: V2NIMPrivateServerOption;
|
|
149
151
|
}
|
|
@@ -1021,7 +1023,7 @@ export interface V2NIMLoginOption {
|
|
|
1021
1023
|
/** 登陆扩展信息获取回调 */
|
|
1022
1024
|
loginExtensionProvider?: V2NIMLoginExtensionProvider;
|
|
1023
1025
|
/** 数据同步等级 */
|
|
1024
|
-
syncLevel?:
|
|
1026
|
+
syncLevel?: V2NIMDataSyncLevel;
|
|
1025
1027
|
/** 登录路由(抄送)配置 @since v10.9.30 */
|
|
1026
1028
|
routeConfig?: V2NIMRouteConfig;
|
|
1027
1029
|
}
|
|
@@ -2510,3 +2512,12 @@ export interface V2NIMUpdateLocalMessageParams {
|
|
|
2510
2512
|
/** 消息发送状态 @since v10.9.1 */
|
|
2511
2513
|
sendingState?: V2NIMMessageSendingState;
|
|
2512
2514
|
}
|
|
2515
|
+
/** @brief 数据库信息 @since v10.9.40 */
|
|
2516
|
+
export interface V2NIMDatabaseInfo {
|
|
2517
|
+
/** 数据库路径 */
|
|
2518
|
+
path: string;
|
|
2519
|
+
/** 数据库名称 */
|
|
2520
|
+
name: string;
|
|
2521
|
+
/** 数据库大小字节 */
|
|
2522
|
+
size: number;
|
|
2523
|
+
}
|