@satorijs/adapter-lark 3.10.6 → 3.11.1
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/content.d.ts +211 -93
- package/lib/index.cjs +2954 -2474
- package/lib/internal.d.ts +4 -4
- package/lib/message.d.ts +2 -3
- package/lib/types/acs.d.ts +212 -172
- package/lib/types/admin.d.ts +331 -291
- package/lib/types/aily.d.ts +331 -216
- package/lib/types/apaas.d.ts +646 -494
- package/lib/types/application.d.ts +559 -458
- package/lib/types/approval.d.ts +826 -791
- package/lib/types/attendance.d.ts +1094 -994
- package/lib/types/auth.d.ts +66 -61
- package/lib/types/authen.d.ts +221 -186
- package/lib/types/baike.d.ts +258 -233
- package/lib/types/base.d.ts +74 -0
- package/lib/types/bitable.d.ts +830 -770
- package/lib/types/board.d.ts +29 -14
- package/lib/types/calendar.d.ts +660 -605
- package/lib/types/cardkit.d.ts +149 -134
- package/lib/types/compensation.d.ts +84 -49
- package/lib/types/contact.d.ts +1279 -1204
- package/lib/types/corehr.d.ts +4982 -4526
- package/lib/types/directory.d.ts +447 -0
- package/lib/types/docs.d.ts +28 -18
- package/lib/types/document_ai.d.ts +347 -252
- package/lib/types/docx.d.ts +428 -383
- package/lib/types/drive.d.ts +1093 -1048
- package/lib/types/ehr.d.ts +66 -51
- package/lib/types/event.d.ts +16 -6
- package/lib/types/helpdesk.d.ts +816 -741
- package/lib/types/hire.d.ts +3955 -3589
- package/lib/types/human_authentication.d.ts +32 -22
- package/lib/types/im.d.ts +1420 -1295
- package/lib/types/index.d.ts +1422 -330
- package/lib/types/lingo.d.ts +279 -249
- package/lib/types/mail.d.ts +1032 -675
- package/lib/types/mdm.d.ts +105 -37
- package/lib/types/minutes.d.ts +73 -26
- package/lib/types/moments.d.ts +23 -13
- package/lib/types/okr.d.ts +266 -225
- package/lib/types/optical_char_recognition.d.ts +22 -12
- package/lib/types/passport.d.ts +58 -48
- package/lib/types/payroll.d.ts +210 -53
- package/lib/types/performance.d.ts +463 -414
- package/lib/types/personal_settings.d.ts +93 -82
- package/lib/types/report.d.ts +79 -58
- package/lib/types/search.d.ts +265 -235
- package/lib/types/security_and_compliance.d.ts +30 -19
- package/lib/types/sheets.d.ts +356 -321
- package/lib/types/speech_to_text.d.ts +44 -34
- package/lib/types/task.d.ts +998 -1087
- package/lib/types/tenant.d.ts +25 -15
- package/lib/types/translation.d.ts +42 -32
- package/lib/types/trust_party.d.ts +81 -0
- package/lib/types/vc.d.ts +1218 -1123
- package/lib/types/verification.d.ts +11 -6
- package/lib/types/wiki.d.ts +270 -235
- package/lib/types/workplace.d.ts +58 -38
- package/lib/utils.d.ts +2 -2
- package/package.json +4 -4
- package/src/bot.ts +15 -15
- package/src/content.ts +230 -107
- package/src/internal.ts +29 -12
- package/src/message.ts +82 -111
- package/src/types/acs.ts +234 -186
- package/src/types/admin.ts +353 -305
- package/src/types/aily.ts +375 -233
- package/src/types/apaas.ts +754 -568
- package/src/types/application.ts +633 -507
- package/src/types/approval.ts +914 -872
- package/src/types/attendance.ts +1226 -1104
- package/src/types/auth.ts +72 -66
- package/src/types/authen.ts +233 -191
- package/src/types/baike.ts +276 -246
- package/src/types/base.ts +93 -0
- package/src/types/bitable.ts +966 -894
- package/src/types/board.ts +34 -16
- package/src/types/calendar.ts +751 -685
- package/src/types/cardkit.ts +164 -146
- package/src/types/compensation.ts +97 -55
- package/src/types/contact.ts +1465 -1375
- package/src/types/corehr.ts +5664 -5077
- package/src/types/directory.ts +569 -0
- package/src/types/docs.ts +31 -19
- package/src/types/document_ai.ts +401 -287
- package/src/types/docx.ts +492 -438
- package/src/types/drive.ts +1266 -1213
- package/src/types/ehr.ts +71 -53
- package/src/types/event.ts +19 -7
- package/src/types/helpdesk.ts +930 -840
- package/src/types/hire.ts +4453 -4019
- package/src/types/human_authentication.ts +35 -23
- package/src/types/im.ts +1626 -1476
- package/src/types/index.ts +1532 -346
- package/src/types/lingo.ts +299 -263
- package/src/types/mail.ts +1231 -779
- package/src/types/mdm.ts +122 -39
- package/src/types/minutes.ts +88 -28
- package/src/types/moments.ts +26 -14
- package/src/types/okr.ts +286 -238
- package/src/types/optical_char_recognition.ts +25 -13
- package/src/types/passport.ts +62 -50
- package/src/types/payroll.ts +254 -57
- package/src/types/performance.ts +528 -467
- package/src/types/personal_settings.ts +101 -89
- package/src/types/report.ts +86 -62
- package/src/types/search.ts +285 -249
- package/src/types/security_and_compliance.ts +33 -21
- package/src/types/sheets.ts +421 -379
- package/src/types/speech_to_text.ts +48 -36
- package/src/types/task.ts +1152 -1260
- package/src/types/tenant.ts +29 -17
- package/src/types/translation.ts +46 -34
- package/src/types/trust_party.ts +110 -0
- package/src/types/vc.ts +1397 -1283
- package/src/types/verification.ts +13 -7
- package/src/types/wiki.ts +293 -251
- package/src/types/workplace.ts +65 -41
- package/src/utils.ts +3 -3
package/lib/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context, Session, Universal } from '@satorijs/core';
|
|
2
2
|
import { LarkBot } from './bot';
|
|
3
|
-
import {
|
|
3
|
+
import { Im, ListChat, Message, User } from './types';
|
|
4
4
|
import { MessageContent } from './content';
|
|
5
5
|
export interface EventHeader<K extends keyof Events> {
|
|
6
6
|
event_id: string;
|
|
@@ -154,7 +154,7 @@ export declare function decodeMessage<C extends Context = Context>(bot: LarkBot<
|
|
|
154
154
|
* @see https://open.larksuite.com/document/home/user-identity-introduction/introduction
|
|
155
155
|
*/
|
|
156
156
|
export declare function extractIdType(id: string): ReceiveIdType;
|
|
157
|
-
export declare function decodeChannel(channelId: string, guild:
|
|
157
|
+
export declare function decodeChannel(channelId: string, guild: Im.Chat.GetResponse): Universal.Channel;
|
|
158
158
|
export declare function decodeGuild(guild: ListChat): Universal.Guild;
|
|
159
159
|
export declare function decodeUser(user: User): Universal.User;
|
|
160
160
|
export declare class Cipher {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@satorijs/adapter-lark",
|
|
3
3
|
"description": "Lark (飞书) Adapter for Satorijs",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.11.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.cjs",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"chat"
|
|
35
35
|
],
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@cordisjs/plugin-server": "^0.2.
|
|
38
|
-
"@satorijs/core": "^4.5.
|
|
37
|
+
"@cordisjs/plugin-server": "^0.2.7",
|
|
38
|
+
"@satorijs/core": "^4.5.2",
|
|
39
39
|
"cordis": "^3.18.1",
|
|
40
40
|
"cosmokit": "^1.7.2",
|
|
41
41
|
"dedent": "^1.5.3"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@satorijs/core": "^4.5.
|
|
44
|
+
"@satorijs/core": "^4.5.2"
|
|
45
45
|
}
|
|
46
46
|
}
|
package/src/bot.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Bot, Context, h, HTTP, Schema, Time, Universal } from '@satorijs/core'
|
|
2
|
-
import {
|
|
2
|
+
import { Im } from './types'
|
|
3
3
|
import { HttpServer } from './http'
|
|
4
4
|
import { LarkMessageEncoder } from './message'
|
|
5
5
|
import { Internal } from './internal'
|
|
6
6
|
import * as Utils from './utils'
|
|
7
7
|
|
|
8
|
-
const fileTypeMap: Record<Exclude<
|
|
8
|
+
const fileTypeMap: Record<Exclude<Im.File.CreateForm['file_type'], 'stream'>, string[]> = {
|
|
9
9
|
opus: ['audio/opus'],
|
|
10
10
|
mp4: ['video/mp4'],
|
|
11
11
|
pdf: ['application/pdf'],
|
|
@@ -80,7 +80,7 @@ export class LarkBot<C extends Context = Context> extends Bot<C, LarkBot.Config>
|
|
|
80
80
|
// 初次获得 token 后的半小时内必须刷新一次,因为初次获得的 token 可能是 1.5 小时前生成的。
|
|
81
81
|
let timeout = Time.minute * 20
|
|
82
82
|
try {
|
|
83
|
-
const { tenant_access_token: token } = await this.internal.
|
|
83
|
+
const { tenant_access_token: token } = await this.internal.auth.tenantAccessTokenInternal({
|
|
84
84
|
app_id: this.config.appId,
|
|
85
85
|
app_secret: this.config.appSecret,
|
|
86
86
|
})
|
|
@@ -103,30 +103,30 @@ export class LarkBot<C extends Context = Context> extends Bot<C, LarkBot.Config>
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
async deleteMessage(channelId: string, messageId: string) {
|
|
106
|
-
await this.internal.
|
|
106
|
+
await this.internal.im.message.delete(messageId)
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
async getMessage(channelId: string, messageId: string, recursive = true) {
|
|
110
|
-
const data = await this.internal.
|
|
110
|
+
const data = await this.internal.im.message.get(messageId)
|
|
111
111
|
const message = await Utils.decodeMessage(this, data.items![0], recursive)
|
|
112
|
-
const im = await this.internal.
|
|
112
|
+
const im = await this.internal.im.chat.get(channelId)
|
|
113
113
|
message.channel!.type = im.chat_mode === 'p2p' ? Universal.Channel.Type.DIRECT : Universal.Channel.Type.TEXT
|
|
114
114
|
return message
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
async getMessageList(channelId: string, before?: string) {
|
|
118
|
-
const messages = await this.internal.
|
|
118
|
+
const messages = await this.internal.im.message.list({ container_id_type: 'chat', container_id: channelId, page_token: before })
|
|
119
119
|
const data = await Promise.all(messages.items.reverse().map(data => Utils.decodeMessage(this, data)))
|
|
120
120
|
return { data, next: data[0]?.id }
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
async getUser(userId: string, guildId?: string) {
|
|
124
|
-
const data = await this.internal.
|
|
124
|
+
const data = await this.internal.contact.user.get(userId)
|
|
125
125
|
return Utils.decodeUser(data.user!)
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
async getChannel(channelId: string) {
|
|
129
|
-
const chat = await this.internal.
|
|
129
|
+
const chat = await this.internal.im.chat.get(channelId)
|
|
130
130
|
return Utils.decodeChannel(channelId, chat)
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -135,31 +135,31 @@ export class LarkBot<C extends Context = Context> extends Bot<C, LarkBot.Config>
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
async getGuild(guildId: string) {
|
|
138
|
-
const chat = await this.internal.
|
|
138
|
+
const chat = await this.internal.im.chat.get(guildId)
|
|
139
139
|
return Utils.decodeGuild(chat)
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
async getGuildList(after?: string) {
|
|
143
|
-
const chats = await this.internal.
|
|
143
|
+
const chats = await this.internal.im.chat.list({ page_token: after })
|
|
144
144
|
return { data: chats.items.map(Utils.decodeGuild), next: chats.page_token }
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
async getGuildMemberList(guildId: string, after?: string) {
|
|
148
|
-
const members = await this.internal.
|
|
148
|
+
const members = await this.internal.im.chat.members.get(guildId, { page_token: after })
|
|
149
149
|
const data = members.items!.map(v => ({ user: { id: v.member_id, name: v.name }, name: v.name }))
|
|
150
150
|
return { data, next: members.page_token }
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
async createUpload(...uploads: Universal.Upload[]): Promise<string[]> {
|
|
154
154
|
return await Promise.all(uploads.map(async (upload) => {
|
|
155
|
-
let type:
|
|
155
|
+
let type: Im.File.CreateForm['file_type'] = 'stream'
|
|
156
156
|
for (const [key, value] of Object.entries(fileTypeMap)) {
|
|
157
157
|
if (value.includes(upload.type)) {
|
|
158
|
-
type = key as
|
|
158
|
+
type = key as Im.File.CreateForm['file_type']
|
|
159
159
|
break
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
const response = await this.internal.
|
|
162
|
+
const response = await this.internal.im.file.create({
|
|
163
163
|
file_name: upload.filename,
|
|
164
164
|
file_type: type,
|
|
165
165
|
file: new Blob([upload.data]),
|