@satorijs/adapter-lark 3.7.1 → 3.7.3
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/index.cjs +132 -115
- package/lib/index.cjs.map +1 -1
- package/lib/types/api.d.ts +348 -52
- package/lib/types/internal.d.ts +8 -5
- package/package.json +3 -3
- package/src/message.ts +20 -17
- package/src/types/api.ts +445 -146
- package/src/types/internal.ts +24 -8
package/lib/index.cjs
CHANGED
|
@@ -480,34 +480,37 @@ var LarkMessageEncoder = class extends import_core3.MessageEncoder {
|
|
|
480
480
|
}
|
|
481
481
|
async createImage(url) {
|
|
482
482
|
const { filename, type, data } = await this.bot.assetsQuester.file(url);
|
|
483
|
-
const
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
483
|
+
const { image_key } = await this.bot.internal.createImImage({
|
|
484
|
+
image_type: "message",
|
|
485
|
+
image: new File([data], filename, { type })
|
|
486
|
+
});
|
|
487
487
|
return image_key;
|
|
488
488
|
}
|
|
489
489
|
async sendFile(_type, attrs) {
|
|
490
490
|
const url = attrs.src || attrs.url;
|
|
491
|
-
const payload = new FormData();
|
|
492
491
|
const { filename, type, data } = await this.bot.assetsQuester.file(url);
|
|
493
|
-
|
|
494
|
-
payload.append("file_name", filename);
|
|
495
|
-
if (attrs.duration) {
|
|
496
|
-
payload.append("duration", attrs.duration);
|
|
497
|
-
}
|
|
492
|
+
let file_type;
|
|
498
493
|
if (_type === "audio") {
|
|
499
|
-
|
|
494
|
+
file_type = "opus";
|
|
500
495
|
} else if (_type === "video") {
|
|
501
|
-
|
|
496
|
+
file_type = "mp4";
|
|
502
497
|
} else {
|
|
503
498
|
const ext = filename.split(".").pop();
|
|
504
499
|
if (["doc", "xls", "ppt", "pdf"].includes(ext)) {
|
|
505
|
-
|
|
500
|
+
file_type = ext;
|
|
506
501
|
} else {
|
|
507
|
-
|
|
502
|
+
file_type = "stream";
|
|
508
503
|
}
|
|
509
504
|
}
|
|
510
|
-
const
|
|
505
|
+
const form = {
|
|
506
|
+
file_type,
|
|
507
|
+
file: new File([data], filename, { type }),
|
|
508
|
+
file_name: filename
|
|
509
|
+
};
|
|
510
|
+
if (attrs.duration) {
|
|
511
|
+
form.duration = attrs.duration;
|
|
512
|
+
}
|
|
513
|
+
const { file_key } = await this.bot.internal.createImFile(form);
|
|
511
514
|
await this.post({
|
|
512
515
|
msg_type: _type === "video" ? "media" : _type,
|
|
513
516
|
content: JSON.stringify({ file_key })
|
|
@@ -729,14 +732,26 @@ var Internal = class _Internal {
|
|
|
729
732
|
static {
|
|
730
733
|
__name(this, "Internal");
|
|
731
734
|
}
|
|
732
|
-
|
|
735
|
+
_assertResponse(response) {
|
|
733
736
|
if (!response.data.code) return;
|
|
734
737
|
this.bot.logger.debug("response: %o", response.data);
|
|
735
738
|
const error = new import_core4.HTTP.Error(`request failed`);
|
|
736
739
|
error.response = response;
|
|
737
740
|
throw error;
|
|
738
741
|
}
|
|
739
|
-
|
|
742
|
+
_buildData(arg, options) {
|
|
743
|
+
if (options.multipart) {
|
|
744
|
+
const form = new FormData();
|
|
745
|
+
for (const key in arg) {
|
|
746
|
+
const value = arg[key];
|
|
747
|
+
form.append(key, value, value instanceof File ? value.name : void 0);
|
|
748
|
+
}
|
|
749
|
+
return form;
|
|
750
|
+
} else {
|
|
751
|
+
return arg;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
static define(routes, options = {}) {
|
|
740
755
|
for (const path in routes) {
|
|
741
756
|
for (const key in routes[path]) {
|
|
742
757
|
const method = key;
|
|
@@ -752,17 +767,17 @@ var Internal = class _Internal {
|
|
|
752
767
|
if (method === "GET" || method === "DELETE") {
|
|
753
768
|
config.params = args[0];
|
|
754
769
|
} else {
|
|
755
|
-
config.data = args[0];
|
|
770
|
+
config.data = this._buildData(args[0], options);
|
|
756
771
|
}
|
|
757
772
|
} else if (args.length === 2 && method !== "GET" && method !== "DELETE") {
|
|
758
|
-
config.data = args[0];
|
|
773
|
+
config.data = this._buildData(args[0], options);
|
|
759
774
|
config.params = args[1];
|
|
760
775
|
} else if (args.length > 1) {
|
|
761
776
|
throw new Error(`too many arguments for ${path}, received ${raw}`);
|
|
762
777
|
}
|
|
763
778
|
const response = await this.bot.http(method, url, config);
|
|
764
|
-
this.
|
|
765
|
-
return
|
|
779
|
+
this._assertResponse(response);
|
|
780
|
+
return options.noExtractData ? response.data : response.data.data;
|
|
766
781
|
};
|
|
767
782
|
}
|
|
768
783
|
}
|
|
@@ -787,7 +802,7 @@ Internal.define({
|
|
|
787
802
|
"/auth/v3/app_ticket/resend": {
|
|
788
803
|
POST: "appTicketResendAuth"
|
|
789
804
|
}
|
|
790
|
-
},
|
|
805
|
+
}, { noExtractData: true });
|
|
791
806
|
Internal.define({
|
|
792
807
|
"/event/v1/outbound_ip": {
|
|
793
808
|
GET: "listEventOutboundIp"
|
|
@@ -1016,15 +1031,9 @@ Internal.define({
|
|
|
1016
1031
|
"/im/v1/batch_messages/{batch_message_id}/get_progress": {
|
|
1017
1032
|
GET: "getProgressImBatchMessage"
|
|
1018
1033
|
},
|
|
1019
|
-
"/im/v1/images": {
|
|
1020
|
-
POST: "createImImage"
|
|
1021
|
-
},
|
|
1022
1034
|
"/im/v1/images/{image_key}": {
|
|
1023
1035
|
GET: "getImImage"
|
|
1024
1036
|
},
|
|
1025
|
-
"/im/v1/files": {
|
|
1026
|
-
POST: "createImFile"
|
|
1027
|
-
},
|
|
1028
1037
|
"/im/v1/files/{file_key}": {
|
|
1029
1038
|
GET: "getImFile"
|
|
1030
1039
|
},
|
|
@@ -1141,9 +1150,6 @@ Internal.define({
|
|
|
1141
1150
|
"/drive/v1/files/task_check": {
|
|
1142
1151
|
GET: "taskCheckDrivev1File"
|
|
1143
1152
|
},
|
|
1144
|
-
"/drive/v1/medias/upload_all": {
|
|
1145
|
-
POST: "uploadAllDrivev1Media"
|
|
1146
|
-
},
|
|
1147
1153
|
"/drive/v1/medias/{file_token}/download": {
|
|
1148
1154
|
GET: "downloadDrivev1Media"
|
|
1149
1155
|
},
|
|
@@ -1153,9 +1159,6 @@ Internal.define({
|
|
|
1153
1159
|
"/drive/v1/medias/upload_prepare": {
|
|
1154
1160
|
POST: "uploadPrepareDrivev1Media"
|
|
1155
1161
|
},
|
|
1156
|
-
"/drive/v1/medias/upload_part": {
|
|
1157
|
-
POST: "uploadPartDrivev1Media"
|
|
1158
|
-
},
|
|
1159
1162
|
"/drive/v1/medias/upload_finish": {
|
|
1160
1163
|
POST: "uploadFinishDrivev1Media"
|
|
1161
1164
|
},
|
|
@@ -1168,15 +1171,9 @@ Internal.define({
|
|
|
1168
1171
|
"/drive/v1/files/{file_token}/get_subscribe": {
|
|
1169
1172
|
GET: "getSubscribeDrivev1File"
|
|
1170
1173
|
},
|
|
1171
|
-
"/drive/v1/files/upload_all": {
|
|
1172
|
-
POST: "uploadAllDrivev1File"
|
|
1173
|
-
},
|
|
1174
1174
|
"/drive/v1/files/upload_prepare": {
|
|
1175
1175
|
POST: "uploadPrepareDrivev1File"
|
|
1176
1176
|
},
|
|
1177
|
-
"/drive/v1/files/upload_part": {
|
|
1178
|
-
POST: "uploadPartDrivev1File"
|
|
1179
|
-
},
|
|
1180
1177
|
"/drive/v1/files/upload_finish": {
|
|
1181
1178
|
POST: "uploadFinishDrivev1File"
|
|
1182
1179
|
},
|
|
@@ -1801,9 +1798,6 @@ Internal.define({
|
|
|
1801
1798
|
"/attendance/v1/user_settings/query": {
|
|
1802
1799
|
GET: "queryAttendanceUserSetting"
|
|
1803
1800
|
},
|
|
1804
|
-
"/attendance/v1/files/upload": {
|
|
1805
|
-
POST: "uploadAttendanceFile"
|
|
1806
|
-
},
|
|
1807
1801
|
"/attendance/v1/files/{file_id}/download": {
|
|
1808
1802
|
GET: "downloadAttendanceFile"
|
|
1809
1803
|
},
|
|
@@ -2137,9 +2131,6 @@ Internal.define({
|
|
|
2137
2131
|
PATCH: "patchTaskv2Comment",
|
|
2138
2132
|
DELETE: "deleteTaskv2Comment"
|
|
2139
2133
|
},
|
|
2140
|
-
"/task/v2/attachments/upload": {
|
|
2141
|
-
POST: "uploadTaskv2Attachment"
|
|
2142
|
-
},
|
|
2143
2134
|
"/task/v2/attachments": {
|
|
2144
2135
|
GET: "listTaskv2Attachment"
|
|
2145
2136
|
},
|
|
@@ -2380,60 +2371,6 @@ Internal.define({
|
|
|
2380
2371
|
PATCH: "patchSearchSchema",
|
|
2381
2372
|
GET: "getSearchSchema"
|
|
2382
2373
|
},
|
|
2383
|
-
"/document_ai/v1/resume/parse": {
|
|
2384
|
-
POST: "parseDocumentAiResume"
|
|
2385
|
-
},
|
|
2386
|
-
"/document_ai/v1/vehicle_invoice/recognize": {
|
|
2387
|
-
POST: "recognizeDocumentAiVehicleInvoice"
|
|
2388
|
-
},
|
|
2389
|
-
"/document_ai/v1/health_certificate/recognize": {
|
|
2390
|
-
POST: "recognizeDocumentAiHealthCertificate"
|
|
2391
|
-
},
|
|
2392
|
-
"/document_ai/v1/hkm_mainland_travel_permit/recognize": {
|
|
2393
|
-
POST: "recognizeDocumentAiHkmMainlandTravelPermit"
|
|
2394
|
-
},
|
|
2395
|
-
"/document_ai/v1/tw_mainland_travel_permit/recognize": {
|
|
2396
|
-
POST: "recognizeDocumentAiTwMainlandTravelPermit"
|
|
2397
|
-
},
|
|
2398
|
-
"/document_ai/v1/chinese_passport/recognize": {
|
|
2399
|
-
POST: "recognizeDocumentAiChinesePassport"
|
|
2400
|
-
},
|
|
2401
|
-
"/document_ai/v1/bank_card/recognize": {
|
|
2402
|
-
POST: "recognizeDocumentAiBankCard"
|
|
2403
|
-
},
|
|
2404
|
-
"/document_ai/v1/vehicle_license/recognize": {
|
|
2405
|
-
POST: "recognizeDocumentAiVehicleLicense"
|
|
2406
|
-
},
|
|
2407
|
-
"/document_ai/v1/train_invoice/recognize": {
|
|
2408
|
-
POST: "recognizeDocumentAiTrainInvoice"
|
|
2409
|
-
},
|
|
2410
|
-
"/document_ai/v1/taxi_invoice/recognize": {
|
|
2411
|
-
POST: "recognizeDocumentAiTaxiInvoice"
|
|
2412
|
-
},
|
|
2413
|
-
"/document_ai/v1/id_card/recognize": {
|
|
2414
|
-
POST: "recognizeDocumentAiIdCard"
|
|
2415
|
-
},
|
|
2416
|
-
"/document_ai/v1/food_produce_license/recognize": {
|
|
2417
|
-
POST: "recognizeDocumentAiFoodProduceLicense"
|
|
2418
|
-
},
|
|
2419
|
-
"/document_ai/v1/food_manage_license/recognize": {
|
|
2420
|
-
POST: "recognizeDocumentAiFoodManageLicense"
|
|
2421
|
-
},
|
|
2422
|
-
"/document_ai/v1/driving_license/recognize": {
|
|
2423
|
-
POST: "recognizeDocumentAiDrivingLicense"
|
|
2424
|
-
},
|
|
2425
|
-
"/document_ai/v1/vat_invoice/recognize": {
|
|
2426
|
-
POST: "recognizeDocumentAiVatInvoice"
|
|
2427
|
-
},
|
|
2428
|
-
"/document_ai/v1/business_license/recognize": {
|
|
2429
|
-
POST: "recognizeDocumentAiBusinessLicense"
|
|
2430
|
-
},
|
|
2431
|
-
"/document_ai/v1/contract/field_extraction": {
|
|
2432
|
-
POST: "fieldExtractionDocumentAiContract"
|
|
2433
|
-
},
|
|
2434
|
-
"/document_ai/v1/business_card/recognize": {
|
|
2435
|
-
POST: "recognizeDocumentAiBusinessCard"
|
|
2436
|
-
},
|
|
2437
2374
|
"/optical_char_recognition/v1/image/basic_recognize": {
|
|
2438
2375
|
POST: "basicRecognizeOpticalCharRecognitionImage"
|
|
2439
2376
|
},
|
|
@@ -2478,9 +2415,6 @@ Internal.define({
|
|
|
2478
2415
|
PUT: "updateAdminBadge",
|
|
2479
2416
|
GET: "getAdminBadge"
|
|
2480
2417
|
},
|
|
2481
|
-
"/admin/v1/badge_images": {
|
|
2482
|
-
POST: "createAdminBadgeImage"
|
|
2483
|
-
},
|
|
2484
2418
|
"/admin/v1/badges/{badge_id}/grants": {
|
|
2485
2419
|
POST: "createAdminBadgeGrant",
|
|
2486
2420
|
GET: "listAdminBadgeGrant"
|
|
@@ -2579,9 +2513,6 @@ Internal.define({
|
|
|
2579
2513
|
DELETE: "deleteCorehrPerson",
|
|
2580
2514
|
GET: "getCorehrPerson"
|
|
2581
2515
|
},
|
|
2582
|
-
"/corehr/v1/persons/upload": {
|
|
2583
|
-
POST: "uploadCorehrPerson"
|
|
2584
|
-
},
|
|
2585
2516
|
"/corehr/v1/files/{id}": {
|
|
2586
2517
|
GET: "getCorehrFile"
|
|
2587
2518
|
},
|
|
@@ -3039,9 +2970,6 @@ Internal.define({
|
|
|
3039
2970
|
PUT: "updateOkrProgressRecord",
|
|
3040
2971
|
GET: "getOkrProgressRecord"
|
|
3041
2972
|
},
|
|
3042
|
-
"/okr/v1/images/upload": {
|
|
3043
|
-
POST: "uploadOkrImage"
|
|
3044
|
-
},
|
|
3045
2973
|
"/human_authentication/v1/identities": {
|
|
3046
2974
|
POST: "createHumanAuthenticationIdentity"
|
|
3047
2975
|
},
|
|
@@ -3121,9 +3049,6 @@ Internal.define({
|
|
|
3121
3049
|
"/lingo/v1/repos": {
|
|
3122
3050
|
GET: "listLingoRepo"
|
|
3123
3051
|
},
|
|
3124
|
-
"/lingo/v1/files/upload": {
|
|
3125
|
-
POST: "uploadLingoFile"
|
|
3126
|
-
},
|
|
3127
3052
|
"/lingo/v1/files/{file_token}/download": {
|
|
3128
3053
|
GET: "downloadLingoFile"
|
|
3129
3054
|
},
|
|
@@ -3207,9 +3132,6 @@ Internal.define({
|
|
|
3207
3132
|
"/baike/v1/classifications": {
|
|
3208
3133
|
GET: "listBaikeClassification"
|
|
3209
3134
|
},
|
|
3210
|
-
"/baike/v1/files/upload": {
|
|
3211
|
-
POST: "uploadBaikeFile"
|
|
3212
|
-
},
|
|
3213
3135
|
"/baike/v1/files/{file_token}/download": {
|
|
3214
3136
|
GET: "downloadBaikeFile"
|
|
3215
3137
|
},
|
|
@@ -3259,6 +3181,101 @@ Internal.define({
|
|
|
3259
3181
|
POST: "setVcRoomConfig"
|
|
3260
3182
|
}
|
|
3261
3183
|
});
|
|
3184
|
+
Internal.define({
|
|
3185
|
+
"/im/v1/images": {
|
|
3186
|
+
POST: "createImImage"
|
|
3187
|
+
},
|
|
3188
|
+
"/im/v1/files": {
|
|
3189
|
+
POST: "createImFile"
|
|
3190
|
+
},
|
|
3191
|
+
"/drive/v1/medias/upload_all": {
|
|
3192
|
+
POST: "uploadAllDrivev1Media"
|
|
3193
|
+
},
|
|
3194
|
+
"/drive/v1/medias/upload_part": {
|
|
3195
|
+
POST: "uploadPartDrivev1Media"
|
|
3196
|
+
},
|
|
3197
|
+
"/drive/v1/files/upload_all": {
|
|
3198
|
+
POST: "uploadAllDrivev1File"
|
|
3199
|
+
},
|
|
3200
|
+
"/drive/v1/files/upload_part": {
|
|
3201
|
+
POST: "uploadPartDrivev1File"
|
|
3202
|
+
},
|
|
3203
|
+
"/attendance/v1/files/upload": {
|
|
3204
|
+
POST: "uploadAttendanceFile"
|
|
3205
|
+
},
|
|
3206
|
+
"/task/v2/attachments/upload": {
|
|
3207
|
+
POST: "uploadTaskv2Attachment"
|
|
3208
|
+
},
|
|
3209
|
+
"/document_ai/v1/resume/parse": {
|
|
3210
|
+
POST: "parseDocumentAiResume"
|
|
3211
|
+
},
|
|
3212
|
+
"/document_ai/v1/vehicle_invoice/recognize": {
|
|
3213
|
+
POST: "recognizeDocumentAiVehicleInvoice"
|
|
3214
|
+
},
|
|
3215
|
+
"/document_ai/v1/health_certificate/recognize": {
|
|
3216
|
+
POST: "recognizeDocumentAiHealthCertificate"
|
|
3217
|
+
},
|
|
3218
|
+
"/document_ai/v1/hkm_mainland_travel_permit/recognize": {
|
|
3219
|
+
POST: "recognizeDocumentAiHkmMainlandTravelPermit"
|
|
3220
|
+
},
|
|
3221
|
+
"/document_ai/v1/tw_mainland_travel_permit/recognize": {
|
|
3222
|
+
POST: "recognizeDocumentAiTwMainlandTravelPermit"
|
|
3223
|
+
},
|
|
3224
|
+
"/document_ai/v1/chinese_passport/recognize": {
|
|
3225
|
+
POST: "recognizeDocumentAiChinesePassport"
|
|
3226
|
+
},
|
|
3227
|
+
"/document_ai/v1/bank_card/recognize": {
|
|
3228
|
+
POST: "recognizeDocumentAiBankCard"
|
|
3229
|
+
},
|
|
3230
|
+
"/document_ai/v1/vehicle_license/recognize": {
|
|
3231
|
+
POST: "recognizeDocumentAiVehicleLicense"
|
|
3232
|
+
},
|
|
3233
|
+
"/document_ai/v1/train_invoice/recognize": {
|
|
3234
|
+
POST: "recognizeDocumentAiTrainInvoice"
|
|
3235
|
+
},
|
|
3236
|
+
"/document_ai/v1/taxi_invoice/recognize": {
|
|
3237
|
+
POST: "recognizeDocumentAiTaxiInvoice"
|
|
3238
|
+
},
|
|
3239
|
+
"/document_ai/v1/id_card/recognize": {
|
|
3240
|
+
POST: "recognizeDocumentAiIdCard"
|
|
3241
|
+
},
|
|
3242
|
+
"/document_ai/v1/food_produce_license/recognize": {
|
|
3243
|
+
POST: "recognizeDocumentAiFoodProduceLicense"
|
|
3244
|
+
},
|
|
3245
|
+
"/document_ai/v1/food_manage_license/recognize": {
|
|
3246
|
+
POST: "recognizeDocumentAiFoodManageLicense"
|
|
3247
|
+
},
|
|
3248
|
+
"/document_ai/v1/driving_license/recognize": {
|
|
3249
|
+
POST: "recognizeDocumentAiDrivingLicense"
|
|
3250
|
+
},
|
|
3251
|
+
"/document_ai/v1/vat_invoice/recognize": {
|
|
3252
|
+
POST: "recognizeDocumentAiVatInvoice"
|
|
3253
|
+
},
|
|
3254
|
+
"/document_ai/v1/business_license/recognize": {
|
|
3255
|
+
POST: "recognizeDocumentAiBusinessLicense"
|
|
3256
|
+
},
|
|
3257
|
+
"/document_ai/v1/contract/field_extraction": {
|
|
3258
|
+
POST: "fieldExtractionDocumentAiContract"
|
|
3259
|
+
},
|
|
3260
|
+
"/document_ai/v1/business_card/recognize": {
|
|
3261
|
+
POST: "recognizeDocumentAiBusinessCard"
|
|
3262
|
+
},
|
|
3263
|
+
"/admin/v1/badge_images": {
|
|
3264
|
+
POST: "createAdminBadgeImage"
|
|
3265
|
+
},
|
|
3266
|
+
"/corehr/v1/persons/upload": {
|
|
3267
|
+
POST: "uploadCorehrPerson"
|
|
3268
|
+
},
|
|
3269
|
+
"/okr/v1/images/upload": {
|
|
3270
|
+
POST: "uploadOkrImage"
|
|
3271
|
+
},
|
|
3272
|
+
"/lingo/v1/files/upload": {
|
|
3273
|
+
POST: "uploadLingoFile"
|
|
3274
|
+
},
|
|
3275
|
+
"/baike/v1/files/upload": {
|
|
3276
|
+
POST: "uploadBaikeFile"
|
|
3277
|
+
}
|
|
3278
|
+
}, { multipart: true });
|
|
3262
3279
|
|
|
3263
3280
|
// src/bot.ts
|
|
3264
3281
|
var LarkBot = class extends import_core5.Bot {
|