mobx-lark 2.0.0 → 2.1.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/LICENSE +165 -165
- package/ReadMe.md +39 -42
- package/dist/Lark.d.ts +22 -8
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/module/BITable/index.d.ts +45 -49
- package/dist/module/BITable/type.d.ts +7 -1
- package/dist/module/BITable/utility.d.ts +10 -0
- package/dist/module/InstantMessenger/index.d.ts +8 -8
- package/dist/module/Task/index.d.ts +16 -16
- package/dist/module/Wiki/type.d.ts +5 -0
- package/dist/module/index.d.ts +1 -0
- package/dist/type.d.ts +2 -2
- package/package.json +20 -20
- package/src/Lark.ts +226 -174
- package/src/index.ts +3 -3
- package/src/module/BITable/index.ts +283 -301
- package/src/module/BITable/type.ts +120 -112
- package/src/module/BITable/utility.ts +57 -0
- package/src/module/InstantMessenger/index.ts +82 -82
- package/src/module/InstantMessenger/type/index.ts +60 -60
- package/src/module/InstantMessenger/type/message.ts +141 -141
- package/src/module/SpreadSheet/index.ts +78 -78
- package/src/module/SpreadSheet/type.ts +31 -31
- package/src/module/Task/index.ts +278 -278
- package/src/module/Task/type.ts +168 -168
- package/src/module/Wiki/type.ts +16 -0
- package/src/module/base.ts +34 -34
- package/src/module/index.ts +6 -5
- package/src/type.ts +75 -71
- package/tsconfig.json +21 -21
|
@@ -1,112 +1,120 @@
|
|
|
1
|
-
import { LarkData, LocaleUser } from '../../type';
|
|
2
|
-
|
|
3
|
-
export interface RevisionTable {
|
|
4
|
-
name: string;
|
|
5
|
-
revision: number;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface BITable extends RevisionTable {
|
|
9
|
-
table_id: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface TableView extends Record<'view_id' | 'view_name', string> {
|
|
13
|
-
view_type: 'grid' | 'form';
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
|
93
|
-
|
|
|
94
|
-
|
|
|
95
|
-
|
|
|
96
|
-
|
|
|
97
|
-
|
|
|
98
|
-
|
|
99
|
-
export type
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
1
|
+
import { LarkData, LocaleUser } from '../../type';
|
|
2
|
+
|
|
3
|
+
export interface RevisionTable {
|
|
4
|
+
name: string;
|
|
5
|
+
revision: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface BITable extends RevisionTable {
|
|
9
|
+
table_id: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface TableView extends Record<'view_id' | 'view_name', string> {
|
|
13
|
+
view_type: 'grid' | 'kanban' | 'gallery' | 'gantt' | 'form';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface TableFormView
|
|
17
|
+
extends Record<'name' | 'description' | 'shared_url', string>,
|
|
18
|
+
Record<'shared' | 'submit_limit_once', boolean> {
|
|
19
|
+
shared_limit: 'tenant_editable';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type LarkFormData = LarkData<{ form: TableFormView }>;
|
|
23
|
+
|
|
24
|
+
export interface TableCellText {
|
|
25
|
+
type: 'text';
|
|
26
|
+
text: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type TableCellLocation = Record<
|
|
30
|
+
| 'name'
|
|
31
|
+
| 'pname'
|
|
32
|
+
| 'cityname'
|
|
33
|
+
| 'adname'
|
|
34
|
+
| 'address'
|
|
35
|
+
| 'full_address'
|
|
36
|
+
| 'location',
|
|
37
|
+
string
|
|
38
|
+
>;
|
|
39
|
+
|
|
40
|
+
export interface TableCellLink extends Record<'link' | 'text', string> {
|
|
41
|
+
type: 'url';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface TableCellMedia
|
|
45
|
+
extends Record<'file_token' | 'name' | `${'' | 'tmp_'}url`, string> {
|
|
46
|
+
type: `${string}/${string}`;
|
|
47
|
+
size: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface TableCellAttachment
|
|
51
|
+
extends Pick<TableCellMedia, 'name' | 'size'>,
|
|
52
|
+
Record<'id' | 'attachmentToken', string>,
|
|
53
|
+
Record<'height' | 'timeStamp' | 'width', number> {
|
|
54
|
+
mimeType: TableCellMedia['type'];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface TableCellUser extends LocaleUser {
|
|
58
|
+
id: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export type TableCellGroup = Record<'id' | 'name' | 'avatar_url', string>;
|
|
62
|
+
|
|
63
|
+
export interface TableCellMetion
|
|
64
|
+
extends Record<'mentionType' | 'text', string> {
|
|
65
|
+
type: 'mention';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface TableCellUserMetion
|
|
69
|
+
extends TableCellMetion,
|
|
70
|
+
Record<'name' | 'token', string> {
|
|
71
|
+
mentionType: 'User';
|
|
72
|
+
mentionNotify: boolean;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface TableCellDocumentMetion
|
|
76
|
+
extends TableCellMetion,
|
|
77
|
+
Record<'link' | 'token', string> {
|
|
78
|
+
mentionType: 'Bitable';
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface TableCellRelation extends TableCellText {
|
|
82
|
+
table_id: string;
|
|
83
|
+
record_ids: string[];
|
|
84
|
+
text_arr: string[];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type TableCellObject =
|
|
88
|
+
| TableCellLocation
|
|
89
|
+
| TableCellText
|
|
90
|
+
| TableCellLink
|
|
91
|
+
| TableCellMedia
|
|
92
|
+
| TableCellAttachment
|
|
93
|
+
| TableCellUser
|
|
94
|
+
| TableCellGroup
|
|
95
|
+
| TableCellUserMetion
|
|
96
|
+
| TableCellDocumentMetion
|
|
97
|
+
| TableCellRelation;
|
|
98
|
+
|
|
99
|
+
export type TableCellValue =
|
|
100
|
+
| string
|
|
101
|
+
| number
|
|
102
|
+
| boolean
|
|
103
|
+
| TableCellObject
|
|
104
|
+
| (string | TableCellObject)[]
|
|
105
|
+
| null;
|
|
106
|
+
|
|
107
|
+
export type TableRecordFields = Record<string, TableCellValue>;
|
|
108
|
+
|
|
109
|
+
export interface TableRecord<T extends TableRecordFields>
|
|
110
|
+
extends Record<'id' | 'record_id', string> {
|
|
111
|
+
created_by: TableCellUser;
|
|
112
|
+
created_time: number;
|
|
113
|
+
last_modified_by?: TableCellUser;
|
|
114
|
+
last_modified_time?: number;
|
|
115
|
+
fields: T;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export type TableRecordData<T extends TableRecordFields> = LarkData<{
|
|
119
|
+
record: TableRecord<T>;
|
|
120
|
+
}>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { DataObject } from 'mobx-restful';
|
|
2
|
+
import {
|
|
3
|
+
TableCellLink,
|
|
4
|
+
TableCellLocation,
|
|
5
|
+
TableCellRelation,
|
|
6
|
+
TableCellText
|
|
7
|
+
} from './type';
|
|
8
|
+
|
|
9
|
+
export type FilterOperator = '<' | '<=' | '=' | '!=' | '=>' | '>' | 'contains';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @see https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/bitable-v1/filter
|
|
13
|
+
*/
|
|
14
|
+
export function makeSimpleFilter(
|
|
15
|
+
data: DataObject,
|
|
16
|
+
operator: FilterOperator = 'contains',
|
|
17
|
+
relation: 'AND' | 'OR' = 'AND'
|
|
18
|
+
) {
|
|
19
|
+
const list = Object.entries(data)
|
|
20
|
+
.map(
|
|
21
|
+
([key, value]) =>
|
|
22
|
+
value != null &&
|
|
23
|
+
(value instanceof Array ? value : [value]).map(
|
|
24
|
+
(item: string) =>
|
|
25
|
+
`CurrentValue.[${key}]` +
|
|
26
|
+
(operator === 'contains'
|
|
27
|
+
? `.contains("${item}")`
|
|
28
|
+
: `${operator}${JSON.stringify(item)}`)
|
|
29
|
+
)
|
|
30
|
+
)
|
|
31
|
+
.filter(Boolean)
|
|
32
|
+
.flat() as string[];
|
|
33
|
+
|
|
34
|
+
return list[1] ? `${relation}(${list})` : list[0];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const normalizeText = (
|
|
38
|
+
value: TableCellText | TableCellLink | TableCellRelation
|
|
39
|
+
) =>
|
|
40
|
+
(value && typeof value === 'object' && 'text' in value && value.text) || '';
|
|
41
|
+
|
|
42
|
+
export const normalizeTextArray = (list: TableCellText[]) =>
|
|
43
|
+
list.reduce(
|
|
44
|
+
(sum, item) => {
|
|
45
|
+
if (item.text === ',') sum.push('');
|
|
46
|
+
else sum[sum.length - 1] += normalizeText(item);
|
|
47
|
+
|
|
48
|
+
return sum;
|
|
49
|
+
},
|
|
50
|
+
['']
|
|
51
|
+
);
|
|
52
|
+
export function coordinateOf(location: TableCellLocation): [number, number] {
|
|
53
|
+
const [longitude, latitude] =
|
|
54
|
+
(location as TableCellLocation)?.location.split(',') || [];
|
|
55
|
+
|
|
56
|
+
return [+latitude, +longitude];
|
|
57
|
+
}
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import { ListModel, NewData, Stream, toggle } from 'mobx-restful';
|
|
2
|
-
import { buildURLData } from 'web-utility';
|
|
3
|
-
|
|
4
|
-
import { LarkData } from '../../type';
|
|
5
|
-
import { createPageStream } from '../base';
|
|
6
|
-
import { ChatMessage, ChatMeta, SendChatMessage } from './type';
|
|
7
|
-
|
|
8
|
-
export * from './type';
|
|
9
|
-
|
|
10
|
-
export abstract class ChatListModel extends Stream<ChatMeta>(ListModel) {
|
|
11
|
-
baseURI = 'im/v1/chats';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @see {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/list}
|
|
15
|
-
*/
|
|
16
|
-
async *openStream() {
|
|
17
|
-
for await (const item of createPageStream<ChatMeta>(
|
|
18
|
-
this.client,
|
|
19
|
-
this.baseURI,
|
|
20
|
-
total => (this.totalCount = total)
|
|
21
|
-
))
|
|
22
|
-
yield item;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @see https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/create
|
|
27
|
-
*/
|
|
28
|
-
@toggle('uploading')
|
|
29
|
-
async updateOne({ chat_id }: NewData<ChatMeta>) {
|
|
30
|
-
const { body } = await (chat_id
|
|
31
|
-
? this.client.put<LarkData<ChatMeta>>(
|
|
32
|
-
`${this.baseURI}/chats/${chat_id}`
|
|
33
|
-
)
|
|
34
|
-
: this.client.post<LarkData<ChatMeta>>(
|
|
35
|
-
`${this.baseURI}/chats?${buildURLData({
|
|
36
|
-
set_bot_manager: true
|
|
37
|
-
})}`
|
|
38
|
-
));
|
|
39
|
-
return (this.currentOne = body!.data!);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export abstract class MessageListModel extends Stream<ChatMessage>(ListModel) {
|
|
44
|
-
baseURI = 'im/v1/messages';
|
|
45
|
-
|
|
46
|
-
constructor(public chatId: string) {
|
|
47
|
-
super();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @see {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/list}
|
|
52
|
-
*/
|
|
53
|
-
async *openStream() {
|
|
54
|
-
for await (const item of createPageStream<ChatMessage>(
|
|
55
|
-
this.client,
|
|
56
|
-
this.baseURI,
|
|
57
|
-
total => (this.totalCount = total)
|
|
58
|
-
))
|
|
59
|
-
yield item;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @see https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/create
|
|
64
|
-
*/
|
|
65
|
-
@toggle('uploading')
|
|
66
|
-
async createOne({
|
|
67
|
-
msg_type,
|
|
68
|
-
content
|
|
69
|
-
}: Omit<SendChatMessage, 'receive_id'>) {
|
|
70
|
-
const { body } = await this.client.post<LarkData<ChatMessage>>(
|
|
71
|
-
`${this.baseURI}?${buildURLData({
|
|
72
|
-
receive_id_type: 'chat_id'
|
|
73
|
-
})}`,
|
|
74
|
-
{
|
|
75
|
-
receive_id: this.chatId,
|
|
76
|
-
msg_type,
|
|
77
|
-
content: JSON.stringify(content)
|
|
78
|
-
}
|
|
79
|
-
);
|
|
80
|
-
return (this.currentOne = body!.data!);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
1
|
+
import { ListModel, NewData, Stream, toggle } from 'mobx-restful';
|
|
2
|
+
import { buildURLData } from 'web-utility';
|
|
3
|
+
|
|
4
|
+
import { LarkData } from '../../type';
|
|
5
|
+
import { createPageStream } from '../base';
|
|
6
|
+
import { ChatMessage, ChatMeta, SendChatMessage } from './type';
|
|
7
|
+
|
|
8
|
+
export * from './type';
|
|
9
|
+
|
|
10
|
+
export abstract class ChatListModel extends Stream<ChatMeta>(ListModel) {
|
|
11
|
+
baseURI = 'im/v1/chats';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @see {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/list}
|
|
15
|
+
*/
|
|
16
|
+
async *openStream() {
|
|
17
|
+
for await (const item of createPageStream<ChatMeta>(
|
|
18
|
+
this.client,
|
|
19
|
+
this.baseURI,
|
|
20
|
+
total => (this.totalCount = total)
|
|
21
|
+
))
|
|
22
|
+
yield item;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @see https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/create
|
|
27
|
+
*/
|
|
28
|
+
@toggle('uploading')
|
|
29
|
+
async updateOne({ chat_id }: NewData<ChatMeta>) {
|
|
30
|
+
const { body } = await (chat_id
|
|
31
|
+
? this.client.put<LarkData<ChatMeta>>(
|
|
32
|
+
`${this.baseURI}/chats/${chat_id}`
|
|
33
|
+
)
|
|
34
|
+
: this.client.post<LarkData<ChatMeta>>(
|
|
35
|
+
`${this.baseURI}/chats?${buildURLData({
|
|
36
|
+
set_bot_manager: true
|
|
37
|
+
})}`
|
|
38
|
+
));
|
|
39
|
+
return (this.currentOne = body!.data!);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export abstract class MessageListModel extends Stream<ChatMessage>(ListModel) {
|
|
44
|
+
baseURI = 'im/v1/messages';
|
|
45
|
+
|
|
46
|
+
constructor(public chatId: string) {
|
|
47
|
+
super();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @see {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/list}
|
|
52
|
+
*/
|
|
53
|
+
async *openStream() {
|
|
54
|
+
for await (const item of createPageStream<ChatMessage>(
|
|
55
|
+
this.client,
|
|
56
|
+
this.baseURI,
|
|
57
|
+
total => (this.totalCount = total)
|
|
58
|
+
))
|
|
59
|
+
yield item;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @see https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/create
|
|
64
|
+
*/
|
|
65
|
+
@toggle('uploading')
|
|
66
|
+
async createOne({
|
|
67
|
+
msg_type,
|
|
68
|
+
content
|
|
69
|
+
}: Omit<SendChatMessage, 'receive_id'>) {
|
|
70
|
+
const { body } = await this.client.post<LarkData<ChatMessage>>(
|
|
71
|
+
`${this.baseURI}?${buildURLData({
|
|
72
|
+
receive_id_type: 'chat_id'
|
|
73
|
+
})}`,
|
|
74
|
+
{
|
|
75
|
+
receive_id: this.chatId,
|
|
76
|
+
msg_type,
|
|
77
|
+
content: JSON.stringify(content)
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
return (this.currentOne = body!.data!);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import { TranslationMap } from '../../../type';
|
|
2
|
-
import { ChatMessageContent } from './message';
|
|
3
|
-
|
|
4
|
-
export * from './message';
|
|
5
|
-
|
|
6
|
-
export type ChatPermission = 'all_members' | 'only_owner' | 'not_anyone';
|
|
7
|
-
|
|
8
|
-
export interface CreateChatMeta
|
|
9
|
-
extends Record<'owner_id' | 'avatar' | 'name' | 'description', string>,
|
|
10
|
-
Record<`${'join' | 'leave'}_message_visibility`, ChatPermission>,
|
|
11
|
-
Record<`${'user' | 'bot'}_id_list`, string[]> {
|
|
12
|
-
chat_mode: 'group';
|
|
13
|
-
chat_type: 'private' | 'public';
|
|
14
|
-
i18n_names: TranslationMap;
|
|
15
|
-
external: boolean;
|
|
16
|
-
membership_approval: 'no_approval_required' | 'approval_required';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface ChatMeta
|
|
20
|
-
extends CreateChatMeta,
|
|
21
|
-
Record<'tenant_key' | 'chat_id', string>,
|
|
22
|
-
Record<
|
|
23
|
-
`${'add_member' | 'at_all' | 'edit' | 'moderation'}_permission`,
|
|
24
|
-
ChatPermission
|
|
25
|
-
> {
|
|
26
|
-
owner_id_type: 'user_id';
|
|
27
|
-
chat_tag: 'inner';
|
|
28
|
-
share_card_permission: 'allowed';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export type ChatMessageType = 'text' | 'card';
|
|
32
|
-
|
|
33
|
-
export interface SendChatMessage {
|
|
34
|
-
msg_type: ChatMessageType;
|
|
35
|
-
content: ChatMessageContent;
|
|
36
|
-
receive_id: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface ChatSender extends Record<'id' | 'tenant_key', string> {
|
|
40
|
-
id_type: 'open_id' | 'app_id';
|
|
41
|
-
sender_type: 'app';
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export type ChatMetion = Pick<ChatSender, 'id' | 'id_type' | 'tenant_key'> &
|
|
45
|
-
Record<'key' | 'name', string>;
|
|
46
|
-
|
|
47
|
-
export interface ChatMessage
|
|
48
|
-
extends Pick<SendChatMessage, 'msg_type'>,
|
|
49
|
-
Record<`${'create' | 'update'}_time`, string>,
|
|
50
|
-
Record<'deleted' | 'updated', boolean>,
|
|
51
|
-
Record<
|
|
52
|
-
`${'chat' | 'message' | 'upper_message' | 'root' | 'parent'}_id`,
|
|
53
|
-
string
|
|
54
|
-
> {
|
|
55
|
-
sender: ChatSender;
|
|
56
|
-
mentions: ChatMetion[];
|
|
57
|
-
body: {
|
|
58
|
-
content: `${ChatMessageType}:${string}`;
|
|
59
|
-
};
|
|
60
|
-
}
|
|
1
|
+
import { TranslationMap } from '../../../type';
|
|
2
|
+
import { ChatMessageContent } from './message';
|
|
3
|
+
|
|
4
|
+
export * from './message';
|
|
5
|
+
|
|
6
|
+
export type ChatPermission = 'all_members' | 'only_owner' | 'not_anyone';
|
|
7
|
+
|
|
8
|
+
export interface CreateChatMeta
|
|
9
|
+
extends Record<'owner_id' | 'avatar' | 'name' | 'description', string>,
|
|
10
|
+
Record<`${'join' | 'leave'}_message_visibility`, ChatPermission>,
|
|
11
|
+
Record<`${'user' | 'bot'}_id_list`, string[]> {
|
|
12
|
+
chat_mode: 'group';
|
|
13
|
+
chat_type: 'private' | 'public';
|
|
14
|
+
i18n_names: TranslationMap;
|
|
15
|
+
external: boolean;
|
|
16
|
+
membership_approval: 'no_approval_required' | 'approval_required';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ChatMeta
|
|
20
|
+
extends CreateChatMeta,
|
|
21
|
+
Record<'tenant_key' | 'chat_id', string>,
|
|
22
|
+
Record<
|
|
23
|
+
`${'add_member' | 'at_all' | 'edit' | 'moderation'}_permission`,
|
|
24
|
+
ChatPermission
|
|
25
|
+
> {
|
|
26
|
+
owner_id_type: 'user_id';
|
|
27
|
+
chat_tag: 'inner';
|
|
28
|
+
share_card_permission: 'allowed';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type ChatMessageType = 'text' | 'card';
|
|
32
|
+
|
|
33
|
+
export interface SendChatMessage {
|
|
34
|
+
msg_type: ChatMessageType;
|
|
35
|
+
content: ChatMessageContent;
|
|
36
|
+
receive_id: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ChatSender extends Record<'id' | 'tenant_key', string> {
|
|
40
|
+
id_type: 'open_id' | 'app_id';
|
|
41
|
+
sender_type: 'app';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type ChatMetion = Pick<ChatSender, 'id' | 'id_type' | 'tenant_key'> &
|
|
45
|
+
Record<'key' | 'name', string>;
|
|
46
|
+
|
|
47
|
+
export interface ChatMessage
|
|
48
|
+
extends Pick<SendChatMessage, 'msg_type'>,
|
|
49
|
+
Record<`${'create' | 'update'}_time`, string>,
|
|
50
|
+
Record<'deleted' | 'updated', boolean>,
|
|
51
|
+
Record<
|
|
52
|
+
`${'chat' | 'message' | 'upper_message' | 'root' | 'parent'}_id`,
|
|
53
|
+
string
|
|
54
|
+
> {
|
|
55
|
+
sender: ChatSender;
|
|
56
|
+
mentions: ChatMetion[];
|
|
57
|
+
body: {
|
|
58
|
+
content: `${ChatMessageType}:${string}`;
|
|
59
|
+
};
|
|
60
|
+
}
|