lansenger-sdk-ts 1.0.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/LICENSE +21 -0
- package/README.fr.md +501 -0
- package/README.md +504 -0
- package/README.zhHans.md +501 -0
- package/README.zhHant.md +501 -0
- package/README.zhHantHK.md +501 -0
- package/dist/accountMessages.d.ts +12 -0
- package/dist/accountMessages.js +41 -0
- package/dist/auth.d.ts +13 -0
- package/dist/auth.js +70 -0
- package/dist/calendars.d.ts +84 -0
- package/dist/calendars.js +278 -0
- package/dist/callbacks.d.ts +384 -0
- package/dist/callbacks.js +712 -0
- package/dist/chats.d.ts +22 -0
- package/dist/chats.js +88 -0
- package/dist/client.d.ts +439 -0
- package/dist/client.js +712 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.js +42 -0
- package/dist/constants.d.ts +30 -0
- package/dist/constants.js +187 -0
- package/dist/contacts.d.ts +38 -0
- package/dist/contacts.js +161 -0
- package/dist/departments.d.ts +18 -0
- package/dist/departments.js +69 -0
- package/dist/exceptions.d.ts +20 -0
- package/dist/exceptions.js +42 -0
- package/dist/groupMessages.d.ts +11 -0
- package/dist/groupMessages.js +39 -0
- package/dist/groups.d.ts +66 -0
- package/dist/groups.js +218 -0
- package/dist/http.d.ts +7 -0
- package/dist/http.js +67 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +189 -0
- package/dist/media.d.ts +16 -0
- package/dist/media.js +178 -0
- package/dist/models.d.ts +925 -0
- package/dist/models.js +991 -0
- package/dist/oauth.d.ts +17 -0
- package/dist/oauth.js +107 -0
- package/dist/persistence.d.ts +26 -0
- package/dist/persistence.js +210 -0
- package/dist/reminders.d.ts +10 -0
- package/dist/reminders.js +31 -0
- package/dist/streaming.d.ts +9 -0
- package/dist/streaming.js +40 -0
- package/dist/todos.d.ts +75 -0
- package/dist/todos.js +282 -0
- package/dist/urlHelpers.d.ts +7 -0
- package/dist/urlHelpers.js +22 -0
- package/dist/userMessages.d.ts +8 -0
- package/dist/userMessages.js +34 -0
- package/dist/users.d.ts +6 -0
- package/dist/users.js +32 -0
- package/package.json +33 -0
package/dist/client.js
ADDED
|
@@ -0,0 +1,712 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.LansengerClient = void 0;
|
|
37
|
+
const config_1 = require("./config");
|
|
38
|
+
const auth_1 = require("./auth");
|
|
39
|
+
const persistence_1 = require("./persistence");
|
|
40
|
+
const http_1 = require("./http");
|
|
41
|
+
const urlHelpers_1 = require("./urlHelpers");
|
|
42
|
+
const constants_1 = require("./constants");
|
|
43
|
+
const exceptions_1 = require("./exceptions");
|
|
44
|
+
const models_1 = require("./models");
|
|
45
|
+
const contacts_1 = require("./contacts");
|
|
46
|
+
const departments_1 = require("./departments");
|
|
47
|
+
const groups_1 = require("./groups");
|
|
48
|
+
const oauth_1 = require("./oauth");
|
|
49
|
+
const users_1 = require("./users");
|
|
50
|
+
const streaming_1 = require("./streaming");
|
|
51
|
+
const calendars_1 = require("./calendars");
|
|
52
|
+
const todos_1 = require("./todos");
|
|
53
|
+
const chats_1 = require("./chats");
|
|
54
|
+
const accountMessages_1 = require("./accountMessages");
|
|
55
|
+
const userMessages_1 = require("./userMessages");
|
|
56
|
+
const groupMessages_1 = require("./groupMessages");
|
|
57
|
+
const reminders_1 = require("./reminders");
|
|
58
|
+
const media_1 = require("./media");
|
|
59
|
+
const callbacks_1 = require("./callbacks");
|
|
60
|
+
function _parseSendResponse(data, msgType = "", operation = "") {
|
|
61
|
+
const errCode = data.errCode ?? -1;
|
|
62
|
+
if (errCode !== 0) {
|
|
63
|
+
const msg = data.errMsg || "Unknown error";
|
|
64
|
+
return new models_1.SendMessageResult({ success: false, error: `API error (errCode=${errCode}): ${msg}`, msg_type: msgType, operation, retryable: true });
|
|
65
|
+
}
|
|
66
|
+
const d = data.data || {};
|
|
67
|
+
return new models_1.SendMessageResult({ success: true, message_id: d.msgId, msg_type: msgType, operation, raw_response: data });
|
|
68
|
+
}
|
|
69
|
+
class LansengerClient {
|
|
70
|
+
constructor(appId, appSecret, apiGatewayUrl = "https://open.e.lanxin.cn/open/apigw", passportUrl = "", httpTimeout = 30, storePath, encodingKey = "", callbackToken = "") {
|
|
71
|
+
this._fetchFn = undefined;
|
|
72
|
+
this._tokenManager = null;
|
|
73
|
+
this._store = null;
|
|
74
|
+
this._config = new config_1.LansengerConfig(appId, appSecret, apiGatewayUrl, passportUrl, httpTimeout, encodingKey, callbackToken);
|
|
75
|
+
if (storePath) {
|
|
76
|
+
this._store = new persistence_1.CredentialStore(storePath);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
static fromEnv(storePath) {
|
|
80
|
+
const config = config_1.LansengerConfig.fromEnv();
|
|
81
|
+
return new LansengerClient(config.app_id, config.app_secret, config.api_gateway_url, config.passport_url, config.http_timeout, storePath, config.encoding_key, config.callback_token);
|
|
82
|
+
}
|
|
83
|
+
static fromConfig(config, storePath) {
|
|
84
|
+
return new LansengerClient(config.app_id, config.app_secret, config.api_gateway_url, config.passport_url, config.http_timeout, storePath, config.encoding_key, config.callback_token);
|
|
85
|
+
}
|
|
86
|
+
static fromStore(profile = "default", filePath) {
|
|
87
|
+
const store = new persistence_1.CredentialStore(filePath, profile);
|
|
88
|
+
const creds = store.loadCredentials();
|
|
89
|
+
if (!creds.app_id || !creds.app_secret)
|
|
90
|
+
throw new exceptions_1.LansengerConfigError("No credentials found in store profile");
|
|
91
|
+
return new LansengerClient(creds.app_id, creds.app_secret, creds.api_gateway_url, creds.passport_url, 30, filePath, creds.encoding_key, creds.callback_token);
|
|
92
|
+
}
|
|
93
|
+
get config() { return this._config; }
|
|
94
|
+
async _ensureInit() {
|
|
95
|
+
if (!this._fetchFn) {
|
|
96
|
+
const nodeFetch = await Promise.resolve().then(() => __importStar(require("node-fetch")));
|
|
97
|
+
this._fetchFn = nodeFetch.default;
|
|
98
|
+
}
|
|
99
|
+
if (!this._tokenManager) {
|
|
100
|
+
this._tokenManager = new auth_1.TokenManager(this._config, this._fetchFn, this._store);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async getToken() {
|
|
104
|
+
await this._ensureInit();
|
|
105
|
+
return this._tokenManager.getToken();
|
|
106
|
+
}
|
|
107
|
+
invalidateToken() {
|
|
108
|
+
if (this._tokenManager)
|
|
109
|
+
this._tokenManager.invalidate();
|
|
110
|
+
}
|
|
111
|
+
async healthCheck() {
|
|
112
|
+
try {
|
|
113
|
+
await this.getToken();
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
_privateMsgUrl(token) {
|
|
121
|
+
return (0, urlHelpers_1.buildApiUrl)(this._config, "smart_bot", "private_message", token);
|
|
122
|
+
}
|
|
123
|
+
_groupMsgUrl(token) {
|
|
124
|
+
return (0, urlHelpers_1.buildApiUrl)(this._config, "smart_bot", "group_message", token);
|
|
125
|
+
}
|
|
126
|
+
async _sendPrivate(chatId, msgType, msgData) {
|
|
127
|
+
await this._ensureInit();
|
|
128
|
+
const token = await this._tokenManager.getToken();
|
|
129
|
+
const url = this._privateMsgUrl(token);
|
|
130
|
+
const payload = { chatId, msgType, msgData };
|
|
131
|
+
const [data, httpErr] = await (0, http_1.doPost)(url, payload, this._fetchFn);
|
|
132
|
+
if (httpErr)
|
|
133
|
+
return new models_1.SendMessageResult({ success: false, error: httpErr, msg_type: msgType, operation: "private_message" });
|
|
134
|
+
return _parseSendResponse(data, msgType, "private_message");
|
|
135
|
+
}
|
|
136
|
+
async _sendGroup(groupId, msgType, msgData, opts) {
|
|
137
|
+
await this._ensureInit();
|
|
138
|
+
const token = await this._tokenManager.getToken();
|
|
139
|
+
const url = this._groupMsgUrl(token);
|
|
140
|
+
const payload = { groupId, msgType, msgData };
|
|
141
|
+
if (opts?.userToken)
|
|
142
|
+
payload.userToken = opts.userToken;
|
|
143
|
+
if (opts?.senderId)
|
|
144
|
+
payload.senderId = opts.senderId;
|
|
145
|
+
const [data, httpErr] = await (0, http_1.doPost)(url, payload, this._fetchFn);
|
|
146
|
+
if (httpErr)
|
|
147
|
+
return new models_1.SendMessageResult({ success: false, error: httpErr, msg_type: msgType, operation: "group_message", retryable: true });
|
|
148
|
+
return _parseSendResponse(data, msgType, "group_message");
|
|
149
|
+
}
|
|
150
|
+
async sendText(chatId, content, opts) {
|
|
151
|
+
const msgData = { text: content };
|
|
152
|
+
const isGroup = opts?.is_group || false;
|
|
153
|
+
if (opts?.reminder_all || opts?.reminder_user_ids) {
|
|
154
|
+
const reminder = {};
|
|
155
|
+
if (opts?.reminder_all)
|
|
156
|
+
reminder.reminderAll = true;
|
|
157
|
+
if (opts?.reminder_user_ids)
|
|
158
|
+
reminder.reminderUserIds = opts.reminder_user_ids;
|
|
159
|
+
msgData.reminder = reminder;
|
|
160
|
+
}
|
|
161
|
+
if (opts?.file_path) {
|
|
162
|
+
await this._ensureInit();
|
|
163
|
+
const token = await this._tokenManager.getToken();
|
|
164
|
+
const mediaResult = await (0, media_1.uploadMedia)(this._config, this._tokenManager, this._fetchFn, opts.file_path, opts.media_type || (0, constants_1.guessMediaType)(opts.file_path), opts.user_token || "");
|
|
165
|
+
if (!mediaResult.success)
|
|
166
|
+
return new models_1.SendMessageResult({ success: false, error: mediaResult.error });
|
|
167
|
+
msgData.mediaId = mediaResult.media_id;
|
|
168
|
+
if (opts.cover_image_path) {
|
|
169
|
+
const coverResult = await (0, media_1.uploadMedia)(this._config, this._tokenManager, this._fetchFn, opts.cover_image_path, constants_1.MEDIA_TYPE_IMAGE, opts.user_token || "");
|
|
170
|
+
if (!coverResult.success)
|
|
171
|
+
return new models_1.SendMessageResult({ success: false, error: coverResult.error });
|
|
172
|
+
msgData.coverMediaId = coverResult.media_id;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (isGroup)
|
|
176
|
+
return this._sendGroup(chatId, "text", msgData, { userToken: opts?.user_token || "", senderId: opts?.sender_id || "" });
|
|
177
|
+
return this._sendPrivate(chatId, "text", msgData);
|
|
178
|
+
}
|
|
179
|
+
async sendMarkdown(chatId, content, opts) {
|
|
180
|
+
const msgData = { formatText: content };
|
|
181
|
+
if (opts?.reminder_all || opts?.reminder_user_ids) {
|
|
182
|
+
const reminder = {};
|
|
183
|
+
if (opts?.reminder_all)
|
|
184
|
+
reminder.reminderAll = true;
|
|
185
|
+
if (opts?.reminder_user_ids)
|
|
186
|
+
reminder.reminderUserIds = opts.reminder_user_ids;
|
|
187
|
+
msgData.reminder = reminder;
|
|
188
|
+
}
|
|
189
|
+
const isGroup = opts?.is_group || false;
|
|
190
|
+
if (isGroup)
|
|
191
|
+
return this._sendGroup(chatId, "formatText", msgData, { userToken: opts?.user_token || "", senderId: opts?.sender_id || "" });
|
|
192
|
+
return this._sendPrivate(chatId, "formatText", msgData);
|
|
193
|
+
}
|
|
194
|
+
async sendFile(chatId, filePath, opts) {
|
|
195
|
+
await this._ensureInit();
|
|
196
|
+
const mediaType = opts?.media_type || (0, constants_1.guessMediaType)(filePath);
|
|
197
|
+
const uploadResult = await (0, media_1.uploadMedia)(this._config, this._tokenManager, this._fetchFn, filePath, mediaType, opts?.user_token || "");
|
|
198
|
+
if (!uploadResult.success)
|
|
199
|
+
return new models_1.SendMessageResult({ success: false, error: uploadResult.error });
|
|
200
|
+
const msgData = { mediaId: uploadResult.media_id };
|
|
201
|
+
if (opts?.caption)
|
|
202
|
+
msgData.text = opts.caption;
|
|
203
|
+
if (opts?.cover_image_path) {
|
|
204
|
+
const coverResult = await (0, media_1.uploadMedia)(this._config, this._tokenManager, this._fetchFn, opts.cover_image_path, constants_1.MEDIA_TYPE_IMAGE, opts?.user_token || "");
|
|
205
|
+
if (!coverResult.success)
|
|
206
|
+
return new models_1.SendMessageResult({ success: false, error: coverResult.error });
|
|
207
|
+
msgData.coverMediaId = coverResult.media_id;
|
|
208
|
+
}
|
|
209
|
+
const isGroup = opts?.is_group || false;
|
|
210
|
+
if (isGroup)
|
|
211
|
+
return this._sendGroup(chatId, "file", msgData, { userToken: opts?.user_token || "", senderId: opts?.sender_id || "" });
|
|
212
|
+
return this._sendPrivate(chatId, "file", msgData);
|
|
213
|
+
}
|
|
214
|
+
async sendImageUrl(chatId, imageUrl, opts) {
|
|
215
|
+
const msgData = { imageUrl };
|
|
216
|
+
if (opts?.caption)
|
|
217
|
+
msgData.text = opts.caption;
|
|
218
|
+
const isGroup = opts?.is_group || false;
|
|
219
|
+
if (isGroup)
|
|
220
|
+
return this._sendGroup(chatId, "image", msgData, { userToken: opts?.user_token || "", senderId: opts?.sender_id || "" });
|
|
221
|
+
return this._sendPrivate(chatId, "image", msgData);
|
|
222
|
+
}
|
|
223
|
+
async sendLinkCard(chatId, title, link, opts) {
|
|
224
|
+
const params = new models_1.LinkCardParams({ chat_id: chatId, title, link, description: opts?.description || "", icon_link: opts?.icon_link || "", pc_link: opts?.pc_link || "", pad_link: opts?.pad_link || "", from_name: opts?.from_name || "", from_icon_link: opts?.from_icon_link || "", is_group: opts?.is_group || false, user_token: opts?.user_token || "", sender_id: opts?.sender_id || "" });
|
|
225
|
+
return this.sendLinkCardWithParams(params);
|
|
226
|
+
}
|
|
227
|
+
async sendLinkCardWithParams(params) {
|
|
228
|
+
await this._ensureInit();
|
|
229
|
+
const token = await this._tokenManager.getToken();
|
|
230
|
+
const url = params.is_group ? this._groupMsgUrl(token) : this._privateMsgUrl(token);
|
|
231
|
+
const payload = { msgType: "linkCard", msgData: params };
|
|
232
|
+
if (params.is_group) {
|
|
233
|
+
payload.groupId = params.chat_id;
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
payload.chatId = params.chat_id;
|
|
237
|
+
}
|
|
238
|
+
if (params.user_token)
|
|
239
|
+
payload.userToken = params.user_token;
|
|
240
|
+
if (params.sender_id)
|
|
241
|
+
payload.senderId = params.sender_id;
|
|
242
|
+
const [data, httpErr] = await (0, http_1.doPost)(url, payload, this._fetchFn);
|
|
243
|
+
if (httpErr)
|
|
244
|
+
return new models_1.SendMessageResult({ success: false, error: httpErr, msg_type: "linkCard" });
|
|
245
|
+
return _parseSendResponse(data, "linkCard");
|
|
246
|
+
}
|
|
247
|
+
async sendAppArticles(chatId, articles, opts) {
|
|
248
|
+
const msgData = { articles };
|
|
249
|
+
const isGroup = opts?.is_group || false;
|
|
250
|
+
if (isGroup)
|
|
251
|
+
return this._sendGroup(chatId, "appArticles", msgData, { userToken: opts?.user_token || "", senderId: opts?.sender_id || "" });
|
|
252
|
+
return this._sendPrivate(chatId, "appArticles", msgData);
|
|
253
|
+
}
|
|
254
|
+
async sendAppCard(chatId, bodyTitle, opts) {
|
|
255
|
+
const params = new models_1.AppCardParams({
|
|
256
|
+
body_title: bodyTitle, chat_id: chatId,
|
|
257
|
+
head_title: opts?.head_title || "", body_sub_title: opts?.body_sub_title || "",
|
|
258
|
+
body_content: opts?.body_content || "", signature: opts?.signature || "",
|
|
259
|
+
fields: opts?.fields, links: opts?.links, card_link: opts?.card_link || "",
|
|
260
|
+
pc_card_link: opts?.pc_card_link || "", pad_card_link: opts?.pad_card_link || "",
|
|
261
|
+
is_dynamic: opts?.is_dynamic || false, head_status_info: opts?.head_status_info,
|
|
262
|
+
staff_id: opts?.staff_id || "", head_icon_url: opts?.head_icon_url || "",
|
|
263
|
+
is_group: opts?.is_group || false, user_token: opts?.user_token || "",
|
|
264
|
+
sender_id: opts?.sender_id || "",
|
|
265
|
+
});
|
|
266
|
+
return this.sendAppCardWithParams(params);
|
|
267
|
+
}
|
|
268
|
+
async sendAppCardWithParams(params) {
|
|
269
|
+
await this._ensureInit();
|
|
270
|
+
const token = await this._tokenManager.getToken();
|
|
271
|
+
const url = params.is_group ? this._groupMsgUrl(token) : this._privateMsgUrl(token);
|
|
272
|
+
const payload = { msgType: "appCard", msgData: params };
|
|
273
|
+
if (params.is_group) {
|
|
274
|
+
payload.groupId = params.chat_id;
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
payload.chatId = params.chat_id;
|
|
278
|
+
}
|
|
279
|
+
if (params.user_token)
|
|
280
|
+
payload.userToken = params.user_token;
|
|
281
|
+
if (params.sender_id)
|
|
282
|
+
payload.senderId = params.sender_id;
|
|
283
|
+
const [data, httpErr] = await (0, http_1.doPost)(url, payload, this._fetchFn);
|
|
284
|
+
if (httpErr)
|
|
285
|
+
return new models_1.SendMessageResult({ success: false, error: httpErr, msg_type: "appCard" });
|
|
286
|
+
return _parseSendResponse(data, "appCard");
|
|
287
|
+
}
|
|
288
|
+
async sendOacard(chatId, title, opts) {
|
|
289
|
+
const params = new models_1.OaCardParams({
|
|
290
|
+
chat_id: chatId, title, head: opts?.head || "", sub_title: opts?.sub_title || "",
|
|
291
|
+
staff_id: opts?.staff_id || "", fields: opts?.fields, link: opts?.link || "",
|
|
292
|
+
pc_link: opts?.pc_link || "", pad_link: opts?.pad_link || "",
|
|
293
|
+
card_action: opts?.card_action, is_group: opts?.is_group || false,
|
|
294
|
+
user_token: opts?.user_token || "", sender_id: opts?.sender_id || "",
|
|
295
|
+
});
|
|
296
|
+
return this.sendOacardWithParams(params);
|
|
297
|
+
}
|
|
298
|
+
async sendOacardWithParams(params) {
|
|
299
|
+
await this._ensureInit();
|
|
300
|
+
const token = await this._tokenManager.getToken();
|
|
301
|
+
const url = params.is_group ? this._groupMsgUrl(token) : this._privateMsgUrl(token);
|
|
302
|
+
const payload = { msgType: "oacard", msgData: params };
|
|
303
|
+
if (params.is_group) {
|
|
304
|
+
payload.groupId = params.chat_id;
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
payload.chatId = params.chat_id;
|
|
308
|
+
}
|
|
309
|
+
if (params.user_token)
|
|
310
|
+
payload.userToken = params.user_token;
|
|
311
|
+
if (params.sender_id)
|
|
312
|
+
payload.senderId = params.sender_id;
|
|
313
|
+
const [data, httpErr] = await (0, http_1.doPost)(url, payload, this._fetchFn);
|
|
314
|
+
if (httpErr)
|
|
315
|
+
return new models_1.SendMessageResult({ success: false, error: httpErr, msg_type: "oacard" });
|
|
316
|
+
return _parseSendResponse(data, "oacard");
|
|
317
|
+
}
|
|
318
|
+
async updateDynamicCard(msgId, opts) {
|
|
319
|
+
const params = new models_1.DynamicCardUpdateParams({
|
|
320
|
+
msg_id: msgId, head_status_info: opts?.head_status_info,
|
|
321
|
+
links: opts?.links, is_last_update: opts?.is_last_update || false,
|
|
322
|
+
});
|
|
323
|
+
return this.updateDynamicCardWithParams(params);
|
|
324
|
+
}
|
|
325
|
+
async updateDynamicCardWithParams(params) {
|
|
326
|
+
await this._ensureInit();
|
|
327
|
+
const token = await this._tokenManager.getToken();
|
|
328
|
+
const url = (0, urlHelpers_1.buildApiUrl)(this._config, "message", "dynamic_update", token);
|
|
329
|
+
const payload = { msgId: params.msg_id };
|
|
330
|
+
if (params.head_status_info)
|
|
331
|
+
payload.headStatusInfo = params.head_status_info;
|
|
332
|
+
if (params.links)
|
|
333
|
+
payload.links = params.links;
|
|
334
|
+
payload.isLastUpdate = params.is_last_update;
|
|
335
|
+
const [data, httpErr] = await (0, http_1.doPost)(url, payload, this._fetchFn);
|
|
336
|
+
if (httpErr)
|
|
337
|
+
return new models_1.SendMessageResult({ success: false, error: httpErr, msg_type: "dynamic_update" });
|
|
338
|
+
return _parseSendResponse(data, "dynamic_update", "update_dynamic_card");
|
|
339
|
+
}
|
|
340
|
+
async revokeMessage(messageIds, opts) {
|
|
341
|
+
await this._ensureInit();
|
|
342
|
+
const token = await this._tokenManager.getToken();
|
|
343
|
+
const url = (0, urlHelpers_1.buildApiUrl)(this._config, "message", "revoke", token);
|
|
344
|
+
const payload = { msgIdList: messageIds, chatType: opts?.chat_type || "bot" };
|
|
345
|
+
if (opts?.sender_id)
|
|
346
|
+
payload.senderId = opts.sender_id;
|
|
347
|
+
const [data, httpErr] = await (0, http_1.doPost)(url, payload, this._fetchFn);
|
|
348
|
+
if (httpErr)
|
|
349
|
+
return new models_1.SendMessageResult({ success: false, error: httpErr, operation: "revoke_message" });
|
|
350
|
+
return _parseSendResponse(data, "", "revoke_message");
|
|
351
|
+
}
|
|
352
|
+
async queryGroups(opts) {
|
|
353
|
+
await this._ensureInit();
|
|
354
|
+
const token = await this._tokenManager.getToken();
|
|
355
|
+
const pageOffset = opts?.page_offset || 1;
|
|
356
|
+
const pageSize = opts?.page_size || 100;
|
|
357
|
+
const url = (0, urlHelpers_1.buildApiUrl)(this._config, "groups", "fetch", token) + `&page_offset=${pageOffset}&page_size=${pageSize}`;
|
|
358
|
+
const [data, httpErr] = await (0, http_1.doGet)(url, this._fetchFn);
|
|
359
|
+
if (httpErr)
|
|
360
|
+
return new models_1.QueryGroupsResult({ success: false, error: httpErr });
|
|
361
|
+
const errCode = data.errCode ?? -1;
|
|
362
|
+
if (errCode !== 0) {
|
|
363
|
+
const msg = data.errMsg || "Unknown error";
|
|
364
|
+
return new models_1.QueryGroupsResult({ success: false, error: `API error (errCode=${errCode}): ${msg}` });
|
|
365
|
+
}
|
|
366
|
+
const d = data.data || {};
|
|
367
|
+
return new models_1.QueryGroupsResult({
|
|
368
|
+
success: true, total_group_ids: d.totalGroupIds || 0,
|
|
369
|
+
group_ids: d.groupIds || [], raw_response: data,
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
async sendReminderMsg(msgId, reminderTypes, userIdList) {
|
|
373
|
+
await this._ensureInit();
|
|
374
|
+
const token = await this._tokenManager.getToken();
|
|
375
|
+
return (0, reminders_1.sendReminder)(this._config, token, msgId, reminderTypes, userIdList, { fetchFn: this._fetchFn });
|
|
376
|
+
}
|
|
377
|
+
async uploadMediaFile(filePath, opts) {
|
|
378
|
+
await this._ensureInit();
|
|
379
|
+
const token = await this._tokenManager.getToken();
|
|
380
|
+
const mediaType = opts?.media_type || (0, constants_1.guessMediaType)(filePath);
|
|
381
|
+
const result = await (0, media_1.uploadMedia)(this._config, this._tokenManager, this._fetchFn, filePath, mediaType, opts?.user_token || "");
|
|
382
|
+
if (!result.success)
|
|
383
|
+
return new models_1.SendMessageResult({ success: false, error: result.error });
|
|
384
|
+
return new models_1.SendMessageResult({ success: true, message_id: result.media_id, operation: "upload_media", raw_response: result.raw_response });
|
|
385
|
+
}
|
|
386
|
+
async uploadAppMediaFile(filePath, opts) {
|
|
387
|
+
await this._ensureInit();
|
|
388
|
+
const result = await (0, media_1.uploadAppMedia)(this._config, this._tokenManager, this._fetchFn, filePath, opts?.media_type || (0, constants_1.guessAppMediaType)(filePath), { width: opts?.width, height: opts?.height, duration: opts?.duration });
|
|
389
|
+
if (!result.success)
|
|
390
|
+
return new models_1.SendMessageResult({ success: false, error: result.error });
|
|
391
|
+
return new models_1.SendMessageResult({ success: true, message_id: result.media_id, operation: "upload_app_media", raw_response: result.raw_response });
|
|
392
|
+
}
|
|
393
|
+
async downloadMediaFile(mediaId) {
|
|
394
|
+
await this._ensureInit();
|
|
395
|
+
return (0, media_1.downloadMedia)(this._config, this._tokenManager, this._fetchFn, mediaId);
|
|
396
|
+
}
|
|
397
|
+
async downloadMediaToFile(mediaId, opts) {
|
|
398
|
+
await this._ensureInit();
|
|
399
|
+
return (0, media_1.downloadMediaToFile)(this._config, this._tokenManager, this._fetchFn, mediaId, opts?.target_path, opts?.media_type || "file");
|
|
400
|
+
}
|
|
401
|
+
async fetchMediaPathInfo(mediaId, opts) {
|
|
402
|
+
await this._ensureInit();
|
|
403
|
+
const token = await this._tokenManager.getToken();
|
|
404
|
+
return (0, media_1.fetchMediaPath)(this._config, token, mediaId, { user_token: opts?.user_token || "", fetchFn: this._fetchFn });
|
|
405
|
+
}
|
|
406
|
+
buildAuthorizeUrl(redirectUri, opts) {
|
|
407
|
+
return (0, oauth_1.buildAuthorizeUrl)(this._config, redirectUri, opts);
|
|
408
|
+
}
|
|
409
|
+
static parseAuthorizeCallback(queryString) {
|
|
410
|
+
return (0, oauth_1.parseAuthorizeCallback)(queryString);
|
|
411
|
+
}
|
|
412
|
+
static validateCallbackState(callbackState, expectedState) {
|
|
413
|
+
return (0, oauth_1.validateCallbackState)(callbackState, expectedState);
|
|
414
|
+
}
|
|
415
|
+
async exchangeCode(code, opts) {
|
|
416
|
+
await this._ensureInit();
|
|
417
|
+
const token = await this._tokenManager.getToken();
|
|
418
|
+
return (0, oauth_1.exchangeCodeForUserToken)(this._config, token, code, { redirect_uri: opts?.redirect_uri, fetchFn: this._fetchFn });
|
|
419
|
+
}
|
|
420
|
+
async refreshUserToken(refreshToken, opts) {
|
|
421
|
+
await this._ensureInit();
|
|
422
|
+
const token = await this._tokenManager.getToken();
|
|
423
|
+
return (0, oauth_1.refreshUserToken)(this._config, token, refreshToken, { scope: opts?.scope, fetchFn: this._fetchFn });
|
|
424
|
+
}
|
|
425
|
+
async fetchUserInfoByToken(userToken) {
|
|
426
|
+
await this._ensureInit();
|
|
427
|
+
const token = await this._tokenManager.getToken();
|
|
428
|
+
return (0, users_1.fetchUserInfo)(this._config, token, userToken, { fetchFn: this._fetchFn });
|
|
429
|
+
}
|
|
430
|
+
async fetchStaffBasicInfo(staffId, opts) {
|
|
431
|
+
await this._ensureInit();
|
|
432
|
+
const token = await this._tokenManager.getToken();
|
|
433
|
+
return (0, contacts_1.fetchStaffBasicInfo)(this._config, token, staffId, { user_token: opts?.user_token || "", fetchFn: this._fetchFn });
|
|
434
|
+
}
|
|
435
|
+
async fetchStaffDetail(staffId, opts) {
|
|
436
|
+
await this._ensureInit();
|
|
437
|
+
const token = await this._tokenManager.getToken();
|
|
438
|
+
return (0, contacts_1.fetchStaffDetail)(this._config, token, staffId, { user_token: opts?.user_token || "", fetchFn: this._fetchFn });
|
|
439
|
+
}
|
|
440
|
+
async fetchDepartmentAncestors(staffId, opts) {
|
|
441
|
+
await this._ensureInit();
|
|
442
|
+
const token = await this._tokenManager.getToken();
|
|
443
|
+
return (0, contacts_1.fetchDepartmentAncestors)(this._config, token, staffId, { user_token: opts?.user_token || "", fetchFn: this._fetchFn });
|
|
444
|
+
}
|
|
445
|
+
async fetchStaffIdMapping(orgId, idType, idValue, opts) {
|
|
446
|
+
await this._ensureInit();
|
|
447
|
+
const token = await this._tokenManager.getToken();
|
|
448
|
+
return (0, contacts_1.fetchStaffIdMapping)(this._config, token, orgId, idType, idValue, { user_token: opts?.user_token || "", fetchFn: this._fetchFn });
|
|
449
|
+
}
|
|
450
|
+
async fetchOrgExtraFieldIds(orgId, opts) {
|
|
451
|
+
await this._ensureInit();
|
|
452
|
+
const token = await this._tokenManager.getToken();
|
|
453
|
+
return (0, contacts_1.fetchOrgExtraFieldIds)(this._config, token, orgId, { user_token: opts?.user_token || "", page: opts?.page, page_size: opts?.page_size, fetchFn: this._fetchFn });
|
|
454
|
+
}
|
|
455
|
+
async fetchOrgInfo(orgId, opts) {
|
|
456
|
+
await this._ensureInit();
|
|
457
|
+
const token = await this._tokenManager.getToken();
|
|
458
|
+
return (0, contacts_1.fetchOrgInfo)(this._config, token, orgId, { user_token: opts?.user_token || "", fetchFn: this._fetchFn });
|
|
459
|
+
}
|
|
460
|
+
async searchStaff(keyword, opts) {
|
|
461
|
+
await this._ensureInit();
|
|
462
|
+
const token = await this._tokenManager.getToken();
|
|
463
|
+
return (0, contacts_1.searchStaff)(this._config, token, keyword, { user_token: opts?.user_token || "", user_id: opts?.user_id || "", recursive: opts?.recursive, sector_ids: opts?.sector_ids, page: opts?.page, page_size: opts?.page_size, fetchFn: this._fetchFn });
|
|
464
|
+
}
|
|
465
|
+
async sendBotMessage(msgType, msgData, chatIds, departmentIds, opts) {
|
|
466
|
+
await this._ensureInit();
|
|
467
|
+
const token = await this._tokenManager.getToken();
|
|
468
|
+
if (opts?.is_group && chatIds && chatIds.length > 0) {
|
|
469
|
+
const results = [];
|
|
470
|
+
for (const gid of chatIds) {
|
|
471
|
+
results.push(await (0, groupMessages_1.sendGroupMessage)(this._config, token, gid, msgType, msgData, { user_token: opts?.user_token || "", fetchFn: this._fetchFn }));
|
|
472
|
+
}
|
|
473
|
+
const first = results[0];
|
|
474
|
+
return new models_1.BotMessageResult({ success: first.success, message_id: first.message_id, error: first.error, raw_response: first.raw_response });
|
|
475
|
+
}
|
|
476
|
+
const url = (0, urlHelpers_1.buildApiUrl)(this._config, "bot", "message_create", token, { userToken: opts?.user_token || "" });
|
|
477
|
+
const payload = { msgType, msgData };
|
|
478
|
+
if (chatIds)
|
|
479
|
+
payload.userIdList = chatIds;
|
|
480
|
+
if (departmentIds)
|
|
481
|
+
payload.departmentIdList = departmentIds;
|
|
482
|
+
if (opts?.entry_id)
|
|
483
|
+
payload.entryId = opts.entry_id;
|
|
484
|
+
const [data, httpErr] = await (0, http_1.doPost)(url, payload, this._fetchFn);
|
|
485
|
+
if (httpErr)
|
|
486
|
+
return new models_1.BotMessageResult({ success: false, error: httpErr });
|
|
487
|
+
const errCode = data.errCode ?? -1;
|
|
488
|
+
if (errCode !== 0) {
|
|
489
|
+
const msg = data.errMsg || "Unknown error";
|
|
490
|
+
return new models_1.BotMessageResult({ success: false, error: `API error (errCode=${errCode}): ${msg}` });
|
|
491
|
+
}
|
|
492
|
+
const d = data.data || {};
|
|
493
|
+
return new models_1.BotMessageResult({ success: true, message_id: d.msgId, invalid_staff: d.invalidStaff, invalid_department: d.invalidDepartment, raw_response: data });
|
|
494
|
+
}
|
|
495
|
+
async sendAccountMessage(msgType, msgData, chatIds, departmentIds, opts) {
|
|
496
|
+
await this._ensureInit();
|
|
497
|
+
const token = await this._tokenManager.getToken();
|
|
498
|
+
return (0, accountMessages_1.sendAccountMessage)(this._config, token, msgType, msgData, { chat_ids: chatIds, department_ids: departmentIds, account_id: opts?.account_id || "", entry_id: opts?.entry_id || "", attach: opts?.attach || "", user_token: opts?.user_token || "", fetchFn: this._fetchFn });
|
|
499
|
+
}
|
|
500
|
+
async sendUserMessage(receiverId, msgType, msgData, opts) {
|
|
501
|
+
await this._ensureInit();
|
|
502
|
+
const token = await this._tokenManager.getToken();
|
|
503
|
+
return (0, userMessages_1.sendUserMessage)(this._config, token, opts?.user_token || "", receiverId, msgType, msgData, { common: opts?.common, uuid: opts?.uuid, fetchFn: this._fetchFn });
|
|
504
|
+
}
|
|
505
|
+
async sendGroupMessage(groupId, msgType, msgData, opts) {
|
|
506
|
+
await this._ensureInit();
|
|
507
|
+
const token = await this._tokenManager.getToken();
|
|
508
|
+
return (0, groupMessages_1.sendGroupMessage)(this._config, token, groupId, msgType, msgData, { user_token: opts?.user_token || "", sender_id: opts?.sender_id || "", outlines: opts?.outlines || "", uuid: opts?.uuid || "", entry_id: opts?.entry_id || "", fetchFn: this._fetchFn });
|
|
509
|
+
}
|
|
510
|
+
async createStreamMessage(receiverId, receiverType, streamId) {
|
|
511
|
+
await this._ensureInit();
|
|
512
|
+
const token = await this._tokenManager.getToken();
|
|
513
|
+
return (0, streaming_1.createStreamMessage)(this._config, token, receiverId, receiverType, streamId, { fetchFn: this._fetchFn });
|
|
514
|
+
}
|
|
515
|
+
async fetchStreamMessage(msgId) {
|
|
516
|
+
await this._ensureInit();
|
|
517
|
+
const token = await this._tokenManager.getToken();
|
|
518
|
+
return (0, streaming_1.fetchStreamMessage)(this._config, token, msgId, { fetchFn: this._fetchFn });
|
|
519
|
+
}
|
|
520
|
+
async createGroup(name, orgId, opts) {
|
|
521
|
+
await this._ensureInit();
|
|
522
|
+
const token = await this._tokenManager.getToken();
|
|
523
|
+
return (0, groups_1.createGroup)(this._config, token, name, orgId, { ...opts, fetchFn: this._fetchFn });
|
|
524
|
+
}
|
|
525
|
+
async fetchGroupInfo(groupId, opts) {
|
|
526
|
+
await this._ensureInit();
|
|
527
|
+
const token = await this._tokenManager.getToken();
|
|
528
|
+
return (0, groups_1.fetchGroupInfo)(this._config, token, groupId, { user_token: opts?.user_token || "", fetchFn: this._fetchFn });
|
|
529
|
+
}
|
|
530
|
+
async fetchGroupMembers(groupId, opts) {
|
|
531
|
+
await this._ensureInit();
|
|
532
|
+
const token = await this._tokenManager.getToken();
|
|
533
|
+
return (0, groups_1.fetchGroupMembers)(this._config, token, groupId, { user_token: opts?.user_token || "", page_offset: opts?.page_offset, page_size: opts?.page_size, fetchFn: this._fetchFn });
|
|
534
|
+
}
|
|
535
|
+
async fetchGroupList(opts) {
|
|
536
|
+
await this._ensureInit();
|
|
537
|
+
const token = await this._tokenManager.getToken();
|
|
538
|
+
return (0, groups_1.fetchGroupList)(this._config, token, { user_token: opts?.user_token || "", page_offset: opts?.page_offset, page_size: opts?.page_size, fetchFn: this._fetchFn });
|
|
539
|
+
}
|
|
540
|
+
async checkIsInGroup(groupId, opts) {
|
|
541
|
+
await this._ensureInit();
|
|
542
|
+
const token = await this._tokenManager.getToken();
|
|
543
|
+
return (0, groups_1.checkIsInGroup)(this._config, token, groupId, { user_token: opts?.user_token || "", staff_id: opts?.staff_id || "", fetchFn: this._fetchFn });
|
|
544
|
+
}
|
|
545
|
+
async updateGroupInfo(groupId, opts) {
|
|
546
|
+
await this._ensureInit();
|
|
547
|
+
const token = await this._tokenManager.getToken();
|
|
548
|
+
return (0, groups_1.updateGroupInfo)(this._config, token, groupId, { ...opts, fetchFn: this._fetchFn });
|
|
549
|
+
}
|
|
550
|
+
async updateGroupMembers(groupId, opts) {
|
|
551
|
+
await this._ensureInit();
|
|
552
|
+
const token = await this._tokenManager.getToken();
|
|
553
|
+
return (0, groups_1.updateGroupMembers)(this._config, token, groupId, { ...opts, fetchFn: this._fetchFn });
|
|
554
|
+
}
|
|
555
|
+
async dismissGroup(groupId, opts) {
|
|
556
|
+
await this._ensureInit();
|
|
557
|
+
const token = await this._tokenManager.getToken();
|
|
558
|
+
return (0, groups_1.dismissGroup)(this._config, token, groupId, { user_token: opts?.user_token || "", fetchFn: this._fetchFn });
|
|
559
|
+
}
|
|
560
|
+
async fetchDepartmentDetail(departmentId, opts) {
|
|
561
|
+
await this._ensureInit();
|
|
562
|
+
const token = await this._tokenManager.getToken();
|
|
563
|
+
return (0, departments_1.fetchDepartmentDetail)(this._config, token, departmentId, { user_token: opts?.user_token || "", tag_id: opts?.tag_id || "", fetchFn: this._fetchFn });
|
|
564
|
+
}
|
|
565
|
+
async fetchDepartmentChildren(departmentId, opts) {
|
|
566
|
+
await this._ensureInit();
|
|
567
|
+
const token = await this._tokenManager.getToken();
|
|
568
|
+
return (0, departments_1.fetchDepartmentChildren)(this._config, token, departmentId, { user_token: opts?.user_token || "", fetchFn: this._fetchFn });
|
|
569
|
+
}
|
|
570
|
+
async fetchDepartmentStaffs(departmentId, opts) {
|
|
571
|
+
await this._ensureInit();
|
|
572
|
+
const token = await this._tokenManager.getToken();
|
|
573
|
+
return (0, departments_1.fetchDepartmentStaffs)(this._config, token, departmentId, { user_token: opts?.user_token || "", page: opts?.page, page_size: opts?.page_size, fetchFn: this._fetchFn });
|
|
574
|
+
}
|
|
575
|
+
async createTodoTask(title, link, pcLink, executorIds, orgId, type = 1, opts) {
|
|
576
|
+
await this._ensureInit();
|
|
577
|
+
const token = await this._tokenManager.getToken();
|
|
578
|
+
return (0, todos_1.createTodoTask)(this._config, token, title, link, pcLink, executorIds, orgId, type, { ...opts, fetchFn: this._fetchFn });
|
|
579
|
+
}
|
|
580
|
+
async updateTodoTask(todotaskId, title, link, pcLink, orgId, opts) {
|
|
581
|
+
await this._ensureInit();
|
|
582
|
+
const token = await this._tokenManager.getToken();
|
|
583
|
+
return (0, todos_1.updateTodoTask)(this._config, token, todotaskId, title, link, pcLink, orgId, { ...opts, fetchFn: this._fetchFn });
|
|
584
|
+
}
|
|
585
|
+
async updateTodoTaskStatus(todotaskId, status, orgId, opts) {
|
|
586
|
+
await this._ensureInit();
|
|
587
|
+
const token = await this._tokenManager.getToken();
|
|
588
|
+
return (0, todos_1.updateTodoTaskStatus)(this._config, token, todotaskId, status, orgId, { ...opts, fetchFn: this._fetchFn });
|
|
589
|
+
}
|
|
590
|
+
async deleteTodoTask(todotaskId, orgId, opts) {
|
|
591
|
+
await this._ensureInit();
|
|
592
|
+
const token = await this._tokenManager.getToken();
|
|
593
|
+
return (0, todos_1.deleteTodoTask)(this._config, token, todotaskId, orgId, { ...opts, fetchFn: this._fetchFn });
|
|
594
|
+
}
|
|
595
|
+
async fetchTodoTaskList(orgId, opts) {
|
|
596
|
+
await this._ensureInit();
|
|
597
|
+
const token = await this._tokenManager.getToken();
|
|
598
|
+
return (0, todos_1.fetchTodoTaskList)(this._config, token, orgId, { ...opts, fetchFn: this._fetchFn });
|
|
599
|
+
}
|
|
600
|
+
async fetchTodoTaskBySourceId(sourceId, orgId, opts) {
|
|
601
|
+
await this._ensureInit();
|
|
602
|
+
const token = await this._tokenManager.getToken();
|
|
603
|
+
return (0, todos_1.fetchTodoTaskBySourceId)(this._config, token, sourceId, orgId, { ...opts, fetchFn: this._fetchFn });
|
|
604
|
+
}
|
|
605
|
+
async fetchTodoTaskById(todotaskId, orgId, opts) {
|
|
606
|
+
await this._ensureInit();
|
|
607
|
+
const token = await this._tokenManager.getToken();
|
|
608
|
+
return (0, todos_1.fetchTodoTaskById)(this._config, token, todotaskId, orgId, { ...opts, fetchFn: this._fetchFn });
|
|
609
|
+
}
|
|
610
|
+
async fetchTodoTaskStatusCounts(staffId, orgId, opts) {
|
|
611
|
+
await this._ensureInit();
|
|
612
|
+
const token = await this._tokenManager.getToken();
|
|
613
|
+
return (0, todos_1.fetchTodoTaskStatusCounts)(this._config, token, staffId, orgId, { ...opts, fetchFn: this._fetchFn });
|
|
614
|
+
}
|
|
615
|
+
async updateExecutorStatus(executorStatusList, orgId, opts) {
|
|
616
|
+
await this._ensureInit();
|
|
617
|
+
const token = await this._tokenManager.getToken();
|
|
618
|
+
return (0, todos_1.updateExecutorStatus)(this._config, token, executorStatusList, orgId, { ...opts, fetchFn: this._fetchFn });
|
|
619
|
+
}
|
|
620
|
+
async addExecutors(executorIds, orgId, opts) {
|
|
621
|
+
await this._ensureInit();
|
|
622
|
+
const token = await this._tokenManager.getToken();
|
|
623
|
+
return (0, todos_1.addExecutors)(this._config, token, executorIds, orgId, { ...opts, fetchFn: this._fetchFn });
|
|
624
|
+
}
|
|
625
|
+
async deleteExecutors(executorIds, orgId, opts) {
|
|
626
|
+
await this._ensureInit();
|
|
627
|
+
const token = await this._tokenManager.getToken();
|
|
628
|
+
return (0, todos_1.deleteExecutors)(this._config, token, executorIds, orgId, { ...opts, fetchFn: this._fetchFn });
|
|
629
|
+
}
|
|
630
|
+
async fetchExecutorList(todotaskId, orgId, opts) {
|
|
631
|
+
await this._ensureInit();
|
|
632
|
+
const token = await this._tokenManager.getToken();
|
|
633
|
+
return (0, todos_1.fetchExecutorList)(this._config, token, todotaskId, orgId, { ...opts, fetchFn: this._fetchFn });
|
|
634
|
+
}
|
|
635
|
+
async fetchPrimaryCalendar(opts) {
|
|
636
|
+
await this._ensureInit();
|
|
637
|
+
const token = await this._tokenManager.getToken();
|
|
638
|
+
return (0, calendars_1.fetchPrimaryCalendar)(this._config, token, { user_token: opts?.user_token || "", user_id: opts?.user_id || "", fetchFn: this._fetchFn });
|
|
639
|
+
}
|
|
640
|
+
async createSchedule(calendarId, summary, startTime, endTime, attendees, opts) {
|
|
641
|
+
await this._ensureInit();
|
|
642
|
+
const token = await this._tokenManager.getToken();
|
|
643
|
+
return (0, calendars_1.createSchedule)(this._config, token, calendarId, summary, startTime, endTime, attendees, { ...opts, fetchFn: this._fetchFn });
|
|
644
|
+
}
|
|
645
|
+
async fetchSchedule(calendarId, scheduleId, opts) {
|
|
646
|
+
await this._ensureInit();
|
|
647
|
+
const token = await this._tokenManager.getToken();
|
|
648
|
+
return (0, calendars_1.fetchSchedule)(this._config, token, calendarId, scheduleId, { user_token: opts?.user_token || "", user_id: opts?.user_id || "", fetchFn: this._fetchFn });
|
|
649
|
+
}
|
|
650
|
+
async deleteSchedule(calendarId, scheduleId, opts) {
|
|
651
|
+
await this._ensureInit();
|
|
652
|
+
const token = await this._tokenManager.getToken();
|
|
653
|
+
return (0, calendars_1.deleteSchedule)(this._config, token, calendarId, scheduleId, { ...opts, fetchFn: this._fetchFn });
|
|
654
|
+
}
|
|
655
|
+
async updateSchedule(calendarId, scheduleId, opts) {
|
|
656
|
+
await this._ensureInit();
|
|
657
|
+
const token = await this._tokenManager.getToken();
|
|
658
|
+
return (0, calendars_1.updateSchedule)(this._config, token, calendarId, scheduleId, { ...opts, fetchFn: this._fetchFn });
|
|
659
|
+
}
|
|
660
|
+
async fetchScheduleList(calendarId, startTime, endTime, opts) {
|
|
661
|
+
await this._ensureInit();
|
|
662
|
+
const token = await this._tokenManager.getToken();
|
|
663
|
+
return (0, calendars_1.fetchScheduleList)(this._config, token, calendarId, startTime, endTime, { user_token: opts?.user_token || "", user_id: opts?.user_id || "", fetchFn: this._fetchFn });
|
|
664
|
+
}
|
|
665
|
+
async fetchScheduleAttendees(calendarId, scheduleId, opts) {
|
|
666
|
+
await this._ensureInit();
|
|
667
|
+
const token = await this._tokenManager.getToken();
|
|
668
|
+
return (0, calendars_1.fetchScheduleAttendees)(this._config, token, calendarId, scheduleId, { ...opts, fetchFn: this._fetchFn });
|
|
669
|
+
}
|
|
670
|
+
async addScheduleAttendees(calendarId, scheduleId, attendees, opts) {
|
|
671
|
+
await this._ensureInit();
|
|
672
|
+
const token = await this._tokenManager.getToken();
|
|
673
|
+
return (0, calendars_1.addScheduleAttendees)(this._config, token, calendarId, scheduleId, attendees, { ...opts, fetchFn: this._fetchFn });
|
|
674
|
+
}
|
|
675
|
+
async deleteScheduleAttendees(calendarId, scheduleId, attendees, opts) {
|
|
676
|
+
await this._ensureInit();
|
|
677
|
+
const token = await this._tokenManager.getToken();
|
|
678
|
+
return (0, calendars_1.deleteScheduleAttendees)(this._config, token, calendarId, scheduleId, attendees, { ...opts, fetchFn: this._fetchFn });
|
|
679
|
+
}
|
|
680
|
+
async updateScheduleAttendeeMeta(calendarId, scheduleId, opts) {
|
|
681
|
+
await this._ensureInit();
|
|
682
|
+
const token = await this._tokenManager.getToken();
|
|
683
|
+
return (0, calendars_1.updateScheduleAttendeeMeta)(this._config, token, calendarId, scheduleId, { ...opts, fetchFn: this._fetchFn });
|
|
684
|
+
}
|
|
685
|
+
async fetchChatList(opts) {
|
|
686
|
+
await this._ensureInit();
|
|
687
|
+
const token = await this._tokenManager.getToken();
|
|
688
|
+
return (0, chats_1.fetchChatList)(this._config, token, { ...opts, fetchFn: this._fetchFn });
|
|
689
|
+
}
|
|
690
|
+
async fetchChatMessages(opts) {
|
|
691
|
+
await this._ensureInit();
|
|
692
|
+
const token = await this._tokenManager.getToken();
|
|
693
|
+
return (0, chats_1.fetchChatMessages)(this._config, token, { ...opts, fetchFn: this._fetchFn });
|
|
694
|
+
}
|
|
695
|
+
static parseCallbackPayload(encryptedData, opts) {
|
|
696
|
+
return (0, callbacks_1.parseCallbackPayload)(encryptedData, { encodingKey: opts?.encoding_key || "", verifySignature: opts?.verify_signature || false, timestamp: opts?.timestamp || "", nonce: opts?.nonce || "", signature: opts?.signature || "", callbackToken: opts?.callback_token || "", knownAppId: opts?.known_app_id || "" });
|
|
697
|
+
}
|
|
698
|
+
parseCallback(encryptedData, opts) {
|
|
699
|
+
return (0, callbacks_1.parseCallbackPayload)(encryptedData, { encodingKey: this._config.encoding_key, verifySignature: opts?.verify_signature || false, timestamp: opts?.timestamp || "", nonce: opts?.nonce || "", signature: opts?.signature || "", callbackToken: this._config.callback_token, knownAppId: opts?.known_app_id || "" });
|
|
700
|
+
}
|
|
701
|
+
static verifyCallbackSignature(timestamp, nonce, signature, encodingKey, opts) {
|
|
702
|
+
return (0, callbacks_1.verifyCallbackSignature)(timestamp, nonce, signature, encodingKey, opts?.data_encrypt || "", opts?.callback_token || "");
|
|
703
|
+
}
|
|
704
|
+
verifyCallback(timestamp, nonce, signature, opts) {
|
|
705
|
+
return (0, callbacks_1.verifyCallbackSignature)(timestamp, nonce, signature, this._config.encoding_key, opts?.data_encrypt || "", this._config.callback_token);
|
|
706
|
+
}
|
|
707
|
+
static getCallbackEventTypes() {
|
|
708
|
+
return (0, callbacks_1.getCallbackEventTypes)();
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
exports.LansengerClient = LansengerClient;
|
|
712
|
+
//# sourceMappingURL=client.js.map
|