@larksuiteoapi/node-sdk 1.34.0 → 1.36.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/es/index.js CHANGED
@@ -277,8 +277,16 @@ class Client$$ {
277
277
  this.logger.error(formatErrors(e));
278
278
  throw e;
279
279
  });
280
+ const checkIsReadable = () => {
281
+ const consumedError = "The stream has already been consumed";
282
+ if (!res.readable) {
283
+ this.logger.error(consumedError);
284
+ throw new Error(consumedError);
285
+ }
286
+ };
280
287
  return {
281
288
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
289
+ checkIsReadable();
282
290
  return new Promise((resolve, reject) => {
283
291
  const writableStream = fs.createWriteStream(filePath);
284
292
  writableStream.on("finish", () => {
@@ -290,6 +298,10 @@ class Client$$ {
290
298
  res.pipe(writableStream);
291
299
  });
292
300
  }),
301
+ getReadableStream: () => {
302
+ checkIsReadable();
303
+ return res;
304
+ },
293
305
  };
294
306
  }),
295
307
  },
@@ -513,8 +525,16 @@ class Client$$ {
513
525
  this.logger.error(formatErrors(e));
514
526
  throw e;
515
527
  });
528
+ const checkIsReadable = () => {
529
+ const consumedError = "The stream has already been consumed";
530
+ if (!res.readable) {
531
+ this.logger.error(consumedError);
532
+ throw new Error(consumedError);
533
+ }
534
+ };
516
535
  return {
517
536
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
537
+ checkIsReadable();
518
538
  return new Promise((resolve, reject) => {
519
539
  const writableStream = fs.createWriteStream(filePath);
520
540
  writableStream.on("finish", () => {
@@ -526,6 +546,10 @@ class Client$$ {
526
546
  res.pipe(writableStream);
527
547
  });
528
548
  }),
549
+ getReadableStream: () => {
550
+ checkIsReadable();
551
+ return res;
552
+ },
529
553
  };
530
554
  }),
531
555
  /**
@@ -758,8 +782,16 @@ class Client$$ {
758
782
  this.logger.error(formatErrors(e));
759
783
  throw e;
760
784
  });
785
+ const checkIsReadable = () => {
786
+ const consumedError = "The stream has already been consumed";
787
+ if (!res.readable) {
788
+ this.logger.error(consumedError);
789
+ throw new Error(consumedError);
790
+ }
791
+ };
761
792
  return {
762
793
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
794
+ checkIsReadable();
763
795
  return new Promise((resolve, reject) => {
764
796
  const writableStream = fs.createWriteStream(filePath);
765
797
  writableStream.on("finish", () => {
@@ -771,6 +803,10 @@ class Client$$ {
771
803
  res.pipe(writableStream);
772
804
  });
773
805
  }),
806
+ getReadableStream: () => {
807
+ checkIsReadable();
808
+ return res;
809
+ },
774
810
  };
775
811
  }),
776
812
  },
@@ -994,8 +1030,16 @@ class Client$$ {
994
1030
  this.logger.error(formatErrors(e));
995
1031
  throw e;
996
1032
  });
1033
+ const checkIsReadable = () => {
1034
+ const consumedError = "The stream has already been consumed";
1035
+ if (!res.readable) {
1036
+ this.logger.error(consumedError);
1037
+ throw new Error(consumedError);
1038
+ }
1039
+ };
997
1040
  return {
998
1041
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
1042
+ checkIsReadable();
999
1043
  return new Promise((resolve, reject) => {
1000
1044
  const writableStream = fs.createWriteStream(filePath);
1001
1045
  writableStream.on("finish", () => {
@@ -1007,6 +1051,10 @@ class Client$$ {
1007
1051
  res.pipe(writableStream);
1008
1052
  });
1009
1053
  }),
1054
+ getReadableStream: () => {
1055
+ checkIsReadable();
1056
+ return res;
1057
+ },
1010
1058
  };
1011
1059
  }),
1012
1060
  /**
@@ -6159,8 +6207,16 @@ class Client$W extends Client$X {
6159
6207
  this.logger.error(formatErrors(e));
6160
6208
  throw e;
6161
6209
  });
6210
+ const checkIsReadable = () => {
6211
+ const consumedError = "The stream has already been consumed";
6212
+ if (!res.readable) {
6213
+ this.logger.error(consumedError);
6214
+ throw new Error(consumedError);
6215
+ }
6216
+ };
6162
6217
  return {
6163
6218
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
6219
+ checkIsReadable();
6164
6220
  return new Promise((resolve, reject) => {
6165
6221
  const writableStream = fs.createWriteStream(filePath);
6166
6222
  writableStream.on("finish", () => {
@@ -6172,6 +6228,10 @@ class Client$W extends Client$X {
6172
6228
  res.pipe(writableStream);
6173
6229
  });
6174
6230
  }),
6231
+ getReadableStream: () => {
6232
+ checkIsReadable();
6233
+ return res;
6234
+ },
6175
6235
  };
6176
6236
  }),
6177
6237
  /**
@@ -7261,8 +7321,16 @@ class Client$W extends Client$X {
7261
7321
  this.logger.error(formatErrors(e));
7262
7322
  throw e;
7263
7323
  });
7324
+ const checkIsReadable = () => {
7325
+ const consumedError = "The stream has already been consumed";
7326
+ if (!res.readable) {
7327
+ this.logger.error(consumedError);
7328
+ throw new Error(consumedError);
7329
+ }
7330
+ };
7264
7331
  return {
7265
7332
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
7333
+ checkIsReadable();
7266
7334
  return new Promise((resolve, reject) => {
7267
7335
  const writableStream = fs.createWriteStream(filePath);
7268
7336
  writableStream.on("finish", () => {
@@ -7274,6 +7342,10 @@ class Client$W extends Client$X {
7274
7342
  res.pipe(writableStream);
7275
7343
  });
7276
7344
  }),
7345
+ getReadableStream: () => {
7346
+ checkIsReadable();
7347
+ return res;
7348
+ },
7277
7349
  };
7278
7350
  }),
7279
7351
  /**
@@ -9161,8 +9233,16 @@ class Client$S extends Client$T {
9161
9233
  this.logger.error(formatErrors(e));
9162
9234
  throw e;
9163
9235
  });
9236
+ const checkIsReadable = () => {
9237
+ const consumedError = "The stream has already been consumed";
9238
+ if (!res.readable) {
9239
+ this.logger.error(consumedError);
9240
+ throw new Error(consumedError);
9241
+ }
9242
+ };
9164
9243
  return {
9165
9244
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
9245
+ checkIsReadable();
9166
9246
  return new Promise((resolve, reject) => {
9167
9247
  const writableStream = fs.createWriteStream(filePath);
9168
9248
  writableStream.on("finish", () => {
@@ -9174,6 +9254,10 @@ class Client$S extends Client$T {
9174
9254
  res.pipe(writableStream);
9175
9255
  });
9176
9256
  }),
9257
+ getReadableStream: () => {
9258
+ checkIsReadable();
9259
+ return res;
9260
+ },
9177
9261
  };
9178
9262
  }),
9179
9263
  /**
@@ -9663,8 +9747,16 @@ class Client$S extends Client$T {
9663
9747
  this.logger.error(formatErrors(e));
9664
9748
  throw e;
9665
9749
  });
9750
+ const checkIsReadable = () => {
9751
+ const consumedError = "The stream has already been consumed";
9752
+ if (!res.readable) {
9753
+ this.logger.error(consumedError);
9754
+ throw new Error(consumedError);
9755
+ }
9756
+ };
9666
9757
  return {
9667
9758
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
9759
+ checkIsReadable();
9668
9760
  return new Promise((resolve, reject) => {
9669
9761
  const writableStream = fs.createWriteStream(filePath);
9670
9762
  writableStream.on("finish", () => {
@@ -9676,6 +9768,10 @@ class Client$S extends Client$T {
9676
9768
  res.pipe(writableStream);
9677
9769
  });
9678
9770
  }),
9771
+ getReadableStream: () => {
9772
+ checkIsReadable();
9773
+ return res;
9774
+ },
9679
9775
  };
9680
9776
  }),
9681
9777
  /**
@@ -13114,8 +13210,16 @@ class Client$P extends Client$Q {
13114
13210
  this.logger.error(formatErrors(e));
13115
13211
  throw e;
13116
13212
  });
13213
+ const checkIsReadable = () => {
13214
+ const consumedError = "The stream has already been consumed";
13215
+ if (!res.readable) {
13216
+ this.logger.error(consumedError);
13217
+ throw new Error(consumedError);
13218
+ }
13219
+ };
13117
13220
  return {
13118
13221
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
13222
+ checkIsReadable();
13119
13223
  return new Promise((resolve, reject) => {
13120
13224
  const writableStream = fs.createWriteStream(filePath);
13121
13225
  writableStream.on("finish", () => {
@@ -13127,6 +13231,10 @@ class Client$P extends Client$Q {
13127
13231
  res.pipe(writableStream);
13128
13232
  });
13129
13233
  }),
13234
+ getReadableStream: () => {
13235
+ checkIsReadable();
13236
+ return res;
13237
+ },
13130
13238
  };
13131
13239
  }),
13132
13240
  },
@@ -22101,8 +22209,16 @@ class Client$I extends Client$J {
22101
22209
  this.logger.error(formatErrors(e));
22102
22210
  throw e;
22103
22211
  });
22212
+ const checkIsReadable = () => {
22213
+ const consumedError = "The stream has already been consumed";
22214
+ if (!res.readable) {
22215
+ this.logger.error(consumedError);
22216
+ throw new Error(consumedError);
22217
+ }
22218
+ };
22104
22219
  return {
22105
22220
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
22221
+ checkIsReadable();
22106
22222
  return new Promise((resolve, reject) => {
22107
22223
  const writableStream = fs.createWriteStream(filePath);
22108
22224
  writableStream.on("finish", () => {
@@ -22114,6 +22230,10 @@ class Client$I extends Client$J {
22114
22230
  res.pipe(writableStream);
22115
22231
  });
22116
22232
  }),
22233
+ getReadableStream: () => {
22234
+ checkIsReadable();
22235
+ return res;
22236
+ },
22117
22237
  };
22118
22238
  }),
22119
22239
  },
@@ -24768,8 +24888,16 @@ class Client$I extends Client$J {
24768
24888
  this.logger.error(formatErrors(e));
24769
24889
  throw e;
24770
24890
  });
24891
+ const checkIsReadable = () => {
24892
+ const consumedError = "The stream has already been consumed";
24893
+ if (!res.readable) {
24894
+ this.logger.error(consumedError);
24895
+ throw new Error(consumedError);
24896
+ }
24897
+ };
24771
24898
  return {
24772
24899
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
24900
+ checkIsReadable();
24773
24901
  return new Promise((resolve, reject) => {
24774
24902
  const writableStream = fs.createWriteStream(filePath);
24775
24903
  writableStream.on("finish", () => {
@@ -24781,6 +24909,10 @@ class Client$I extends Client$J {
24781
24909
  res.pipe(writableStream);
24782
24910
  });
24783
24911
  }),
24912
+ getReadableStream: () => {
24913
+ checkIsReadable();
24914
+ return res;
24915
+ },
24784
24916
  };
24785
24917
  }),
24786
24918
  },
@@ -30018,8 +30150,16 @@ class Client$E extends Client$F {
30018
30150
  this.logger.error(formatErrors(e));
30019
30151
  throw e;
30020
30152
  });
30153
+ const checkIsReadable = () => {
30154
+ const consumedError = "The stream has already been consumed";
30155
+ if (!res.readable) {
30156
+ this.logger.error(consumedError);
30157
+ throw new Error(consumedError);
30158
+ }
30159
+ };
30021
30160
  return {
30022
30161
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
30162
+ checkIsReadable();
30023
30163
  return new Promise((resolve, reject) => {
30024
30164
  const writableStream = fs.createWriteStream(filePath);
30025
30165
  writableStream.on("finish", () => {
@@ -30031,6 +30171,10 @@ class Client$E extends Client$F {
30031
30171
  res.pipe(writableStream);
30032
30172
  });
30033
30173
  }),
30174
+ getReadableStream: () => {
30175
+ checkIsReadable();
30176
+ return res;
30177
+ },
30034
30178
  };
30035
30179
  }),
30036
30180
  /**
@@ -30512,8 +30656,16 @@ class Client$E extends Client$F {
30512
30656
  this.logger.error(formatErrors(e));
30513
30657
  throw e;
30514
30658
  });
30659
+ const checkIsReadable = () => {
30660
+ const consumedError = "The stream has already been consumed";
30661
+ if (!res.readable) {
30662
+ this.logger.error(consumedError);
30663
+ throw new Error(consumedError);
30664
+ }
30665
+ };
30515
30666
  return {
30516
30667
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
30668
+ checkIsReadable();
30517
30669
  return new Promise((resolve, reject) => {
30518
30670
  const writableStream = fs.createWriteStream(filePath);
30519
30671
  writableStream.on("finish", () => {
@@ -30525,6 +30677,10 @@ class Client$E extends Client$F {
30525
30677
  res.pipe(writableStream);
30526
30678
  });
30527
30679
  }),
30680
+ getReadableStream: () => {
30681
+ checkIsReadable();
30682
+ return res;
30683
+ },
30528
30684
  };
30529
30685
  }),
30530
30686
  /**
@@ -31246,8 +31402,16 @@ class Client$E extends Client$F {
31246
31402
  this.logger.error(formatErrors(e));
31247
31403
  throw e;
31248
31404
  });
31405
+ const checkIsReadable = () => {
31406
+ const consumedError = "The stream has already been consumed";
31407
+ if (!res.readable) {
31408
+ this.logger.error(consumedError);
31409
+ throw new Error(consumedError);
31410
+ }
31411
+ };
31249
31412
  return {
31250
31413
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
31414
+ checkIsReadable();
31251
31415
  return new Promise((resolve, reject) => {
31252
31416
  const writableStream = fs.createWriteStream(filePath);
31253
31417
  writableStream.on("finish", () => {
@@ -31259,6 +31423,10 @@ class Client$E extends Client$F {
31259
31423
  res.pipe(writableStream);
31260
31424
  });
31261
31425
  }),
31426
+ getReadableStream: () => {
31427
+ checkIsReadable();
31428
+ return res;
31429
+ },
31262
31430
  };
31263
31431
  }),
31264
31432
  /**
@@ -31737,8 +31905,16 @@ class Client$E extends Client$F {
31737
31905
  this.logger.error(formatErrors(e));
31738
31906
  throw e;
31739
31907
  });
31908
+ const checkIsReadable = () => {
31909
+ const consumedError = "The stream has already been consumed";
31910
+ if (!res.readable) {
31911
+ this.logger.error(consumedError);
31912
+ throw new Error(consumedError);
31913
+ }
31914
+ };
31740
31915
  return {
31741
31916
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
31917
+ checkIsReadable();
31742
31918
  return new Promise((resolve, reject) => {
31743
31919
  const writableStream = fs.createWriteStream(filePath);
31744
31920
  writableStream.on("finish", () => {
@@ -31750,6 +31926,10 @@ class Client$E extends Client$F {
31750
31926
  res.pipe(writableStream);
31751
31927
  });
31752
31928
  }),
31929
+ getReadableStream: () => {
31930
+ checkIsReadable();
31931
+ return res;
31932
+ },
31753
31933
  };
31754
31934
  }),
31755
31935
  /**
@@ -32231,8 +32411,16 @@ class Client$E extends Client$F {
32231
32411
  this.logger.error(formatErrors(e));
32232
32412
  throw e;
32233
32413
  });
32414
+ const checkIsReadable = () => {
32415
+ const consumedError = "The stream has already been consumed";
32416
+ if (!res.readable) {
32417
+ this.logger.error(consumedError);
32418
+ throw new Error(consumedError);
32419
+ }
32420
+ };
32234
32421
  return {
32235
32422
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
32423
+ checkIsReadable();
32236
32424
  return new Promise((resolve, reject) => {
32237
32425
  const writableStream = fs.createWriteStream(filePath);
32238
32426
  writableStream.on("finish", () => {
@@ -32244,6 +32432,10 @@ class Client$E extends Client$F {
32244
32432
  res.pipe(writableStream);
32245
32433
  });
32246
32434
  }),
32435
+ getReadableStream: () => {
32436
+ checkIsReadable();
32437
+ return res;
32438
+ },
32247
32439
  };
32248
32440
  }),
32249
32441
  /**
@@ -32965,8 +33157,16 @@ class Client$E extends Client$F {
32965
33157
  this.logger.error(formatErrors(e));
32966
33158
  throw e;
32967
33159
  });
33160
+ const checkIsReadable = () => {
33161
+ const consumedError = "The stream has already been consumed";
33162
+ if (!res.readable) {
33163
+ this.logger.error(consumedError);
33164
+ throw new Error(consumedError);
33165
+ }
33166
+ };
32968
33167
  return {
32969
33168
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
33169
+ checkIsReadable();
32970
33170
  return new Promise((resolve, reject) => {
32971
33171
  const writableStream = fs.createWriteStream(filePath);
32972
33172
  writableStream.on("finish", () => {
@@ -32978,6 +33178,10 @@ class Client$E extends Client$F {
32978
33178
  res.pipe(writableStream);
32979
33179
  });
32980
33180
  }),
33181
+ getReadableStream: () => {
33182
+ checkIsReadable();
33183
+ return res;
33184
+ },
32981
33185
  };
32982
33186
  }),
32983
33187
  /**
@@ -33504,8 +33708,16 @@ class Client$C extends Client$D {
33504
33708
  this.logger.error(formatErrors(e));
33505
33709
  throw e;
33506
33710
  });
33711
+ const checkIsReadable = () => {
33712
+ const consumedError = "The stream has already been consumed";
33713
+ if (!res.readable) {
33714
+ this.logger.error(consumedError);
33715
+ throw new Error(consumedError);
33716
+ }
33717
+ };
33507
33718
  return {
33508
33719
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
33720
+ checkIsReadable();
33509
33721
  return new Promise((resolve, reject) => {
33510
33722
  const writableStream = fs.createWriteStream(filePath);
33511
33723
  writableStream.on("finish", () => {
@@ -33517,6 +33729,10 @@ class Client$C extends Client$D {
33517
33729
  res.pipe(writableStream);
33518
33730
  });
33519
33731
  }),
33732
+ getReadableStream: () => {
33733
+ checkIsReadable();
33734
+ return res;
33735
+ },
33520
33736
  };
33521
33737
  }),
33522
33738
  },
@@ -33629,8 +33845,16 @@ class Client$C extends Client$D {
33629
33845
  this.logger.error(formatErrors(e));
33630
33846
  throw e;
33631
33847
  });
33848
+ const checkIsReadable = () => {
33849
+ const consumedError = "The stream has already been consumed";
33850
+ if (!res.readable) {
33851
+ this.logger.error(consumedError);
33852
+ throw new Error(consumedError);
33853
+ }
33854
+ };
33632
33855
  return {
33633
33856
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
33857
+ checkIsReadable();
33634
33858
  return new Promise((resolve, reject) => {
33635
33859
  const writableStream = fs.createWriteStream(filePath);
33636
33860
  writableStream.on("finish", () => {
@@ -33642,6 +33866,10 @@ class Client$C extends Client$D {
33642
33866
  res.pipe(writableStream);
33643
33867
  });
33644
33868
  }),
33869
+ getReadableStream: () => {
33870
+ checkIsReadable();
33871
+ return res;
33872
+ },
33645
33873
  };
33646
33874
  }),
33647
33875
  },
@@ -34816,8 +35044,16 @@ class Client$v extends Client$w {
34816
35044
  this.logger.error(formatErrors(e));
34817
35045
  throw e;
34818
35046
  });
35047
+ const checkIsReadable = () => {
35048
+ const consumedError = "The stream has already been consumed";
35049
+ if (!res.readable) {
35050
+ this.logger.error(consumedError);
35051
+ throw new Error(consumedError);
35052
+ }
35053
+ };
34819
35054
  return {
34820
35055
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
35056
+ checkIsReadable();
34821
35057
  return new Promise((resolve, reject) => {
34822
35058
  const writableStream = fs.createWriteStream(filePath);
34823
35059
  writableStream.on("finish", () => {
@@ -34829,6 +35065,10 @@ class Client$v extends Client$w {
34829
35065
  res.pipe(writableStream);
34830
35066
  });
34831
35067
  }),
35068
+ getReadableStream: () => {
35069
+ checkIsReadable();
35070
+ return res;
35071
+ },
34832
35072
  };
34833
35073
  }),
34834
35074
  /**
@@ -35371,8 +35611,16 @@ class Client$v extends Client$w {
35371
35611
  this.logger.error(formatErrors(e));
35372
35612
  throw e;
35373
35613
  });
35614
+ const checkIsReadable = () => {
35615
+ const consumedError = "The stream has already been consumed";
35616
+ if (!res.readable) {
35617
+ this.logger.error(consumedError);
35618
+ throw new Error(consumedError);
35619
+ }
35620
+ };
35374
35621
  return {
35375
35622
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
35623
+ checkIsReadable();
35376
35624
  return new Promise((resolve, reject) => {
35377
35625
  const writableStream = fs.createWriteStream(filePath);
35378
35626
  writableStream.on("finish", () => {
@@ -35384,6 +35632,10 @@ class Client$v extends Client$w {
35384
35632
  res.pipe(writableStream);
35385
35633
  });
35386
35634
  }),
35635
+ getReadableStream: () => {
35636
+ checkIsReadable();
35637
+ return res;
35638
+ },
35387
35639
  };
35388
35640
  }),
35389
35641
  /**
@@ -36259,8 +36511,16 @@ class Client$v extends Client$w {
36259
36511
  this.logger.error(formatErrors(e));
36260
36512
  throw e;
36261
36513
  });
36514
+ const checkIsReadable = () => {
36515
+ const consumedError = "The stream has already been consumed";
36516
+ if (!res.readable) {
36517
+ this.logger.error(consumedError);
36518
+ throw new Error(consumedError);
36519
+ }
36520
+ };
36262
36521
  return {
36263
36522
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
36523
+ checkIsReadable();
36264
36524
  return new Promise((resolve, reject) => {
36265
36525
  const writableStream = fs.createWriteStream(filePath);
36266
36526
  writableStream.on("finish", () => {
@@ -36272,6 +36532,10 @@ class Client$v extends Client$w {
36272
36532
  res.pipe(writableStream);
36273
36533
  });
36274
36534
  }),
36535
+ getReadableStream: () => {
36536
+ checkIsReadable();
36537
+ return res;
36538
+ },
36275
36539
  };
36276
36540
  }),
36277
36541
  /**
@@ -36814,8 +37078,16 @@ class Client$v extends Client$w {
36814
37078
  this.logger.error(formatErrors(e));
36815
37079
  throw e;
36816
37080
  });
37081
+ const checkIsReadable = () => {
37082
+ const consumedError = "The stream has already been consumed";
37083
+ if (!res.readable) {
37084
+ this.logger.error(consumedError);
37085
+ throw new Error(consumedError);
37086
+ }
37087
+ };
36817
37088
  return {
36818
37089
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
37090
+ checkIsReadable();
36819
37091
  return new Promise((resolve, reject) => {
36820
37092
  const writableStream = fs.createWriteStream(filePath);
36821
37093
  writableStream.on("finish", () => {
@@ -36827,6 +37099,10 @@ class Client$v extends Client$w {
36827
37099
  res.pipe(writableStream);
36828
37100
  });
36829
37101
  }),
37102
+ getReadableStream: () => {
37103
+ checkIsReadable();
37104
+ return res;
37105
+ },
36830
37106
  };
36831
37107
  }),
36832
37108
  /**
@@ -48637,8 +48913,16 @@ class Client$s extends Client$t {
48637
48913
  this.logger.error(formatErrors(e));
48638
48914
  throw e;
48639
48915
  });
48916
+ const checkIsReadable = () => {
48917
+ const consumedError = "The stream has already been consumed";
48918
+ if (!res.readable) {
48919
+ this.logger.error(consumedError);
48920
+ throw new Error(consumedError);
48921
+ }
48922
+ };
48640
48923
  return {
48641
48924
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
48925
+ checkIsReadable();
48642
48926
  return new Promise((resolve, reject) => {
48643
48927
  const writableStream = fs.createWriteStream(filePath);
48644
48928
  writableStream.on("finish", () => {
@@ -48650,6 +48934,10 @@ class Client$s extends Client$t {
48650
48934
  res.pipe(writableStream);
48651
48935
  });
48652
48936
  }),
48937
+ getReadableStream: () => {
48938
+ checkIsReadable();
48939
+ return res;
48940
+ },
48653
48941
  };
48654
48942
  }),
48655
48943
  },
@@ -48710,8 +48998,16 @@ class Client$s extends Client$t {
48710
48998
  this.logger.error(formatErrors(e));
48711
48999
  throw e;
48712
49000
  });
49001
+ const checkIsReadable = () => {
49002
+ const consumedError = "The stream has already been consumed";
49003
+ if (!res.readable) {
49004
+ this.logger.error(consumedError);
49005
+ throw new Error(consumedError);
49006
+ }
49007
+ };
48713
49008
  return {
48714
49009
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
49010
+ checkIsReadable();
48715
49011
  return new Promise((resolve, reject) => {
48716
49012
  const writableStream = fs.createWriteStream(filePath);
48717
49013
  writableStream.on("finish", () => {
@@ -48723,6 +49019,10 @@ class Client$s extends Client$t {
48723
49019
  res.pipe(writableStream);
48724
49020
  });
48725
49021
  }),
49022
+ getReadableStream: () => {
49023
+ checkIsReadable();
49024
+ return res;
49025
+ },
48726
49026
  };
48727
49027
  }),
48728
49028
  },
@@ -49390,8 +49690,16 @@ class Client$s extends Client$t {
49390
49690
  this.logger.error(formatErrors(e));
49391
49691
  throw e;
49392
49692
  });
49693
+ const checkIsReadable = () => {
49694
+ const consumedError = "The stream has already been consumed";
49695
+ if (!res.readable) {
49696
+ this.logger.error(consumedError);
49697
+ throw new Error(consumedError);
49698
+ }
49699
+ };
49393
49700
  return {
49394
49701
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
49702
+ checkIsReadable();
49395
49703
  return new Promise((resolve, reject) => {
49396
49704
  const writableStream = fs.createWriteStream(filePath);
49397
49705
  writableStream.on("finish", () => {
@@ -49403,6 +49711,10 @@ class Client$s extends Client$t {
49403
49711
  res.pipe(writableStream);
49404
49712
  });
49405
49713
  }),
49714
+ getReadableStream: () => {
49715
+ checkIsReadable();
49716
+ return res;
49717
+ },
49406
49718
  };
49407
49719
  }),
49408
49720
  },
@@ -50727,8 +51039,16 @@ class Client$s extends Client$t {
50727
51039
  this.logger.error(formatErrors(e));
50728
51040
  throw e;
50729
51041
  });
51042
+ const checkIsReadable = () => {
51043
+ const consumedError = "The stream has already been consumed";
51044
+ if (!res.readable) {
51045
+ this.logger.error(consumedError);
51046
+ throw new Error(consumedError);
51047
+ }
51048
+ };
50730
51049
  return {
50731
51050
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
51051
+ checkIsReadable();
50732
51052
  return new Promise((resolve, reject) => {
50733
51053
  const writableStream = fs.createWriteStream(filePath);
50734
51054
  writableStream.on("finish", () => {
@@ -50740,6 +51060,10 @@ class Client$s extends Client$t {
50740
51060
  res.pipe(writableStream);
50741
51061
  });
50742
51062
  }),
51063
+ getReadableStream: () => {
51064
+ checkIsReadable();
51065
+ return res;
51066
+ },
50743
51067
  };
50744
51068
  }),
50745
51069
  },
@@ -50800,8 +51124,16 @@ class Client$s extends Client$t {
50800
51124
  this.logger.error(formatErrors(e));
50801
51125
  throw e;
50802
51126
  });
51127
+ const checkIsReadable = () => {
51128
+ const consumedError = "The stream has already been consumed";
51129
+ if (!res.readable) {
51130
+ this.logger.error(consumedError);
51131
+ throw new Error(consumedError);
51132
+ }
51133
+ };
50803
51134
  return {
50804
51135
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
51136
+ checkIsReadable();
50805
51137
  return new Promise((resolve, reject) => {
50806
51138
  const writableStream = fs.createWriteStream(filePath);
50807
51139
  writableStream.on("finish", () => {
@@ -50813,6 +51145,10 @@ class Client$s extends Client$t {
50813
51145
  res.pipe(writableStream);
50814
51146
  });
50815
51147
  }),
51148
+ getReadableStream: () => {
51149
+ checkIsReadable();
51150
+ return res;
51151
+ },
50816
51152
  };
50817
51153
  }),
50818
51154
  },
@@ -51480,8 +51816,16 @@ class Client$s extends Client$t {
51480
51816
  this.logger.error(formatErrors(e));
51481
51817
  throw e;
51482
51818
  });
51819
+ const checkIsReadable = () => {
51820
+ const consumedError = "The stream has already been consumed";
51821
+ if (!res.readable) {
51822
+ this.logger.error(consumedError);
51823
+ throw new Error(consumedError);
51824
+ }
51825
+ };
51483
51826
  return {
51484
51827
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
51828
+ checkIsReadable();
51485
51829
  return new Promise((resolve, reject) => {
51486
51830
  const writableStream = fs.createWriteStream(filePath);
51487
51831
  writableStream.on("finish", () => {
@@ -51493,6 +51837,10 @@ class Client$s extends Client$t {
51493
51837
  res.pipe(writableStream);
51494
51838
  });
51495
51839
  }),
51840
+ getReadableStream: () => {
51841
+ checkIsReadable();
51842
+ return res;
51843
+ },
51496
51844
  };
51497
51845
  }),
51498
51846
  },
@@ -52352,8 +52700,16 @@ class Client$r extends Client$s {
52352
52700
  this.logger.error(formatErrors(e));
52353
52701
  throw e;
52354
52702
  });
52703
+ const checkIsReadable = () => {
52704
+ const consumedError = "The stream has already been consumed";
52705
+ if (!res.readable) {
52706
+ this.logger.error(consumedError);
52707
+ throw new Error(consumedError);
52708
+ }
52709
+ };
52355
52710
  return {
52356
52711
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
52712
+ checkIsReadable();
52357
52713
  return new Promise((resolve, reject) => {
52358
52714
  const writableStream = fs.createWriteStream(filePath);
52359
52715
  writableStream.on("finish", () => {
@@ -52365,6 +52721,10 @@ class Client$r extends Client$s {
52365
52721
  res.pipe(writableStream);
52366
52722
  });
52367
52723
  }),
52724
+ getReadableStream: () => {
52725
+ checkIsReadable();
52726
+ return res;
52727
+ },
52368
52728
  };
52369
52729
  }),
52370
52730
  /**
@@ -63018,8 +63378,16 @@ class Client$4 extends Client$5 {
63018
63378
  this.logger.error(formatErrors(e));
63019
63379
  throw e;
63020
63380
  });
63381
+ const checkIsReadable = () => {
63382
+ const consumedError = "The stream has already been consumed";
63383
+ if (!res.readable) {
63384
+ this.logger.error(consumedError);
63385
+ throw new Error(consumedError);
63386
+ }
63387
+ };
63021
63388
  return {
63022
63389
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
63390
+ checkIsReadable();
63023
63391
  return new Promise((resolve, reject) => {
63024
63392
  const writableStream = fs.createWriteStream(filePath);
63025
63393
  writableStream.on("finish", () => {
@@ -63031,6 +63399,10 @@ class Client$4 extends Client$5 {
63031
63399
  res.pipe(writableStream);
63032
63400
  });
63033
63401
  }),
63402
+ getReadableStream: () => {
63403
+ checkIsReadable();
63404
+ return res;
63405
+ },
63034
63406
  };
63035
63407
  }),
63036
63408
  /**
@@ -64834,8 +65206,16 @@ class Client$4 extends Client$5 {
64834
65206
  this.logger.error(formatErrors(e));
64835
65207
  throw e;
64836
65208
  });
65209
+ const checkIsReadable = () => {
65210
+ const consumedError = "The stream has already been consumed";
65211
+ if (!res.readable) {
65212
+ this.logger.error(consumedError);
65213
+ throw new Error(consumedError);
65214
+ }
65215
+ };
64837
65216
  return {
64838
65217
  writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {
65218
+ checkIsReadable();
64839
65219
  return new Promise((resolve, reject) => {
64840
65220
  const writableStream = fs.createWriteStream(filePath);
64841
65221
  writableStream.on("finish", () => {
@@ -64847,6 +65227,10 @@ class Client$4 extends Client$5 {
64847
65227
  res.pipe(writableStream);
64848
65228
  });
64849
65229
  }),
65230
+ getReadableStream: () => {
65231
+ checkIsReadable();
65232
+ return res;
65233
+ },
64850
65234
  };
64851
65235
  }),
64852
65236
  /**
@@ -69508,6 +69892,13 @@ var MessageType;
69508
69892
  MessageType["ping"] = "ping";
69509
69893
  MessageType["pong"] = "pong";
69510
69894
  })(MessageType || (MessageType = {}));
69895
+ var HttpStatusCode;
69896
+ (function (HttpStatusCode) {
69897
+ // 2xx Success
69898
+ HttpStatusCode[HttpStatusCode["ok"] = 200] = "ok";
69899
+ // 5xx Server errors
69900
+ HttpStatusCode[HttpStatusCode["internal_server_error"] = 500] = "internal_server_error";
69901
+ })(HttpStatusCode || (HttpStatusCode = {}));
69511
69902
 
69512
69903
  class WSClient {
69513
69904
  constructor(params) {
@@ -69725,13 +70116,22 @@ class WSClient {
69725
70116
  return;
69726
70117
  }
69727
70118
  this.logger.debug('[ws]', `receive message, message_type: ${type}; message_id: ${message_id}; trace_id: ${trace_id}; data: ${mergedData.data}`);
70119
+ const respPayload = {
70120
+ code: HttpStatusCode.ok,
70121
+ };
69728
70122
  const startTime = Date.now();
69729
- yield ((_a = this.eventDispatcher) === null || _a === void 0 ? void 0 : _a.invoke(mergedData, { needCheck: false }));
70123
+ try {
70124
+ const result = yield ((_a = this.eventDispatcher) === null || _a === void 0 ? void 0 : _a.invoke(mergedData, { needCheck: false }));
70125
+ if (result) {
70126
+ respPayload.data = Buffer.from(JSON.stringify(result)).toString("base64");
70127
+ }
70128
+ }
70129
+ catch (error) {
70130
+ respPayload.code = HttpStatusCode.internal_server_error;
70131
+ this.logger.error('[ws]', `invoke event failed, message_type: ${type}; message_id: ${message_id}; trace_id: ${trace_id}; error: ${error}`);
70132
+ }
69730
70133
  const endTime = Date.now();
69731
- this.sendMessage(Object.assign(Object.assign({}, data), { headers: [...data.headers, { key: HeaderKey.biz_rt, value: String(startTime - endTime) }], payload: new TextEncoder().encode(JSON.stringify({
69732
- // http code
69733
- code: 200
69734
- })) }));
70134
+ this.sendMessage(Object.assign(Object.assign({}, data), { headers: [...data.headers, { key: HeaderKey.biz_rt, value: String(startTime - endTime) }], payload: new TextEncoder().encode(JSON.stringify(respPayload)) }));
69735
70135
  });
69736
70136
  }
69737
70137
  sendMessage(data) {
@@ -69748,14 +70148,14 @@ class WSClient {
69748
70148
  }
69749
70149
  start(params) {
69750
70150
  return __awaiter(this, void 0, void 0, function* () {
69751
- this.logger.info('[ws]', `receive events through persistent connection only available in self-build & Feishu app, Configured in:
70151
+ this.logger.info('[ws]', `receive events or callbacks through persistent connection only available in self-build & Feishu app, Configured in:
69752
70152
  Developer Console(开发者后台)
69753
70153
  ->
69754
- Events and Callbacks(事件配置)
70154
+ Events and Callbacks(事件与回调)
69755
70155
  ->
69756
- Mode of event subscription(配置订阅方式)
70156
+ Mode of event/callback subscription(订阅方式)
69757
70157
  ->
69758
- Receive events through persistent connection(使用长连接接收事件)`);
70158
+ Receive events/callbacks through persistent connection(使用 长连接 接收事件/回调)`);
69759
70159
  const { eventDispatcher } = params;
69760
70160
  if (!eventDispatcher) {
69761
70161
  this.logger.warn('[ws]', 'client need to start with a eventDispatcher');