@dereekb/trello 13.11.14

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.
Files changed (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +6 -0
  3. package/index.cjs.default.js +1 -0
  4. package/index.cjs.js +1629 -0
  5. package/index.cjs.mjs +2 -0
  6. package/index.d.ts +1 -0
  7. package/index.esm.js +1583 -0
  8. package/nestjs/index.cjs.default.js +1 -0
  9. package/nestjs/index.cjs.js +1127 -0
  10. package/nestjs/index.cjs.mjs +2 -0
  11. package/nestjs/index.d.ts +1 -0
  12. package/nestjs/index.esm.js +1105 -0
  13. package/nestjs/package.json +28 -0
  14. package/nestjs/src/index.d.ts +1 -0
  15. package/nestjs/src/lib/index.d.ts +2 -0
  16. package/nestjs/src/lib/trello/index.d.ts +3 -0
  17. package/nestjs/src/lib/trello/trello.api.d.ts +36 -0
  18. package/nestjs/src/lib/trello/trello.config.d.ts +12 -0
  19. package/nestjs/src/lib/trello/trello.module.d.ts +21 -0
  20. package/nestjs/src/lib/webhook/index.d.ts +7 -0
  21. package/nestjs/src/lib/webhook/webhook.trello.config.d.ts +22 -0
  22. package/nestjs/src/lib/webhook/webhook.trello.controller.d.ts +12 -0
  23. package/nestjs/src/lib/webhook/webhook.trello.d.ts +50 -0
  24. package/nestjs/src/lib/webhook/webhook.trello.module.d.ts +13 -0
  25. package/nestjs/src/lib/webhook/webhook.trello.service.d.ts +24 -0
  26. package/nestjs/src/lib/webhook/webhook.trello.type.d.ts +85 -0
  27. package/nestjs/src/lib/webhook/webhook.trello.verify.d.ts +46 -0
  28. package/package.json +34 -0
  29. package/src/index.d.ts +1 -0
  30. package/src/lib/index.d.ts +7 -0
  31. package/src/lib/shared/index.d.ts +1 -0
  32. package/src/lib/shared/trello.type.d.ts +23 -0
  33. package/src/lib/trello/index.d.ts +11 -0
  34. package/src/lib/trello/trello.api.board.d.ts +103 -0
  35. package/src/lib/trello/trello.api.board.type.d.ts +75 -0
  36. package/src/lib/trello/trello.api.card.d.ts +116 -0
  37. package/src/lib/trello/trello.api.card.type.d.ts +141 -0
  38. package/src/lib/trello/trello.api.list.d.ts +46 -0
  39. package/src/lib/trello/trello.api.list.type.d.ts +40 -0
  40. package/src/lib/trello/trello.api.member.d.ts +25 -0
  41. package/src/lib/trello/trello.api.member.type.d.ts +20 -0
  42. package/src/lib/trello/trello.api.webhook.d.ts +57 -0
  43. package/src/lib/trello/trello.api.webhook.type.d.ts +41 -0
  44. package/src/lib/trello/trello.factory.d.ts +54 -0
  45. package/src/lib/trello.api.page.d.ts +92 -0
  46. package/src/lib/trello.config.d.ts +20 -0
  47. package/src/lib/trello.error.api.d.ts +77 -0
  48. package/src/lib/trello.limit.d.ts +40 -0
  49. package/src/lib/trello.type.d.ts +39 -0
package/index.cjs.js ADDED
@@ -0,0 +1,1629 @@
1
+ 'use strict';
2
+
3
+ var fetch = require('@dereekb/util/fetch');
4
+ var makeError = require('make-error');
5
+ var util = require('@dereekb/util');
6
+
7
+ function _assert_this_initialized(self) {
8
+ if (self === void 0) {
9
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
10
+ }
11
+ return self;
12
+ }
13
+ function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
14
+ try {
15
+ var info = gen[key](arg);
16
+ var value = info.value;
17
+ } catch (error) {
18
+ reject(error);
19
+ return;
20
+ }
21
+ if (info.done) {
22
+ resolve(value);
23
+ } else {
24
+ Promise.resolve(value).then(_next, _throw);
25
+ }
26
+ }
27
+ function _async_to_generator$3(fn) {
28
+ return function() {
29
+ var self = this, args = arguments;
30
+ return new Promise(function(resolve, reject) {
31
+ var gen = fn.apply(self, args);
32
+ function _next(value) {
33
+ asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
34
+ }
35
+ function _throw(err) {
36
+ asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
37
+ }
38
+ _next(undefined);
39
+ });
40
+ };
41
+ }
42
+ function _call_super(_this, derived, args) {
43
+ derived = _get_prototype_of(derived);
44
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
45
+ }
46
+ function _class_call_check(instance, Constructor) {
47
+ if (!(instance instanceof Constructor)) {
48
+ throw new TypeError("Cannot call a class as a function");
49
+ }
50
+ }
51
+ function _defineProperties(target, props) {
52
+ for(var i = 0; i < props.length; i++){
53
+ var descriptor = props[i];
54
+ descriptor.enumerable = descriptor.enumerable || false;
55
+ descriptor.configurable = true;
56
+ if ("value" in descriptor) descriptor.writable = true;
57
+ Object.defineProperty(target, descriptor.key, descriptor);
58
+ }
59
+ }
60
+ function _create_class(Constructor, protoProps, staticProps) {
61
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
62
+ return Constructor;
63
+ }
64
+ function _define_property$2(obj, key, value) {
65
+ if (key in obj) {
66
+ Object.defineProperty(obj, key, {
67
+ value: value,
68
+ enumerable: true,
69
+ configurable: true,
70
+ writable: true
71
+ });
72
+ } else {
73
+ obj[key] = value;
74
+ }
75
+ return obj;
76
+ }
77
+ function _get_prototype_of(o) {
78
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
79
+ return o.__proto__ || Object.getPrototypeOf(o);
80
+ };
81
+ return _get_prototype_of(o);
82
+ }
83
+ function _inherits(subClass, superClass) {
84
+ if (typeof superClass !== "function" && superClass !== null) {
85
+ throw new TypeError("Super expression must either be null or a function");
86
+ }
87
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
88
+ constructor: {
89
+ value: subClass,
90
+ writable: true,
91
+ configurable: true
92
+ }
93
+ });
94
+ if (superClass) _set_prototype_of(subClass, superClass);
95
+ }
96
+ function _instanceof(left, right) {
97
+ "@swc/helpers - instanceof";
98
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
99
+ return !!right[Symbol.hasInstance](left);
100
+ } else {
101
+ return left instanceof right;
102
+ }
103
+ }
104
+ function _possible_constructor_return(self, call) {
105
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
106
+ return call;
107
+ }
108
+ return _assert_this_initialized(self);
109
+ }
110
+ function _set_prototype_of(o, p) {
111
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
112
+ o.__proto__ = p;
113
+ return o;
114
+ };
115
+ return _set_prototype_of(o, p);
116
+ }
117
+ function _type_of(obj) {
118
+ "@swc/helpers - typeof";
119
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
120
+ }
121
+ function _is_native_reflect_construct() {
122
+ try {
123
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
124
+ } catch (_) {}
125
+ return (_is_native_reflect_construct = function() {
126
+ return !!result;
127
+ })();
128
+ }
129
+ function _ts_generator$3(thisArg, body) {
130
+ var f, y, t, _ = {
131
+ label: 0,
132
+ sent: function() {
133
+ if (t[0] & 1) throw t[1];
134
+ return t[1];
135
+ },
136
+ trys: [],
137
+ ops: []
138
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
139
+ return d(g, "next", {
140
+ value: verb(0)
141
+ }), d(g, "throw", {
142
+ value: verb(1)
143
+ }), d(g, "return", {
144
+ value: verb(2)
145
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
146
+ value: function() {
147
+ return this;
148
+ }
149
+ }), g;
150
+ function verb(n) {
151
+ return function(v) {
152
+ return step([
153
+ n,
154
+ v
155
+ ]);
156
+ };
157
+ }
158
+ function step(op) {
159
+ if (f) throw new TypeError("Generator is already executing.");
160
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
161
+ 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;
162
+ if (y = 0, t) op = [
163
+ op[0] & 2,
164
+ t.value
165
+ ];
166
+ switch(op[0]){
167
+ case 0:
168
+ case 1:
169
+ t = op;
170
+ break;
171
+ case 4:
172
+ _.label++;
173
+ return {
174
+ value: op[1],
175
+ done: false
176
+ };
177
+ case 5:
178
+ _.label++;
179
+ y = op[1];
180
+ op = [
181
+ 0
182
+ ];
183
+ continue;
184
+ case 7:
185
+ op = _.ops.pop();
186
+ _.trys.pop();
187
+ continue;
188
+ default:
189
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
190
+ _ = 0;
191
+ continue;
192
+ }
193
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
194
+ _.label = op[1];
195
+ break;
196
+ }
197
+ if (op[0] === 6 && _.label < t[1]) {
198
+ _.label = t[1];
199
+ t = op;
200
+ break;
201
+ }
202
+ if (t && _.label < t[2]) {
203
+ _.label = t[2];
204
+ _.ops.push(op);
205
+ break;
206
+ }
207
+ if (t[2]) _.ops.pop();
208
+ _.trys.pop();
209
+ continue;
210
+ }
211
+ op = body.call(thisArg, _);
212
+ } catch (e) {
213
+ op = [
214
+ 6,
215
+ e
216
+ ];
217
+ y = 0;
218
+ } finally{
219
+ f = t = 0;
220
+ }
221
+ if (op[0] & 5) throw op[1];
222
+ return {
223
+ value: op[0] ? op[1] : void 0,
224
+ done: true
225
+ };
226
+ }
227
+ }
228
+ /**
229
+ * Base Trello server error.
230
+ */ var TrelloServerError = /*#__PURE__*/ function(BaseError) {
231
+ _inherits(TrelloServerError, BaseError);
232
+ function TrelloServerError(message, data) {
233
+ _class_call_check(this, TrelloServerError);
234
+ var _this;
235
+ _this = _call_super(this, TrelloServerError, [
236
+ message
237
+ ]), _define_property$2(_this, "data", void 0);
238
+ _this.data = data;
239
+ return _this;
240
+ }
241
+ _create_class(TrelloServerError, [
242
+ {
243
+ key: "status",
244
+ get: function get() {
245
+ return this.data.status;
246
+ }
247
+ }
248
+ ]);
249
+ return TrelloServerError;
250
+ }(makeError.BaseError);
251
+ /**
252
+ * Trello server error that retains the originating fetch response.
253
+ */ var TrelloServerFetchResponseError = /*#__PURE__*/ function(TrelloServerError) {
254
+ _inherits(TrelloServerFetchResponseError, TrelloServerError);
255
+ function TrelloServerFetchResponseError(message, data, responseError) {
256
+ _class_call_check(this, TrelloServerFetchResponseError);
257
+ var _this;
258
+ _this = _call_super(this, TrelloServerFetchResponseError, [
259
+ message,
260
+ data
261
+ ]), _define_property$2(_this, "responseError", void 0);
262
+ _this.responseError = responseError;
263
+ return _this;
264
+ }
265
+ return TrelloServerFetchResponseError;
266
+ }(TrelloServerError);
267
+ /**
268
+ * Trello returned 401 — typically a revoked or otherwise invalid token.
269
+ *
270
+ * @see https://developer.atlassian.com/cloud/trello/guides/rest-api/authorization/
271
+ */ var TrelloInvalidTokenError = /*#__PURE__*/ function(TrelloServerFetchResponseError) {
272
+ _inherits(TrelloInvalidTokenError, TrelloServerFetchResponseError);
273
+ function TrelloInvalidTokenError() {
274
+ _class_call_check(this, TrelloInvalidTokenError);
275
+ return _call_super(this, TrelloInvalidTokenError, arguments);
276
+ }
277
+ return TrelloInvalidTokenError;
278
+ }(TrelloServerFetchResponseError);
279
+ /**
280
+ * Trello returned 429 — too many requests.
281
+ */ var TrelloTooManyRequestsError = /*#__PURE__*/ function(TrelloServerFetchResponseError) {
282
+ _inherits(TrelloTooManyRequestsError, TrelloServerFetchResponseError);
283
+ function TrelloTooManyRequestsError() {
284
+ _class_call_check(this, TrelloTooManyRequestsError);
285
+ return _call_super(this, TrelloTooManyRequestsError, arguments);
286
+ }
287
+ _create_class(TrelloTooManyRequestsError, [
288
+ {
289
+ key: "retryAfter",
290
+ get: function get() {
291
+ var headerValue = this.responseError.response.headers.get('Retry-After');
292
+ return headerValue ? Number(headerValue) : undefined;
293
+ }
294
+ }
295
+ ]);
296
+ return TrelloTooManyRequestsError;
297
+ }(TrelloServerFetchResponseError);
298
+ /**
299
+ * Creates a logTrelloServerErrorFunction that logs the error to console.
300
+ *
301
+ * @param trelloApiNamePrefix Prefix to use when logging.
302
+ * @returns A function that logs Trello server errors to the console.
303
+ * @__NO_SIDE_EFFECTS__
304
+ */ function logTrelloServerErrorFunction(trelloApiNamePrefix) {
305
+ return function(error) {
306
+ if (_instanceof(error, TrelloServerFetchResponseError)) {
307
+ console.log("".concat(trelloApiNamePrefix, "Error(").concat(error.responseError.response.status, "): "), {
308
+ error: error,
309
+ errorData: error.data
310
+ });
311
+ } else if (_instanceof(error, TrelloServerError)) {
312
+ console.log("".concat(trelloApiNamePrefix, "Error(status:").concat(error.status, "): "), {
313
+ error: error
314
+ });
315
+ } else {
316
+ console.log("".concat(trelloApiNamePrefix, "Error(name:").concat(error.name, "): "), {
317
+ error: error
318
+ });
319
+ }
320
+ };
321
+ }
322
+ var logTrelloErrorToConsole = logTrelloServerErrorFunction('Trello');
323
+ /**
324
+ * Parses a FetchResponseError into a typed Trello API error.
325
+ *
326
+ * @param responseError The fetch response error to parse.
327
+ * @returns A typed Trello error, or undefined if the response could not be parsed.
328
+ */ function parseTrelloApiError(responseError) {
329
+ return _async_to_generator$3(function() {
330
+ var response, bodyText, bodyJson, data, message, result;
331
+ return _ts_generator$3(this, function(_state) {
332
+ switch(_state.label){
333
+ case 0:
334
+ response = responseError.response;
335
+ return [
336
+ 4,
337
+ response.clone().text().catch(function() {
338
+ return '';
339
+ })
340
+ ];
341
+ case 1:
342
+ bodyText = _state.sent();
343
+ try {
344
+ bodyJson = bodyText ? JSON.parse(bodyText) : undefined;
345
+ } catch (unused) {
346
+ bodyJson = undefined;
347
+ }
348
+ data = {
349
+ status: response.status,
350
+ bodyText: bodyText,
351
+ bodyJson: bodyJson
352
+ };
353
+ message = bodyText || "Trello request failed with status ".concat(response.status);
354
+ switch(response.status){
355
+ case 401:
356
+ result = new TrelloInvalidTokenError(message, data, responseError);
357
+ break;
358
+ case 429:
359
+ result = new TrelloTooManyRequestsError(message, data, responseError);
360
+ break;
361
+ default:
362
+ result = new TrelloServerFetchResponseError(message, data, responseError);
363
+ break;
364
+ }
365
+ return [
366
+ 2,
367
+ result
368
+ ];
369
+ }
370
+ });
371
+ })();
372
+ }
373
+ /**
374
+ * Wraps a ConfiguredFetch to translate FetchResponseError into typed Trello errors.
375
+ *
376
+ * @param fetch The fetch to wrap.
377
+ * @param logError Optional logger.
378
+ * @returns A ConfiguredFetch that throws typed Trello errors for known error responses.
379
+ * @__NO_SIDE_EFFECTS__
380
+ */ function handleTrelloErrorFetch(fetch$1) {
381
+ var logError = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : logTrelloErrorToConsole;
382
+ return function(x, y) {
383
+ return _async_to_generator$3(function() {
384
+ var e, error;
385
+ return _ts_generator$3(this, function(_state) {
386
+ switch(_state.label){
387
+ case 0:
388
+ _state.trys.push([
389
+ 0,
390
+ 2,
391
+ ,
392
+ 5
393
+ ]);
394
+ return [
395
+ 4,
396
+ fetch$1(x, y)
397
+ ];
398
+ case 1:
399
+ return [
400
+ 2,
401
+ _state.sent()
402
+ ];
403
+ case 2:
404
+ e = _state.sent();
405
+ if (!_instanceof(e, fetch.FetchResponseError)) return [
406
+ 3,
407
+ 4
408
+ ];
409
+ return [
410
+ 4,
411
+ parseTrelloApiError(e)
412
+ ];
413
+ case 3:
414
+ error = _state.sent();
415
+ if (error) {
416
+ logError(error);
417
+ throw error;
418
+ }
419
+ _state.label = 4;
420
+ case 4:
421
+ throw e;
422
+ case 5:
423
+ return [
424
+ 2
425
+ ];
426
+ }
427
+ });
428
+ })();
429
+ };
430
+ }
431
+
432
+ /**
433
+ * Documented per-token rate limit: 100 requests per 10 seconds.
434
+ *
435
+ * @see https://developer.atlassian.com/cloud/trello/guides/rest-api/rate-limits/
436
+ */ var DEFAULT_TRELLO_API_RATE_LIMIT = 100;
437
+ /**
438
+ * Reset period for the per-token rate limit (10 seconds).
439
+ */ var DEFAULT_TRELLO_API_RATE_LIMIT_RESET_PERIOD = util.MS_IN_SECOND * 10;
440
+ /**
441
+ * Creates a rate-limited fetch handler configured for the Trello API.
442
+ *
443
+ * Backs off after 429 responses and respects the documented per-token rate limit.
444
+ *
445
+ * @param config Optional configuration for rate limiting behavior.
446
+ * @returns A configured rate-limited fetch handler.
447
+ * @__NO_SIDE_EFFECTS__
448
+ */ function trelloRateLimitedFetchHandler(config) {
449
+ var _ref, _ref1;
450
+ var limit = (_ref = config === null || config === void 0 ? void 0 : config.maxRateLimit) !== null && _ref !== void 0 ? _ref : DEFAULT_TRELLO_API_RATE_LIMIT;
451
+ var resetPeriod = (_ref1 = config === null || config === void 0 ? void 0 : config.resetPeriod) !== null && _ref1 !== void 0 ? _ref1 : DEFAULT_TRELLO_API_RATE_LIMIT_RESET_PERIOD;
452
+ var rateLimiter = util.resetPeriodPromiseRateLimiter({
453
+ limit: limit,
454
+ startLimitAt: Math.max(2, Math.ceil(limit / 10)),
455
+ cooldownRate: 1,
456
+ exponentRate: 1.1,
457
+ maxWaitTime: util.MS_IN_SECOND * 10,
458
+ resetPeriod: resetPeriod
459
+ });
460
+ return fetch.rateLimitedFetchHandler({
461
+ rateLimiter: rateLimiter,
462
+ updateWithResponse: function updateWithResponse(response) {
463
+ // Trello does not document rate limit headers, but it does return 429 when exceeded.
464
+ // Schedule a retry after the rate limiter cooldown when a 429 is observed.
465
+ if (response.status === 429) {
466
+ return true;
467
+ }
468
+ return false;
469
+ }
470
+ });
471
+ }
472
+
473
+ /**
474
+ * Trello API URL (versioned).
475
+ */ var TRELLO_API_URL = 'https://api.trello.com/1';
476
+
477
+ /**
478
+ * Builds a Trello API factory.
479
+ *
480
+ * Auth uses Trello's `Authorization: OAuth oauth_consumer_key=..., oauth_token=...` header form so credentials never appear in URLs or logs.
481
+ *
482
+ * @param factoryConfig Factory-level configuration shared across created Trello instances.
483
+ * @returns A factory function that creates a configured Trello API instance.
484
+ * @__NO_SIDE_EFFECTS__
485
+ */ function trelloFactory() {
486
+ var factoryConfig = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
487
+ var logTrelloServerErrorFunction = factoryConfig.logTrelloServerErrorFunction;
488
+ var fetchHandler = trelloRateLimitedFetchHandler(factoryConfig.rateLimiterConfig);
489
+ return function(config) {
490
+ var _config_apiUrl;
491
+ var authHeader = 'OAuth oauth_consumer_key="'.concat(config.apiKey, '", oauth_token="').concat(config.apiToken, '"');
492
+ var baseFetch = fetch.fetchApiFetchService.makeFetch({
493
+ baseUrl: (_config_apiUrl = config.apiUrl) !== null && _config_apiUrl !== void 0 ? _config_apiUrl : TRELLO_API_URL,
494
+ baseRequest: function baseRequest() {
495
+ return {
496
+ headers: {
497
+ 'Content-Type': 'application/json',
498
+ Authorization: authHeader
499
+ }
500
+ };
501
+ },
502
+ fetchHandler: fetchHandler,
503
+ timeout: 20 * 1000,
504
+ requireOkResponse: true,
505
+ useTimeout: true
506
+ });
507
+ var fetch$1 = handleTrelloErrorFetch(baseFetch, logTrelloServerErrorFunction);
508
+ var fetchJsonInst = fetch.fetchJsonFunction(fetch$1, {
509
+ handleFetchJsonParseErrorFunction: fetch.returnNullHandleFetchJsonParseErrorFunction
510
+ });
511
+ var trelloContext = {
512
+ fetch: fetch$1,
513
+ fetchJson: fetchJsonInst,
514
+ config: config,
515
+ trelloRateLimiter: fetchHandler._rateLimiter
516
+ };
517
+ var trello = {
518
+ trelloContext: trelloContext
519
+ };
520
+ return trello;
521
+ };
522
+ }
523
+
524
+ function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
525
+ try {
526
+ var info = gen[key](arg);
527
+ var value = info.value;
528
+ } catch (error) {
529
+ reject(error);
530
+ return;
531
+ }
532
+ if (info.done) {
533
+ resolve(value);
534
+ } else {
535
+ Promise.resolve(value).then(_next, _throw);
536
+ }
537
+ }
538
+ function _async_to_generator$2(fn) {
539
+ return function() {
540
+ var self = this, args = arguments;
541
+ return new Promise(function(resolve, reject) {
542
+ var gen = fn.apply(self, args);
543
+ function _next(value) {
544
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
545
+ }
546
+ function _throw(err) {
547
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
548
+ }
549
+ _next(undefined);
550
+ });
551
+ };
552
+ }
553
+ function _object_without_properties$3(source, excluded) {
554
+ if (source == null) return {};
555
+ var target = {}, sourceKeys, key, i;
556
+ if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
557
+ sourceKeys = Reflect.ownKeys(Object(source));
558
+ for(i = 0; i < sourceKeys.length; i++){
559
+ key = sourceKeys[i];
560
+ if (excluded.indexOf(key) >= 0) continue;
561
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
562
+ target[key] = source[key];
563
+ }
564
+ return target;
565
+ }
566
+ target = _object_without_properties_loose$3(source, excluded);
567
+ if (Object.getOwnPropertySymbols) {
568
+ sourceKeys = Object.getOwnPropertySymbols(source);
569
+ for(i = 0; i < sourceKeys.length; i++){
570
+ key = sourceKeys[i];
571
+ if (excluded.indexOf(key) >= 0) continue;
572
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
573
+ target[key] = source[key];
574
+ }
575
+ }
576
+ return target;
577
+ }
578
+ function _object_without_properties_loose$3(source, excluded) {
579
+ if (source == null) return {};
580
+ var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
581
+ for(i = 0; i < sourceKeys.length; i++){
582
+ key = sourceKeys[i];
583
+ if (excluded.indexOf(key) >= 0) continue;
584
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
585
+ target[key] = source[key];
586
+ }
587
+ return target;
588
+ }
589
+ function _ts_generator$2(thisArg, body) {
590
+ var f, y, t, _ = {
591
+ label: 0,
592
+ sent: function() {
593
+ if (t[0] & 1) throw t[1];
594
+ return t[1];
595
+ },
596
+ trys: [],
597
+ ops: []
598
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
599
+ return d(g, "next", {
600
+ value: verb(0)
601
+ }), d(g, "throw", {
602
+ value: verb(1)
603
+ }), d(g, "return", {
604
+ value: verb(2)
605
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
606
+ value: function() {
607
+ return this;
608
+ }
609
+ }), g;
610
+ function verb(n) {
611
+ return function(v) {
612
+ return step([
613
+ n,
614
+ v
615
+ ]);
616
+ };
617
+ }
618
+ function step(op) {
619
+ if (f) throw new TypeError("Generator is already executing.");
620
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
621
+ 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;
622
+ if (y = 0, t) op = [
623
+ op[0] & 2,
624
+ t.value
625
+ ];
626
+ switch(op[0]){
627
+ case 0:
628
+ case 1:
629
+ t = op;
630
+ break;
631
+ case 4:
632
+ _.label++;
633
+ return {
634
+ value: op[1],
635
+ done: false
636
+ };
637
+ case 5:
638
+ _.label++;
639
+ y = op[1];
640
+ op = [
641
+ 0
642
+ ];
643
+ continue;
644
+ case 7:
645
+ op = _.ops.pop();
646
+ _.trys.pop();
647
+ continue;
648
+ default:
649
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
650
+ _ = 0;
651
+ continue;
652
+ }
653
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
654
+ _.label = op[1];
655
+ break;
656
+ }
657
+ if (op[0] === 6 && _.label < t[1]) {
658
+ _.label = t[1];
659
+ t = op;
660
+ break;
661
+ }
662
+ if (t && _.label < t[2]) {
663
+ _.label = t[2];
664
+ _.ops.push(op);
665
+ break;
666
+ }
667
+ if (t[2]) _.ops.pop();
668
+ _.trys.pop();
669
+ continue;
670
+ }
671
+ op = body.call(thisArg, _);
672
+ } catch (e) {
673
+ op = [
674
+ 6,
675
+ e
676
+ ];
677
+ y = 0;
678
+ } finally{
679
+ f = t = 0;
680
+ }
681
+ if (op[0] & 5) throw op[1];
682
+ return {
683
+ value: op[0] ? op[1] : void 0,
684
+ done: true
685
+ };
686
+ }
687
+ }
688
+ /**
689
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-get
690
+ *
691
+ * @param context The Trello API context.
692
+ * @returns A function that retrieves a board by id.
693
+ */ function getBoard(context) {
694
+ return function(input) {
695
+ return context.fetchJson("/boards/".concat(input.boardId), 'GET');
696
+ };
697
+ }
698
+ /**
699
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-post
700
+ *
701
+ * @param context The Trello API context.
702
+ * @returns A function that creates a new board.
703
+ */ function createBoard(context) {
704
+ return function(input) {
705
+ var queryString = fetch.makeUrlSearchParams(input);
706
+ return context.fetchJson("/boards?".concat(queryString), 'POST');
707
+ };
708
+ }
709
+ /**
710
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-put
711
+ *
712
+ * @param context The Trello API context.
713
+ * @returns A function that updates an existing board.
714
+ */ function updateBoard(context) {
715
+ return function(input) {
716
+ var boardId = input.boardId, body = _object_without_properties$3(input, [
717
+ "boardId"
718
+ ]);
719
+ return context.fetchJson("/boards/".concat(boardId), 'PUT', body);
720
+ };
721
+ }
722
+ /**
723
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-delete
724
+ *
725
+ * @param context The Trello API context.
726
+ * @returns A function that deletes a board.
727
+ */ function deleteBoard(context) {
728
+ return function(input) {
729
+ return _async_to_generator$2(function() {
730
+ return _ts_generator$2(this, function(_state) {
731
+ switch(_state.label){
732
+ case 0:
733
+ return [
734
+ 4,
735
+ context.fetchJson("/boards/".concat(input.boardId), 'DELETE')
736
+ ];
737
+ case 1:
738
+ _state.sent();
739
+ return [
740
+ 2
741
+ ];
742
+ }
743
+ });
744
+ })();
745
+ };
746
+ }
747
+ /**
748
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-lists-get
749
+ *
750
+ * @param context The Trello API context.
751
+ * @returns A function that lists all lists on a board.
752
+ */ function listBoardLists(context) {
753
+ return function(input) {
754
+ var boardId = input.boardId, query = _object_without_properties$3(input, [
755
+ "boardId"
756
+ ]);
757
+ var queryString = fetch.makeUrlSearchParams(query);
758
+ return context.fetchJson("/boards/".concat(boardId, "/lists?").concat(queryString), 'GET');
759
+ };
760
+ }
761
+ /**
762
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-cards-get
763
+ *
764
+ * @param context The Trello API context.
765
+ * @returns A function that lists all cards on a board.
766
+ */ function listBoardCards(context) {
767
+ return function(input) {
768
+ var boardId = input.boardId, query = _object_without_properties$3(input, [
769
+ "boardId"
770
+ ]);
771
+ var queryString = fetch.makeUrlSearchParams(query);
772
+ return context.fetchJson("/boards/".concat(boardId, "/cards?").concat(queryString), 'GET');
773
+ };
774
+ }
775
+ /**
776
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-labels-get
777
+ *
778
+ * @param context The Trello API context.
779
+ * @returns A function that lists every label defined on a board.
780
+ */ function listBoardLabels(context) {
781
+ return function(input) {
782
+ var boardId = input.boardId, query = _object_without_properties$3(input, [
783
+ "boardId"
784
+ ]);
785
+ var queryString = fetch.makeUrlSearchParams(query);
786
+ return context.fetchJson("/boards/".concat(boardId, "/labels?").concat(queryString), 'GET');
787
+ };
788
+ }
789
+ /**
790
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-members-get
791
+ *
792
+ * @param context The Trello API context.
793
+ * @returns A function that lists all members of a board.
794
+ */ function listBoardMembers(context) {
795
+ return function(input) {
796
+ return context.fetchJson("/boards/".concat(input.boardId, "/members"), 'GET');
797
+ };
798
+ }
799
+
800
+ function _object_without_properties$2(source, excluded) {
801
+ if (source == null) return {};
802
+ var target = {}, sourceKeys, key, i;
803
+ if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
804
+ sourceKeys = Reflect.ownKeys(Object(source));
805
+ for(i = 0; i < sourceKeys.length; i++){
806
+ key = sourceKeys[i];
807
+ if (excluded.indexOf(key) >= 0) continue;
808
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
809
+ target[key] = source[key];
810
+ }
811
+ return target;
812
+ }
813
+ target = _object_without_properties_loose$2(source, excluded);
814
+ if (Object.getOwnPropertySymbols) {
815
+ sourceKeys = Object.getOwnPropertySymbols(source);
816
+ for(i = 0; i < sourceKeys.length; i++){
817
+ key = sourceKeys[i];
818
+ if (excluded.indexOf(key) >= 0) continue;
819
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
820
+ target[key] = source[key];
821
+ }
822
+ }
823
+ return target;
824
+ }
825
+ function _object_without_properties_loose$2(source, excluded) {
826
+ if (source == null) return {};
827
+ var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
828
+ for(i = 0; i < sourceKeys.length; i++){
829
+ key = sourceKeys[i];
830
+ if (excluded.indexOf(key) >= 0) continue;
831
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
832
+ target[key] = source[key];
833
+ }
834
+ return target;
835
+ }
836
+ /**
837
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-lists/#api-lists-id-get
838
+ *
839
+ * @param context The Trello API context.
840
+ * @returns A function that retrieves a list by id.
841
+ */ function getList(context) {
842
+ return function(input) {
843
+ return context.fetchJson("/lists/".concat(input.listId), 'GET');
844
+ };
845
+ }
846
+ /**
847
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-lists/#api-lists-post
848
+ *
849
+ * @param context The Trello API context.
850
+ * @returns A function that creates a new list on a board.
851
+ */ function createList(context) {
852
+ return function(input) {
853
+ var queryString = fetch.makeUrlSearchParams(input);
854
+ return context.fetchJson("/lists?".concat(queryString), 'POST');
855
+ };
856
+ }
857
+ /**
858
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-lists/#api-lists-id-put
859
+ *
860
+ * @param context The Trello API context.
861
+ * @returns A function that updates an existing list.
862
+ */ function updateList(context) {
863
+ return function(input) {
864
+ var listId = input.listId, body = _object_without_properties$2(input, [
865
+ "listId"
866
+ ]);
867
+ return context.fetchJson("/lists/".concat(listId), 'PUT', body);
868
+ };
869
+ }
870
+ /**
871
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-lists/#api-lists-id-cards-get
872
+ *
873
+ * @param context The Trello API context.
874
+ * @returns A function that lists all cards on a list.
875
+ */ function listCardsInList(context) {
876
+ return function(input) {
877
+ var listId = input.listId, query = _object_without_properties$2(input, [
878
+ "listId"
879
+ ]);
880
+ var queryString = fetch.makeUrlSearchParams(query);
881
+ return context.fetchJson("/lists/".concat(listId, "/cards?").concat(queryString), 'GET');
882
+ };
883
+ }
884
+
885
+ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
886
+ try {
887
+ var info = gen[key](arg);
888
+ var value = info.value;
889
+ } catch (error) {
890
+ reject(error);
891
+ return;
892
+ }
893
+ if (info.done) {
894
+ resolve(value);
895
+ } else {
896
+ Promise.resolve(value).then(_next, _throw);
897
+ }
898
+ }
899
+ function _async_to_generator$1(fn) {
900
+ return function() {
901
+ var self = this, args = arguments;
902
+ return new Promise(function(resolve, reject) {
903
+ var gen = fn.apply(self, args);
904
+ function _next(value) {
905
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
906
+ }
907
+ function _throw(err) {
908
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
909
+ }
910
+ _next(undefined);
911
+ });
912
+ };
913
+ }
914
+ function _define_property$1(obj, key, value) {
915
+ if (key in obj) {
916
+ Object.defineProperty(obj, key, {
917
+ value: value,
918
+ enumerable: true,
919
+ configurable: true,
920
+ writable: true
921
+ });
922
+ } else {
923
+ obj[key] = value;
924
+ }
925
+ return obj;
926
+ }
927
+ function _object_spread$1(target) {
928
+ for(var i = 1; i < arguments.length; i++){
929
+ var source = arguments[i] != null ? arguments[i] : {};
930
+ var ownKeys = Object.keys(source);
931
+ if (typeof Object.getOwnPropertySymbols === "function") {
932
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
933
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
934
+ }));
935
+ }
936
+ ownKeys.forEach(function(key) {
937
+ _define_property$1(target, key, source[key]);
938
+ });
939
+ }
940
+ return target;
941
+ }
942
+ function _object_without_properties$1(source, excluded) {
943
+ if (source == null) return {};
944
+ var target = {}, sourceKeys, key, i;
945
+ if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
946
+ sourceKeys = Reflect.ownKeys(Object(source));
947
+ for(i = 0; i < sourceKeys.length; i++){
948
+ key = sourceKeys[i];
949
+ if (excluded.indexOf(key) >= 0) continue;
950
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
951
+ target[key] = source[key];
952
+ }
953
+ return target;
954
+ }
955
+ target = _object_without_properties_loose$1(source, excluded);
956
+ if (Object.getOwnPropertySymbols) {
957
+ sourceKeys = Object.getOwnPropertySymbols(source);
958
+ for(i = 0; i < sourceKeys.length; i++){
959
+ key = sourceKeys[i];
960
+ if (excluded.indexOf(key) >= 0) continue;
961
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
962
+ target[key] = source[key];
963
+ }
964
+ }
965
+ return target;
966
+ }
967
+ function _object_without_properties_loose$1(source, excluded) {
968
+ if (source == null) return {};
969
+ var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
970
+ for(i = 0; i < sourceKeys.length; i++){
971
+ key = sourceKeys[i];
972
+ if (excluded.indexOf(key) >= 0) continue;
973
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
974
+ target[key] = source[key];
975
+ }
976
+ return target;
977
+ }
978
+ function _ts_generator$1(thisArg, body) {
979
+ var f, y, t, _ = {
980
+ label: 0,
981
+ sent: function() {
982
+ if (t[0] & 1) throw t[1];
983
+ return t[1];
984
+ },
985
+ trys: [],
986
+ ops: []
987
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
988
+ return d(g, "next", {
989
+ value: verb(0)
990
+ }), d(g, "throw", {
991
+ value: verb(1)
992
+ }), d(g, "return", {
993
+ value: verb(2)
994
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
995
+ value: function() {
996
+ return this;
997
+ }
998
+ }), g;
999
+ function verb(n) {
1000
+ return function(v) {
1001
+ return step([
1002
+ n,
1003
+ v
1004
+ ]);
1005
+ };
1006
+ }
1007
+ function step(op) {
1008
+ if (f) throw new TypeError("Generator is already executing.");
1009
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
1010
+ 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;
1011
+ if (y = 0, t) op = [
1012
+ op[0] & 2,
1013
+ t.value
1014
+ ];
1015
+ switch(op[0]){
1016
+ case 0:
1017
+ case 1:
1018
+ t = op;
1019
+ break;
1020
+ case 4:
1021
+ _.label++;
1022
+ return {
1023
+ value: op[1],
1024
+ done: false
1025
+ };
1026
+ case 5:
1027
+ _.label++;
1028
+ y = op[1];
1029
+ op = [
1030
+ 0
1031
+ ];
1032
+ continue;
1033
+ case 7:
1034
+ op = _.ops.pop();
1035
+ _.trys.pop();
1036
+ continue;
1037
+ default:
1038
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
1039
+ _ = 0;
1040
+ continue;
1041
+ }
1042
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
1043
+ _.label = op[1];
1044
+ break;
1045
+ }
1046
+ if (op[0] === 6 && _.label < t[1]) {
1047
+ _.label = t[1];
1048
+ t = op;
1049
+ break;
1050
+ }
1051
+ if (t && _.label < t[2]) {
1052
+ _.label = t[2];
1053
+ _.ops.push(op);
1054
+ break;
1055
+ }
1056
+ if (t[2]) _.ops.pop();
1057
+ _.trys.pop();
1058
+ continue;
1059
+ }
1060
+ op = body.call(thisArg, _);
1061
+ } catch (e) {
1062
+ op = [
1063
+ 6,
1064
+ e
1065
+ ];
1066
+ y = 0;
1067
+ } finally{
1068
+ f = t = 0;
1069
+ }
1070
+ if (op[0] & 5) throw op[1];
1071
+ return {
1072
+ value: op[0] ? op[1] : void 0,
1073
+ done: true
1074
+ };
1075
+ }
1076
+ }
1077
+ /**
1078
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-get
1079
+ *
1080
+ * @param context The Trello API context.
1081
+ * @returns A function that retrieves a card by id.
1082
+ */ function getCard(context) {
1083
+ return function(input) {
1084
+ return context.fetchJson("/cards/".concat(input.cardId), 'GET');
1085
+ };
1086
+ }
1087
+ /**
1088
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-post
1089
+ *
1090
+ * @param context The Trello API context.
1091
+ * @returns A function that creates a card on a list.
1092
+ */ function createCard(context) {
1093
+ return function(input) {
1094
+ var idLabels = input.idLabels, idMembers = input.idMembers, rest = _object_without_properties$1(input, [
1095
+ "idLabels",
1096
+ "idMembers"
1097
+ ]);
1098
+ var query = _object_spread$1({}, rest);
1099
+ if (idLabels) {
1100
+ query.idLabels = idLabels.join(',');
1101
+ }
1102
+ if (idMembers) {
1103
+ query.idMembers = idMembers.join(',');
1104
+ }
1105
+ var queryString = fetch.makeUrlSearchParams(query);
1106
+ return context.fetchJson("/cards?".concat(queryString), 'POST');
1107
+ };
1108
+ }
1109
+ /**
1110
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-put
1111
+ *
1112
+ * @param context The Trello API context.
1113
+ * @returns A function that updates an existing card.
1114
+ */ function updateCard(context) {
1115
+ return function(input) {
1116
+ var cardId = input.cardId, idLabels = input.idLabels, idMembers = input.idMembers, rest = _object_without_properties$1(input, [
1117
+ "cardId",
1118
+ "idLabels",
1119
+ "idMembers"
1120
+ ]);
1121
+ var body = _object_spread$1({}, rest);
1122
+ if (idLabels) {
1123
+ body.idLabels = idLabels.join(',');
1124
+ }
1125
+ if (idMembers) {
1126
+ body.idMembers = idMembers.join(',');
1127
+ }
1128
+ return context.fetchJson("/cards/".concat(cardId), 'PUT', body);
1129
+ };
1130
+ }
1131
+ /**
1132
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-delete
1133
+ *
1134
+ * @param context The Trello API context.
1135
+ * @returns A function that deletes a card.
1136
+ */ function deleteCard(context) {
1137
+ return function(input) {
1138
+ return _async_to_generator$1(function() {
1139
+ return _ts_generator$1(this, function(_state) {
1140
+ switch(_state.label){
1141
+ case 0:
1142
+ return [
1143
+ 4,
1144
+ context.fetchJson("/cards/".concat(input.cardId), 'DELETE')
1145
+ ];
1146
+ case 1:
1147
+ _state.sent();
1148
+ return [
1149
+ 2
1150
+ ];
1151
+ }
1152
+ });
1153
+ })();
1154
+ };
1155
+ }
1156
+ /**
1157
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-actions-get
1158
+ *
1159
+ * Comments are returned as actions with `type === 'commentCard'`; pass `filter: 'commentCard'` and the generic
1160
+ * type parameter `TrelloCommentCardActionData` to get a comment-typed result.
1161
+ *
1162
+ * @param context The Trello API context.
1163
+ * @returns A function that lists actions on a card.
1164
+ */ function listCardActions(context) {
1165
+ return function(input) {
1166
+ var cardId = input.cardId, query = _object_without_properties$1(input, [
1167
+ "cardId"
1168
+ ]);
1169
+ var queryString = fetch.makeUrlSearchParams(query);
1170
+ return context.fetchJson("/cards/".concat(cardId, "/actions?").concat(queryString), 'GET');
1171
+ };
1172
+ }
1173
+ /**
1174
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-actions-comments-post
1175
+ *
1176
+ * @param context The Trello API context.
1177
+ * @returns A function that adds a comment to a card.
1178
+ */ function addCommentToCard(context) {
1179
+ return function(input) {
1180
+ var queryString = fetch.makeUrlSearchParams({
1181
+ text: input.text
1182
+ });
1183
+ return context.fetchJson("/cards/".concat(input.cardId, "/actions/comments?").concat(queryString), 'POST');
1184
+ };
1185
+ }
1186
+ /**
1187
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-idmembers-post
1188
+ *
1189
+ * @param context The Trello API context.
1190
+ * @returns A function that adds a member to a card.
1191
+ */ function addMemberToCard(context) {
1192
+ return function(input) {
1193
+ var queryString = fetch.makeUrlSearchParams({
1194
+ value: input.memberId
1195
+ });
1196
+ return context.fetchJson("/cards/".concat(input.cardId, "/idMembers?").concat(queryString), 'POST');
1197
+ };
1198
+ }
1199
+ /**
1200
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-idlabels-post
1201
+ *
1202
+ * @param context The Trello API context.
1203
+ * @returns A function that adds an existing label to a card.
1204
+ */ function addLabelToCard(context) {
1205
+ return function(input) {
1206
+ var queryString = fetch.makeUrlSearchParams({
1207
+ value: input.labelId
1208
+ });
1209
+ return context.fetchJson("/cards/".concat(input.cardId, "/idLabels?").concat(queryString), 'POST');
1210
+ };
1211
+ }
1212
+
1213
+ /**
1214
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-members/#api-members-id-get
1215
+ *
1216
+ * @param context The Trello API context.
1217
+ * @returns A function that retrieves a member by id (or `me`).
1218
+ */ function getMember(context) {
1219
+ return function(input) {
1220
+ return context.fetchJson("/members/".concat(input.memberId), 'GET');
1221
+ };
1222
+ }
1223
+ /**
1224
+ * Convenience wrapper around `getMember({ memberId: 'me' })`.
1225
+ *
1226
+ * @param context The Trello API context.
1227
+ * @returns A function that retrieves the authenticated user.
1228
+ */ function getMe(context) {
1229
+ return function() {
1230
+ return context.fetchJson("/members/me", 'GET');
1231
+ };
1232
+ }
1233
+
1234
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
1235
+ try {
1236
+ var info = gen[key](arg);
1237
+ var value = info.value;
1238
+ } catch (error) {
1239
+ reject(error);
1240
+ return;
1241
+ }
1242
+ if (info.done) {
1243
+ resolve(value);
1244
+ } else {
1245
+ Promise.resolve(value).then(_next, _throw);
1246
+ }
1247
+ }
1248
+ function _async_to_generator(fn) {
1249
+ return function() {
1250
+ var self = this, args = arguments;
1251
+ return new Promise(function(resolve, reject) {
1252
+ var gen = fn.apply(self, args);
1253
+ function _next(value) {
1254
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
1255
+ }
1256
+ function _throw(err) {
1257
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
1258
+ }
1259
+ _next(undefined);
1260
+ });
1261
+ };
1262
+ }
1263
+ function _object_without_properties(source, excluded) {
1264
+ if (source == null) return {};
1265
+ var target = {}, sourceKeys, key, i;
1266
+ if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
1267
+ sourceKeys = Reflect.ownKeys(Object(source));
1268
+ for(i = 0; i < sourceKeys.length; i++){
1269
+ key = sourceKeys[i];
1270
+ if (excluded.indexOf(key) >= 0) continue;
1271
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
1272
+ target[key] = source[key];
1273
+ }
1274
+ return target;
1275
+ }
1276
+ target = _object_without_properties_loose(source, excluded);
1277
+ if (Object.getOwnPropertySymbols) {
1278
+ sourceKeys = Object.getOwnPropertySymbols(source);
1279
+ for(i = 0; i < sourceKeys.length; i++){
1280
+ key = sourceKeys[i];
1281
+ if (excluded.indexOf(key) >= 0) continue;
1282
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
1283
+ target[key] = source[key];
1284
+ }
1285
+ }
1286
+ return target;
1287
+ }
1288
+ function _object_without_properties_loose(source, excluded) {
1289
+ if (source == null) return {};
1290
+ var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
1291
+ for(i = 0; i < sourceKeys.length; i++){
1292
+ key = sourceKeys[i];
1293
+ if (excluded.indexOf(key) >= 0) continue;
1294
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
1295
+ target[key] = source[key];
1296
+ }
1297
+ return target;
1298
+ }
1299
+ function _ts_generator(thisArg, body) {
1300
+ var f, y, t, _ = {
1301
+ label: 0,
1302
+ sent: function() {
1303
+ if (t[0] & 1) throw t[1];
1304
+ return t[1];
1305
+ },
1306
+ trys: [],
1307
+ ops: []
1308
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
1309
+ return d(g, "next", {
1310
+ value: verb(0)
1311
+ }), d(g, "throw", {
1312
+ value: verb(1)
1313
+ }), d(g, "return", {
1314
+ value: verb(2)
1315
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
1316
+ value: function() {
1317
+ return this;
1318
+ }
1319
+ }), g;
1320
+ function verb(n) {
1321
+ return function(v) {
1322
+ return step([
1323
+ n,
1324
+ v
1325
+ ]);
1326
+ };
1327
+ }
1328
+ function step(op) {
1329
+ if (f) throw new TypeError("Generator is already executing.");
1330
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
1331
+ 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;
1332
+ if (y = 0, t) op = [
1333
+ op[0] & 2,
1334
+ t.value
1335
+ ];
1336
+ switch(op[0]){
1337
+ case 0:
1338
+ case 1:
1339
+ t = op;
1340
+ break;
1341
+ case 4:
1342
+ _.label++;
1343
+ return {
1344
+ value: op[1],
1345
+ done: false
1346
+ };
1347
+ case 5:
1348
+ _.label++;
1349
+ y = op[1];
1350
+ op = [
1351
+ 0
1352
+ ];
1353
+ continue;
1354
+ case 7:
1355
+ op = _.ops.pop();
1356
+ _.trys.pop();
1357
+ continue;
1358
+ default:
1359
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
1360
+ _ = 0;
1361
+ continue;
1362
+ }
1363
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
1364
+ _.label = op[1];
1365
+ break;
1366
+ }
1367
+ if (op[0] === 6 && _.label < t[1]) {
1368
+ _.label = t[1];
1369
+ t = op;
1370
+ break;
1371
+ }
1372
+ if (t && _.label < t[2]) {
1373
+ _.label = t[2];
1374
+ _.ops.push(op);
1375
+ break;
1376
+ }
1377
+ if (t[2]) _.ops.pop();
1378
+ _.trys.pop();
1379
+ continue;
1380
+ }
1381
+ op = body.call(thisArg, _);
1382
+ } catch (e) {
1383
+ op = [
1384
+ 6,
1385
+ e
1386
+ ];
1387
+ y = 0;
1388
+ } finally{
1389
+ f = t = 0;
1390
+ }
1391
+ if (op[0] & 5) throw op[1];
1392
+ return {
1393
+ value: op[0] ? op[1] : void 0,
1394
+ done: true
1395
+ };
1396
+ }
1397
+ }
1398
+ /**
1399
+ * Trello validates the callback URL with a HEAD request before creation. The endpoint MUST return 200.
1400
+ *
1401
+ * https://developer.atlassian.com/cloud/trello/guides/rest-api/webhooks/#creating-a-webhook
1402
+ *
1403
+ * @param context The Trello API context.
1404
+ * @returns A function that registers a new webhook.
1405
+ */ function createWebhook(context) {
1406
+ return function(input) {
1407
+ var queryString = fetch.makeUrlSearchParams(input);
1408
+ return context.fetchJson("/webhooks?".concat(queryString), 'POST');
1409
+ };
1410
+ }
1411
+ /**
1412
+ * https://developer.atlassian.com/cloud/trello/guides/rest-api/webhooks/#retrieving-a-webhook
1413
+ *
1414
+ * @param context The Trello API context.
1415
+ * @returns A function that retrieves a webhook by id.
1416
+ */ function getWebhook(context) {
1417
+ return function(input) {
1418
+ return context.fetchJson("/webhooks/".concat(input.webhookId), 'GET');
1419
+ };
1420
+ }
1421
+ /**
1422
+ * https://developer.atlassian.com/cloud/trello/guides/rest-api/webhooks/#updating-a-webhook
1423
+ *
1424
+ * @param context The Trello API context.
1425
+ * @returns A function that updates an existing webhook.
1426
+ */ function updateWebhook(context) {
1427
+ return function(input) {
1428
+ var webhookId = input.webhookId, body = _object_without_properties(input, [
1429
+ "webhookId"
1430
+ ]);
1431
+ return context.fetchJson("/webhooks/".concat(webhookId), 'PUT', body);
1432
+ };
1433
+ }
1434
+ /**
1435
+ * https://developer.atlassian.com/cloud/trello/guides/rest-api/webhooks/#deleting-a-webhook
1436
+ *
1437
+ * @param context The Trello API context.
1438
+ * @returns A function that deletes a webhook.
1439
+ */ function deleteWebhook(context) {
1440
+ return function(input) {
1441
+ return _async_to_generator(function() {
1442
+ return _ts_generator(this, function(_state) {
1443
+ switch(_state.label){
1444
+ case 0:
1445
+ return [
1446
+ 4,
1447
+ context.fetchJson("/webhooks/".concat(input.webhookId), 'DELETE')
1448
+ ];
1449
+ case 1:
1450
+ _state.sent();
1451
+ return [
1452
+ 2
1453
+ ];
1454
+ }
1455
+ });
1456
+ })();
1457
+ };
1458
+ }
1459
+ /**
1460
+ * https://developer.atlassian.com/cloud/trello/guides/rest-api/webhooks/
1461
+ *
1462
+ * @param context The Trello API context.
1463
+ * @returns A function that lists all webhooks registered for a token.
1464
+ */ function listWebhooksForToken(context) {
1465
+ return function(input) {
1466
+ var _ref;
1467
+ var token = (_ref = input === null || input === void 0 ? void 0 : input.apiToken) !== null && _ref !== void 0 ? _ref : context.config.apiToken;
1468
+ return context.fetchJson("/tokens/".concat(token, "/webhooks"), 'GET');
1469
+ };
1470
+ }
1471
+
1472
+ function _define_property(obj, key, value) {
1473
+ if (key in obj) {
1474
+ Object.defineProperty(obj, key, {
1475
+ value: value,
1476
+ enumerable: true,
1477
+ configurable: true,
1478
+ writable: true
1479
+ });
1480
+ } else {
1481
+ obj[key] = value;
1482
+ }
1483
+ return obj;
1484
+ }
1485
+ function _object_spread(target) {
1486
+ for(var i = 1; i < arguments.length; i++){
1487
+ var source = arguments[i] != null ? arguments[i] : {};
1488
+ var ownKeys = Object.keys(source);
1489
+ if (typeof Object.getOwnPropertySymbols === "function") {
1490
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1491
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1492
+ }));
1493
+ }
1494
+ ownKeys.forEach(function(key) {
1495
+ _define_property(target, key, source[key]);
1496
+ });
1497
+ }
1498
+ return target;
1499
+ }
1500
+ function ownKeys(object, enumerableOnly) {
1501
+ var keys = Object.keys(object);
1502
+ if (Object.getOwnPropertySymbols) {
1503
+ var symbols = Object.getOwnPropertySymbols(object);
1504
+ keys.push.apply(keys, symbols);
1505
+ }
1506
+ return keys;
1507
+ }
1508
+ function _object_spread_props(target, source) {
1509
+ source = source != null ? source : {};
1510
+ if (Object.getOwnPropertyDescriptors) {
1511
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1512
+ } else {
1513
+ ownKeys(Object(source)).forEach(function(key) {
1514
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1515
+ });
1516
+ }
1517
+ return target;
1518
+ }
1519
+ /**
1520
+ * Maximum allowed `limit` value for most Trello collection endpoints.
1521
+ *
1522
+ * @see https://developer.atlassian.com/cloud/trello/rest/
1523
+ */ var TRELLO_MAX_PAGE_LIMIT = 1000;
1524
+ /**
1525
+ * Default reader that pulls `id` off the item. Works for most Trello resource types.
1526
+ *
1527
+ * @param item The page item whose id to read.
1528
+ * @returns The item's id.
1529
+ */ var defaultTrelloPageItemIdReader = function defaultTrelloPageItemIdReader(item) {
1530
+ return item.id;
1531
+ };
1532
+ /**
1533
+ * Reader that pulls the action id off a Trello action item.
1534
+ *
1535
+ * @param item The action page item whose id to read.
1536
+ * @returns The item's action id.
1537
+ */ var trelloActionIdReader = function trelloActionIdReader(item) {
1538
+ return item.id;
1539
+ };
1540
+ /**
1541
+ * Wraps a raw Trello collection fetch into a {@link TrelloPageResult}.
1542
+ *
1543
+ * @param input The page filter that was used.
1544
+ * @param data The raw page items.
1545
+ * @param idReader Function to read the id from the last item.
1546
+ * @returns A page result with the data and a cursor for the next page.
1547
+ * @__NO_SIDE_EFFECTS__
1548
+ */ function buildTrelloPageResult(input, data, idReader) {
1549
+ var _input_limit;
1550
+ var limit = (_input_limit = input.limit) !== null && _input_limit !== void 0 ? _input_limit : data.length;
1551
+ var hasMore = data.length === limit && data.length > 0;
1552
+ var nextBefore = hasMore ? idReader(data[data.length - 1]) : undefined;
1553
+ return {
1554
+ data: data,
1555
+ limit: limit,
1556
+ nextBefore: nextBefore
1557
+ };
1558
+ }
1559
+ /**
1560
+ * Creates a FetchPageFactory using the input TrelloFetchPageFetchFunction.
1561
+ *
1562
+ * @param fetch Function that fetches a single page of results from the Trello API.
1563
+ * @param defaults Optional default pagination configuration.
1564
+ * @returns A configured FetchPageFactory that handles Trello's cursor-based pagination using `before`.
1565
+ * @__NO_SIDE_EFFECTS__
1566
+ */ function trelloFetchPageFactory(fetch$1, defaults) {
1567
+ return fetch.fetchPageFactory(_object_spread_props(_object_spread({}, defaults), {
1568
+ fetch: fetch$1,
1569
+ readFetchPageResultInfo: function readFetchPageResultInfo(result) {
1570
+ return {
1571
+ nextPageCursor: result.nextBefore,
1572
+ hasNext: Boolean(result.nextBefore)
1573
+ };
1574
+ },
1575
+ buildInputForNextPage: function buildInputForNextPage(pageResult, input, options) {
1576
+ var _options_maxItemsPerPage;
1577
+ return _object_spread_props(_object_spread({}, input), {
1578
+ before: pageResult.nextPageCursor,
1579
+ limit: (_options_maxItemsPerPage = options.maxItemsPerPage) !== null && _options_maxItemsPerPage !== void 0 ? _options_maxItemsPerPage : input.limit
1580
+ });
1581
+ }
1582
+ }));
1583
+ }
1584
+
1585
+ exports.DEFAULT_TRELLO_API_RATE_LIMIT = DEFAULT_TRELLO_API_RATE_LIMIT;
1586
+ exports.DEFAULT_TRELLO_API_RATE_LIMIT_RESET_PERIOD = DEFAULT_TRELLO_API_RATE_LIMIT_RESET_PERIOD;
1587
+ exports.TRELLO_API_URL = TRELLO_API_URL;
1588
+ exports.TRELLO_MAX_PAGE_LIMIT = TRELLO_MAX_PAGE_LIMIT;
1589
+ exports.TrelloInvalidTokenError = TrelloInvalidTokenError;
1590
+ exports.TrelloServerError = TrelloServerError;
1591
+ exports.TrelloServerFetchResponseError = TrelloServerFetchResponseError;
1592
+ exports.TrelloTooManyRequestsError = TrelloTooManyRequestsError;
1593
+ exports.addCommentToCard = addCommentToCard;
1594
+ exports.addLabelToCard = addLabelToCard;
1595
+ exports.addMemberToCard = addMemberToCard;
1596
+ exports.buildTrelloPageResult = buildTrelloPageResult;
1597
+ exports.createBoard = createBoard;
1598
+ exports.createCard = createCard;
1599
+ exports.createList = createList;
1600
+ exports.createWebhook = createWebhook;
1601
+ exports.defaultTrelloPageItemIdReader = defaultTrelloPageItemIdReader;
1602
+ exports.deleteBoard = deleteBoard;
1603
+ exports.deleteCard = deleteCard;
1604
+ exports.deleteWebhook = deleteWebhook;
1605
+ exports.getBoard = getBoard;
1606
+ exports.getCard = getCard;
1607
+ exports.getList = getList;
1608
+ exports.getMe = getMe;
1609
+ exports.getMember = getMember;
1610
+ exports.getWebhook = getWebhook;
1611
+ exports.handleTrelloErrorFetch = handleTrelloErrorFetch;
1612
+ exports.listBoardCards = listBoardCards;
1613
+ exports.listBoardLabels = listBoardLabels;
1614
+ exports.listBoardLists = listBoardLists;
1615
+ exports.listBoardMembers = listBoardMembers;
1616
+ exports.listCardActions = listCardActions;
1617
+ exports.listCardsInList = listCardsInList;
1618
+ exports.listWebhooksForToken = listWebhooksForToken;
1619
+ exports.logTrelloErrorToConsole = logTrelloErrorToConsole;
1620
+ exports.logTrelloServerErrorFunction = logTrelloServerErrorFunction;
1621
+ exports.parseTrelloApiError = parseTrelloApiError;
1622
+ exports.trelloActionIdReader = trelloActionIdReader;
1623
+ exports.trelloFactory = trelloFactory;
1624
+ exports.trelloFetchPageFactory = trelloFetchPageFactory;
1625
+ exports.trelloRateLimitedFetchHandler = trelloRateLimitedFetchHandler;
1626
+ exports.updateBoard = updateBoard;
1627
+ exports.updateCard = updateCard;
1628
+ exports.updateList = updateList;
1629
+ exports.updateWebhook = updateWebhook;