@saltify/milky-types 1.0.0-draft.1 → 1.0.0-draft.10
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/index.d.ts +3037 -0
- package/dist/index.js +1076 -0
- package/dist/index.js.map +1 -0
- package/package.json +10 -10
- package/src/api/file.ts +0 -110
- package/src/api/friend.ts +0 -40
- package/src/api/group.ts +0 -160
- package/src/api/index.ts +0 -5
- package/src/api/message.ts +0 -94
- package/src/api/system.ts +0 -125
- package/src/common.ts +0 -134
- package/src/constants.ts +0 -1
- package/src/event.ts +0 -279
- package/src/index.ts +0 -5
- package/src/message.ts +0 -236
- package/src/scalar.ts +0 -6
package/src/message.ts
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { ZInt32, ZInt64, ZString } from './scalar';
|
|
3
|
-
import { FriendEntity, GroupEntity, GroupMemberEntity } from './common';
|
|
4
|
-
|
|
5
|
-
export const SharedSegment = z.object({
|
|
6
|
-
type: ZString.describe('消息段类型'),
|
|
7
|
-
}).describe('共享消息段基础');
|
|
8
|
-
|
|
9
|
-
export const IncomingResourceSegmentBase = z.object({
|
|
10
|
-
resource_id: ZString.describe('资源 ID'),
|
|
11
|
-
temp_url: ZString.describe('临时 URL'),
|
|
12
|
-
}).describe('接收资源消息段基础');
|
|
13
|
-
|
|
14
|
-
export const OutgoingResourceSegmentBase = z.object({
|
|
15
|
-
uri: ZString.describe('文件 URI,支持 `file://` `http(s)://` `base64://` 三种格式'),
|
|
16
|
-
}).describe('发送资源消息段基础');
|
|
17
|
-
|
|
18
|
-
export const IncomingSegment = z.discriminatedUnion('type', [
|
|
19
|
-
z.object({
|
|
20
|
-
type: z.literal('text'),
|
|
21
|
-
data: z.object({
|
|
22
|
-
text: ZString.describe('文本内容'),
|
|
23
|
-
}).describe('文本消息段'),
|
|
24
|
-
}).describe('文本消息段'),
|
|
25
|
-
|
|
26
|
-
z.object({
|
|
27
|
-
type: z.literal('mention'),
|
|
28
|
-
data: z.object({
|
|
29
|
-
user_id: ZInt64.describe('提及的 QQ 号'),
|
|
30
|
-
}).describe('提及消息段'),
|
|
31
|
-
}).describe('提及消息段'),
|
|
32
|
-
|
|
33
|
-
z.object({
|
|
34
|
-
type: z.literal('mention_all'),
|
|
35
|
-
data: z.object({}).describe('提及全体消息段'),
|
|
36
|
-
}).describe('提及全体消息段'),
|
|
37
|
-
|
|
38
|
-
z.object({
|
|
39
|
-
type: z.literal('face'),
|
|
40
|
-
data: z.object({
|
|
41
|
-
face_id: ZString.describe('表情 ID'),
|
|
42
|
-
}).describe('表情消息段'),
|
|
43
|
-
}).describe('表情消息段'),
|
|
44
|
-
|
|
45
|
-
z.object({
|
|
46
|
-
type: z.literal('reply'),
|
|
47
|
-
data: z.object({
|
|
48
|
-
message_seq: ZInt64.describe('被引用的消息序列号'),
|
|
49
|
-
}).describe('回复消息段'),
|
|
50
|
-
}).describe('回复消息段'),
|
|
51
|
-
|
|
52
|
-
z.object({
|
|
53
|
-
type: z.literal('image'),
|
|
54
|
-
data: IncomingResourceSegmentBase.extend({
|
|
55
|
-
width: ZInt32.describe('图片宽度'),
|
|
56
|
-
height: ZInt32.describe('图片高度'),
|
|
57
|
-
summary: ZString.describe('图片预览文本'),
|
|
58
|
-
sub_type: z.enum(['normal', 'sticker']).describe('图片类型'),
|
|
59
|
-
}).describe('图片消息段'),
|
|
60
|
-
}).describe('图片消息段'),
|
|
61
|
-
|
|
62
|
-
z.object({
|
|
63
|
-
type: z.literal('record'),
|
|
64
|
-
data: IncomingResourceSegmentBase.extend({
|
|
65
|
-
duration: ZInt32.describe('语音时长(秒)'),
|
|
66
|
-
}).describe('语音消息段'),
|
|
67
|
-
}).describe('语音消息段'),
|
|
68
|
-
|
|
69
|
-
z.object({
|
|
70
|
-
type: z.literal('video'),
|
|
71
|
-
data: IncomingResourceSegmentBase.extend({
|
|
72
|
-
width: ZInt32.describe('视频宽度'),
|
|
73
|
-
height: ZInt32.describe('视频高度'),
|
|
74
|
-
duration: ZInt32.describe('视频时长(秒)'),
|
|
75
|
-
}).describe('视频消息段'),
|
|
76
|
-
}).describe('视频消息段'),
|
|
77
|
-
|
|
78
|
-
z.object({
|
|
79
|
-
type: z.literal('forward'),
|
|
80
|
-
data: z.object({
|
|
81
|
-
forward_id: ZString.describe('合并转发 ID'),
|
|
82
|
-
}).describe('合并转发消息段'),
|
|
83
|
-
}).describe('合并转发消息段'),
|
|
84
|
-
|
|
85
|
-
z.object({
|
|
86
|
-
type: z.literal('market_face'),
|
|
87
|
-
data: z.object({
|
|
88
|
-
url: ZString.describe('市场表情 URL'),
|
|
89
|
-
}).describe('市场表情消息段'),
|
|
90
|
-
}).describe('市场表情消息段'),
|
|
91
|
-
|
|
92
|
-
z.object({
|
|
93
|
-
type: z.literal('light_app'),
|
|
94
|
-
data: z.object({
|
|
95
|
-
app_name: ZString.describe('小程序名称'),
|
|
96
|
-
json_payload: ZString.describe('小程序 JSON 数据'),
|
|
97
|
-
}).describe('小程序消息段'),
|
|
98
|
-
}).describe('小程序消息段'),
|
|
99
|
-
|
|
100
|
-
z.object({
|
|
101
|
-
type: z.literal('xml'),
|
|
102
|
-
data: z.object({
|
|
103
|
-
service_id: ZInt32.describe('服务 ID'),
|
|
104
|
-
xml_payload: ZString.describe('XML 数据'),
|
|
105
|
-
}).describe('XML 消息段'),
|
|
106
|
-
}).describe('XML 消息段'),
|
|
107
|
-
]).describe('接收消息段');
|
|
108
|
-
|
|
109
|
-
export const IncomingForwardedMessage = z.object({
|
|
110
|
-
sender_name: ZString.describe('发送者名称'),
|
|
111
|
-
avatar_url: ZString.describe('发送者头像 URL'),
|
|
112
|
-
time: ZInt64.describe('消息 Unix 时间戳(秒)'),
|
|
113
|
-
segments: z.array(z.lazy(() => IncomingSegment)).describe('消息段列表'),
|
|
114
|
-
}).describe('接收转发消息');
|
|
115
|
-
|
|
116
|
-
export const OutgoingSegment = z.discriminatedUnion('type', [
|
|
117
|
-
z.object({
|
|
118
|
-
type: z.literal('text'),
|
|
119
|
-
data: z.object({
|
|
120
|
-
text: ZString.describe('文本内容'),
|
|
121
|
-
}).describe('文本消息段'),
|
|
122
|
-
}).describe('文本消息段'),
|
|
123
|
-
|
|
124
|
-
z.object({
|
|
125
|
-
type: z.literal('mention'),
|
|
126
|
-
data: z.object({
|
|
127
|
-
user_id: ZInt64.describe('提及的 QQ 号'),
|
|
128
|
-
}).describe('提及消息段'),
|
|
129
|
-
}).describe('提及消息段'),
|
|
130
|
-
|
|
131
|
-
z.object({
|
|
132
|
-
type: z.literal('mention_all'),
|
|
133
|
-
data: z.object({}).describe('提及全体消息段'),
|
|
134
|
-
}).describe('提及全体消息段'),
|
|
135
|
-
|
|
136
|
-
z.object({
|
|
137
|
-
type: z.literal('face'),
|
|
138
|
-
data: z.object({
|
|
139
|
-
face_id: ZString.describe('表情 ID'),
|
|
140
|
-
}).describe('表情消息段'),
|
|
141
|
-
}).describe('表情消息段'),
|
|
142
|
-
|
|
143
|
-
z.object({
|
|
144
|
-
type: z.literal('reply'),
|
|
145
|
-
data: z.object({
|
|
146
|
-
message_seq: ZInt64.describe('被引用的消息序列号'),
|
|
147
|
-
}).describe('回复消息段'),
|
|
148
|
-
}).describe('回复消息段'),
|
|
149
|
-
|
|
150
|
-
z.object({
|
|
151
|
-
type: z.literal('image'),
|
|
152
|
-
data: OutgoingResourceSegmentBase.extend({
|
|
153
|
-
summary: ZString.optional().describe('图片预览文本'),
|
|
154
|
-
sub_type: z.enum(['normal', 'sticker']).describe('图片类型'),
|
|
155
|
-
}).describe('图片消息段'),
|
|
156
|
-
}).describe('图片消息段'),
|
|
157
|
-
|
|
158
|
-
z.object({
|
|
159
|
-
type: z.literal('record'),
|
|
160
|
-
data: OutgoingResourceSegmentBase.describe('语音消息段'),
|
|
161
|
-
}).describe('语音消息段'),
|
|
162
|
-
|
|
163
|
-
z.object({
|
|
164
|
-
type: z.literal('video'),
|
|
165
|
-
data: OutgoingResourceSegmentBase.extend({
|
|
166
|
-
thumb_uri: ZString.optional().describe('封面图片 URI'),
|
|
167
|
-
}).describe('视频消息段'),
|
|
168
|
-
}).describe('视频消息段'),
|
|
169
|
-
|
|
170
|
-
z.object({
|
|
171
|
-
type: z.literal('forward'),
|
|
172
|
-
data: z.object({
|
|
173
|
-
get messages() {
|
|
174
|
-
return z.array(z.lazy(() => OutgoingForwardedMessage)).describe('合并转发消息段');
|
|
175
|
-
}
|
|
176
|
-
}).describe('合并转发消息段'),
|
|
177
|
-
}).describe('合并转发消息段'),
|
|
178
|
-
]).describe('发送消息段');
|
|
179
|
-
|
|
180
|
-
export const OutgoingForwardedMessage = z.object({
|
|
181
|
-
user_id: ZInt64.describe('发送者 QQ 号'),
|
|
182
|
-
sender_name: ZString.describe('发送者名称'),
|
|
183
|
-
segments: z.array(z.lazy(() => OutgoingSegment)).describe('消息段列表'),
|
|
184
|
-
}).describe('发送转发消息');
|
|
185
|
-
|
|
186
|
-
export const IncomingMessage = z.discriminatedUnion('message_scene', [
|
|
187
|
-
z.object({
|
|
188
|
-
message_scene: z.literal('friend'),
|
|
189
|
-
peer_id: ZInt64.describe('好友 QQ 号或群号'),
|
|
190
|
-
message_seq: ZInt64.describe('消息序列号'),
|
|
191
|
-
sender_id: ZInt64.describe('发送者 QQ 号'),
|
|
192
|
-
time: ZInt64.describe('消息 Unix 时间戳(秒)'),
|
|
193
|
-
segments: z.array(z.lazy(() => IncomingSegment)).describe('消息段列表'),
|
|
194
|
-
friend: z.lazy(() => FriendEntity).describe('好友信息'),
|
|
195
|
-
}).describe('好友消息'),
|
|
196
|
-
|
|
197
|
-
z.object({
|
|
198
|
-
message_scene: z.literal('group'),
|
|
199
|
-
peer_id: ZInt64.describe('好友 QQ 号或群号'),
|
|
200
|
-
message_seq: ZInt64.describe('消息序列号'),
|
|
201
|
-
sender_id: ZInt64.describe('发送者 QQ 号'),
|
|
202
|
-
time: ZInt64.describe('消息 Unix 时间戳(秒)'),
|
|
203
|
-
segments: z.array(z.lazy(() => IncomingSegment)).describe('消息段列表'),
|
|
204
|
-
group: z.lazy(() => GroupEntity).describe('群信息'),
|
|
205
|
-
group_member: z.lazy(() => GroupMemberEntity).describe('群成员信息'),
|
|
206
|
-
}).describe('群消息'),
|
|
207
|
-
|
|
208
|
-
z.object({
|
|
209
|
-
message_scene: z.literal('temp'),
|
|
210
|
-
peer_id: ZInt64.describe('好友 QQ 号或群号'),
|
|
211
|
-
message_seq: ZInt64.describe('消息序列号'),
|
|
212
|
-
sender_id: ZInt64.describe('发送者 QQ 号'),
|
|
213
|
-
time: ZInt64.describe('消息 Unix 时间戳(秒)'),
|
|
214
|
-
segments: z.array(z.lazy(() => IncomingSegment)).describe('消息段列表'),
|
|
215
|
-
group: z.lazy(() => GroupEntity).optional().describe('临时会话发送者的所在的群信息'),
|
|
216
|
-
}).describe('临时会话消息'),
|
|
217
|
-
]).describe('接收消息');
|
|
218
|
-
|
|
219
|
-
export const GroupEssenceMessage = z.object({
|
|
220
|
-
group_id: ZInt64.describe('群号'),
|
|
221
|
-
message_seq: ZInt64.describe('消息序列号'),
|
|
222
|
-
message_time: ZInt64.describe('消息发送时的 Unix 时间戳(秒)'),
|
|
223
|
-
sender_id: ZInt64.describe('发送者 QQ 号'),
|
|
224
|
-
sender_name: ZString.describe('发送者名称'),
|
|
225
|
-
operator_id: ZInt64.describe('设置精华的操作者 QQ 号'),
|
|
226
|
-
operator_name: ZString.describe('设置精华的操作者名称'),
|
|
227
|
-
operation_time: ZInt64.describe('消息被设置精华时的 Unix 时间戳(秒)'),
|
|
228
|
-
segments: z.array(z.lazy(() => IncomingSegment)).describe('消息段列表'),
|
|
229
|
-
}).describe('群精华消息');
|
|
230
|
-
|
|
231
|
-
export type IncomingSegment = z.infer<typeof IncomingSegment>;
|
|
232
|
-
export type OutgoingSegment = z.infer<typeof OutgoingSegment>;
|
|
233
|
-
export type IncomingMessage = z.infer<typeof IncomingMessage>;
|
|
234
|
-
export type GroupEssenceMessage = z.infer<typeof GroupEssenceMessage>;
|
|
235
|
-
export type IncomingForwardedMessage = z.infer<typeof IncomingForwardedMessage>;
|
|
236
|
-
export type OutgoingForwardedMessage = z.infer<typeof OutgoingForwardedMessage>;
|
package/src/scalar.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
export const ZInt32 = z.number().int().min(-2147483648).max(2147483647).meta({ scalarType: 'int32' });
|
|
4
|
-
export const ZInt64 = z.number().int().meta({ scalarType: 'int64' });
|
|
5
|
-
export const ZBoolean = z.boolean().meta({ scalarType: 'boolean' });
|
|
6
|
-
export const ZString = z.string().meta({ scalarType: 'string' });
|