feat: add upload logs func (#4)
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@openim/electron-client-sdk",
|
"name": "@openim/electron-client-sdk",
|
||||||
"version": "1.0.0",
|
"version": "1.0.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@openim/electron-client-sdk",
|
"name": "@openim/electron-client-sdk",
|
||||||
"version": "1.0.0",
|
"version": "1.0.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"koffi": "^2.8.0",
|
"koffi": "^2.8.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@openim/electron-client-sdk",
|
"name": "@openim/electron-client-sdk",
|
||||||
"version": "1.0.5",
|
"version": "1.0.6",
|
||||||
"description": "open im sdk for node",
|
"description": "open im sdk for node",
|
||||||
"source": "src/index.ts",
|
"source": "src/index.ts",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
@@ -81,6 +81,6 @@
|
|||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"electron": ">=12.0.0",
|
"electron": ">=12.0.0",
|
||||||
"open-im-sdk-wasm": "^3.8.0-rc.6"
|
"open-im-sdk-wasm": "^3.8.0-rc.8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ export enum NativeEvent {
|
|||||||
ROOM_PARTICIPANT_DISCONNECTED,
|
ROOM_PARTICIPANT_DISCONNECTED,
|
||||||
STREAM_CHANGE,
|
STREAM_CHANGE,
|
||||||
RECEIVE_CUSTOM_SIGNAL,
|
RECEIVE_CUSTOM_SIGNAL,
|
||||||
|
ON_PROGRESS,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const eventMapping: Record<NativeEvent, CbEvents> = {
|
export const eventMapping: Record<NativeEvent, CbEvents> = {
|
||||||
@@ -150,4 +151,5 @@ export const eventMapping: Record<NativeEvent, CbEvents> = {
|
|||||||
CbEvents.OnRoomParticipantDisconnected,
|
CbEvents.OnRoomParticipantDisconnected,
|
||||||
[NativeEvent.STREAM_CHANGE]: CbEvents.OnStreamChange,
|
[NativeEvent.STREAM_CHANGE]: CbEvents.OnStreamChange,
|
||||||
[NativeEvent.RECEIVE_CUSTOM_SIGNAL]: CbEvents.OnReceiveCustomSignal,
|
[NativeEvent.RECEIVE_CUSTOM_SIGNAL]: CbEvents.OnReceiveCustomSignal,
|
||||||
|
[NativeEvent.ON_PROGRESS]: CbEvents.OnUploadLogsProgress,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import koffi from 'koffi';
|
|||||||
import { v4 as uuidV4 } from 'uuid';
|
import { v4 as uuidV4 } from 'uuid';
|
||||||
import type { LibOpenIMSDK } from 'libOpenIMSDK';
|
import type { LibOpenIMSDK } from 'libOpenIMSDK';
|
||||||
import { UserModuleApi, setupUserModule } from './modules/user';
|
import { UserModuleApi, setupUserModule } from './modules/user';
|
||||||
import { InitConfig, LoginParams } from '@/types/params';
|
import { InitConfig, LoginParams, UploadLogsParams } from '@/types/params';
|
||||||
import { BaseResponse, EmitProxy } from '@/types/entity';
|
import { BaseResponse, EmitProxy } from '@/types/entity';
|
||||||
import { ErrorCode } from '@/constant/api';
|
import { ErrorCode } from '@/constant/api';
|
||||||
import { NativeEvent, eventMapping } from '@/constant/callback';
|
import { NativeEvent, eventMapping } from '@/constant/callback';
|
||||||
@@ -855,6 +855,12 @@ class OpenIMSDK
|
|||||||
'void',
|
'void',
|
||||||
['baseCallback *', 'str', 'str', 'listenerCallback *']
|
['baseCallback *', 'str', 'str', 'listenerCallback *']
|
||||||
);
|
);
|
||||||
|
this.libOpenIMSDK.upload_logs = this.lib.func(
|
||||||
|
'__stdcall',
|
||||||
|
'upload_logs',
|
||||||
|
'void',
|
||||||
|
['baseCallback *', 'str', 'int', 'str', 'listenerCallback *']
|
||||||
|
);
|
||||||
|
|
||||||
// advance
|
// advance
|
||||||
if (this.enterprise) {
|
if (this.enterprise) {
|
||||||
@@ -1222,6 +1228,17 @@ class OpenIMSDK
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
uploadLogs = (params: UploadLogsParams, opid = uuidV4()) =>
|
||||||
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
|
this.libOpenIMSDK.upload_logs(
|
||||||
|
this.baseCallbackWrap(resolve, reject),
|
||||||
|
opid,
|
||||||
|
params.line,
|
||||||
|
params.ex || '',
|
||||||
|
this.listenerCallback
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
// implements user api
|
// implements user api
|
||||||
getSelfUserInfo!: UserModuleApi['getSelfUserInfo'];
|
getSelfUserInfo!: UserModuleApi['getSelfUserInfo'];
|
||||||
setSelfInfo!: UserModuleApi['setSelfInfo'];
|
setSelfInfo!: UserModuleApi['setSelfInfo'];
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
FileMsgByPathParams,
|
FileMsgByPathParams,
|
||||||
SoundMsgByPathParams,
|
SoundMsgByPathParams,
|
||||||
VideoMsgByPathParams,
|
VideoMsgByPathParams,
|
||||||
|
UploadLogsParams,
|
||||||
} from './types/params';
|
} from './types/params';
|
||||||
|
|
||||||
type EmitterEvents = {
|
type EmitterEvents = {
|
||||||
@@ -83,6 +84,13 @@ type IMSDKInterface = Omit<WasmInterface, 'login'> & {
|
|||||||
params: FileMsgByPathParams,
|
params: FileMsgByPathParams,
|
||||||
opid?: string
|
opid?: string
|
||||||
) => Promise<WsResponse<MessageItem>>;
|
) => Promise<WsResponse<MessageItem>>;
|
||||||
|
/**
|
||||||
|
* @access only for electron
|
||||||
|
*/
|
||||||
|
uploadLogs: (
|
||||||
|
params: UploadLogsParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<WsResponse<string>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ElectronInvoke = (method: string, ...args: any[]) => Promise<WsResponse>;
|
type ElectronInvoke = (method: string, ...args: any[]) => Promise<WsResponse>;
|
||||||
|
|||||||
7
src/types/libOpenIMSDK.d.ts
vendored
7
src/types/libOpenIMSDK.d.ts
vendored
@@ -745,6 +745,13 @@ declare module 'libOpenIMSDK' {
|
|||||||
cFileInfo: string,
|
cFileInfo: string,
|
||||||
pCallback: CB_I_S
|
pCallback: CB_I_S
|
||||||
): void;
|
): void;
|
||||||
|
upload_logs(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
line: number,
|
||||||
|
ex: string,
|
||||||
|
pCallback: CB_I_S
|
||||||
|
): void;
|
||||||
}
|
}
|
||||||
const lib: LibOpenIMSDK;
|
const lib: LibOpenIMSDK;
|
||||||
export default lib;
|
export default lib;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export interface InitConfig {
|
|||||||
logFilePath?: string;
|
logFilePath?: string;
|
||||||
isLogStandardOutput?: boolean;
|
isLogStandardOutput?: boolean;
|
||||||
isExternalExtensions?: boolean;
|
isExternalExtensions?: boolean;
|
||||||
|
systemType: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LoginParams {
|
export interface LoginParams {
|
||||||
@@ -31,3 +32,8 @@ export type FileMsgByPathParams = {
|
|||||||
filePath: string;
|
filePath: string;
|
||||||
fileName: string;
|
fileName: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type UploadLogsParams = {
|
||||||
|
line: number;
|
||||||
|
ex?: string;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user