@dereekb/trello 13.11.15 → 13.11.17

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/index.esm.js CHANGED
@@ -8,7 +8,7 @@ function _assert_this_initialized(self) {
8
8
  }
9
9
  return self;
10
10
  }
11
- function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
11
+ function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
12
12
  try {
13
13
  var info = gen[key](arg);
14
14
  var value = info.value;
@@ -22,16 +22,16 @@ function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
22
22
  Promise.resolve(value).then(_next, _throw);
23
23
  }
24
24
  }
25
- function _async_to_generator$3(fn) {
25
+ function _async_to_generator$4(fn) {
26
26
  return function() {
27
27
  var self = this, args = arguments;
28
28
  return new Promise(function(resolve, reject) {
29
29
  var gen = fn.apply(self, args);
30
30
  function _next(value) {
31
- asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
31
+ asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "next", value);
32
32
  }
33
33
  function _throw(err) {
34
- asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
34
+ asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "throw", err);
35
35
  }
36
36
  _next(undefined);
37
37
  });
@@ -124,7 +124,7 @@ function _is_native_reflect_construct() {
124
124
  return !!result;
125
125
  })();
126
126
  }
127
- function _ts_generator$3(thisArg, body) {
127
+ function _ts_generator$4(thisArg, body) {
128
128
  var f, y, t, _ = {
129
129
  label: 0,
130
130
  sent: function() {
@@ -325,9 +325,9 @@ var logTrelloErrorToConsole = logTrelloServerErrorFunction('Trello');
325
325
  * @param responseError - The fetch response error to parse.
326
326
  * @returns A typed Trello error, or undefined if the response could not be parsed.
327
327
  */ function parseTrelloApiError(responseError) {
328
- return _async_to_generator$3(function() {
328
+ return _async_to_generator$4(function() {
329
329
  var response, bodyText, bodyJson, data, message, result;
330
- return _ts_generator$3(this, function(_state) {
330
+ return _ts_generator$4(this, function(_state) {
331
331
  switch(_state.label){
332
332
  case 0:
333
333
  response = responseError.response;
@@ -380,9 +380,9 @@ var logTrelloErrorToConsole = logTrelloServerErrorFunction('Trello');
380
380
  */ function handleTrelloErrorFetch(fetch) {
381
381
  var logError = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : logTrelloErrorToConsole;
382
382
  return function(x, y) {
383
- return _async_to_generator$3(function() {
383
+ return _async_to_generator$4(function() {
384
384
  var e, error;
385
- return _ts_generator$3(this, function(_state) {
385
+ return _ts_generator$4(this, function(_state) {
386
386
  switch(_state.label){
387
387
  case 0:
388
388
  _state.trys.push([
@@ -520,7 +520,7 @@ var logTrelloErrorToConsole = logTrelloServerErrorFunction('Trello');
520
520
  };
521
521
  }
522
522
 
523
- function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
523
+ function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
524
524
  try {
525
525
  var info = gen[key](arg);
526
526
  var value = info.value;
@@ -534,22 +534,22 @@ function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
534
534
  Promise.resolve(value).then(_next, _throw);
535
535
  }
536
536
  }
537
- function _async_to_generator$2(fn) {
537
+ function _async_to_generator$3(fn) {
538
538
  return function() {
539
539
  var self = this, args = arguments;
540
540
  return new Promise(function(resolve, reject) {
541
541
  var gen = fn.apply(self, args);
542
542
  function _next(value) {
543
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
543
+ asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
544
544
  }
545
545
  function _throw(err) {
546
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
546
+ asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
547
547
  }
548
548
  _next(undefined);
549
549
  });
550
550
  };
551
551
  }
552
- function _object_without_properties$3(source, excluded) {
552
+ function _object_without_properties$4(source, excluded) {
553
553
  if (source == null) return {};
554
554
  var target = {}, sourceKeys, key, i;
555
555
  if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
@@ -562,7 +562,7 @@ function _object_without_properties$3(source, excluded) {
562
562
  }
563
563
  return target;
564
564
  }
565
- target = _object_without_properties_loose$3(source, excluded);
565
+ target = _object_without_properties_loose$4(source, excluded);
566
566
  if (Object.getOwnPropertySymbols) {
567
567
  sourceKeys = Object.getOwnPropertySymbols(source);
568
568
  for(i = 0; i < sourceKeys.length; i++){
@@ -574,7 +574,7 @@ function _object_without_properties$3(source, excluded) {
574
574
  }
575
575
  return target;
576
576
  }
577
- function _object_without_properties_loose$3(source, excluded) {
577
+ function _object_without_properties_loose$4(source, excluded) {
578
578
  if (source == null) return {};
579
579
  var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
580
580
  for(i = 0; i < sourceKeys.length; i++){
@@ -585,7 +585,7 @@ function _object_without_properties_loose$3(source, excluded) {
585
585
  }
586
586
  return target;
587
587
  }
588
- function _ts_generator$2(thisArg, body) {
588
+ function _ts_generator$3(thisArg, body) {
589
589
  var f, y, t, _ = {
590
590
  label: 0,
591
591
  sent: function() {
@@ -712,7 +712,7 @@ function _ts_generator$2(thisArg, body) {
712
712
  * @returns Updates an existing board.
713
713
  */ function updateBoard(context) {
714
714
  return function(input) {
715
- var boardId = input.boardId, body = _object_without_properties$3(input, [
715
+ var boardId = input.boardId, body = _object_without_properties$4(input, [
716
716
  "boardId"
717
717
  ]);
718
718
  return context.fetchJson("/boards/".concat(boardId), 'PUT', body);
@@ -725,8 +725,8 @@ function _ts_generator$2(thisArg, body) {
725
725
  * @returns Deletes a board.
726
726
  */ function deleteBoard(context) {
727
727
  return function(input) {
728
- return _async_to_generator$2(function() {
729
- return _ts_generator$2(this, function(_state) {
728
+ return _async_to_generator$3(function() {
729
+ return _ts_generator$3(this, function(_state) {
730
730
  switch(_state.label){
731
731
  case 0:
732
732
  return [
@@ -750,7 +750,7 @@ function _ts_generator$2(thisArg, body) {
750
750
  * @returns Lists all lists on a board.
751
751
  */ function listBoardLists(context) {
752
752
  return function(input) {
753
- var boardId = input.boardId, query = _object_without_properties$3(input, [
753
+ var boardId = input.boardId, query = _object_without_properties$4(input, [
754
754
  "boardId"
755
755
  ]);
756
756
  var queryString = makeUrlSearchParams(query);
@@ -764,7 +764,7 @@ function _ts_generator$2(thisArg, body) {
764
764
  * @returns Lists all cards on a board.
765
765
  */ function listBoardCards(context) {
766
766
  return function(input) {
767
- var boardId = input.boardId, query = _object_without_properties$3(input, [
767
+ var boardId = input.boardId, query = _object_without_properties$4(input, [
768
768
  "boardId"
769
769
  ]);
770
770
  var queryString = makeUrlSearchParams(query);
@@ -778,7 +778,7 @@ function _ts_generator$2(thisArg, body) {
778
778
  * @returns Lists every label defined on a board.
779
779
  */ function listBoardLabels(context) {
780
780
  return function(input) {
781
- var boardId = input.boardId, query = _object_without_properties$3(input, [
781
+ var boardId = input.boardId, query = _object_without_properties$4(input, [
782
782
  "boardId"
783
783
  ]);
784
784
  var queryString = makeUrlSearchParams(query);
@@ -796,7 +796,7 @@ function _ts_generator$2(thisArg, body) {
796
796
  };
797
797
  }
798
798
 
799
- function _object_without_properties$2(source, excluded) {
799
+ function _object_without_properties$3(source, excluded) {
800
800
  if (source == null) return {};
801
801
  var target = {}, sourceKeys, key, i;
802
802
  if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
@@ -809,7 +809,7 @@ function _object_without_properties$2(source, excluded) {
809
809
  }
810
810
  return target;
811
811
  }
812
- target = _object_without_properties_loose$2(source, excluded);
812
+ target = _object_without_properties_loose$3(source, excluded);
813
813
  if (Object.getOwnPropertySymbols) {
814
814
  sourceKeys = Object.getOwnPropertySymbols(source);
815
815
  for(i = 0; i < sourceKeys.length; i++){
@@ -821,7 +821,7 @@ function _object_without_properties$2(source, excluded) {
821
821
  }
822
822
  return target;
823
823
  }
824
- function _object_without_properties_loose$2(source, excluded) {
824
+ function _object_without_properties_loose$3(source, excluded) {
825
825
  if (source == null) return {};
826
826
  var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
827
827
  for(i = 0; i < sourceKeys.length; i++){
@@ -860,7 +860,7 @@ function _object_without_properties_loose$2(source, excluded) {
860
860
  * @returns Updates an existing list.
861
861
  */ function updateList(context) {
862
862
  return function(input) {
863
- var listId = input.listId, body = _object_without_properties$2(input, [
863
+ var listId = input.listId, body = _object_without_properties$3(input, [
864
864
  "listId"
865
865
  ]);
866
866
  return context.fetchJson("/lists/".concat(listId), 'PUT', body);
@@ -873,7 +873,7 @@ function _object_without_properties_loose$2(source, excluded) {
873
873
  * @returns Lists all cards on a list.
874
874
  */ function listCardsInList(context) {
875
875
  return function(input) {
876
- var listId = input.listId, query = _object_without_properties$2(input, [
876
+ var listId = input.listId, query = _object_without_properties$3(input, [
877
877
  "listId"
878
878
  ]);
879
879
  var queryString = makeUrlSearchParams(query);
@@ -881,7 +881,7 @@ function _object_without_properties_loose$2(source, excluded) {
881
881
  };
882
882
  }
883
883
 
884
- function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
884
+ function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
885
885
  try {
886
886
  var info = gen[key](arg);
887
887
  var value = info.value;
@@ -895,16 +895,16 @@ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
895
895
  Promise.resolve(value).then(_next, _throw);
896
896
  }
897
897
  }
898
- function _async_to_generator$1(fn) {
898
+ function _async_to_generator$2(fn) {
899
899
  return function() {
900
900
  var self = this, args = arguments;
901
901
  return new Promise(function(resolve, reject) {
902
902
  var gen = fn.apply(self, args);
903
903
  function _next(value) {
904
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
904
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
905
905
  }
906
906
  function _throw(err) {
907
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
907
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
908
908
  }
909
909
  _next(undefined);
910
910
  });
@@ -938,7 +938,7 @@ function _object_spread$1(target) {
938
938
  }
939
939
  return target;
940
940
  }
941
- function _object_without_properties$1(source, excluded) {
941
+ function _object_without_properties$2(source, excluded) {
942
942
  if (source == null) return {};
943
943
  var target = {}, sourceKeys, key, i;
944
944
  if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
@@ -951,7 +951,7 @@ function _object_without_properties$1(source, excluded) {
951
951
  }
952
952
  return target;
953
953
  }
954
- target = _object_without_properties_loose$1(source, excluded);
954
+ target = _object_without_properties_loose$2(source, excluded);
955
955
  if (Object.getOwnPropertySymbols) {
956
956
  sourceKeys = Object.getOwnPropertySymbols(source);
957
957
  for(i = 0; i < sourceKeys.length; i++){
@@ -963,7 +963,7 @@ function _object_without_properties$1(source, excluded) {
963
963
  }
964
964
  return target;
965
965
  }
966
- function _object_without_properties_loose$1(source, excluded) {
966
+ function _object_without_properties_loose$2(source, excluded) {
967
967
  if (source == null) return {};
968
968
  var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
969
969
  for(i = 0; i < sourceKeys.length; i++){
@@ -974,7 +974,7 @@ function _object_without_properties_loose$1(source, excluded) {
974
974
  }
975
975
  return target;
976
976
  }
977
- function _ts_generator$1(thisArg, body) {
977
+ function _ts_generator$2(thisArg, body) {
978
978
  var f, y, t, _ = {
979
979
  label: 0,
980
980
  sent: function() {
@@ -1090,7 +1090,7 @@ function _ts_generator$1(thisArg, body) {
1090
1090
  * @returns Creates a card on a list.
1091
1091
  */ function createCard(context) {
1092
1092
  return function(input) {
1093
- var idLabels = input.idLabels, idMembers = input.idMembers, rest = _object_without_properties$1(input, [
1093
+ var idLabels = input.idLabels, idMembers = input.idMembers, rest = _object_without_properties$2(input, [
1094
1094
  "idLabels",
1095
1095
  "idMembers"
1096
1096
  ]);
@@ -1112,7 +1112,7 @@ function _ts_generator$1(thisArg, body) {
1112
1112
  * @returns Updates an existing card.
1113
1113
  */ function updateCard(context) {
1114
1114
  return function(input) {
1115
- var cardId = input.cardId, idLabels = input.idLabels, idMembers = input.idMembers, rest = _object_without_properties$1(input, [
1115
+ var cardId = input.cardId, idLabels = input.idLabels, idMembers = input.idMembers, rest = _object_without_properties$2(input, [
1116
1116
  "cardId",
1117
1117
  "idLabels",
1118
1118
  "idMembers"
@@ -1134,8 +1134,8 @@ function _ts_generator$1(thisArg, body) {
1134
1134
  * @returns Deletes a card.
1135
1135
  */ function deleteCard(context) {
1136
1136
  return function(input) {
1137
- return _async_to_generator$1(function() {
1138
- return _ts_generator$1(this, function(_state) {
1137
+ return _async_to_generator$2(function() {
1138
+ return _ts_generator$2(this, function(_state) {
1139
1139
  switch(_state.label){
1140
1140
  case 0:
1141
1141
  return [
@@ -1162,7 +1162,7 @@ function _ts_generator$1(thisArg, body) {
1162
1162
  * @returns Lists actions on a card.
1163
1163
  */ function listCardActions(context) {
1164
1164
  return function(input) {
1165
- var cardId = input.cardId, query = _object_without_properties$1(input, [
1165
+ var cardId = input.cardId, query = _object_without_properties$2(input, [
1166
1166
  "cardId"
1167
1167
  ]);
1168
1168
  var queryString = makeUrlSearchParams(query);
@@ -1209,6 +1209,383 @@ function _ts_generator$1(thisArg, body) {
1209
1209
  };
1210
1210
  }
1211
1211
 
1212
+ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
1213
+ try {
1214
+ var info = gen[key](arg);
1215
+ var value = info.value;
1216
+ } catch (error) {
1217
+ reject(error);
1218
+ return;
1219
+ }
1220
+ if (info.done) {
1221
+ resolve(value);
1222
+ } else {
1223
+ Promise.resolve(value).then(_next, _throw);
1224
+ }
1225
+ }
1226
+ function _async_to_generator$1(fn) {
1227
+ return function() {
1228
+ var self = this, args = arguments;
1229
+ return new Promise(function(resolve, reject) {
1230
+ var gen = fn.apply(self, args);
1231
+ function _next(value) {
1232
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
1233
+ }
1234
+ function _throw(err) {
1235
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
1236
+ }
1237
+ _next(undefined);
1238
+ });
1239
+ };
1240
+ }
1241
+ function _object_without_properties$1(source, excluded) {
1242
+ if (source == null) return {};
1243
+ var target = {}, sourceKeys, key, i;
1244
+ if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
1245
+ sourceKeys = Reflect.ownKeys(Object(source));
1246
+ for(i = 0; i < sourceKeys.length; i++){
1247
+ key = sourceKeys[i];
1248
+ if (excluded.indexOf(key) >= 0) continue;
1249
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
1250
+ target[key] = source[key];
1251
+ }
1252
+ return target;
1253
+ }
1254
+ target = _object_without_properties_loose$1(source, excluded);
1255
+ if (Object.getOwnPropertySymbols) {
1256
+ sourceKeys = Object.getOwnPropertySymbols(source);
1257
+ for(i = 0; i < sourceKeys.length; i++){
1258
+ key = sourceKeys[i];
1259
+ if (excluded.indexOf(key) >= 0) continue;
1260
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
1261
+ target[key] = source[key];
1262
+ }
1263
+ }
1264
+ return target;
1265
+ }
1266
+ function _object_without_properties_loose$1(source, excluded) {
1267
+ if (source == null) return {};
1268
+ var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
1269
+ for(i = 0; i < sourceKeys.length; i++){
1270
+ key = sourceKeys[i];
1271
+ if (excluded.indexOf(key) >= 0) continue;
1272
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
1273
+ target[key] = source[key];
1274
+ }
1275
+ return target;
1276
+ }
1277
+ function _ts_generator$1(thisArg, body) {
1278
+ var f, y, t, _ = {
1279
+ label: 0,
1280
+ sent: function() {
1281
+ if (t[0] & 1) throw t[1];
1282
+ return t[1];
1283
+ },
1284
+ trys: [],
1285
+ ops: []
1286
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
1287
+ return d(g, "next", {
1288
+ value: verb(0)
1289
+ }), d(g, "throw", {
1290
+ value: verb(1)
1291
+ }), d(g, "return", {
1292
+ value: verb(2)
1293
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
1294
+ value: function() {
1295
+ return this;
1296
+ }
1297
+ }), g;
1298
+ function verb(n) {
1299
+ return function(v) {
1300
+ return step([
1301
+ n,
1302
+ v
1303
+ ]);
1304
+ };
1305
+ }
1306
+ function step(op) {
1307
+ if (f) throw new TypeError("Generator is already executing.");
1308
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
1309
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
1310
+ if (y = 0, t) op = [
1311
+ op[0] & 2,
1312
+ t.value
1313
+ ];
1314
+ switch(op[0]){
1315
+ case 0:
1316
+ case 1:
1317
+ t = op;
1318
+ break;
1319
+ case 4:
1320
+ _.label++;
1321
+ return {
1322
+ value: op[1],
1323
+ done: false
1324
+ };
1325
+ case 5:
1326
+ _.label++;
1327
+ y = op[1];
1328
+ op = [
1329
+ 0
1330
+ ];
1331
+ continue;
1332
+ case 7:
1333
+ op = _.ops.pop();
1334
+ _.trys.pop();
1335
+ continue;
1336
+ default:
1337
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
1338
+ _ = 0;
1339
+ continue;
1340
+ }
1341
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
1342
+ _.label = op[1];
1343
+ break;
1344
+ }
1345
+ if (op[0] === 6 && _.label < t[1]) {
1346
+ _.label = t[1];
1347
+ t = op;
1348
+ break;
1349
+ }
1350
+ if (t && _.label < t[2]) {
1351
+ _.label = t[2];
1352
+ _.ops.push(op);
1353
+ break;
1354
+ }
1355
+ if (t[2]) _.ops.pop();
1356
+ _.trys.pop();
1357
+ continue;
1358
+ }
1359
+ op = body.call(thisArg, _);
1360
+ } catch (e) {
1361
+ op = [
1362
+ 6,
1363
+ e
1364
+ ];
1365
+ y = 0;
1366
+ } finally{
1367
+ f = t = 0;
1368
+ }
1369
+ if (op[0] & 5) throw op[1];
1370
+ return {
1371
+ value: op[0] ? op[1] : void 0,
1372
+ done: true
1373
+ };
1374
+ }
1375
+ }
1376
+ /**
1377
+ * Https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-attachments-get.
1378
+ *
1379
+ * @param context - The Trello API context.
1380
+ * @returns Lists attachments on a card.
1381
+ */ function listCardAttachments(context) {
1382
+ return function(input) {
1383
+ var cardId = input.cardId, query = _object_without_properties$1(input, [
1384
+ "cardId"
1385
+ ]);
1386
+ var queryString = makeUrlSearchParams(query);
1387
+ return context.fetchJson("/cards/".concat(cardId, "/attachments?").concat(queryString), 'GET');
1388
+ };
1389
+ }
1390
+ /**
1391
+ * Https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-attachments-idattachment-get.
1392
+ *
1393
+ * @param context - The Trello API context.
1394
+ * @returns Retrieves a single attachment on a card.
1395
+ */ function getCardAttachment(context) {
1396
+ return function(input) {
1397
+ var cardId = input.cardId, attachmentId = input.attachmentId, query = _object_without_properties$1(input, [
1398
+ "cardId",
1399
+ "attachmentId"
1400
+ ]);
1401
+ var queryString = makeUrlSearchParams(query);
1402
+ return context.fetchJson("/cards/".concat(cardId, "/attachments/").concat(attachmentId, "?").concat(queryString), 'GET');
1403
+ };
1404
+ }
1405
+ /**
1406
+ * Https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-attachments-post.
1407
+ *
1408
+ * Supports both file uploads (multipart/form-data) and url-only attachments. Pass exactly one of `file` or `url`.
1409
+ *
1410
+ * @param context - The Trello API context.
1411
+ * @returns Adds an attachment (file or url) to a card.
1412
+ */ function addAttachmentToCard(context) {
1413
+ return function(input) {
1414
+ return _async_to_generator$1(function() {
1415
+ var cardId, name, file, url, setCover, mimeType, formData, _file_mimeType, fileMimeType, blob, response;
1416
+ return _ts_generator$1(this, function(_state) {
1417
+ switch(_state.label){
1418
+ case 0:
1419
+ cardId = input.cardId, name = input.name, file = input.file, url = input.url, setCover = input.setCover, mimeType = input.mimeType;
1420
+ if (file && url || !file && !url) {
1421
+ throw new Error('addAttachmentToCard requires exactly one of `file` or `url`.');
1422
+ }
1423
+ formData = new FormData();
1424
+ if (name) {
1425
+ formData.append('name', name);
1426
+ }
1427
+ if (setCover !== undefined) {
1428
+ formData.append('setCover', setCover ? 'true' : 'false');
1429
+ }
1430
+ if (file) {
1431
+ fileMimeType = (_file_mimeType = file.mimeType) !== null && _file_mimeType !== void 0 ? _file_mimeType : 'application/octet-stream';
1432
+ blob = new Blob([
1433
+ file.content
1434
+ ], {
1435
+ type: fileMimeType
1436
+ });
1437
+ formData.append('file', blob, file.fileName);
1438
+ } else if (url) {
1439
+ formData.append('url', url);
1440
+ if (mimeType) {
1441
+ formData.append('mimeType', mimeType);
1442
+ }
1443
+ }
1444
+ return [
1445
+ 4,
1446
+ context.fetch("/cards/".concat(cardId, "/attachments"), {
1447
+ method: 'POST',
1448
+ body: formData,
1449
+ headers: {
1450
+ 'Content-Type': ''
1451
+ }
1452
+ })
1453
+ ];
1454
+ case 1:
1455
+ response = _state.sent();
1456
+ return [
1457
+ 4,
1458
+ response.json()
1459
+ ];
1460
+ case 2:
1461
+ return [
1462
+ 2,
1463
+ _state.sent()
1464
+ ];
1465
+ }
1466
+ });
1467
+ })();
1468
+ };
1469
+ }
1470
+ /**
1471
+ * Https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-attachments-idattachment-delete.
1472
+ *
1473
+ * @param context - The Trello API context.
1474
+ * @returns Removes an attachment from a card.
1475
+ */ function deleteAttachmentFromCard(context) {
1476
+ return function(input) {
1477
+ return _async_to_generator$1(function() {
1478
+ return _ts_generator$1(this, function(_state) {
1479
+ switch(_state.label){
1480
+ case 0:
1481
+ return [
1482
+ 4,
1483
+ context.fetchJson("/cards/".concat(input.cardId, "/attachments/").concat(input.attachmentId), 'DELETE')
1484
+ ];
1485
+ case 1:
1486
+ _state.sent();
1487
+ return [
1488
+ 2
1489
+ ];
1490
+ }
1491
+ });
1492
+ })();
1493
+ };
1494
+ }
1495
+ /**
1496
+ * Downloads the raw bytes of a card attachment via the authenticated Trello download endpoint:
1497
+ * `GET /cards/{id}/attachments/{idAttachment}/download/{filename}`.
1498
+ *
1499
+ * The configured Trello fetch automatically attaches the OAuth `Authorization` header required by Trello
1500
+ * for private file downloads.
1501
+ *
1502
+ * @param context - The Trello API context.
1503
+ * @returns Downloads the attachment bytes along with its metadata.
1504
+ *
1505
+ * @see https://developer.atlassian.com/cloud/trello/guides/rest-api/file-attachments/
1506
+ */ function downloadCardAttachment(context) {
1507
+ var getAttachment = getCardAttachment(context);
1508
+ return function(input) {
1509
+ return _async_to_generator$1(function() {
1510
+ var _input_attachment, attachment, _tmp, fileName, response, mimeType;
1511
+ return _ts_generator$1(this, function(_state) {
1512
+ switch(_state.label){
1513
+ case 0:
1514
+ if (!((_input_attachment = input.attachment) !== null && _input_attachment !== void 0)) return [
1515
+ 3,
1516
+ 1
1517
+ ];
1518
+ _tmp = _input_attachment;
1519
+ return [
1520
+ 3,
1521
+ 3
1522
+ ];
1523
+ case 1:
1524
+ return [
1525
+ 4,
1526
+ getAttachment({
1527
+ cardId: input.cardId,
1528
+ attachmentId: input.attachmentId
1529
+ })
1530
+ ];
1531
+ case 2:
1532
+ _tmp = _state.sent();
1533
+ _state.label = 3;
1534
+ case 3:
1535
+ attachment = _tmp;
1536
+ fileName = attachment.fileName || attachment.name;
1537
+ return [
1538
+ 4,
1539
+ context.fetch("/cards/".concat(input.cardId, "/attachments/").concat(input.attachmentId, "/download/").concat(encodeURIComponent(fileName)), {
1540
+ method: 'GET'
1541
+ })
1542
+ ];
1543
+ case 4:
1544
+ response = _state.sent();
1545
+ mimeType = attachment.mimeType;
1546
+ return [
1547
+ 2,
1548
+ {
1549
+ attachment: attachment,
1550
+ response: response,
1551
+ arrayBuffer: function arrayBuffer() {
1552
+ return response.arrayBuffer();
1553
+ },
1554
+ blob: function blob() {
1555
+ return _async_to_generator$1(function() {
1556
+ var buffer;
1557
+ return _ts_generator$1(this, function(_state) {
1558
+ switch(_state.label){
1559
+ case 0:
1560
+ return [
1561
+ 4,
1562
+ response.arrayBuffer()
1563
+ ];
1564
+ case 1:
1565
+ buffer = _state.sent();
1566
+ return [
1567
+ 2,
1568
+ new Blob([
1569
+ buffer
1570
+ ], mimeType ? {
1571
+ type: mimeType
1572
+ } : undefined)
1573
+ ];
1574
+ }
1575
+ });
1576
+ })();
1577
+ },
1578
+ text: function text() {
1579
+ return response.text();
1580
+ }
1581
+ }
1582
+ ];
1583
+ }
1584
+ });
1585
+ })();
1586
+ };
1587
+ }
1588
+
1212
1589
  /**
1213
1590
  * Https://developer.atlassian.com/cloud/trello/rest/api-group-members/#api-members-id-get.
1214
1591
  *
@@ -1584,4 +1961,4 @@ function _object_spread_props(target, source) {
1584
1961
  }));
1585
1962
  }
1586
1963
 
1587
- export { DEFAULT_TRELLO_API_RATE_LIMIT, DEFAULT_TRELLO_API_RATE_LIMIT_RESET_PERIOD, TRELLO_API_URL, TRELLO_MAX_PAGE_LIMIT, TrelloInvalidTokenError, TrelloServerError, TrelloServerFetchResponseError, TrelloTooManyRequestsError, addCommentToCard, addLabelToCard, addMemberToCard, buildTrelloPageResult, createBoard, createCard, createList, createWebhook, defaultTrelloPageItemIdReader, deleteBoard, deleteCard, deleteWebhook, getBoard, getCard, getList, getMe, getMember, getWebhook, handleTrelloErrorFetch, listBoardCards, listBoardLabels, listBoardLists, listBoardMembers, listCardActions, listCardsInList, listWebhooksForToken, logTrelloErrorToConsole, logTrelloServerErrorFunction, parseTrelloApiError, trelloActionIdReader, trelloFactory, trelloFetchPageFactory, trelloRateLimitedFetchHandler, updateBoard, updateCard, updateList, updateWebhook };
1964
+ export { DEFAULT_TRELLO_API_RATE_LIMIT, DEFAULT_TRELLO_API_RATE_LIMIT_RESET_PERIOD, TRELLO_API_URL, TRELLO_MAX_PAGE_LIMIT, TrelloInvalidTokenError, TrelloServerError, TrelloServerFetchResponseError, TrelloTooManyRequestsError, addAttachmentToCard, addCommentToCard, addLabelToCard, addMemberToCard, buildTrelloPageResult, createBoard, createCard, createList, createWebhook, defaultTrelloPageItemIdReader, deleteAttachmentFromCard, deleteBoard, deleteCard, deleteWebhook, downloadCardAttachment, getBoard, getCard, getCardAttachment, getList, getMe, getMember, getWebhook, handleTrelloErrorFetch, listBoardCards, listBoardLabels, listBoardLists, listBoardMembers, listCardActions, listCardAttachments, listCardsInList, listWebhooksForToken, logTrelloErrorToConsole, logTrelloServerErrorFunction, parseTrelloApiError, trelloActionIdReader, trelloFactory, trelloFetchPageFactory, trelloRateLimitedFetchHandler, updateBoard, updateCard, updateList, updateWebhook };