@zhin.js/core 1.1.0 → 1.1.3
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/lib/adapter.d.ts +1 -26
- package/lib/adapter.d.ts.map +1 -1
- package/lib/adapter.js +20 -117
- package/lib/adapter.js.map +1 -1
- package/lib/built/adapter-process.d.ts +0 -4
- package/lib/built/adapter-process.d.ts.map +1 -1
- package/lib/built/adapter-process.js +0 -95
- package/lib/built/adapter-process.js.map +1 -1
- package/lib/built/agent-preset.d.ts +2 -0
- package/lib/built/agent-preset.d.ts.map +1 -1
- package/lib/built/agent-preset.js +4 -0
- package/lib/built/agent-preset.js.map +1 -1
- package/lib/built/command.d.ts +4 -0
- package/lib/built/command.d.ts.map +1 -1
- package/lib/built/command.js +6 -0
- package/lib/built/command.js.map +1 -1
- package/lib/built/component.d.ts.map +1 -1
- package/lib/built/component.js +1 -0
- package/lib/built/component.js.map +1 -1
- package/lib/built/dispatcher.d.ts.map +1 -1
- package/lib/built/dispatcher.js +0 -13
- package/lib/built/dispatcher.js.map +1 -1
- package/lib/built/message-filter.d.ts +2 -0
- package/lib/built/message-filter.d.ts.map +1 -1
- package/lib/built/message-filter.js +5 -0
- package/lib/built/message-filter.js.map +1 -1
- package/lib/built/skill.d.ts +11 -0
- package/lib/built/skill.d.ts.map +1 -1
- package/lib/built/skill.js +14 -0
- package/lib/built/skill.js.map +1 -1
- package/lib/built/tool.d.ts +11 -44
- package/lib/built/tool.d.ts.map +1 -1
- package/lib/built/tool.js +14 -353
- package/lib/built/tool.js.map +1 -1
- package/lib/plugin.d.ts +1 -25
- package/lib/plugin.d.ts.map +1 -1
- package/lib/plugin.js +1 -77
- package/lib/plugin.js.map +1 -1
- package/lib/types.d.ts +0 -25
- package/lib/types.d.ts.map +1 -1
- package/package.json +10 -7
- package/CHANGELOG.md +0 -561
- package/REFACTORING_COMPLETE.md +0 -178
- package/REFACTORING_STATUS.md +0 -263
- package/src/adapter.ts +0 -275
- package/src/ai/index.ts +0 -55
- package/src/ai/providers/anthropic.ts +0 -379
- package/src/ai/providers/base.ts +0 -175
- package/src/ai/providers/index.ts +0 -13
- package/src/ai/providers/ollama.ts +0 -302
- package/src/ai/providers/openai.ts +0 -174
- package/src/ai/types.ts +0 -348
- package/src/bot.ts +0 -37
- package/src/built/adapter-process.ts +0 -177
- package/src/built/agent-preset.ts +0 -136
- package/src/built/ai-trigger.ts +0 -259
- package/src/built/command.ts +0 -108
- package/src/built/common-adapter-tools.ts +0 -242
- package/src/built/component.ts +0 -130
- package/src/built/config.ts +0 -335
- package/src/built/cron.ts +0 -156
- package/src/built/database.ts +0 -134
- package/src/built/dispatcher.ts +0 -496
- package/src/built/login-assist.ts +0 -131
- package/src/built/message-filter.ts +0 -390
- package/src/built/permission.ts +0 -151
- package/src/built/schema-feature.ts +0 -190
- package/src/built/skill.ts +0 -221
- package/src/built/tool.ts +0 -948
- package/src/command.ts +0 -87
- package/src/component.ts +0 -565
- package/src/cron.ts +0 -4
- package/src/errors.ts +0 -46
- package/src/feature.ts +0 -7
- package/src/index.ts +0 -53
- package/src/jsx-dev-runtime.ts +0 -2
- package/src/jsx-runtime.ts +0 -12
- package/src/jsx.ts +0 -135
- package/src/message.ts +0 -48
- package/src/models/system-log.ts +0 -20
- package/src/models/user.ts +0 -15
- package/src/notice.ts +0 -98
- package/src/plugin.ts +0 -896
- package/src/prompt.ts +0 -293
- package/src/request.ts +0 -95
- package/src/scheduler/index.ts +0 -19
- package/src/scheduler/scheduler.ts +0 -372
- package/src/scheduler/types.ts +0 -74
- package/src/tool-zod.ts +0 -115
- package/src/types-generator.ts +0 -78
- package/src/types.ts +0 -505
- package/src/utils.ts +0 -227
- package/tests/adapter.test.ts +0 -638
- package/tests/ai/ai-trigger.test.ts +0 -368
- package/tests/ai/providers.integration.test.ts +0 -227
- package/tests/ai/setup.ts +0 -308
- package/tests/ai/tool.test.ts +0 -800
- package/tests/bot.test.ts +0 -151
- package/tests/command.test.ts +0 -737
- package/tests/component-new.test.ts +0 -361
- package/tests/config.test.ts +0 -372
- package/tests/cron.test.ts +0 -82
- package/tests/dispatcher.test.ts +0 -293
- package/tests/errors.test.ts +0 -21
- package/tests/expression-evaluation.test.ts +0 -258
- package/tests/features-builtin.test.ts +0 -191
- package/tests/jsx-runtime.test.ts +0 -45
- package/tests/jsx.test.ts +0 -319
- package/tests/message-filter.test.ts +0 -566
- package/tests/message.test.ts +0 -402
- package/tests/notice.test.ts +0 -198
- package/tests/plugin.test.ts +0 -779
- package/tests/prompt.test.ts +0 -78
- package/tests/redos-protection.test.ts +0 -198
- package/tests/request.test.ts +0 -221
- package/tests/schema.test.ts +0 -248
- package/tests/skill-feature.test.ts +0 -179
- package/tests/test-utils.ts +0 -59
- package/tests/tool-feature.test.ts +0 -254
- package/tests/types.test.ts +0 -162
- package/tests/utils.test.ts +0 -135
- package/tsconfig.json +0 -24
package/src/index.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// Core exports
|
|
2
|
-
export * from './feature.js'
|
|
3
|
-
export * from './bot.js'
|
|
4
|
-
export * from './plugin.js'
|
|
5
|
-
export * from './command.js'
|
|
6
|
-
export * from './component.js'
|
|
7
|
-
export * from './adapter.js'
|
|
8
|
-
export * from './message.js'
|
|
9
|
-
export * from './notice.js'
|
|
10
|
-
export * from './request.js'
|
|
11
|
-
export * from './prompt.js'
|
|
12
|
-
// Models
|
|
13
|
-
export * from './models/system-log.js'
|
|
14
|
-
export * from './models/user.js'
|
|
15
|
-
// Built-in Contexts
|
|
16
|
-
export * from './built/config.js'
|
|
17
|
-
export * from './built/command.js'
|
|
18
|
-
export * from './built/cron.js'
|
|
19
|
-
export * from './built/permission.js'
|
|
20
|
-
export * from './built/adapter-process.js'
|
|
21
|
-
export * from './built/component.js'
|
|
22
|
-
export * from './built/database.js'
|
|
23
|
-
export * from './built/message-filter.js'
|
|
24
|
-
// Tool Service (纯工具,无副作用)
|
|
25
|
-
export * from './built/tool.js'
|
|
26
|
-
// AI Trigger Service (纯工具,无副作用)
|
|
27
|
-
export * from './built/ai-trigger.js'
|
|
28
|
-
// MessageDispatcher (消息调度器)
|
|
29
|
-
export * from './built/dispatcher.js'
|
|
30
|
-
// Skill 系统 (AI 能力描述)
|
|
31
|
-
export * from './built/skill.js'
|
|
32
|
-
// Agent 预设 (插件声明的专长 Agent)
|
|
33
|
-
export * from './built/agent-preset.js'
|
|
34
|
-
// Schema 注册表 (插件配置声明)
|
|
35
|
-
export * from './built/schema-feature.js'
|
|
36
|
-
// Common adapter tool factories (shared across adapters)
|
|
37
|
-
export * from './built/common-adapter-tools.js'
|
|
38
|
-
// Login assist (producer-consumer for QR / SMS / slider etc.)
|
|
39
|
-
export * from './built/login-assist.js'
|
|
40
|
-
// AI 模块 (原 @zhin.js/ai,已合并至 core)
|
|
41
|
-
export * from './ai/index.js'
|
|
42
|
-
|
|
43
|
-
export * from './types.js'
|
|
44
|
-
export * from './utils.js'
|
|
45
|
-
export * from './errors.js' // 导出错误处理系统
|
|
46
|
-
export * from './cron.js'
|
|
47
|
-
export * from './scheduler/index.js'
|
|
48
|
-
export * from '@zhin.js/database'
|
|
49
|
-
export * from '@zhin.js/logger'
|
|
50
|
-
// 只导出 Schema 类,避免与 utils.js 的 isEmpty 冲突
|
|
51
|
-
export { Schema } from '@zhin.js/schema'
|
|
52
|
-
// Re-export PluginLike from kernel (generic plugin interface)
|
|
53
|
-
export type { PluginLike } from '@zhin.js/kernel'
|
package/src/jsx-dev-runtime.ts
DELETED
package/src/jsx-runtime.ts
DELETED
package/src/jsx.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { SendContent,MessageElement } from './types.js';
|
|
2
|
-
import { MessageComponent } from './message.js';
|
|
3
|
-
import { Component, ComponentContext } from './component.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// JSX 子元素类型
|
|
7
|
-
export type JSXChildren = MessageElement | string | number | boolean | null | undefined | JSXChildren[];
|
|
8
|
-
|
|
9
|
-
// JSX 元素类型
|
|
10
|
-
export type JSXElementType = string | Component<any> ;
|
|
11
|
-
|
|
12
|
-
// JSX 属性类型
|
|
13
|
-
export type JSXProps = Record<string, any> & {
|
|
14
|
-
children?: JSXChildren;
|
|
15
|
-
};
|
|
16
|
-
export {Fragment} from './component.js'
|
|
17
|
-
// 全局 JSX 命名空间
|
|
18
|
-
declare global {
|
|
19
|
-
namespace JSX {
|
|
20
|
-
// 支持同步和异步组件 - Element 可以是 MessageComponent
|
|
21
|
-
// TypeScript 会在编译时允许异步组件,运行时会自动 await
|
|
22
|
-
type Element = SendContent | Promise<SendContent>
|
|
23
|
-
interface ElementClass {
|
|
24
|
-
render(props: any, context?: ComponentContext): Element;
|
|
25
|
-
}
|
|
26
|
-
interface ElementAttributesProperty {
|
|
27
|
-
data: {};
|
|
28
|
-
}
|
|
29
|
-
interface ElementChildrenAttribute {
|
|
30
|
-
children: {};
|
|
31
|
-
}
|
|
32
|
-
interface IntrinsicElements {
|
|
33
|
-
[elemName: string]: any;
|
|
34
|
-
}
|
|
35
|
-
// 添加对异步组件的支持
|
|
36
|
-
interface IntrinsicAttributes {
|
|
37
|
-
key?: string | number;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// JSX 运行时函数 - 支持异步组件
|
|
43
|
-
export function jsx(type: JSXElementType, data: JSXProps): MessageComponent<any> {
|
|
44
|
-
return {
|
|
45
|
-
type,
|
|
46
|
-
data,
|
|
47
|
-
} as MessageComponent<any>;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// JSX Fragment 支持
|
|
51
|
-
export function jsxs(type: JSXElementType, props: JSXProps): MessageElement {
|
|
52
|
-
return jsx(type, props);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// JSX 渲染函数
|
|
57
|
-
export async function renderJSX(element: MessageComponent<any>, context?: ComponentContext): Promise<SendContent> {
|
|
58
|
-
try {
|
|
59
|
-
if (typeof element.type === 'string') {
|
|
60
|
-
if (element.type === 'Fragment') {
|
|
61
|
-
return await renderChildren(element.data.children, context);
|
|
62
|
-
}
|
|
63
|
-
// 其他内置组件处理
|
|
64
|
-
return await renderChildren(element.data.children, context);
|
|
65
|
-
} else if (typeof element.type === 'function') {
|
|
66
|
-
// 函数组件
|
|
67
|
-
const component = element.type as Component<any>;
|
|
68
|
-
const result = await component(element.data, context || {} as ComponentContext);
|
|
69
|
-
|
|
70
|
-
// 如果组件返回 Promise,自动 await
|
|
71
|
-
if (result && typeof result === 'object' && 'then' in result) {
|
|
72
|
-
return await result;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return result;
|
|
76
|
-
} else {
|
|
77
|
-
// 类组件或其他类型
|
|
78
|
-
const component = element.type as Component<any>;
|
|
79
|
-
const result = await component(element.data, context || {} as ComponentContext);
|
|
80
|
-
|
|
81
|
-
// 如果组件返回 Promise,自动 await
|
|
82
|
-
if (result && typeof result === 'object' && 'then' in result) {
|
|
83
|
-
return await result;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return result;
|
|
87
|
-
}
|
|
88
|
-
} catch (error) {
|
|
89
|
-
// 渲染错误时返回错误信息
|
|
90
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
91
|
-
return `❌ 组件渲染失败: ${errorMessage}`;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// 渲染子元素
|
|
96
|
-
async function renderChildren(children: JSXChildren, context?: ComponentContext): Promise<SendContent> {
|
|
97
|
-
if (children == null) return '';
|
|
98
|
-
if (typeof children === 'string' || typeof children === 'number' || typeof children === 'boolean') {
|
|
99
|
-
return String(children);
|
|
100
|
-
}
|
|
101
|
-
if (Array.isArray(children)) {
|
|
102
|
-
const results = await Promise.all(children.map(async child => {
|
|
103
|
-
if (typeof child === 'string' || typeof child === 'number' || typeof child === 'boolean') {
|
|
104
|
-
return String(child);
|
|
105
|
-
}
|
|
106
|
-
if (child && typeof child === 'object' && 'type' in child) {
|
|
107
|
-
return await renderJSX(child as MessageComponent<any>, context);
|
|
108
|
-
}
|
|
109
|
-
// 如果子元素是 Promise,自动 await
|
|
110
|
-
if (child && typeof child === 'object' && 'then' in child) {
|
|
111
|
-
try {
|
|
112
|
-
return await child;
|
|
113
|
-
} catch (error) {
|
|
114
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
115
|
-
return `❌ 组件渲染失败: ${errorMessage}`;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return '';
|
|
119
|
-
}));
|
|
120
|
-
return results.join('');
|
|
121
|
-
}
|
|
122
|
-
if (children && typeof children === 'object' && 'type' in children) {
|
|
123
|
-
return await renderJSX(children as MessageComponent<any>, context);
|
|
124
|
-
}
|
|
125
|
-
// 如果子元素是 Promise,自动 await
|
|
126
|
-
if (children && typeof children === 'object' && 'then' in children) {
|
|
127
|
-
try {
|
|
128
|
-
return await children;
|
|
129
|
-
} catch (error) {
|
|
130
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
131
|
-
return `❌ 组件渲染失败: ${errorMessage}`;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return '';
|
|
135
|
-
}
|
package/src/message.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import {MessageElement, MessageSender, SendContent} from "./types";
|
|
2
|
-
import { Component } from "./component.js";
|
|
3
|
-
import { Adapters } from "./adapter.js";
|
|
4
|
-
/**
|
|
5
|
-
* 消息组件类型:用于自定义消息结构
|
|
6
|
-
*/
|
|
7
|
-
export type MessageComponent<T extends object>={
|
|
8
|
-
type:Component<T&{children?:SendContent|Promise<SendContent>}>
|
|
9
|
-
data:T
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 消息频道信息
|
|
13
|
-
*/
|
|
14
|
-
export interface MessageChannel{
|
|
15
|
-
id: string;
|
|
16
|
-
type: MessageType;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* 消息类型枚举
|
|
20
|
-
*/
|
|
21
|
-
export type MessageType = 'group' | 'private' | 'channel'
|
|
22
|
-
/**
|
|
23
|
-
* 消息基础结构
|
|
24
|
-
*/
|
|
25
|
-
export interface MessageBase {
|
|
26
|
-
$id: string;
|
|
27
|
-
$adapter:keyof Adapters
|
|
28
|
-
$bot:string
|
|
29
|
-
$content: MessageElement[];
|
|
30
|
-
$sender: MessageSender;
|
|
31
|
-
$reply(content:SendContent,quote?:boolean|string):Promise<string>
|
|
32
|
-
$recall():Promise<void>
|
|
33
|
-
$channel: MessageChannel;
|
|
34
|
-
$timestamp: number;
|
|
35
|
-
$raw: string;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* 完整消息类型,支持扩展
|
|
39
|
-
*/
|
|
40
|
-
export type Message<T extends object={}>=MessageBase&T;
|
|
41
|
-
export namespace Message{
|
|
42
|
-
/**
|
|
43
|
-
* 工具方法:合并自定义字段与基础消息结构
|
|
44
|
-
*/
|
|
45
|
-
export function from<T extends object>(input:T,format:MessageBase):Message<T>{
|
|
46
|
-
return Object.assign(input,format)
|
|
47
|
-
}
|
|
48
|
-
}
|
package/src/models/system-log.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Definition } from '@zhin.js/database'
|
|
2
|
-
|
|
3
|
-
export interface SystemLog {
|
|
4
|
-
id?: number
|
|
5
|
-
level: string
|
|
6
|
-
name: string
|
|
7
|
-
message: string
|
|
8
|
-
source: string
|
|
9
|
-
timestamp: Date
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const SystemLogDefinition:Definition<SystemLog>={
|
|
13
|
-
id: { type: 'integer', autoIncrement: true, primary: true },
|
|
14
|
-
level: { type: 'text', nullable: false },
|
|
15
|
-
name: { type: 'text', nullable: false },
|
|
16
|
-
message: { type: 'text', nullable: false },
|
|
17
|
-
source: { type: 'text', nullable: false },
|
|
18
|
-
timestamp: { type: 'date', nullable: false }
|
|
19
|
-
}
|
|
20
|
-
|
package/src/models/user.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Definition } from '@zhin.js/database'
|
|
2
|
-
export interface User{
|
|
3
|
-
id:string
|
|
4
|
-
name?:string
|
|
5
|
-
password?:string
|
|
6
|
-
third_part:string[];
|
|
7
|
-
permissions?:string[]
|
|
8
|
-
}
|
|
9
|
-
export const UserDefinition:Definition<User>={
|
|
10
|
-
id:{type:"text",nullable:false},
|
|
11
|
-
name:{type:'text',nullable:true},
|
|
12
|
-
password:{type:'text',nullable:true},
|
|
13
|
-
third_part:{type:'json',default:[]},
|
|
14
|
-
permissions:{type:'json',default:[]}
|
|
15
|
-
}
|
package/src/notice.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { Adapters } from './adapter.js';
|
|
2
|
-
import type { MessageSender } from './types.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 通知类型枚举
|
|
6
|
-
*
|
|
7
|
-
* 常见 IM 通知事件分类:
|
|
8
|
-
* - group_member_increase: 群成员增加(入群)
|
|
9
|
-
* - group_member_decrease: 群成员减少(退群/被踢)
|
|
10
|
-
* - group_admin_change: 群管理员变动
|
|
11
|
-
* - group_ban: 群禁言
|
|
12
|
-
* - group_recall: 群消息撤回
|
|
13
|
-
* - friend_recall: 好友消息撤回
|
|
14
|
-
* - friend_add: 新增好友
|
|
15
|
-
* - group_poke: 群戳一戳
|
|
16
|
-
* - friend_poke: 好友戳一戳
|
|
17
|
-
* - group_transfer: 群转让
|
|
18
|
-
*
|
|
19
|
-
* 适配器可自行扩展更多子类型
|
|
20
|
-
*/
|
|
21
|
-
export type NoticeType =
|
|
22
|
-
| 'group_member_increase'
|
|
23
|
-
| 'group_member_decrease'
|
|
24
|
-
| 'group_admin_change'
|
|
25
|
-
| 'group_ban'
|
|
26
|
-
| 'group_recall'
|
|
27
|
-
| 'friend_recall'
|
|
28
|
-
| 'friend_add'
|
|
29
|
-
| 'group_poke'
|
|
30
|
-
| 'friend_poke'
|
|
31
|
-
| 'group_transfer'
|
|
32
|
-
| (string & {}); // 允许适配器扩展自定义类型
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* 通知频道信息
|
|
36
|
-
*/
|
|
37
|
-
export interface NoticeChannel {
|
|
38
|
-
id: string;
|
|
39
|
-
type: 'group' | 'private' | 'channel';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* 通知基础结构
|
|
44
|
-
*
|
|
45
|
-
* 与 MessageBase 同构设计,所有通知共享以下字段。
|
|
46
|
-
* 适配器通过 `Notice.from(raw, base)` 合并平台原始数据和标准字段。
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* // 适配器中格式化通知
|
|
51
|
-
* const notice = Notice.from(rawEvent, {
|
|
52
|
-
* $id: rawEvent.id,
|
|
53
|
-
* $adapter: 'icqq',
|
|
54
|
-
* $bot: botName,
|
|
55
|
-
* $type: 'group_member_decrease',
|
|
56
|
-
* $subType: 'kick',
|
|
57
|
-
* $channel: { id: groupId, type: 'group' },
|
|
58
|
-
* $operator: { id: operatorId, name: '管理员' },
|
|
59
|
-
* $target: { id: userId, name: '被踢者' },
|
|
60
|
-
* $timestamp: Date.now(),
|
|
61
|
-
* });
|
|
62
|
-
* this.adapter.emit('notice.receive', notice);
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
export interface NoticeBase {
|
|
66
|
-
/** 通知唯一 ID(平台提供或自生成) */
|
|
67
|
-
$id: string;
|
|
68
|
-
/** 适配器名称 */
|
|
69
|
-
$adapter: keyof Adapters;
|
|
70
|
-
/** Bot 名称 */
|
|
71
|
-
$bot: string;
|
|
72
|
-
/** 通知类型 */
|
|
73
|
-
$type: NoticeType;
|
|
74
|
-
/** 通知子类型(如 leave/kick、set/unset) */
|
|
75
|
-
$subType?: string;
|
|
76
|
-
/** 通知发生的频道/群/会话 */
|
|
77
|
-
$channel: NoticeChannel;
|
|
78
|
-
/** 操作者信息(如管理员) */
|
|
79
|
-
$operator?: MessageSender;
|
|
80
|
-
/** 被操作目标信息(如被踢的成员) */
|
|
81
|
-
$target?: MessageSender;
|
|
82
|
-
/** 通知时间戳 */
|
|
83
|
-
$timestamp: number;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* 完整通知类型,支持平台原始数据扩展
|
|
88
|
-
*/
|
|
89
|
-
export type Notice<T extends object = {}> = NoticeBase & T;
|
|
90
|
-
|
|
91
|
-
export namespace Notice {
|
|
92
|
-
/**
|
|
93
|
-
* 工具方法:合并自定义字段与基础通知结构
|
|
94
|
-
*/
|
|
95
|
-
export function from<T extends object>(input: T, format: NoticeBase): Notice<T> {
|
|
96
|
-
return Object.assign(input, format);
|
|
97
|
-
}
|
|
98
|
-
}
|