@satorijs/adapter-lark 3.8.5 → 3.9.0

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.
Files changed (126) hide show
  1. package/lib/bot.d.ts +1 -1
  2. package/lib/content.d.ts +433 -0
  3. package/lib/http.d.ts +1 -1
  4. package/lib/index.cjs +2796 -1713
  5. package/lib/index.cjs.map +6 -0
  6. package/lib/index.d.ts +4 -2
  7. package/lib/internal.d.ts +38 -0
  8. package/lib/message.d.ts +2 -0
  9. package/lib/types/acs.d.ts +177 -0
  10. package/lib/types/admin.d.ts +270 -0
  11. package/lib/types/aily.d.ts +221 -0
  12. package/lib/types/apaas.d.ts +499 -0
  13. package/lib/types/application.d.ts +406 -0
  14. package/lib/types/approval.d.ts +779 -0
  15. package/lib/types/attendance.d.ts +957 -0
  16. package/lib/types/auth.d.ts +86 -0
  17. package/lib/types/authen.d.ts +191 -0
  18. package/lib/types/baike.d.ts +239 -0
  19. package/lib/types/bitable.d.ts +691 -0
  20. package/lib/types/board.d.ts +19 -0
  21. package/lib/types/calendar.d.ts +653 -0
  22. package/lib/types/cardkit.d.ts +139 -0
  23. package/lib/types/compensation.d.ts +54 -0
  24. package/lib/types/contact.d.ts +1137 -0
  25. package/lib/types/corehr.d.ts +4383 -0
  26. package/lib/types/docs.d.ts +23 -0
  27. package/lib/types/document_ai.d.ts +257 -0
  28. package/lib/types/docx.d.ts +380 -0
  29. package/lib/types/drive.d.ts +1045 -0
  30. package/lib/types/ehr.d.ts +32 -0
  31. package/lib/types/event.d.ts +9 -18
  32. package/lib/types/guild.d.ts +59 -0
  33. package/lib/types/helpdesk.d.ts +738 -0
  34. package/lib/types/hire.d.ts +3150 -0
  35. package/lib/types/human_authentication.d.ts +27 -0
  36. package/lib/types/im.d.ts +1300 -0
  37. package/lib/types/index.d.ts +16432 -34
  38. package/lib/types/lingo.d.ts +254 -0
  39. package/lib/types/mail.d.ts +680 -0
  40. package/lib/types/mdm.d.ts +42 -0
  41. package/lib/types/message/asset.d.ts +40 -0
  42. package/lib/types/minutes.d.ts +31 -0
  43. package/lib/types/moments.d.ts +18 -0
  44. package/lib/types/okr.d.ts +205 -0
  45. package/lib/types/optical_char_recognition.d.ts +17 -0
  46. package/lib/types/passport.d.ts +45 -0
  47. package/lib/types/payroll.d.ts +50 -0
  48. package/lib/types/performance.d.ts +413 -0
  49. package/lib/types/personal_settings.d.ts +87 -0
  50. package/lib/types/report.d.ts +57 -0
  51. package/lib/types/search.d.ts +216 -0
  52. package/lib/types/security_and_compliance.d.ts +24 -0
  53. package/lib/types/sheets.d.ts +326 -0
  54. package/lib/types/speech_to_text.d.ts +39 -0
  55. package/lib/types/task.d.ts +1153 -0
  56. package/lib/types/tenant.d.ts +23 -0
  57. package/lib/types/translation.d.ts +37 -0
  58. package/lib/types/user.d.ts +78 -0
  59. package/lib/types/utils.d.ts +9 -0
  60. package/lib/types/vc.d.ts +948 -0
  61. package/lib/types/verification.d.ts +14 -0
  62. package/lib/types/wiki.d.ts +240 -0
  63. package/lib/types/workplace.d.ts +43 -0
  64. package/lib/utils.d.ts +143 -7
  65. package/package.json +6 -4
  66. package/src/bot.ts +19 -3
  67. package/src/{types/message/content.ts → content.ts} +1 -0
  68. package/src/http.ts +1 -3
  69. package/src/index.ts +4 -2
  70. package/src/internal.ts +144 -0
  71. package/src/message.ts +24 -11
  72. package/src/types/acs.ts +236 -0
  73. package/src/types/admin.ts +328 -0
  74. package/src/types/aily.ts +288 -0
  75. package/src/types/apaas.ts +646 -0
  76. package/src/types/application.ts +520 -0
  77. package/src/types/approval.ts +924 -0
  78. package/src/types/attendance.ts +1153 -0
  79. package/src/types/auth.ts +114 -0
  80. package/src/types/authen.ts +220 -0
  81. package/src/types/baike.ts +306 -0
  82. package/src/types/bitable.ts +879 -0
  83. package/src/types/board.ts +31 -0
  84. package/src/types/calendar.ts +817 -0
  85. package/src/types/cardkit.ts +182 -0
  86. package/src/types/compensation.ts +79 -0
  87. package/src/types/contact.ts +1411 -0
  88. package/src/types/corehr.ts +5288 -0
  89. package/src/types/docs.ts +33 -0
  90. package/src/types/document_ai.ts +352 -0
  91. package/src/types/docx.ts +471 -0
  92. package/src/types/drive.ts +1312 -0
  93. package/src/types/ehr.ts +43 -0
  94. package/src/types/event.ts +15 -21
  95. package/src/types/helpdesk.ts +916 -0
  96. package/src/types/hire.ts +3918 -0
  97. package/src/types/human_authentication.ts +38 -0
  98. package/src/types/im.ts +1605 -0
  99. package/src/types/index.ts +17754 -39
  100. package/src/types/lingo.ts +321 -0
  101. package/src/types/mail.ts +851 -0
  102. package/src/types/mdm.ts +57 -0
  103. package/src/types/minutes.ts +46 -0
  104. package/src/types/moments.ts +28 -0
  105. package/src/types/okr.ts +261 -0
  106. package/src/types/optical_char_recognition.ts +27 -0
  107. package/src/types/passport.ts +61 -0
  108. package/src/types/payroll.ts +69 -0
  109. package/src/types/performance.ts +524 -0
  110. package/src/types/personal_settings.ts +116 -0
  111. package/src/types/report.ts +77 -0
  112. package/src/types/search.ts +268 -0
  113. package/src/types/security_and_compliance.ts +33 -0
  114. package/src/types/sheets.ts +425 -0
  115. package/src/types/speech_to_text.ts +54 -0
  116. package/src/types/task.ts +1464 -0
  117. package/src/types/tenant.ts +36 -0
  118. package/src/types/translation.ts +52 -0
  119. package/src/types/vc.ts +1197 -0
  120. package/src/types/verification.ts +23 -0
  121. package/src/types/wiki.ts +313 -0
  122. package/src/types/workplace.ts +59 -0
  123. package/src/utils.ts +160 -8
  124. package/src/types/api.ts +0 -30835
  125. package/src/types/internal.ts +0 -84
  126. package/src/types/message/index.ts +0 -97
@@ -0,0 +1,23 @@
1
+ import { Verification } from '.'
2
+ import { Internal } from '../internal'
3
+
4
+ declare module '../internal' {
5
+ interface Internal {
6
+ /**
7
+ * 获取认证信息
8
+ * @see https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/verification-v1/verification/get
9
+ */
10
+ getVerification(): Promise<GetVerificationResponse>
11
+ }
12
+ }
13
+
14
+ export interface GetVerificationResponse {
15
+ /** 认证信息 */
16
+ verification?: Verification
17
+ }
18
+
19
+ Internal.define({
20
+ '/verification/v1/verification': {
21
+ GET: 'getVerification',
22
+ },
23
+ })
@@ -0,0 +1,313 @@
1
+ import { Member, Node, Setting, Space, TaskResult } from '.'
2
+ import { Internal, Pagination } from '../internal'
3
+
4
+ declare module '../internal' {
5
+ interface Internal {
6
+ /**
7
+ * 获取知识空间列表
8
+ * @see https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space/list
9
+ */
10
+ listWikiSpace(query?: ListWikiSpaceQuery): Paginated<Space>
11
+ /**
12
+ * 获取知识空间信息
13
+ * @see https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space/get
14
+ */
15
+ getWikiSpace(space_id: string, query?: GetWikiSpaceQuery): Promise<GetWikiSpaceResponse>
16
+ /**
17
+ * 创建知识空间
18
+ * @see https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space/create
19
+ */
20
+ createWikiSpace(body: CreateWikiSpaceRequest): Promise<CreateWikiSpaceResponse>
21
+ /**
22
+ * 获取知识空间成员列表
23
+ * @see https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space-member/list
24
+ */
25
+ listWikiSpaceMember(space_id: string, query?: Pagination): Paginated<Member, 'members'>
26
+ /**
27
+ * 添加知识空间成员
28
+ * @see https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space-member/create
29
+ */
30
+ createWikiSpaceMember(space_id: string, body: CreateWikiSpaceMemberRequest, query?: CreateWikiSpaceMemberQuery): Promise<CreateWikiSpaceMemberResponse>
31
+ /**
32
+ * 删除知识空间成员
33
+ * @see https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space-member/delete
34
+ */
35
+ deleteWikiSpaceMember(space_id: string, member_id: string, body: DeleteWikiSpaceMemberRequest): Promise<DeleteWikiSpaceMemberResponse>
36
+ /**
37
+ * 更新知识空间设置
38
+ * @see https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space-setting/update
39
+ */
40
+ updateWikiSpaceSetting(space_id: string, body: UpdateWikiSpaceSettingRequest): Promise<UpdateWikiSpaceSettingResponse>
41
+ /**
42
+ * 创建知识空间节点
43
+ * @see https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space-node/create
44
+ */
45
+ createWikiSpaceNode(space_id: string, body: CreateWikiSpaceNodeRequest): Promise<CreateWikiSpaceNodeResponse>
46
+ /**
47
+ * 获取知识空间节点信息
48
+ * @see https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space/get_node
49
+ */
50
+ getNodeWikiSpace(query?: GetNodeWikiSpaceQuery): Promise<GetNodeWikiSpaceResponse>
51
+ /**
52
+ * 获取知识空间子节点列表
53
+ * @see https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space-node/list
54
+ */
55
+ listWikiSpaceNode(space_id: string, query?: ListWikiSpaceNodeQuery): Paginated<Node>
56
+ /**
57
+ * 移动知识空间节点
58
+ * @see https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space-node/move
59
+ */
60
+ moveWikiSpaceNode(space_id: string, node_token: string, body: MoveWikiSpaceNodeRequest): Promise<MoveWikiSpaceNodeResponse>
61
+ /**
62
+ * 更新知识空间节点标题
63
+ * @see https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space-node/update_title
64
+ */
65
+ updateTitleWikiSpaceNode(space_id: string, node_token: string, body: UpdateTitleWikiSpaceNodeRequest): Promise<void>
66
+ /**
67
+ * 创建知识空间节点副本
68
+ * @see https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space-node/copy
69
+ */
70
+ copyWikiSpaceNode(space_id: string, node_token: string, body: CopyWikiSpaceNodeRequest): Promise<CopyWikiSpaceNodeResponse>
71
+ /**
72
+ * 移动云空间文档至知识空间
73
+ * @see https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space-node/move_docs_to_wiki
74
+ */
75
+ moveDocsToWikiWikiSpaceNode(space_id: string, body: MoveDocsToWikiWikiSpaceNodeRequest): Promise<MoveDocsToWikiWikiSpaceNodeResponse>
76
+ /**
77
+ * 获取任务结果
78
+ * @see https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/task/get
79
+ */
80
+ getWikiTask(task_id: string, query?: GetWikiTaskQuery): Promise<GetWikiTaskResponse>
81
+ /**
82
+ * 搜索 Wiki
83
+ * @see https://open.feishu.cn/document/ukTMukTMukTM/uEzN0YjLxcDN24SM3QjN/search_wiki
84
+ */
85
+ searchWikiNode(body: SearchWikiNodeRequest, query?: Pagination): Paginated<Node>
86
+ }
87
+ }
88
+
89
+ export interface ListWikiSpaceQuery extends Pagination {
90
+ /** 当查询个人文档库时,指定返回的文档库名称展示语言。可选值有:zh, id, de, en, es, fr, it, pt, vi, ru, hi, th, ko, ja, zh-HK, zh-TW。 */
91
+ lang?: 'zh' | 'id' | 'de' | 'en' | 'es' | 'fr' | 'it' | 'pt' | 'vi' | 'ru' | 'hi' | 'th' | 'ko' | 'ja' | 'zh-HK' | 'zh-TW'
92
+ }
93
+
94
+ export interface GetWikiSpaceQuery {
95
+ /** 当查询个人文档库时,指定返回的文档库名称展示语言。可选值有:zh, id, de, en, es, fr, it, pt, vi, ru, hi, th, ko, ja, zh-HK, zh-TW。 */
96
+ lang?: 'zh' | 'id' | 'de' | 'en' | 'es' | 'fr' | 'it' | 'pt' | 'vi' | 'ru' | 'hi' | 'th' | 'ko' | 'ja' | 'zh-HK' | 'zh-TW'
97
+ }
98
+
99
+ export interface CreateWikiSpaceRequest {
100
+ /** 知识空间名称 */
101
+ name?: string
102
+ /** 知识空间描述 */
103
+ description?: string
104
+ /** 表示知识空间的分享状态 */
105
+ open_sharing?: 'open' | 'closed'
106
+ }
107
+
108
+ export interface CreateWikiSpaceMemberRequest {
109
+ /** 知识库协作者 ID 类型 */
110
+ member_type: string
111
+ /** 知识库协作者 ID */
112
+ member_id: string
113
+ /** 知识库协作者角色 */
114
+ member_role: string
115
+ }
116
+
117
+ export interface CreateWikiSpaceMemberQuery {
118
+ /** 添加权限后是否通知对方 */
119
+ need_notification?: boolean
120
+ }
121
+
122
+ export interface DeleteWikiSpaceMemberRequest {
123
+ /** 知识库协作者 ID 类型 */
124
+ member_type: string
125
+ /** 知识库协作者角色 */
126
+ member_role: string
127
+ /** 知识库协作者类型 */
128
+ type?: 'user' | 'chat' | 'department'
129
+ }
130
+
131
+ export interface UpdateWikiSpaceSettingRequest {
132
+ /** 谁可以创建空间的一级页面: "admin_and_member" = 管理员和成员 "admin" - 仅管理员 */
133
+ create_setting?: string
134
+ /** 可阅读用户可否创建副本/打印/导出/复制: "allow" - 允许 "not_allow" - 不允许 */
135
+ security_setting?: string
136
+ /** 可阅读用户可否评论: "allow" - 允许 "not_allow" - 不允许 */
137
+ comment_setting?: string
138
+ }
139
+
140
+ export interface CreateWikiSpaceNodeRequest {
141
+ /** 文档类型,对于快捷方式,该字段是对应的实体的obj_type。 */
142
+ obj_type: 'doc' | 'sheet' | 'mindnote' | 'bitable' | 'file' | 'docx' | 'slides'
143
+ /** 父节点 token。若当前节点为一级节点,父节点 token 为空。 */
144
+ parent_node_token?: string
145
+ /** 节点类型 */
146
+ node_type: 'origin' | 'shortcut'
147
+ /** 快捷方式对应的实体node_token,当节点为快捷方式时,该值不为空。 */
148
+ origin_node_token?: string
149
+ /** 文档标题 */
150
+ title?: string
151
+ }
152
+
153
+ export interface GetNodeWikiSpaceQuery {
154
+ /** 文档的wiki token */
155
+ token: string
156
+ /** 文档类型 */
157
+ obj_type?: 'doc' | 'docx' | 'sheet' | 'mindnote' | 'bitable' | 'file' | 'slides' | 'wiki'
158
+ }
159
+
160
+ export interface ListWikiSpaceNodeQuery extends Pagination {
161
+ /** 父节点token */
162
+ parent_node_token?: string
163
+ }
164
+
165
+ export interface MoveWikiSpaceNodeRequest {
166
+ /** 移动到的父节点token */
167
+ target_parent_token?: string
168
+ /** 移动到的知识空间ID */
169
+ target_space_id?: string
170
+ }
171
+
172
+ export interface UpdateTitleWikiSpaceNodeRequest {
173
+ /** 节点新标题 */
174
+ title: string
175
+ }
176
+
177
+ export interface CopyWikiSpaceNodeRequest {
178
+ /** 目标父节点token */
179
+ target_parent_token?: string
180
+ /** 目标知识空间id */
181
+ target_space_id?: string
182
+ /** 复制后的新标题。如果填空,则新标题为空。如果不填,则使用原节点标题。 */
183
+ title?: string
184
+ }
185
+
186
+ export interface MoveDocsToWikiWikiSpaceNodeRequest {
187
+ /** 节点的父亲token */
188
+ parent_wiki_token?: string
189
+ /** 文档类型 */
190
+ obj_type: 'doc' | 'sheet' | 'bitable' | 'mindnote' | 'docx' | 'file' | 'slides'
191
+ /** 文档token */
192
+ obj_token: string
193
+ /** 没有权限时,是否申请迁入文档 */
194
+ apply?: boolean
195
+ }
196
+
197
+ export interface GetWikiTaskQuery {
198
+ /** 任务类型 */
199
+ task_type: 'move'
200
+ }
201
+
202
+ export interface SearchWikiNodeRequest {
203
+ /** 搜索关键词 */
204
+ query: string
205
+ /** 文档所属的知识空间ID,为空搜索所有 wiki */
206
+ space_id?: string
207
+ /** wiki token,不为空搜索该节点及其所有子节点,为空搜索所有 wiki(根据 space_id 选择 space) */
208
+ node_id?: string
209
+ }
210
+
211
+ export interface GetWikiSpaceResponse {
212
+ /** 知识空间 */
213
+ space?: Space
214
+ }
215
+
216
+ export interface CreateWikiSpaceResponse {
217
+ /** 知识空间信息 */
218
+ space?: Space
219
+ }
220
+
221
+ export interface CreateWikiSpaceMemberResponse {
222
+ /** 知识库协作者 */
223
+ member?: Member
224
+ }
225
+
226
+ export interface DeleteWikiSpaceMemberResponse {
227
+ /** 成员信息 */
228
+ member: Member
229
+ }
230
+
231
+ export interface UpdateWikiSpaceSettingResponse {
232
+ /** 空间设置 */
233
+ setting?: Setting
234
+ }
235
+
236
+ export interface CreateWikiSpaceNodeResponse {
237
+ /** 节点 */
238
+ node?: Node
239
+ }
240
+
241
+ export interface GetNodeWikiSpaceResponse {
242
+ /** 节点信息 */
243
+ node?: Node
244
+ }
245
+
246
+ export interface MoveWikiSpaceNodeResponse {
247
+ /** 移动后的节点信息 */
248
+ node?: Node
249
+ }
250
+
251
+ export interface CopyWikiSpaceNodeResponse {
252
+ /** copy后的节点 */
253
+ node: Node
254
+ }
255
+
256
+ export interface MoveDocsToWikiWikiSpaceNodeResponse {
257
+ /** 移动后的知识库token */
258
+ wiki_token?: string
259
+ /** 任务id */
260
+ task_id?: string
261
+ /** 是否提交了文档迁入申请 */
262
+ applied?: boolean
263
+ }
264
+
265
+ export interface GetWikiTaskResponse {
266
+ /** 任务结果 */
267
+ task: TaskResult
268
+ }
269
+
270
+ Internal.define({
271
+ '/wiki/v2/spaces': {
272
+ GET: { name: 'listWikiSpace', pagination: { argIndex: 0 } },
273
+ POST: 'createWikiSpace',
274
+ },
275
+ '/wiki/v2/spaces/{space_id}': {
276
+ GET: 'getWikiSpace',
277
+ },
278
+ '/wiki/v2/spaces/{space_id}/members': {
279
+ GET: { name: 'listWikiSpaceMember', pagination: { argIndex: 1, itemsKey: 'members' } },
280
+ POST: 'createWikiSpaceMember',
281
+ },
282
+ '/wiki/v2/spaces/{space_id}/members/{member_id}': {
283
+ DELETE: 'deleteWikiSpaceMember',
284
+ },
285
+ '/wiki/v2/spaces/{space_id}/setting': {
286
+ PUT: 'updateWikiSpaceSetting',
287
+ },
288
+ '/wiki/v2/spaces/{space_id}/nodes': {
289
+ POST: 'createWikiSpaceNode',
290
+ GET: { name: 'listWikiSpaceNode', pagination: { argIndex: 1 } },
291
+ },
292
+ '/wiki/v2/spaces/get_node': {
293
+ GET: 'getNodeWikiSpace',
294
+ },
295
+ '/wiki/v2/spaces/{space_id}/nodes/{node_token}/move': {
296
+ POST: 'moveWikiSpaceNode',
297
+ },
298
+ '/wiki/v2/spaces/{space_id}/nodes/{node_token}/update_title': {
299
+ POST: 'updateTitleWikiSpaceNode',
300
+ },
301
+ '/wiki/v2/spaces/{space_id}/nodes/{node_token}/copy': {
302
+ POST: 'copyWikiSpaceNode',
303
+ },
304
+ '/wiki/v2/spaces/{space_id}/nodes/move_docs_to_wiki': {
305
+ POST: 'moveDocsToWikiWikiSpaceNode',
306
+ },
307
+ '/wiki/v2/tasks/{task_id}': {
308
+ GET: 'getWikiTask',
309
+ },
310
+ '/wiki/v1/nodes/search': {
311
+ POST: { name: 'searchWikiNode', pagination: { argIndex: 1 } },
312
+ },
313
+ })
@@ -0,0 +1,59 @@
1
+ import { BlockAccessData, CustomWorkplaceAccessData, WorkplaceAccessData } from '.'
2
+ import { Internal, Pagination } from '../internal'
3
+
4
+ declare module '../internal' {
5
+ interface Internal {
6
+ /**
7
+ * 获取工作台访问数据
8
+ * @see https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/workplace-v1/workplace_access_data/search
9
+ */
10
+ searchWorkplaceWorkplaceAccessData(query?: SearchWorkplaceWorkplaceAccessDataQuery): Paginated<WorkplaceAccessData>
11
+ /**
12
+ * 获取定制工作台访问数据
13
+ * @see https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/workplace-v1/custom_workplace_access_data/search
14
+ */
15
+ searchWorkplaceCustomWorkplaceAccessData(query?: SearchWorkplaceCustomWorkplaceAccessDataQuery): Paginated<CustomWorkplaceAccessData>
16
+ /**
17
+ * 获取定制工作台小组件访问数据
18
+ * @see https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/workplace-v1/workplace_block_access_data/search
19
+ */
20
+ searchWorkplaceWorkplaceBlockAccessData(query?: SearchWorkplaceWorkplaceBlockAccessDataQuery): Paginated<BlockAccessData>
21
+ }
22
+ }
23
+
24
+ export interface SearchWorkplaceWorkplaceAccessDataQuery extends Pagination {
25
+ /** 数据检索开始时间,精确到日。格式yyyy-MM-dd */
26
+ from_date: string
27
+ /** 数据检索结束时间,精确到日。格式yyyy-MM-dd。 */
28
+ to_date: string
29
+ }
30
+
31
+ export interface SearchWorkplaceCustomWorkplaceAccessDataQuery extends Pagination {
32
+ /** 数据检索开始时间,精确到日。格式yyyy-MM-dd */
33
+ from_date: string
34
+ /** 数据检索结束时间,精确到日。格式yyyy-MM-dd。 */
35
+ to_date: string
36
+ /** 定制化工作台id.非必填,不填的时候,返回所有定制化工作台数据。 */
37
+ custom_workplace_id?: string
38
+ }
39
+
40
+ export interface SearchWorkplaceWorkplaceBlockAccessDataQuery extends Pagination {
41
+ /** 数据检索开始时间,精确到日。格式yyyy-MM-dd。 */
42
+ from_date: string
43
+ /** 数据检索结束时间,精确到日。格式yyyy-MM-dd。 */
44
+ to_date: string
45
+ /** 小组件id */
46
+ block_id?: string
47
+ }
48
+
49
+ Internal.define({
50
+ '/workplace/v1/workplace_access_data/search': {
51
+ POST: { name: 'searchWorkplaceWorkplaceAccessData', pagination: { argIndex: 0 } },
52
+ },
53
+ '/workplace/v1/custom_workplace_access_data/search': {
54
+ POST: { name: 'searchWorkplaceCustomWorkplaceAccessData', pagination: { argIndex: 0 } },
55
+ },
56
+ '/workplace/v1/workplace_block_access_data/search': {
57
+ POST: { name: 'searchWorkplaceWorkplaceBlockAccessData', pagination: { argIndex: 0 } },
58
+ },
59
+ })
package/src/utils.ts CHANGED
@@ -1,15 +1,161 @@
1
1
  import crypto from 'crypto'
2
- import { Context, h, Session, Universal } from '@satorijs/core'
2
+ import { Context, h, pick, Session, Universal } from '@satorijs/core'
3
3
  import { LarkBot } from './bot'
4
- import { EventPayload, Events, GetImChatResponse, Lark } from './types'
4
+ import { GetImChatResponse, ListChat, Message, User } from './types'
5
+ import { MessageContent } from './content'
6
+
7
+ export interface EventHeader<K extends keyof Events> {
8
+ event_id: string
9
+ event_type: K
10
+ create_time: string
11
+ token: string
12
+ app_id: string
13
+ tenant_key: string
14
+ }
15
+
16
+ export interface Events {
17
+ /**
18
+ * Receive message event.
19
+ * @see https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/events/receive
20
+ */
21
+ 'im.message.receive_v1': {
22
+ sender: {
23
+ sender_id: UserIds
24
+ sender_type?: string
25
+ tenant_key: string
26
+ }
27
+ message: {
28
+ message_id: string
29
+ root_id: string
30
+ parent_id: string
31
+ thread_id: string
32
+ create_time: string
33
+ chat_id: string
34
+ chat_type: string
35
+ message_type: keyof MessageContent
36
+ content: string
37
+ mentions: {
38
+ key: string
39
+ id: UserIds
40
+ name: string
41
+ tenant_key: string
42
+ }[]
43
+ }
44
+ }
45
+ /**
46
+ * Message read event.
47
+ * @see https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/events/message_read
48
+ */
49
+ 'im.message.message_read_v1': {
50
+ reader: {
51
+ reader_id: UserIds
52
+ read_time: string
53
+ tenant_key: string
54
+ }
55
+ message_id_list: string[]
56
+ }
57
+ /**
58
+ * Message card callback event.
59
+ * @see https://open.feishu.cn/document/uAjLw4CM/ukzMukzMukzM/feishu-cards/card-callback-communication
60
+ */
61
+ 'card.action.trigger': {
62
+ operator: {
63
+ tenant_key: string
64
+ user_id: string
65
+ union_id: string
66
+ open_id: string
67
+ }
68
+ token: string
69
+ action: {
70
+ value: any
71
+ tag: string
72
+ timezone?: string
73
+ name?: string
74
+ form_value?: any
75
+ input_value?: string
76
+ option?: string
77
+ options?: string[]
78
+ checked?: boolean
79
+ }
80
+ host: string
81
+ /** 卡片分发类型,固定取值为 url_preview,表示链接预览卡片。仅链接预览卡片有此字段。 */
82
+ delivery_type?: 'url_preview'
83
+ context: {
84
+ url?: string
85
+ preview_token?: string
86
+ open_message_id: string
87
+ open_chat_id: string
88
+ }
89
+ }
90
+ /**
91
+ * 机器人自定义菜单事件
92
+ * @see https://open.feishu.cn/document/client-docs/bot-v3/events/menu
93
+ */
94
+ 'application.bot.menu_v6': {
95
+ operator: {
96
+ operator_name: string
97
+ operator_id: {
98
+ union_id: string
99
+ user_id: string
100
+ open_id: string
101
+ }
102
+ }
103
+ event_key: string
104
+ timestamp: number
105
+ }
106
+ }
107
+
108
+ // In fact, this is the 2.0 version of the event sent by Lark.
109
+ // And only the 2.0 version has the `schema` field.
110
+ export type EventPayload = {
111
+ [K in keyof Events]: {
112
+ schema: '2.0'
113
+ // special added field for TypeScript
114
+ type: K
115
+ header: EventHeader<K>
116
+ event: Events[K]
117
+ }
118
+ }[keyof Events]
119
+
120
+ /**
121
+ * A user in Lark has several different IDs.
122
+ * @see https://open.larksuite.com/document/home/user-identity-introduction/introduction
123
+ */
124
+ export interface UserIds {
125
+ union_id: string
126
+ /** *user_id* only available when the app has permissions granted by the administrator */
127
+ user_id?: string
128
+ open_id: string
129
+ }
130
+
131
+ /**
132
+ * Identify a user in Lark.
133
+ * This behaves like {@link UserIds}, but it only contains *open_id*.
134
+ * (i.e. the id_type is always `open_id`)
135
+ */
136
+ export interface UserIdentifiers {
137
+ id: string
138
+ id_type: string
139
+ }
140
+
141
+ export type UserIdType = 'union_id' | 'user_id' | 'open_id'
142
+ /**
143
+ * The id type when specify a receiver, would be used in the request query.
144
+ *
145
+ * NOTE: we always use **open_id** to identify a user, use **chat_id** to identify a channel.
146
+ * @see https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/create
147
+ */
148
+ export type ReceiveIdType = UserIdType | 'email' | 'chat_id'
149
+
150
+ export type DepartmentIdType = 'department_id' | 'open_department_id'
5
151
 
6
152
  export type Sender =
7
153
  | {
8
- sender_id: Lark.UserIds
154
+ sender_id: UserIds
9
155
  sender_type?: string
10
156
  tenant_key: string
11
157
  }
12
- | (Lark.UserIdentifiers & { sender_type?: string; tenant_key: string })
158
+ | (UserIdentifiers & { sender_type?: string; tenant_key: string })
13
159
 
14
160
  export function adaptSender(sender: Sender, session: Session): Session {
15
161
  let userId: string | undefined
@@ -75,9 +221,14 @@ export async function adaptMessage(bot: LarkBot, data: Events['im.message.receiv
75
221
  export async function adaptSession<C extends Context>(bot: LarkBot<C>, body: EventPayload) {
76
222
  const session = bot.session()
77
223
  session.setInternal('lark', body)
224
+ session.event.referrer = {
225
+ type: body.type,
226
+ event: {},
227
+ }
78
228
 
79
229
  switch (body.type) {
80
230
  case 'im.message.receive_v1':
231
+ session.event.referrer.event.message = pick(body.event.message, ['message_id', 'thread_id'])
81
232
  session.type = 'message'
82
233
  session.subtype = body.event.message.chat_type
83
234
  if (session.subtype === 'p2p') session.subtype = 'private'
@@ -95,6 +246,7 @@ export async function adaptSession<C extends Context>(bot: LarkBot<C>, body: Eve
95
246
  }
96
247
  break
97
248
  case 'card.action.trigger':
249
+ session.event.referrer.event.context = pick(body.event.context, ['open_message_id'])
98
250
  if (body.event.action.value?._satori_type === 'command') {
99
251
  session.type = 'interaction/command'
100
252
  let content = body.event.action.value.content
@@ -134,7 +286,7 @@ export async function adaptSession<C extends Context>(bot: LarkBot<C>, body: Eve
134
286
  }
135
287
 
136
288
  // TODO: This function has many duplicated code with `adaptMessage`, should refactor them
137
- export async function decodeMessage(bot: LarkBot, body: Lark.Message, details = true): Promise<Universal.Message> {
289
+ export async function decodeMessage(bot: LarkBot, body: Message, details = true): Promise<Universal.Message> {
138
290
  const json = JSON.parse(body.body.content)
139
291
  const content: h[] = []
140
292
  switch (body.msg_type) {
@@ -195,7 +347,7 @@ export async function decodeMessage(bot: LarkBot, body: Lark.Message, details =
195
347
  * Get ID type from id string
196
348
  * @see https://open.larksuite.com/document/home/user-identity-introduction/introduction
197
349
  */
198
- export function extractIdType(id: string): Lark.ReceiveIdType {
350
+ export function extractIdType(id: string): ReceiveIdType {
199
351
  if (id.startsWith('ou')) return 'open_id'
200
352
  if (id.startsWith('on')) return 'union_id'
201
353
  if (id.startsWith('oc')) return 'chat_id'
@@ -212,7 +364,7 @@ export function decodeChannel(channelId: string, guild: GetImChatResponse): Univ
212
364
  }
213
365
  }
214
366
 
215
- export function decodeGuild(guild: Lark.ListChat): Universal.Guild {
367
+ export function decodeGuild(guild: ListChat): Universal.Guild {
216
368
  return {
217
369
  id: guild.chat_id,
218
370
  name: guild.name,
@@ -220,7 +372,7 @@ export function decodeGuild(guild: Lark.ListChat): Universal.Guild {
220
372
  }
221
373
  }
222
374
 
223
- export function decodeUser(user: Lark.User): Universal.User {
375
+ export function decodeUser(user: User): Universal.User {
224
376
  return {
225
377
  id: user.open_id,
226
378
  avatar: user.avatar?.avatar_origin,