@satorijs/adapter-lark 3.11.9 → 3.12.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.
- package/lib/bot.d.ts +5 -5
- package/lib/http.d.ts +6 -3
- package/lib/index.cjs +293 -223
- package/lib/types/acs.d.ts +4 -1
- package/lib/types/apaas.d.ts +152 -0
- package/lib/types/application.d.ts +20 -4
- package/lib/types/approval.d.ts +0 -13
- package/lib/types/attendance.d.ts +11 -5
- package/lib/types/authen.d.ts +8 -2
- package/lib/types/bitable.d.ts +25 -4
- package/lib/types/board.d.ts +17 -0
- package/lib/types/calendar.d.ts +16 -5
- package/lib/types/contact.d.ts +55 -12
- package/lib/types/corehr.d.ts +754 -142
- package/lib/types/drive.d.ts +20 -3
- package/lib/types/ehr.d.ts +11 -2
- package/lib/types/helpdesk.d.ts +15 -6
- package/lib/types/hire.d.ts +13 -13
- package/lib/types/human_authentication.d.ts +1 -1
- package/lib/types/im.d.ts +76 -20
- package/lib/types/index.d.ts +712 -115
- package/lib/types/mail.d.ts +106 -16
- package/lib/types/search.d.ts +4 -1
- package/lib/ws.d.ts +30 -0
- package/package.json +6 -3
- package/src/bot.ts +28 -15
- package/src/http.ts +10 -4
- package/src/types/acs.ts +4 -1
- package/src/types/apaas.ts +185 -0
- package/src/types/application.ts +20 -4
- package/src/types/approval.ts +0 -15
- package/src/types/attendance.ts +11 -5
- package/src/types/authen.ts +8 -2
- package/src/types/bitable.ts +25 -4
- package/src/types/board.ts +22 -0
- package/src/types/calendar.ts +16 -5
- package/src/types/contact.ts +55 -12
- package/src/types/corehr.ts +796 -142
- package/src/types/drive.ts +20 -3
- package/src/types/ehr.ts +11 -2
- package/src/types/helpdesk.ts +15 -6
- package/src/types/hire.ts +17 -17
- package/src/types/human_authentication.ts +1 -1
- package/src/types/im.ts +76 -20
- package/src/types/index.ts +738 -115
- package/src/types/mail.ts +106 -16
- package/src/types/search.ts +4 -1
- package/src/ws.ts +183 -0
- package/lib/types/api.d.ts +0 -28510
- package/lib/types/internal.d.ts +0 -21
- package/lib/types/message/content.d.ts +0 -433
- package/lib/types/message/index.d.ts +0 -95
package/lib/types/mail.d.ts
CHANGED
|
@@ -416,7 +416,13 @@ export declare namespace Mail {
|
|
|
416
416
|
name?: string;
|
|
417
417
|
/** The mail group's description */
|
|
418
418
|
description?: string;
|
|
419
|
-
/**
|
|
419
|
+
/**
|
|
420
|
+
* Who can send mail to this mail group. Possible values are:
|
|
421
|
+
* - ANYONE: Any Internet user can send mail to this mail group
|
|
422
|
+
* - ALL_INTERNAL_USERS: Anyone in the team can send mail to this mail group
|
|
423
|
+
* - ALL_GROUP_MEMBERS: Any group member can send mail to this mail group
|
|
424
|
+
* - CUSTOM_MEMBERS: Only custom members can send mail to this mail group, define in mailgroup.permission_members resoure
|
|
425
|
+
*/
|
|
420
426
|
who_can_send_mail?: 'ANYONE' | 'ALL_INTERNAL_USERS' | 'ALL_GROUP_MEMBERS' | 'CUSTOM_MEMBERS';
|
|
421
427
|
}
|
|
422
428
|
interface CreateResponse {
|
|
@@ -434,7 +440,13 @@ export declare namespace Mail {
|
|
|
434
440
|
include_external_member?: boolean;
|
|
435
441
|
/** Value is true if all company members are in this mail group */
|
|
436
442
|
include_all_company_member?: boolean;
|
|
437
|
-
/**
|
|
443
|
+
/**
|
|
444
|
+
* Who can send mail to this mail group. Possible values are:
|
|
445
|
+
* - ANYONE: Any Internet user can send mail to this mail group
|
|
446
|
+
* - ALL_INTERNAL_USERS: Anyone in the team can send mail to this mail group
|
|
447
|
+
* - ALL_GROUP_MEMBERS: Any group member can send mail to this mail group
|
|
448
|
+
* - CUSTOM_MEMBERS: Only custom members can send mail to this mail group, define in mailgroup.permission_members resoure
|
|
449
|
+
*/
|
|
438
450
|
who_can_send_mail?: 'ANYONE' | 'ALL_INTERNAL_USERS' | 'ALL_GROUP_MEMBERS' | 'CUSTOM_MEMBERS';
|
|
439
451
|
}
|
|
440
452
|
interface PatchRequest {
|
|
@@ -444,7 +456,13 @@ export declare namespace Mail {
|
|
|
444
456
|
name?: string;
|
|
445
457
|
/** The mail group's description */
|
|
446
458
|
description?: string;
|
|
447
|
-
/**
|
|
459
|
+
/**
|
|
460
|
+
* Who can send mail to this mail group. Possible values are:
|
|
461
|
+
* - ANYONE: Any Internet user can send mail to this mail group
|
|
462
|
+
* - ALL_INTERNAL_USERS: Anyone in the team can send mail to this mail group
|
|
463
|
+
* - ALL_GROUP_MEMBERS: Any group member can send mail to this mail group
|
|
464
|
+
* - CUSTOM_MEMBERS: Only custom members can send mail to this mail group, define in mailgroup.permission_members resoure
|
|
465
|
+
*/
|
|
448
466
|
who_can_send_mail?: 'ANYONE' | 'ALL_INTERNAL_USERS' | 'ALL_GROUP_MEMBERS' | 'CUSTOM_MEMBERS';
|
|
449
467
|
}
|
|
450
468
|
interface PatchResponse {
|
|
@@ -462,7 +480,13 @@ export declare namespace Mail {
|
|
|
462
480
|
include_external_member?: boolean;
|
|
463
481
|
/** Value is true if all company members are in this mail group */
|
|
464
482
|
include_all_company_member?: boolean;
|
|
465
|
-
/**
|
|
483
|
+
/**
|
|
484
|
+
* Who can send mail to this mail group. Possible values are:
|
|
485
|
+
* - ANYONE: Any Internet user can send mail to this mail group
|
|
486
|
+
* - ALL_INTERNAL_USERS: Anyone in the team can send mail to this mail group
|
|
487
|
+
* - ALL_GROUP_MEMBERS: Any group member can send mail to this mail group
|
|
488
|
+
* - CUSTOM_MEMBERS: Only custom members can send mail to this mail group, define in mailgroup.permission_members resoure
|
|
489
|
+
*/
|
|
466
490
|
who_can_send_mail?: 'ANYONE' | 'ALL_INTERNAL_USERS' | 'ALL_GROUP_MEMBERS' | 'CUSTOM_MEMBERS';
|
|
467
491
|
}
|
|
468
492
|
interface UpdateRequest {
|
|
@@ -472,7 +496,13 @@ export declare namespace Mail {
|
|
|
472
496
|
name?: string;
|
|
473
497
|
/** The mail group's description */
|
|
474
498
|
description?: string;
|
|
475
|
-
/**
|
|
499
|
+
/**
|
|
500
|
+
* Who can send mail to this mail group. Possible values are:
|
|
501
|
+
* - ANYONE: Any Internet user can send mail to this mail group
|
|
502
|
+
* - ALL_INTERNAL_USERS: Anyone in the team can send mail to this mail group
|
|
503
|
+
* - ALL_GROUP_MEMBERS: Any group member can send mail to this mail group
|
|
504
|
+
* - CUSTOM_MEMBERS: Only custom members can send mail to this mail group, define in mailgroup.permission_members resoure
|
|
505
|
+
*/
|
|
476
506
|
who_can_send_mail?: 'ANYONE' | 'ALL_INTERNAL_USERS' | 'ALL_GROUP_MEMBERS' | 'CUSTOM_MEMBERS';
|
|
477
507
|
}
|
|
478
508
|
interface UpdateResponse {
|
|
@@ -490,7 +520,13 @@ export declare namespace Mail {
|
|
|
490
520
|
include_external_member?: boolean;
|
|
491
521
|
/** Value is true if all company members are in this mail group */
|
|
492
522
|
include_all_company_member?: boolean;
|
|
493
|
-
/**
|
|
523
|
+
/**
|
|
524
|
+
* Who can send mail to this mail group. Possible values are:
|
|
525
|
+
* - ANYONE: Any Internet user can send mail to this mail group
|
|
526
|
+
* - ALL_INTERNAL_USERS: Anyone in the team can send mail to this mail group
|
|
527
|
+
* - ALL_GROUP_MEMBERS: Any group member can send mail to this mail group
|
|
528
|
+
* - CUSTOM_MEMBERS: Only custom members can send mail to this mail group, define in mailgroup.permission_members resoure
|
|
529
|
+
*/
|
|
494
530
|
who_can_send_mail?: 'ANYONE' | 'ALL_INTERNAL_USERS' | 'ALL_GROUP_MEMBERS' | 'CUSTOM_MEMBERS';
|
|
495
531
|
}
|
|
496
532
|
interface GetResponse {
|
|
@@ -508,7 +544,13 @@ export declare namespace Mail {
|
|
|
508
544
|
include_external_member?: boolean;
|
|
509
545
|
/** Value is true if all company members are in this mail group */
|
|
510
546
|
include_all_company_member?: boolean;
|
|
511
|
-
/**
|
|
547
|
+
/**
|
|
548
|
+
* Who can send mail to this mail group. Possible values are:
|
|
549
|
+
* - ANYONE: Any Internet user can send mail to this mail group
|
|
550
|
+
* - ALL_INTERNAL_USERS: Anyone in the team can send mail to this mail group
|
|
551
|
+
* - ALL_GROUP_MEMBERS: Any group member can send mail to this mail group
|
|
552
|
+
* - CUSTOM_MEMBERS: Only custom members can send mail to this mail group, define in mailgroup.permission_members resoure
|
|
553
|
+
*/
|
|
512
554
|
who_can_send_mail?: 'ANYONE' | 'ALL_INTERNAL_USERS' | 'ALL_GROUP_MEMBERS' | 'CUSTOM_MEMBERS';
|
|
513
555
|
}
|
|
514
556
|
interface ListQuery extends Pagination {
|
|
@@ -596,7 +638,16 @@ export declare namespace Mail {
|
|
|
596
638
|
user_id?: string;
|
|
597
639
|
/** The member's department id. Value is valid when type is DEPARTMENT */
|
|
598
640
|
department_id?: string;
|
|
599
|
-
/**
|
|
641
|
+
/**
|
|
642
|
+
* The type of member. Possible values are:
|
|
643
|
+
* - USER: internal user in the team
|
|
644
|
+
* - DEPARTMENT: member is a department
|
|
645
|
+
* - COMPANY: member is the company
|
|
646
|
+
* - EXTERNAL_USER: internet user outside the organization
|
|
647
|
+
* - MAIL_GROUP: member is another mail group
|
|
648
|
+
* - PUBLIC_MAILBOX: member is a public mailbox
|
|
649
|
+
* - OTHER_MEMBER: other internal member
|
|
650
|
+
*/
|
|
600
651
|
type?: 'USER' | 'DEPARTMENT' | 'COMPANY' | 'EXTERNAL_USER' | 'MAIL_GROUP' | 'PUBLIC_MAILBOX' | 'OTHER_MEMBER';
|
|
601
652
|
}
|
|
602
653
|
interface CreateQuery {
|
|
@@ -614,7 +665,16 @@ export declare namespace Mail {
|
|
|
614
665
|
user_id?: string;
|
|
615
666
|
/** The member's department id. Value is valid when type is DEPARTMENT */
|
|
616
667
|
department_id?: string;
|
|
617
|
-
/**
|
|
668
|
+
/**
|
|
669
|
+
* The type of member. Possible values are:
|
|
670
|
+
* - USER: internal user in the team
|
|
671
|
+
* - DEPARTMENT: member is a department
|
|
672
|
+
* - COMPANY: member is the company
|
|
673
|
+
* - EXTERNAL_USER: internet user outside the organization
|
|
674
|
+
* - MAIL_GROUP: member is another mail group
|
|
675
|
+
* - PUBLIC_MAILBOX: member is a public mailbox
|
|
676
|
+
* - OTHER_MEMBER: other internal member
|
|
677
|
+
*/
|
|
618
678
|
type?: 'USER' | 'DEPARTMENT' | 'COMPANY' | 'EXTERNAL_USER' | 'MAIL_GROUP' | 'PUBLIC_MAILBOX' | 'OTHER_MEMBER';
|
|
619
679
|
}
|
|
620
680
|
interface GetQuery {
|
|
@@ -632,7 +692,16 @@ export declare namespace Mail {
|
|
|
632
692
|
user_id?: string;
|
|
633
693
|
/** The member's department id. Value is valid when type is DEPARTMENT */
|
|
634
694
|
department_id?: string;
|
|
635
|
-
/**
|
|
695
|
+
/**
|
|
696
|
+
* The type of member. Possible values are:
|
|
697
|
+
* - USER: internal user in the team
|
|
698
|
+
* - DEPARTMENT: member is a department
|
|
699
|
+
* - COMPANY: member is the company
|
|
700
|
+
* - EXTERNAL_USER: internet user outside the organization
|
|
701
|
+
* - MAIL_GROUP: member is another mail group
|
|
702
|
+
* - PUBLIC_MAILBOX: member is a public mailbox
|
|
703
|
+
* - OTHER_MEMBER: other internal member
|
|
704
|
+
*/
|
|
636
705
|
type?: 'USER' | 'DEPARTMENT' | 'COMPANY' | 'EXTERNAL_USER' | 'MAIL_GROUP' | 'PUBLIC_MAILBOX' | 'OTHER_MEMBER';
|
|
637
706
|
}
|
|
638
707
|
interface ListQuery extends Pagination {
|
|
@@ -731,7 +800,11 @@ export declare namespace Mail {
|
|
|
731
800
|
department_id?: string;
|
|
732
801
|
/** The member's email address. Value is valid when type is MAIL_GROUP/PUBLIC_MAILBOX */
|
|
733
802
|
email?: string;
|
|
734
|
-
/**
|
|
803
|
+
/**
|
|
804
|
+
* The type of member. Possible values are:
|
|
805
|
+
* - USER: internal user in the team
|
|
806
|
+
* - DEPARTMENT: member is a department
|
|
807
|
+
*/
|
|
735
808
|
type?: 'USER' | 'DEPARTMENT' | 'MAIL_GROUP' | 'PUBLIC_MAILBOX';
|
|
736
809
|
}
|
|
737
810
|
interface CreateQuery {
|
|
@@ -749,7 +822,11 @@ export declare namespace Mail {
|
|
|
749
822
|
department_id?: string;
|
|
750
823
|
/** The member's email address. Value is valid when type is MAIL_GROUP/PUBLIC_MAILBOX */
|
|
751
824
|
email?: string;
|
|
752
|
-
/**
|
|
825
|
+
/**
|
|
826
|
+
* The type of member. Possible values are:
|
|
827
|
+
* - USER: internal user in the team
|
|
828
|
+
* - DEPARTMENT: member is a department
|
|
829
|
+
*/
|
|
753
830
|
type?: 'USER' | 'DEPARTMENT' | 'MAIL_GROUP' | 'PUBLIC_MAILBOX';
|
|
754
831
|
}
|
|
755
832
|
interface GetQuery {
|
|
@@ -767,7 +844,11 @@ export declare namespace Mail {
|
|
|
767
844
|
department_id?: string;
|
|
768
845
|
/** The member's email address. Value is valid when type is MAIL_GROUP/PUBLIC_MAILBOX */
|
|
769
846
|
email?: string;
|
|
770
|
-
/**
|
|
847
|
+
/**
|
|
848
|
+
* The type of member. Possible values are:
|
|
849
|
+
* - USER: internal user in the team
|
|
850
|
+
* - DEPARTMENT: member is a department
|
|
851
|
+
*/
|
|
771
852
|
type?: 'USER' | 'DEPARTMENT' | 'MAIL_GROUP' | 'PUBLIC_MAILBOX';
|
|
772
853
|
}
|
|
773
854
|
interface ListQuery extends Pagination {
|
|
@@ -937,7 +1018,10 @@ export declare namespace Mail {
|
|
|
937
1018
|
interface CreateRequest {
|
|
938
1019
|
/** The member's user id. Value is valid when type is USER */
|
|
939
1020
|
user_id?: string;
|
|
940
|
-
/**
|
|
1021
|
+
/**
|
|
1022
|
+
* The type of member. Possible values are:
|
|
1023
|
+
* - USER: internal user in the team
|
|
1024
|
+
*/
|
|
941
1025
|
type?: 'USER';
|
|
942
1026
|
}
|
|
943
1027
|
interface CreateQuery {
|
|
@@ -949,7 +1033,10 @@ export declare namespace Mail {
|
|
|
949
1033
|
member_id?: string;
|
|
950
1034
|
/** The member's user id. Value is valid when type is USER */
|
|
951
1035
|
user_id?: string;
|
|
952
|
-
/**
|
|
1036
|
+
/**
|
|
1037
|
+
* The type of member. Possible values are:
|
|
1038
|
+
* - USER: internal user in the team
|
|
1039
|
+
*/
|
|
953
1040
|
type?: 'USER';
|
|
954
1041
|
}
|
|
955
1042
|
interface GetQuery {
|
|
@@ -961,7 +1048,10 @@ export declare namespace Mail {
|
|
|
961
1048
|
member_id?: string;
|
|
962
1049
|
/** The member's user id. Value is valid when type is USER */
|
|
963
1050
|
user_id?: string;
|
|
964
|
-
/**
|
|
1051
|
+
/**
|
|
1052
|
+
* The type of member. Possible values are:
|
|
1053
|
+
* - USER: internal user in the team
|
|
1054
|
+
*/
|
|
965
1055
|
type?: 'USER';
|
|
966
1056
|
}
|
|
967
1057
|
interface ListQuery extends Pagination {
|
package/lib/types/search.d.ts
CHANGED
|
@@ -174,7 +174,10 @@ export declare namespace Search {
|
|
|
174
174
|
BASIC = 1
|
|
175
175
|
}
|
|
176
176
|
interface ListQuery extends Pagination {
|
|
177
|
-
/**
|
|
177
|
+
/**
|
|
178
|
+
* 回包数据格式,0-全量数据;1-摘要数据。
|
|
179
|
+
* **注**:摘要数据仅包含"id","name","state"。
|
|
180
|
+
*/
|
|
178
181
|
view?: ListQueryView;
|
|
179
182
|
}
|
|
180
183
|
namespace Item {
|
package/lib/ws.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Adapter, Context, Schema } from '@satorijs/core';
|
|
2
|
+
import { LarkBot } from './bot';
|
|
3
|
+
import pb from 'protobufjs/light';
|
|
4
|
+
interface FrameSegment {
|
|
5
|
+
message_id: string;
|
|
6
|
+
sum: number;
|
|
7
|
+
seq: number;
|
|
8
|
+
data: Uint8Array;
|
|
9
|
+
}
|
|
10
|
+
export declare class WsClient<C extends Context = Context> extends Adapter.WsClient<C, LarkBot<C, LarkBot.BaseConfig & WsClient.Options>> {
|
|
11
|
+
_deviceId: string;
|
|
12
|
+
_serviceId: number;
|
|
13
|
+
_pingInterval: number;
|
|
14
|
+
_ping: NodeJS.Timeout;
|
|
15
|
+
_cache: Record<string, FrameSegment[]>;
|
|
16
|
+
_frame: pb.Type;
|
|
17
|
+
constructor(ctx: C, bot: LarkBot<C, LarkBot.BaseConfig & WsClient.Options>);
|
|
18
|
+
prepare(): Promise<WebSocket>;
|
|
19
|
+
ping(): void;
|
|
20
|
+
accept(): Promise<void>;
|
|
21
|
+
send(frame: any): void;
|
|
22
|
+
retrieve(seg: FrameSegment): Uint8Array | undefined;
|
|
23
|
+
}
|
|
24
|
+
export declare namespace WsClient {
|
|
25
|
+
interface Options extends Adapter.WsClientConfig {
|
|
26
|
+
protocol: 'ws';
|
|
27
|
+
}
|
|
28
|
+
const Options: Schema<Options>;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
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.12.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.cjs",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -34,13 +34,16 @@
|
|
|
34
34
|
"chat"
|
|
35
35
|
],
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@cordisjs/plugin-server": "^0.2.
|
|
37
|
+
"@cordisjs/plugin-server": "^0.2.9",
|
|
38
38
|
"@satorijs/core": "^4.5.2",
|
|
39
39
|
"cordis": "^3.18.1",
|
|
40
|
-
"cosmokit": "^1.
|
|
40
|
+
"cosmokit": "^1.8.1",
|
|
41
41
|
"dedent": "^1.5.3"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@satorijs/core": "^4.5.2"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"protobufjs": "^8.0.0"
|
|
45
48
|
}
|
|
46
49
|
}
|
package/src/bot.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Bot, Context, h, HTTP, Schema, Time, Universal } from '@satorijs/core'
|
|
2
2
|
import { Im } from './types'
|
|
3
3
|
import { HttpServer } from './http'
|
|
4
|
+
import { WsClient } from './ws'
|
|
4
5
|
import { LarkMessageEncoder } from './message'
|
|
5
6
|
import { Internal } from './internal'
|
|
6
7
|
import * as Utils from './utils'
|
|
@@ -14,7 +15,7 @@ const fileTypeMap: Record<Exclude<Im.File.CreateForm['file_type'], 'stream'>, st
|
|
|
14
15
|
ppt: ['application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
export class LarkBot<C extends Context = Context> extends Bot<C,
|
|
18
|
+
export class LarkBot<C extends Context = Context, T extends LarkBot.Config = LarkBot.Config> extends Bot<C, T> {
|
|
18
19
|
static inject = ['server', 'http']
|
|
19
20
|
static MessageEncoder = LarkMessageEncoder
|
|
20
21
|
|
|
@@ -23,7 +24,7 @@ export class LarkBot<C extends Context = Context> extends Bot<C, LarkBot.Config>
|
|
|
23
24
|
assetsQuester: HTTP
|
|
24
25
|
internal: Internal<C>
|
|
25
26
|
|
|
26
|
-
constructor(ctx: C, config:
|
|
27
|
+
constructor(ctx: C, config: T) {
|
|
27
28
|
super(ctx, config, 'lark')
|
|
28
29
|
|
|
29
30
|
this.http = ctx.http.extend({
|
|
@@ -32,7 +33,11 @@ export class LarkBot<C extends Context = Context> extends Bot<C, LarkBot.Config>
|
|
|
32
33
|
this.assetsQuester = ctx.http
|
|
33
34
|
this.internal = new Internal(this)
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
if (config.protocol === 'http') {
|
|
37
|
+
ctx.plugin(HttpServer, this)
|
|
38
|
+
} else if (config.protocol === 'ws') {
|
|
39
|
+
ctx.plugin(WsClient, this as any)
|
|
40
|
+
}
|
|
36
41
|
|
|
37
42
|
this.defineInternalRoute('/*path', async ({ params, method, headers, body, query }) => {
|
|
38
43
|
const response = await this.http('/' + params.path, {
|
|
@@ -78,6 +83,7 @@ export class LarkBot<C extends Context = Context> extends Bot<C, LarkBot.Config>
|
|
|
78
83
|
// 剩余有效期小于 30 分钟时,调用本接口会返回一个新的 tenant_access_token,此时会同时存在两个有效的 tenant_access_token。
|
|
79
84
|
// 剩余有效期大于等于 30 分钟时,调用本接口会返回原有的 tenant_access_token。
|
|
80
85
|
// 初次获得 token 后的半小时内必须刷新一次,因为初次获得的 token 可能是 1.5 小时前生成的。
|
|
86
|
+
if (!this.isActive) return
|
|
81
87
|
let timeout = Time.minute * 20
|
|
82
88
|
try {
|
|
83
89
|
const { tenant_access_token: token } = await this.internal.auth.tenantAccessTokenInternal({
|
|
@@ -170,35 +176,42 @@ export class LarkBot<C extends Context = Context> extends Bot<C, LarkBot.Config>
|
|
|
170
176
|
}
|
|
171
177
|
|
|
172
178
|
export namespace LarkBot {
|
|
173
|
-
export interface
|
|
179
|
+
export interface BaseConfig extends HTTP.Config {
|
|
174
180
|
appId: string
|
|
175
181
|
appSecret: string
|
|
176
|
-
encryptKey?: string
|
|
177
|
-
verificationToken?: string
|
|
178
182
|
}
|
|
179
183
|
|
|
184
|
+
export type Config = BaseConfig & (HttpServer.Options | WsClient.Options)
|
|
185
|
+
|
|
180
186
|
export const Config: Schema<Config> = Schema.intersect([
|
|
181
187
|
Schema.object({
|
|
182
|
-
platform: Schema.union(['feishu', 'lark']).
|
|
188
|
+
platform: Schema.union(['feishu', 'lark']).default('feishu').description('平台名称。'),
|
|
183
189
|
appId: Schema.string().required().description('机器人的应用 ID。'),
|
|
184
190
|
appSecret: Schema.string().role('secret').required().description('机器人的应用密钥。'),
|
|
185
|
-
|
|
186
|
-
|
|
191
|
+
protocol: process.env.KOISHI_ENV === 'browser'
|
|
192
|
+
? Schema.const('ws').default('ws')
|
|
193
|
+
: Schema.union(['http', 'ws']).description('选择要使用的协议。').default('http'),
|
|
187
194
|
}),
|
|
188
195
|
Schema.union([
|
|
189
196
|
Schema.intersect([
|
|
190
197
|
Schema.object({
|
|
191
|
-
platform: Schema.const('
|
|
198
|
+
platform: Schema.const('lark').required(),
|
|
192
199
|
}),
|
|
193
|
-
HTTP.createConfig('https://open.
|
|
194
|
-
|
|
200
|
+
HTTP.createConfig('https://open.larksuite.com/open-apis'),
|
|
201
|
+
Schema.union([
|
|
202
|
+
HttpServer.createConfig('/lark'),
|
|
203
|
+
WsClient.Options,
|
|
204
|
+
]),
|
|
195
205
|
]),
|
|
196
206
|
Schema.intersect([
|
|
197
207
|
Schema.object({
|
|
198
|
-
platform: Schema.const('
|
|
208
|
+
platform: Schema.const('feishu') as any,
|
|
199
209
|
}),
|
|
200
|
-
HTTP.createConfig('https://open.
|
|
201
|
-
|
|
210
|
+
HTTP.createConfig('https://open.feishu.cn/open-apis'),
|
|
211
|
+
Schema.union([
|
|
212
|
+
HttpServer.createConfig('/feishu'),
|
|
213
|
+
WsClient.Options,
|
|
214
|
+
]),
|
|
202
215
|
]),
|
|
203
216
|
]),
|
|
204
217
|
])
|
package/src/http.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {} from '@cordisjs/plugin-server'
|
|
|
3
3
|
import { LarkBot } from './bot'
|
|
4
4
|
import { adaptSession, Cipher, EventPayload } from './utils'
|
|
5
5
|
|
|
6
|
-
export class HttpServer<C extends Context = Context> extends Adapter<C, LarkBot<C>> {
|
|
6
|
+
export class HttpServer<C extends Context = Context> extends Adapter<C, LarkBot<C, LarkBot.BaseConfig & HttpServer.Options>> {
|
|
7
7
|
static inject = ['server']
|
|
8
8
|
|
|
9
9
|
private logger: Logger
|
|
@@ -14,14 +14,14 @@ export class HttpServer<C extends Context = Context> extends Adapter<C, LarkBot<
|
|
|
14
14
|
this.logger = ctx.logger('lark')
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
fork(ctx: C, bot: LarkBot<C>) {
|
|
17
|
+
fork(ctx: C, bot: LarkBot<C, LarkBot.BaseConfig & HttpServer.Options>) {
|
|
18
18
|
super.fork(ctx, bot)
|
|
19
19
|
|
|
20
20
|
this._refreshCipher()
|
|
21
21
|
return bot.initialize()
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
async connect(bot: LarkBot) {
|
|
24
|
+
async connect(bot: LarkBot<C, LarkBot.BaseConfig & HttpServer.Options>) {
|
|
25
25
|
const { path } = bot.config
|
|
26
26
|
bot.ctx.server.post(path, (ctx) => {
|
|
27
27
|
this._refreshCipher()
|
|
@@ -70,7 +70,7 @@ export class HttpServer<C extends Context = Context> extends Adapter<C, LarkBot<
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
// dispatch message
|
|
73
|
-
bot.logger.debug('received
|
|
73
|
+
bot.logger.debug('received decrypted event: %o', body)
|
|
74
74
|
this.dispatchSession(body)
|
|
75
75
|
|
|
76
76
|
// Lark requires 200 OK response to make sure event is received
|
|
@@ -124,15 +124,21 @@ export class HttpServer<C extends Context = Context> extends Adapter<C, LarkBot<
|
|
|
124
124
|
|
|
125
125
|
export namespace HttpServer {
|
|
126
126
|
export interface Options {
|
|
127
|
+
protocol: 'http'
|
|
127
128
|
selfUrl?: string
|
|
128
129
|
path?: string
|
|
130
|
+
encryptKey?: string
|
|
131
|
+
verificationToken?: string
|
|
129
132
|
verifyToken?: boolean
|
|
130
133
|
verifySignature?: boolean
|
|
131
134
|
}
|
|
132
135
|
|
|
133
136
|
export const createConfig = (path: string): Schema<Options> => Schema.object({
|
|
137
|
+
protocol: Schema.const('http'),
|
|
134
138
|
path: Schema.string().role('url').description('要连接的服务器地址。').default(path),
|
|
135
139
|
selfUrl: Schema.string().role('link').description('服务器暴露在公网的地址。缺省时将使用全局配置。'),
|
|
140
|
+
encryptKey: Schema.string().role('secret').description('机器人的 Encrypt Key。'),
|
|
141
|
+
verificationToken: Schema.string().description('事件推送的验证令牌。'),
|
|
136
142
|
verifyToken: Schema.boolean().description('是否验证令牌。'),
|
|
137
143
|
verifySignature: Schema.boolean().description('是否验证签名。'),
|
|
138
144
|
}).description('服务端设置')
|
package/src/types/acs.ts
CHANGED
|
@@ -226,7 +226,10 @@ export namespace Acs {
|
|
|
226
226
|
export interface ListQuery extends Pagination {
|
|
227
227
|
/** 记录开始时间,单位秒 */
|
|
228
228
|
from: number
|
|
229
|
-
/**
|
|
229
|
+
/**
|
|
230
|
+
* 记录结束时间,单位秒,
|
|
231
|
+
* 时间跨度不能超过30天
|
|
232
|
+
*/
|
|
230
233
|
to: number
|
|
231
234
|
/** 门禁设备 ID */
|
|
232
235
|
device_id?: string
|