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