feat(api): add definitions

This commit is contained in:
Il Harper 2024-03-05 23:26:34 +08:00
parent 2d85d4ee22
commit 874b15c5af
No known key found for this signature in database
GPG Key ID: 4B71FCA698E7E8EC
7 changed files with 353 additions and 0 deletions

View File

@ -0,0 +1,27 @@
import { define } from '../invoke'
export const approvalFriendRequest = define<
unknown,
[
{
approvalInfo: {
friendUid: string
reqTime: string // '1700000000'
accept: boolean
}
},
]
>('ns-ntApi-2', 'nodeIKernelBuddyService/approvalFriendRequest')
export const delBuddy = define<
unknown,
[
{
delInfo: {
friendUid: string
tempBlock: boolean
tempBothDel: boolean
}
},
]
>('ns-ntApi-2', 'nodeIKernelBuddyService/delBuddy')

View File

@ -0,0 +1,28 @@
import type { PathLike } from 'node:fs'
import { define } from '../invoke'
import { qqVersion } from '../utils'
const fsApiName = qqVersion > 19000 ? 'ns-FsApi-2' : 'ns-fsApi-2'
export const getFileMd5 = define<string, [PathLike]>(fsApiName, 'getFileMd5')
export const getImageSizeFromPath = define<
{
width: number
height: number
type: string // png
mime: string // image/png
wUnits: string // px
hUnits: string // px
},
[PathLike]
>(fsApiName, 'getImageSizeFromPath')
export const getFileSize = define<number, [PathLike]>(fsApiName, 'getFileSize')
export const getFileType = define<
{
mime: string
},
[PathLike]
>(fsApiName, 'getFileType')

View File

@ -0,0 +1,158 @@
import type { Result } from '@chronocat/red'
import { define } from '../invoke'
export type SceneId = unknown
export const getMemberInfo = define<
unknown,
[
{
forceUpdate: boolean
groupCode: number
uids: string[]
},
]
>('ns-ntApi-2', 'nodeIKernelGroupService/getMemberInfo')
export const getGroupDetailInfo = define<
Result,
[
{
groupCode: string
source: 4
},
]
>('ns-ntApi-2', 'nodeIKernelGroupService/getGroupDetailInfo')
export const createMemberListScene = define<
SceneId,
[
{
groupCode: number
scene: 'groupMemberList_MainWindow'
},
]
>('ns-ntApi-2', 'nodeIKernelGroupService/createMemberListScene')
export const searchMember = define<
undefined,
[
{
sceneId: SceneId
keyword: string
},
]
>('ns-ntApi-2', 'nodeIKernelGroupService/searchMember')
export const destroyMemberListScene = define<
undefined,
[
{
sceneId: SceneId
},
]
>('ns-ntApi-2', 'nodeIKernelGroupService/destroyMemberListScene')
export interface MemberListResult {
result: {
ids: {
uid: string
index: string
}[]
infos: {
get: (uid: string) =>
| {
uid: string
qid: ''
uin: string
nick: string
remark: string
cardType: 0
cardName: string
role: number
avatarPath: string
shutUpTime: number
isDelete: boolean
isSpecialConcerned: boolean
}
| undefined
}
}
}
export const getNextMemberList = define<
MemberListResult,
[
{
sceneId: SceneId
lastId: undefined
num: number
},
]
>('ns-ntApi-2', 'nodeIKernelGroupService/getNextMemberList')
export const setMemberShutUp = define<
unknown,
[
{
groupCode: string
memList: {
uin?: string
uid?: string
timeStamp: number
}[]
},
]
>('ns-ntApi-2', 'nodeIKernelGroupService/setMemberShutUp')
export const setGroupShutUp = define<
unknown,
[
{
groupCode: string
shutUp: boolean
},
]
>('ns-ntApi-2', 'nodeIKernelGroupService/setGroupShutUp')
export const kickMember = define<
unknown,
[
{
groupCode: string
kickUids: string[]
refuseForever: boolean
kickReason: string
},
]
>('ns-ntApi-2', 'nodeIKernelGroupService/kickMember')
export const quitGroup = define<
{
result: number
errMsg: string
},
[
{
groupCode: string
},
]
>('ns-ntApi-2', 'nodeIKernelGroupService/quitGroup')
export const operateSysNotify = define<
unknown,
[
{
doubt: false
operateMsg: {
operateType: 1
targetMsg: {
seq: ''
type: 1
groupCode: string
postscript: ''
}
}
},
]
>('ns-ntApi-2', 'nodeIKernelGroupService/operateSysNotify')

View File

@ -0,0 +1,114 @@
import type { Peer } from '@chronocat/red'
import type { O } from 'ts-toolbelt'
import { define } from '../invoke'
export const recallMsg = define<
unknown,
[
{
peer: Peer
msgIds: string[]
},
]
>('ns-ntApi-2', 'nodeIKernelMsgService/recallMsg')
export const downloadRichMedia = define<
unknown,
[
{
getReq: {
msgId: string
chatType: number
peerUid: string
elementId: string
thumbSize: number
downloadType: number
}
},
]
>('ns-ntApi-2', 'nodeIKernelMsgService/downloadRichMedia')
export const getMsgsIncludeSelf = define<
object,
[
{
peer: Peer
msgId: string
cnt: number
queryOrder: boolean
},
]
>('ns-ntApi-2', 'nodeIKernelMsgService/getMsgsIncludeSelf')
export const getRichMediaFilePath = define<
string,
[
{
md5HexStr: string
fileName: string
elementType: number
elementSubType: number
thumbSize: number
needCreate: boolean
fileType: number
},
]
>('ns-ntApi-2', 'nodeIKernelMsgService/getRichMediaFilePath')
export const getRichMediaFilePathForGuild = define<
string,
[
{
path_info: {
md5HexStr: string
fileName: string
elementType: number
elementSubType: number
thumbSize: number
needCreate: boolean
fileType: number
downloadType: number
file_uuid: string
}
},
]
>('ns-ntApi-2', 'nodeIKernelMsgService/getRichMediaFilePathForGuild')
export const sendMsg = define<
unknown,
[
{
msgId: '0'
peer: Peer
msgElements: O.Partial<Element, 'deep'>[]
},
]
>('ns-ntApi-2', 'nodeIKernelMsgService/sendMsg')
export const multiForwardMsgWithComment = define<
unknown,
[
{
msgInfos: {
msgId: string
senderShowName: string
}[]
srcContact: Peer
dstContact: Peer
commentElements: []
},
]
>('ns-ntApi-2', 'nodeIKernelMsgService/multiForwardMsgWithComment')
export const getEmojiResourcePath = define<
{
result: 0
errMsg: 'success'
resourcePath: string
},
[
{
type: 0 | 1 | 2 | 3 | 4
},
]
>('ns-ntApi-2', 'nodeIKernelMsgService/getEmojiResourcePath')

View File

@ -0,0 +1,11 @@
import { define } from '../invoke'
export const getBuddyList = define<never, []>(
'ns-NodeStoreApi-2',
'getBuddyList',
)
export const getGroupList = define<never, []>(
'ns-NodeStoreApi-2',
'getGroupList',
)

View File

@ -0,0 +1,11 @@
import { define } from '../invoke'
export const getUserSimpleInfo = define<
unknown,
[
{
force: boolean
uids: string[]
},
]
>('ns-ntApi-2', 'nodeIKernelProfileService/getUserSimpleInfo')

View File

@ -0,0 +1,4 @@
// eslint-disable-next-line import/no-unresolved
import { app } from 'electron'
export const qqVersion = +app.getVersion().split('-')[1]!