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",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@openim/electron-client-sdk",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"koffi": "^2.8.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@openim/electron-client-sdk",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"description": "open im sdk for node",
|
||||
"source": "src/index.ts",
|
||||
"main": "lib/index.js",
|
||||
@@ -81,6 +81,6 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"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,
|
||||
STREAM_CHANGE,
|
||||
RECEIVE_CUSTOM_SIGNAL,
|
||||
ON_PROGRESS,
|
||||
}
|
||||
|
||||
export const eventMapping: Record<NativeEvent, CbEvents> = {
|
||||
@@ -150,4 +151,5 @@ export const eventMapping: Record<NativeEvent, CbEvents> = {
|
||||
CbEvents.OnRoomParticipantDisconnected,
|
||||
[NativeEvent.STREAM_CHANGE]: CbEvents.OnStreamChange,
|
||||
[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 type { LibOpenIMSDK } from 'libOpenIMSDK';
|
||||
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 { ErrorCode } from '@/constant/api';
|
||||
import { NativeEvent, eventMapping } from '@/constant/callback';
|
||||
@@ -855,6 +855,12 @@ class OpenIMSDK
|
||||
'void',
|
||||
['baseCallback *', 'str', 'str', 'listenerCallback *']
|
||||
);
|
||||
this.libOpenIMSDK.upload_logs = this.lib.func(
|
||||
'__stdcall',
|
||||
'upload_logs',
|
||||
'void',
|
||||
['baseCallback *', 'str', 'int', 'str', 'listenerCallback *']
|
||||
);
|
||||
|
||||
// advance
|
||||
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
|
||||
getSelfUserInfo!: UserModuleApi['getSelfUserInfo'];
|
||||
setSelfInfo!: UserModuleApi['setSelfInfo'];
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
FileMsgByPathParams,
|
||||
SoundMsgByPathParams,
|
||||
VideoMsgByPathParams,
|
||||
UploadLogsParams,
|
||||
} from './types/params';
|
||||
|
||||
type EmitterEvents = {
|
||||
@@ -83,6 +84,13 @@ type IMSDKInterface = Omit<WasmInterface, 'login'> & {
|
||||
params: FileMsgByPathParams,
|
||||
opid?: string
|
||||
) => Promise<WsResponse<MessageItem>>;
|
||||
/**
|
||||
* @access only for electron
|
||||
*/
|
||||
uploadLogs: (
|
||||
params: UploadLogsParams,
|
||||
opid?: string
|
||||
) => Promise<WsResponse<string>>;
|
||||
};
|
||||
|
||||
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,
|
||||
pCallback: CB_I_S
|
||||
): void;
|
||||
upload_logs(
|
||||
cCallback: CB_S_I_S_S,
|
||||
operationID: string,
|
||||
line: number,
|
||||
ex: string,
|
||||
pCallback: CB_I_S
|
||||
): void;
|
||||
}
|
||||
const lib: LibOpenIMSDK;
|
||||
export default lib;
|
||||
|
||||
@@ -8,6 +8,7 @@ export interface InitConfig {
|
||||
logFilePath?: string;
|
||||
isLogStandardOutput?: boolean;
|
||||
isExternalExtensions?: boolean;
|
||||
systemType: string;
|
||||
}
|
||||
|
||||
export interface LoginParams {
|
||||
@@ -31,3 +32,8 @@ export type FileMsgByPathParams = {
|
||||
filePath: string;
|
||||
fileName: string;
|
||||
};
|
||||
|
||||
export type UploadLogsParams = {
|
||||
line: number;
|
||||
ex?: string;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user