cloudstructs 0.6.17 → 0.6.18

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 (45) hide show
  1. package/.jsii +3 -3
  2. package/assets/slack-app/provider.lambda/index.js +130 -4
  3. package/assets/slack-events/events.lambda/index.js +4 -0
  4. package/assets/slack-textract/detect.lambda/index.js +347 -73
  5. package/assets/ssl-server-test/analyze.lambda/index.js +130 -4
  6. package/assets/static-website/origin-request.edge-lambda/index.js +4 -0
  7. package/assets/toolkit-cleaner/clean-objects.lambda/index.js +4 -0
  8. package/lib/codecommit-mirror/index.js +2 -2
  9. package/lib/ecs-service-roller/index.js +2 -2
  10. package/lib/email-receiver/receiver.js +1 -1
  11. package/lib/saml-identity-provider/index.js +2 -2
  12. package/lib/slack-app/manifest.js +1 -1
  13. package/lib/slack-app/slack-app.js +2 -2
  14. package/lib/slack-events/index.js +1 -1
  15. package/lib/slack-textract/index.js +3 -3
  16. package/lib/ssl-server-test/index.js +1 -1
  17. package/lib/state-machine-cr-provider/index.js +1 -1
  18. package/lib/static-website/index.js +1 -1
  19. package/lib/toolkit-cleaner/index.js +1 -1
  20. package/lib/url-shortener/index.js +1 -1
  21. package/node_modules/@slack/logger/node_modules/@types/node/README.md +1 -1
  22. package/node_modules/@slack/logger/node_modules/@types/node/child_process.d.ts +1 -1
  23. package/node_modules/@slack/logger/node_modules/@types/node/package.json +2 -2
  24. package/node_modules/@slack/logger/node_modules/@types/node/ts4.8/child_process.d.ts +1 -1
  25. package/node_modules/@slack/web-api/node_modules/@types/node/README.md +1 -1
  26. package/node_modules/@slack/web-api/node_modules/@types/node/child_process.d.ts +1 -1
  27. package/node_modules/@slack/web-api/node_modules/@types/node/package.json +2 -2
  28. package/node_modules/@slack/web-api/node_modules/@types/node/ts4.8/child_process.d.ts +1 -1
  29. package/node_modules/@types/cacheable-request/node_modules/@types/node/README.md +1 -1
  30. package/node_modules/@types/cacheable-request/node_modules/@types/node/child_process.d.ts +1 -1
  31. package/node_modules/@types/cacheable-request/node_modules/@types/node/package.json +2 -2
  32. package/node_modules/@types/cacheable-request/node_modules/@types/node/ts4.8/child_process.d.ts +1 -1
  33. package/node_modules/@types/is-stream/node_modules/@types/node/README.md +1 -1
  34. package/node_modules/@types/is-stream/node_modules/@types/node/child_process.d.ts +1 -1
  35. package/node_modules/@types/is-stream/node_modules/@types/node/package.json +2 -2
  36. package/node_modules/@types/is-stream/node_modules/@types/node/ts4.8/child_process.d.ts +1 -1
  37. package/node_modules/@types/keyv/node_modules/@types/node/README.md +1 -1
  38. package/node_modules/@types/keyv/node_modules/@types/node/child_process.d.ts +1 -1
  39. package/node_modules/@types/keyv/node_modules/@types/node/package.json +2 -2
  40. package/node_modules/@types/keyv/node_modules/@types/node/ts4.8/child_process.d.ts +1 -1
  41. package/node_modules/@types/responselike/node_modules/@types/node/README.md +1 -1
  42. package/node_modules/@types/responselike/node_modules/@types/node/child_process.d.ts +1 -1
  43. package/node_modules/@types/responselike/node_modules/@types/node/package.json +2 -2
  44. package/node_modules/@types/responselike/node_modules/@types/node/ts4.8/child_process.d.ts +1 -1
  45. package/package.json +10 -10
@@ -21,6 +21,10 @@ var __copyProps = (to, from, except, desc) => {
21
21
  return to;
22
22
  };
23
23
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
28
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
29
  mod
26
30
  ));
@@ -287,6 +291,7 @@ var require_p_timeout = __commonJS({
287
291
  reject(timeoutError);
288
292
  }, milliseconds);
289
293
  pFinally(
294
+ // eslint-disable-next-line promise/prefer-await-to-then
290
295
  promise.then(resolve, reject),
291
296
  () => {
292
297
  clearTimeout(timer);
@@ -484,6 +489,9 @@ var require_dist = __commonJS({
484
489
  this._intervalCount = this._carryoverConcurrencyCount ? this._pendingCount : 0;
485
490
  this._processQueue();
486
491
  }
492
+ /**
493
+ Executes all queued functions until it reaches the limit.
494
+ */
487
495
  _processQueue() {
488
496
  while (this._tryToStartAnother()) {
489
497
  }
@@ -498,6 +506,9 @@ var require_dist = __commonJS({
498
506
  this._concurrency = newConcurrency;
499
507
  this._processQueue();
500
508
  }
509
+ /**
510
+ Adds a sync or async task to the queue. Always returns a promise.
511
+ */
501
512
  async add(fn, options = {}) {
502
513
  return new Promise((resolve, reject) => {
503
514
  const run = async () => {
@@ -521,9 +532,17 @@ var require_dist = __commonJS({
521
532
  this.emit("add");
522
533
  });
523
534
  }
535
+ /**
536
+ Same as `.add()`, but accepts an array of sync or async functions.
537
+
538
+ @returns A promise that resolves when all functions are resolved.
539
+ */
524
540
  async addAll(functions, options) {
525
541
  return Promise.all(functions.map(async (function_) => this.add(function_, options)));
526
542
  }
543
+ /**
544
+ Start (or resume) executing enqueued tasks within concurrency limit. No need to call this if queue is not paused (via `options.autoStart = false` or by `.pause()` method.)
545
+ */
527
546
  start() {
528
547
  if (!this._isPaused) {
529
548
  return this;
@@ -532,12 +551,23 @@ var require_dist = __commonJS({
532
551
  this._processQueue();
533
552
  return this;
534
553
  }
554
+ /**
555
+ Put queue execution on hold.
556
+ */
535
557
  pause() {
536
558
  this._isPaused = true;
537
559
  }
560
+ /**
561
+ Clear the queue.
562
+ */
538
563
  clear() {
539
564
  this._queue = new this._queueClass();
540
565
  }
566
+ /**
567
+ Can be called multiple times. Useful if you for example add additional items at a later time.
568
+
569
+ @returns A promise that settles when the queue becomes empty.
570
+ */
541
571
  async onEmpty() {
542
572
  if (this._queue.size === 0) {
543
573
  return;
@@ -550,6 +580,11 @@ var require_dist = __commonJS({
550
580
  };
551
581
  });
552
582
  }
583
+ /**
584
+ The difference with `.onEmpty` is that `.onIdle` guarantees that all work from the queue has finished. `.onEmpty` merely signals that the queue is empty, but it could mean that some promises haven't completed yet.
585
+
586
+ @returns A promise that settles when the queue becomes empty, and all promises have completed; `queue.size === 0 && queue.pending === 0`.
587
+ */
553
588
  async onIdle() {
554
589
  if (this._pendingCount === 0 && this._queue.size === 0) {
555
590
  return;
@@ -562,21 +597,38 @@ var require_dist = __commonJS({
562
597
  };
563
598
  });
564
599
  }
600
+ /**
601
+ Size of the queue.
602
+ */
565
603
  get size() {
566
604
  return this._queue.size;
567
605
  }
606
+ /**
607
+ Size of the queue, filtered by the given options.
608
+
609
+ For example, this can be used to find the number of items remaining in the queue with a specific priority level.
610
+ */
568
611
  sizeBy(options) {
569
612
  return this._queue.filter(options).length;
570
613
  }
614
+ /**
615
+ Number of pending promises.
616
+ */
571
617
  get pending() {
572
618
  return this._pendingCount;
573
619
  }
620
+ /**
621
+ Whether the queue is currently paused.
622
+ */
574
623
  get isPaused() {
575
624
  return this._isPaused;
576
625
  }
577
626
  get timeout() {
578
627
  return this._timeout;
579
628
  }
629
+ /**
630
+ Set the timeout for future operations.
631
+ */
580
632
  set timeout(milliseconds) {
581
633
  this._timeout = milliseconds;
582
634
  }
@@ -820,9 +872,13 @@ var require_p_retry = __commonJS({
820
872
  var retry = require_retry2();
821
873
  var networkErrorMsgs = [
822
874
  "Failed to fetch",
875
+ // Chrome
823
876
  "NetworkError when attempting to fetch resource.",
877
+ // Firefox
824
878
  "The Internet connection appears to be offline.",
879
+ // Safari
825
880
  "Network request failed"
881
+ // `cross-fetch`
826
882
  ];
827
883
  var AbortError = class extends Error {
828
884
  constructor(message) {
@@ -1171,14 +1227,18 @@ var require_enhanceError = __commonJS({
1171
1227
  error.isAxiosError = true;
1172
1228
  error.toJSON = function toJSON() {
1173
1229
  return {
1230
+ // Standard
1174
1231
  message: this.message,
1175
1232
  name: this.name,
1233
+ // Microsoft
1176
1234
  description: this.description,
1177
1235
  number: this.number,
1236
+ // Mozilla
1178
1237
  fileName: this.fileName,
1179
1238
  lineNumber: this.lineNumber,
1180
1239
  columnNumber: this.columnNumber,
1181
1240
  stack: this.stack,
1241
+ // Axios
1182
1242
  config: this.config,
1183
1243
  code: this.code
1184
1244
  };
@@ -1227,44 +1287,50 @@ var require_cookies = __commonJS({
1227
1287
  "node_modules/axios/lib/helpers/cookies.js"(exports, module2) {
1228
1288
  "use strict";
1229
1289
  var utils = require_utils();
1230
- module2.exports = utils.isStandardBrowserEnv() ? function standardBrowserEnv() {
1231
- return {
1232
- write: function write(name, value, expires, path, domain, secure) {
1233
- var cookie = [];
1234
- cookie.push(name + "=" + encodeURIComponent(value));
1235
- if (utils.isNumber(expires)) {
1236
- cookie.push("expires=" + new Date(expires).toGMTString());
1237
- }
1238
- if (utils.isString(path)) {
1239
- cookie.push("path=" + path);
1240
- }
1241
- if (utils.isString(domain)) {
1242
- cookie.push("domain=" + domain);
1290
+ module2.exports = utils.isStandardBrowserEnv() ? (
1291
+ // Standard browser envs support document.cookie
1292
+ function standardBrowserEnv() {
1293
+ return {
1294
+ write: function write(name, value, expires, path, domain, secure) {
1295
+ var cookie = [];
1296
+ cookie.push(name + "=" + encodeURIComponent(value));
1297
+ if (utils.isNumber(expires)) {
1298
+ cookie.push("expires=" + new Date(expires).toGMTString());
1299
+ }
1300
+ if (utils.isString(path)) {
1301
+ cookie.push("path=" + path);
1302
+ }
1303
+ if (utils.isString(domain)) {
1304
+ cookie.push("domain=" + domain);
1305
+ }
1306
+ if (secure === true) {
1307
+ cookie.push("secure");
1308
+ }
1309
+ document.cookie = cookie.join("; ");
1310
+ },
1311
+ read: function read(name) {
1312
+ var match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
1313
+ return match ? decodeURIComponent(match[3]) : null;
1314
+ },
1315
+ remove: function remove(name) {
1316
+ this.write(name, "", Date.now() - 864e5);
1243
1317
  }
1244
- if (secure === true) {
1245
- cookie.push("secure");
1318
+ };
1319
+ }()
1320
+ ) : (
1321
+ // Non standard browser env (web workers, react-native) lack needed support.
1322
+ function nonStandardBrowserEnv() {
1323
+ return {
1324
+ write: function write() {
1325
+ },
1326
+ read: function read() {
1327
+ return null;
1328
+ },
1329
+ remove: function remove() {
1246
1330
  }
1247
- document.cookie = cookie.join("; ");
1248
- },
1249
- read: function read(name) {
1250
- var match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
1251
- return match ? decodeURIComponent(match[3]) : null;
1252
- },
1253
- remove: function remove(name) {
1254
- this.write(name, "", Date.now() - 864e5);
1255
- }
1256
- };
1257
- }() : function nonStandardBrowserEnv() {
1258
- return {
1259
- write: function write() {
1260
- },
1261
- read: function read() {
1262
- return null;
1263
- },
1264
- remove: function remove() {
1265
- }
1266
- };
1267
- }();
1331
+ };
1332
+ }()
1333
+ );
1268
1334
  }
1269
1335
  });
1270
1336
 
@@ -1360,38 +1426,45 @@ var require_isURLSameOrigin = __commonJS({
1360
1426
  "node_modules/axios/lib/helpers/isURLSameOrigin.js"(exports, module2) {
1361
1427
  "use strict";
1362
1428
  var utils = require_utils();
1363
- module2.exports = utils.isStandardBrowserEnv() ? function standardBrowserEnv() {
1364
- var msie = /(msie|trident)/i.test(navigator.userAgent);
1365
- var urlParsingNode = document.createElement("a");
1366
- var originURL;
1367
- function resolveURL(url) {
1368
- var href = url;
1369
- if (msie) {
1429
+ module2.exports = utils.isStandardBrowserEnv() ? (
1430
+ // Standard browser envs have full support of the APIs needed to test
1431
+ // whether the request URL is of the same origin as current location.
1432
+ function standardBrowserEnv() {
1433
+ var msie = /(msie|trident)/i.test(navigator.userAgent);
1434
+ var urlParsingNode = document.createElement("a");
1435
+ var originURL;
1436
+ function resolveURL(url) {
1437
+ var href = url;
1438
+ if (msie) {
1439
+ urlParsingNode.setAttribute("href", href);
1440
+ href = urlParsingNode.href;
1441
+ }
1370
1442
  urlParsingNode.setAttribute("href", href);
1371
- href = urlParsingNode.href;
1443
+ return {
1444
+ href: urlParsingNode.href,
1445
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "",
1446
+ host: urlParsingNode.host,
1447
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "",
1448
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "",
1449
+ hostname: urlParsingNode.hostname,
1450
+ port: urlParsingNode.port,
1451
+ pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname
1452
+ };
1372
1453
  }
1373
- urlParsingNode.setAttribute("href", href);
1374
- return {
1375
- href: urlParsingNode.href,
1376
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "",
1377
- host: urlParsingNode.host,
1378
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "",
1379
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "",
1380
- hostname: urlParsingNode.hostname,
1381
- port: urlParsingNode.port,
1382
- pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname
1454
+ originURL = resolveURL(window.location.href);
1455
+ return function isURLSameOrigin(requestURL) {
1456
+ var parsed = utils.isString(requestURL) ? resolveURL(requestURL) : requestURL;
1457
+ return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
1383
1458
  };
1384
- }
1385
- originURL = resolveURL(window.location.href);
1386
- return function isURLSameOrigin(requestURL) {
1387
- var parsed = utils.isString(requestURL) ? resolveURL(requestURL) : requestURL;
1388
- return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
1389
- };
1390
- }() : function nonStandardBrowserEnv() {
1391
- return function isURLSameOrigin() {
1392
- return true;
1393
- };
1394
- }();
1459
+ }()
1460
+ ) : (
1461
+ // Non standard browser envs (web workers, react-native) lack needed support.
1462
+ function nonStandardBrowserEnv() {
1463
+ return function isURLSameOrigin() {
1464
+ return true;
1465
+ };
1466
+ }()
1467
+ );
1395
1468
  }
1396
1469
  });
1397
1470
 
@@ -1905,7 +1978,11 @@ var require_browser = __commonJS({
1905
1978
  if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
1906
1979
  return false;
1907
1980
  }
1908
- return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
1981
+ return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
1982
+ typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
1983
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
1984
+ typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
1985
+ typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
1909
1986
  }
1910
1987
  function formatArgs(args) {
1911
1988
  args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module2.exports.humanize(this.diff);
@@ -2504,7 +2581,11 @@ var require_follow_redirects = __commonJS({
2504
2581
  for (var event of events) {
2505
2582
  request.on(event, eventHandlers[event]);
2506
2583
  }
2507
- this._currentUrl = /^\//.test(this._options.path) ? url.format(this._options) : this._options.path;
2584
+ this._currentUrl = /^\//.test(this._options.path) ? url.format(this._options) : (
2585
+ // When making a request to a proxy, […]
2586
+ // a client MUST send the target URI in absolute-form […].
2587
+ this._options.path
2588
+ );
2508
2589
  if (this._isRedirect) {
2509
2590
  var i = 0;
2510
2591
  var self = this;
@@ -2552,11 +2633,16 @@ var require_follow_redirects = __commonJS({
2552
2633
  var beforeRedirect = this._options.beforeRedirect;
2553
2634
  if (beforeRedirect) {
2554
2635
  requestHeaders = Object.assign({
2636
+ // The Host header was set by nativeProtocol.request
2555
2637
  Host: response.req.getHeader("host")
2556
2638
  }, this._options.headers);
2557
2639
  }
2558
2640
  var method = this._options.method;
2559
- if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" || statusCode === 303 && !/^(?:GET|HEAD)$/.test(this._options.method)) {
2641
+ if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" || // RFC7231§6.4.4: The 303 (See Other) status code indicates that
2642
+ // the server is redirecting the user agent to a different resource […]
2643
+ // A user agent can perform a retrieval request targeting that URI
2644
+ // (a GET or HEAD request if using HTTP) […]
2645
+ statusCode === 303 && !/^(?:GET|HEAD)$/.test(this._options.method)) {
2560
2646
  this._options.method = "GET";
2561
2647
  this._requestBodyBuffers = [];
2562
2648
  removeMatchingHeaders(/^content-/i, this._options.headers);
@@ -2665,7 +2751,10 @@ var require_follow_redirects = __commonJS({
2665
2751
  function urlToOptions(urlObject) {
2666
2752
  var options = {
2667
2753
  protocol: urlObject.protocol,
2668
- hostname: urlObject.hostname.startsWith("[") ? urlObject.hostname.slice(1, -1) : urlObject.hostname,
2754
+ hostname: urlObject.hostname.startsWith("[") ? (
2755
+ /* istanbul ignore next */
2756
+ urlObject.hostname.slice(1, -1)
2757
+ ) : urlObject.hostname,
2669
2758
  hash: urlObject.hash,
2670
2759
  search: urlObject.search,
2671
2760
  pathname: urlObject.pathname,
@@ -3160,6 +3249,10 @@ var require_defaults = __commonJS({
3160
3249
  }
3161
3250
  return data;
3162
3251
  }],
3252
+ /**
3253
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
3254
+ * timeout is not created.
3255
+ */
3163
3256
  timeout: 0,
3164
3257
  xsrfCookieName: "XSRF-TOKEN",
3165
3258
  xsrfHeaderName: "X-XSRF-TOKEN",
@@ -12870,7 +12963,9 @@ var require_form_data = __commonJS({
12870
12963
  var contentType = this._getContentType(value, options);
12871
12964
  var contents = "";
12872
12965
  var headers = {
12966
+ // add custom disposition as third element or keep it two elements if not
12873
12967
  "Content-Disposition": ["form-data", 'name="' + field + '"'].concat(contentDisposition || []),
12968
+ // if no content type. allow it to be empty array
12874
12969
  "Content-Type": [].concat(contentType || [])
12875
12970
  };
12876
12971
  if (typeof options.header == "object") {
@@ -13285,6 +13380,12 @@ var require_methods = __commonJS({
13285
13380
  return self.apiCall.bind(self, method);
13286
13381
  }
13287
13382
  var Methods = class extends eventemitter3_1.EventEmitter {
13383
+ // TODO: As of writing, `WebClient` already extends EventEmitter...
13384
+ // and I want WebClient to extend this class...
13385
+ // and multiple inheritance in JS is cursed...
13386
+ // so I'm just making this class extend EventEmitter.
13387
+ //
13388
+ // It shouldn't be here, indeed. Nothing here uses it, indeed. But it must be here for the sake of sanity.
13288
13389
  constructor() {
13289
13390
  super();
13290
13391
  this.admin = {
@@ -13877,32 +13978,53 @@ var require_dist3 = __commonJS({
13877
13978
  getLevel() {
13878
13979
  return this.level;
13879
13980
  }
13981
+ /**
13982
+ * Sets the instance's log level so that only messages which are equal or more severe are output to the console.
13983
+ */
13880
13984
  setLevel(level) {
13881
13985
  this.level = level;
13882
13986
  }
13987
+ /**
13988
+ * Set the instance's name, which will appear on each log line before the message.
13989
+ */
13883
13990
  setName(name) {
13884
13991
  this.name = name;
13885
13992
  }
13993
+ /**
13994
+ * Log a debug message
13995
+ */
13886
13996
  debug(...msg) {
13887
13997
  if (ConsoleLogger.isMoreOrEqualSevere(LogLevel.DEBUG, this.level)) {
13888
13998
  console.debug(ConsoleLogger.labels.get(LogLevel.DEBUG), this.name, ...msg);
13889
13999
  }
13890
14000
  }
14001
+ /**
14002
+ * Log an info message
14003
+ */
13891
14004
  info(...msg) {
13892
14005
  if (ConsoleLogger.isMoreOrEqualSevere(LogLevel.INFO, this.level)) {
13893
14006
  console.info(ConsoleLogger.labels.get(LogLevel.INFO), this.name, ...msg);
13894
14007
  }
13895
14008
  }
14009
+ /**
14010
+ * Log a warning message
14011
+ */
13896
14012
  warn(...msg) {
13897
14013
  if (ConsoleLogger.isMoreOrEqualSevere(LogLevel.WARN, this.level)) {
13898
14014
  console.warn(ConsoleLogger.labels.get(LogLevel.WARN), this.name, ...msg);
13899
14015
  }
13900
14016
  }
14017
+ /**
14018
+ * Log an error message
14019
+ */
13901
14020
  error(...msg) {
13902
14021
  if (ConsoleLogger.isMoreOrEqualSevere(LogLevel.ERROR, this.level)) {
13903
14022
  console.error(ConsoleLogger.labels.get(LogLevel.ERROR), this.name, ...msg);
13904
14023
  }
13905
14024
  }
14025
+ /**
14026
+ * Helper to compare two log levels and determine if a is equal or more severe than b
14027
+ */
13906
14028
  static isMoreOrEqualSevere(a, b) {
13907
14029
  return ConsoleLogger.severity[a] >= ConsoleLogger.severity[b];
13908
14030
  }
@@ -14111,6 +14233,9 @@ var require_WebClient = __commonJS({
14111
14233
  var retry_policies_1 = __importDefault(require_retry_policies());
14112
14234
  var helpers_1 = require_helpers();
14113
14235
  var WebClient2 = class extends methods_1.Methods {
14236
+ /**
14237
+ * @param token - An API token to authenticate/authorize with Slack (usually start with `xoxp`, `xoxb`)
14238
+ */
14114
14239
  constructor(token, { slackApiUrl = "https://slack.com/api/", logger = void 0, logLevel = logger_1.LogLevel.INFO, maxRequestConcurrency = 3, retryConfig = retry_policies_1.default.tenRetriesInAboutThirtyMinutes, agent = void 0, tls = void 0, rejectRateLimitedCalls = false, headers = {}, teamId = void 0 } = {}) {
14115
14240
  super();
14116
14241
  this.token = token;
@@ -14138,11 +14263,21 @@ var require_WebClient = __commonJS({
14138
14263
  transformRequest: [this.serializeApiCallOptions.bind(this)],
14139
14264
  validateStatus: () => true,
14140
14265
  maxRedirects: 0,
14266
+ // disabling axios' automatic proxy support:
14267
+ // axios would read from envvars to configure a proxy automatically, but it doesn't support TLS destinations.
14268
+ // for compatibility with https://api.slack.com, and for a larger set of possible proxies (SOCKS or other
14269
+ // protocols), users of this package should use the `agent` option to configure a proxy.
14141
14270
  proxy: false
14142
14271
  });
14143
14272
  delete this.axios.defaults.headers.post["Content-Type"];
14144
14273
  this.logger.debug("initialized");
14145
14274
  }
14275
+ /**
14276
+ * Generic method for calling a Web API method
14277
+ *
14278
+ * @param method - the Web API method to call {@link https://api.slack.com/methods}
14279
+ * @param options - options
14280
+ */
14146
14281
  async apiCall(method, options) {
14147
14282
  this.logger.debug(`apiCall('${method}') start`);
14148
14283
  warnDeprecations(method, this.logger);
@@ -14245,6 +14380,9 @@ var require_WebClient = __commonJS({
14245
14380
  return accumulator;
14246
14381
  })();
14247
14382
  }
14383
+ /**
14384
+ * Low-level function to make a single API request. handles queuing, retries, and http-level errors
14385
+ */
14248
14386
  async makeRequest(url, body, headers = {}) {
14249
14387
  const task = () => this.requestQueue.add(async () => {
14250
14388
  this.logger.debug("will perform http request");
@@ -14283,6 +14421,15 @@ var require_WebClient = __commonJS({
14283
14421
  });
14284
14422
  return p_retry_1.default(task, this.retryConfig);
14285
14423
  }
14424
+ /**
14425
+ * Transforms options (a simple key-value object) into an acceptable value for a body. This can be either
14426
+ * a string, used when posting with a content-type of url-encoded. Or, it can be a readable stream, used
14427
+ * when the options contain a binary (a stream or a buffer) and the upload should be done with content-type
14428
+ * multipart/form-data.
14429
+ *
14430
+ * @param options - arguments for the Web API method
14431
+ * @param headers - a mutable object representing the HTTP headers for the outgoing request
14432
+ */
14286
14433
  serializeApiCallOptions(options, headers) {
14287
14434
  let containsBinaryData = false;
14288
14435
  const flattened = Object.entries(options).map(([key, value]) => {
@@ -14332,6 +14479,11 @@ var require_WebClient = __commonJS({
14332
14479
  return accumulator;
14333
14480
  }, initialValue));
14334
14481
  }
14482
+ /**
14483
+ * Processes an HTTP response into a WebAPICallResult by performing JSON parsing on the body and merging relevent
14484
+ * HTTP headers into the object.
14485
+ * @param response - an http response
14486
+ */
14335
14487
  buildResult(response) {
14336
14488
  const data = response.data;
14337
14489
  if (data.response_metadata === void 0) {
@@ -14744,10 +14896,12 @@ var require_dist5 = __commonJS({
14744
14896
  }
14745
14897
  };
14746
14898
  exports.assert = {
14899
+ // Unknowns.
14747
14900
  undefined: (value) => assertType(is.undefined(value), "undefined", value),
14748
14901
  string: (value) => assertType(is.string(value), "string", value),
14749
14902
  number: (value) => assertType(is.number(value), "number", value),
14750
14903
  bigint: (value) => assertType(is.bigint(value), "bigint", value),
14904
+ // eslint-disable-next-line @typescript-eslint/ban-types
14751
14905
  function_: (value) => assertType(is.function_(value), "Function", value),
14752
14906
  null_: (value) => assertType(is.null_(value), "null", value),
14753
14907
  class_: (value) => assertType(is.class_(value), "Class", value),
@@ -14773,7 +14927,9 @@ var require_dist5 = __commonJS({
14773
14927
  promise: (value) => assertType(is.promise(value), "Promise", value),
14774
14928
  generatorFunction: (value) => assertType(is.generatorFunction(value), "GeneratorFunction", value),
14775
14929
  asyncGeneratorFunction: (value) => assertType(is.asyncGeneratorFunction(value), "AsyncGeneratorFunction", value),
14930
+ // eslint-disable-next-line @typescript-eslint/ban-types
14776
14931
  asyncFunction: (value) => assertType(is.asyncFunction(value), "AsyncFunction", value),
14932
+ // eslint-disable-next-line @typescript-eslint/ban-types
14777
14933
  boundFunction: (value) => assertType(is.boundFunction(value), "Function", value),
14778
14934
  regExp: (value) => assertType(is.regExp(value), "RegExp", value),
14779
14935
  date: (value) => assertType(is.date(value), "Date", value),
@@ -14827,10 +14983,13 @@ var require_dist5 = __commonJS({
14827
14983
  propertyKey: (value) => assertType(is.propertyKey(value), "PropertyKey", value),
14828
14984
  formData: (value) => assertType(is.formData(value), "FormData", value),
14829
14985
  urlSearchParams: (value) => assertType(is.urlSearchParams(value), "URLSearchParams", value),
14986
+ // Numbers.
14830
14987
  evenInteger: (value) => assertType(is.evenInteger(value), "even integer", value),
14831
14988
  oddInteger: (value) => assertType(is.oddInteger(value), "odd integer", value),
14989
+ // Two arguments.
14832
14990
  directInstanceOf: (instance, class_) => assertType(is.directInstanceOf(instance, class_), "T", instance),
14833
14991
  inRange: (value, range) => assertType(is.inRange(value, range), "in range", value),
14992
+ // Variadic functions.
14834
14993
  any: (predicate, ...values) => {
14835
14994
  return assertType(is.any(predicate, ...values), "predicate returns truthy for any value", values, { multipleValues: true });
14836
14995
  },
@@ -16024,6 +16183,7 @@ var require_http_cache_semantics = __commonJS({
16024
16183
  ]);
16025
16184
  var hopByHopHeaders = {
16026
16185
  date: true,
16186
+ // included, because we add Age update Date
16027
16187
  connection: true,
16028
16188
  "keep-alive": true,
16029
16189
  "proxy-authenticate": true,
@@ -16034,6 +16194,7 @@ var require_http_cache_semantics = __commonJS({
16034
16194
  upgrade: true
16035
16195
  };
16036
16196
  var excludedFromRevalidationUpdate = {
16197
+ // Since the old body is reused, it doesn't make sense to change properties of the body
16037
16198
  "content-length": true,
16038
16199
  "content-encoding": true,
16039
16200
  "transfer-encoding": true,
@@ -16120,7 +16281,19 @@ var require_http_cache_semantics = __commonJS({
16120
16281
  return Date.now();
16121
16282
  }
16122
16283
  storable() {
16123
- return !!(!this._reqcc["no-store"] && ("GET" === this._method || "HEAD" === this._method || "POST" === this._method && this._hasExplicitExpiration()) && understoodStatuses.has(this._status) && !this._rescc["no-store"] && (!this._isShared || !this._rescc.private) && (!this._isShared || this._noAuthorization || this._allowsStoringAuthenticated()) && (this._resHeaders.expires || this._rescc["max-age"] || this._isShared && this._rescc["s-maxage"] || this._rescc.public || statusCodeCacheableByDefault.has(this._status)));
16284
+ return !!(!this._reqcc["no-store"] && // A cache MUST NOT store a response to any request, unless:
16285
+ // The request method is understood by the cache and defined as being cacheable, and
16286
+ ("GET" === this._method || "HEAD" === this._method || "POST" === this._method && this._hasExplicitExpiration()) && // the response status code is understood by the cache, and
16287
+ understoodStatuses.has(this._status) && // the "no-store" cache directive does not appear in request or response header fields, and
16288
+ !this._rescc["no-store"] && // the "private" response directive does not appear in the response, if the cache is shared, and
16289
+ (!this._isShared || !this._rescc.private) && // the Authorization header field does not appear in the request, if the cache is shared,
16290
+ (!this._isShared || this._noAuthorization || this._allowsStoringAuthenticated()) && // the response either:
16291
+ // contains an Expires header field, or
16292
+ (this._resHeaders.expires || // contains a max-age response directive, or
16293
+ // contains a s-maxage response directive and the cache is shared, or
16294
+ // contains a public response directive.
16295
+ this._rescc["max-age"] || this._isShared && this._rescc["s-maxage"] || this._rescc.public || // has a status code that is defined as cacheable by default
16296
+ statusCodeCacheableByDefault.has(this._status)));
16124
16297
  }
16125
16298
  _hasExplicitExpiration() {
16126
16299
  return this._isShared && this._rescc["s-maxage"] || this._rescc["max-age"] || this._resHeaders.expires;
@@ -16151,7 +16324,9 @@ var require_http_cache_semantics = __commonJS({
16151
16324
  return this._requestMatches(req, false);
16152
16325
  }
16153
16326
  _requestMatches(req, allowHeadMethod) {
16154
- return (!this._url || this._url === req.url) && this._host === req.headers.host && (!req.method || this._method === req.method || allowHeadMethod && "HEAD" === req.method) && this._varyMatches(req);
16327
+ return (!this._url || this._url === req.url) && this._host === req.headers.host && // the request method associated with the stored response allows it to be used for the presented request, and
16328
+ (!req.method || this._method === req.method || allowHeadMethod && "HEAD" === req.method) && // selecting header fields nominated by the stored response (if any) match those presented, and
16329
+ this._varyMatches(req);
16155
16330
  }
16156
16331
  _allowsStoringAuthenticated() {
16157
16332
  return this._rescc["must-revalidate"] || this._rescc.public || this._rescc["s-maxage"];
@@ -16205,6 +16380,10 @@ var require_http_cache_semantics = __commonJS({
16205
16380
  headers.date = new Date(this.now()).toUTCString();
16206
16381
  return headers;
16207
16382
  }
16383
+ /**
16384
+ * Value of the Date response header or current time if Date was invalid
16385
+ * @return timestamp
16386
+ */
16208
16387
  date() {
16209
16388
  const serverDate = Date.parse(this._resHeaders.date);
16210
16389
  if (isFinite(serverDate)) {
@@ -16212,6 +16391,12 @@ var require_http_cache_semantics = __commonJS({
16212
16391
  }
16213
16392
  return this._responseTime;
16214
16393
  }
16394
+ /**
16395
+ * Value of the Age header, in seconds, updated for the current time.
16396
+ * May be fractional.
16397
+ *
16398
+ * @return Number
16399
+ */
16215
16400
  age() {
16216
16401
  let age = this._ageValue();
16217
16402
  const residentTime = (this.now() - this._responseTime) / 1e3;
@@ -16220,6 +16405,13 @@ var require_http_cache_semantics = __commonJS({
16220
16405
  _ageValue() {
16221
16406
  return toNumberOrZero(this._resHeaders.age);
16222
16407
  }
16408
+ /**
16409
+ * Value of applicable max-age (or heuristic equivalent) in seconds. This counts since response's `Date`.
16410
+ *
16411
+ * For an up-to-date value, see `timeToLive()`.
16412
+ *
16413
+ * @return Number
16414
+ */
16223
16415
  maxAge() {
16224
16416
  if (!this.storable() || this._rescc["no-cache"]) {
16225
16417
  return 0;
@@ -16316,6 +16508,13 @@ var require_http_cache_semantics = __commonJS({
16316
16508
  reqcc: this._reqcc
16317
16509
  };
16318
16510
  }
16511
+ /**
16512
+ * Headers for sending to the origin server to revalidate stale response.
16513
+ * Allows server to return 304 to allow reuse of the previous response.
16514
+ *
16515
+ * Hop by hop headers are always stripped.
16516
+ * Revalidation headers may be added or removed, depending on request.
16517
+ */
16319
16518
  revalidationHeaders(incomingReq) {
16320
16519
  this._assertRequestHasHeaders(incomingReq);
16321
16520
  const headers = this._copyWithoutHopByHopHeaders(incomingReq.headers);
@@ -16346,6 +16545,15 @@ var require_http_cache_semantics = __commonJS({
16346
16545
  }
16347
16546
  return headers;
16348
16547
  }
16548
+ /**
16549
+ * Creates new CachePolicy with information combined from the previews response,
16550
+ * and the new revalidation response.
16551
+ *
16552
+ * Returns {policy, modified} where modified is a boolean indicating
16553
+ * whether the response body has been modified, and old cached body can't be used.
16554
+ *
16555
+ * @return {Object} {policy: CachePolicy, modified: Boolean}
16556
+ */
16349
16557
  revalidatedPolicy(request, response) {
16350
16558
  this._assertRequestHasHeaders(request);
16351
16559
  if (this._useStaleIfError() && isErrorResponse(response)) {
@@ -16375,6 +16583,9 @@ var require_http_cache_semantics = __commonJS({
16375
16583
  if (!matches) {
16376
16584
  return {
16377
16585
  policy: new this.constructor(request, response),
16586
+ // Client receiving 304 without body, even if it's invalid/mismatched has no option
16587
+ // but to reuse a cached body. We don't have a good way to tell clients to do
16588
+ // error recovery in such case.
16378
16589
  modified: response.status != 304,
16379
16590
  matches: false
16380
16591
  };
@@ -17206,6 +17417,7 @@ var require_agent = __commonJS({
17206
17417
  var kOriginSet = Symbol("cachedOriginSet");
17207
17418
  var kGracefullyClosing = Symbol("gracefullyClosing");
17208
17419
  var nameKeys = [
17420
+ // `http2.connect()` options
17209
17421
  "maxDeflateDynamicTableSize",
17210
17422
  "maxSessionMemory",
17211
17423
  "maxHeaderListPairs",
@@ -17213,10 +17425,12 @@ var require_agent = __commonJS({
17213
17425
  "maxReservedRemoteStreams",
17214
17426
  "maxSendHeaderBlockLength",
17215
17427
  "paddingStrategy",
17428
+ // `tls.connect()` options
17216
17429
  "localAddress",
17217
17430
  "path",
17218
17431
  "rejectUnauthorized",
17219
17432
  "minDHSize",
17433
+ // `tls.createSecureContext()` options
17220
17434
  "ca",
17221
17435
  "cert",
17222
17436
  "clientCertEngine",
@@ -17252,7 +17466,12 @@ var require_agent = __commonJS({
17252
17466
  };
17253
17467
  var closeCoveredSessions = (where, session) => {
17254
17468
  for (const coveredSession of where) {
17255
- if (coveredSession[kOriginSet].length < session[kOriginSet].length && coveredSession[kOriginSet].every((origin) => session[kOriginSet].includes(origin)) && coveredSession[kCurrentStreamsCount] + session[kCurrentStreamsCount] <= session.remoteSettings.maxConcurrentStreams) {
17469
+ if (
17470
+ // The set is a proper subset when its length is less than the other set.
17471
+ coveredSession[kOriginSet].length < session[kOriginSet].length && // And the other set includes all elements of the subset.
17472
+ coveredSession[kOriginSet].every((origin) => session[kOriginSet].includes(origin)) && // Makes sure that the session can handle all requests from the covered session.
17473
+ coveredSession[kCurrentStreamsCount] + session[kCurrentStreamsCount] <= session.remoteSettings.maxConcurrentStreams
17474
+ ) {
17256
17475
  gracefullyClose(coveredSession);
17257
17476
  }
17258
17477
  }
@@ -17357,7 +17576,9 @@ var require_agent = __commonJS({
17357
17576
  }
17358
17577
  if (session[kOriginSet].includes(normalizedOrigin)) {
17359
17578
  const sessionCurrentStreamsCount = session[kCurrentStreamsCount];
17360
- if (sessionCurrentStreamsCount >= sessionMaxConcurrentStreams || session[kGracefullyClosing] || session.destroyed) {
17579
+ if (sessionCurrentStreamsCount >= sessionMaxConcurrentStreams || session[kGracefullyClosing] || // Unfortunately the `close` event isn't called immediately,
17580
+ // so `session.destroyed` is `true`, but `session.closed` is `false`.
17581
+ session.destroyed) {
17361
17582
  continue;
17362
17583
  }
17363
17584
  if (!optimalSession) {
@@ -18915,6 +19136,7 @@ var require_core = __commonJS({
18915
19136
  "beforeRedirect",
18916
19137
  "beforeError",
18917
19138
  "beforeRetry",
19139
+ // Promise-Only
18918
19140
  "afterResponse"
18919
19141
  ];
18920
19142
  function validateSearchParameters(searchParameters) {
@@ -18963,6 +19185,7 @@ var require_core = __commonJS({
18963
19185
  writable: true,
18964
19186
  configurable: true,
18965
19187
  enumerable: false,
19188
+ // @ts-expect-error TS doesn't see the check above
18966
19189
  value: source[name]
18967
19190
  };
18968
19191
  }
@@ -18986,11 +19209,15 @@ var require_core = __commonJS({
18986
19209
  value: self[kResponse]
18987
19210
  });
18988
19211
  Object.defineProperty(this, "options", {
19212
+ // This fails because of TS 3.7.2 useDefineForClassFields
19213
+ // Ref: https://github.com/microsoft/TypeScript/issues/34972
18989
19214
  enumerable: false,
18990
19215
  value: self.options
18991
19216
  });
18992
19217
  } else {
18993
19218
  Object.defineProperty(this, "options", {
19219
+ // This fails because of TS 3.7.2 useDefineForClassFields
19220
+ // Ref: https://github.com/microsoft/TypeScript/issues/34972
18994
19221
  enumerable: false,
18995
19222
  value: self
18996
19223
  });
@@ -19076,7 +19303,10 @@ var require_core = __commonJS({
19076
19303
  var Request = class extends stream_1.Duplex {
19077
19304
  constructor(url, options = {}, defaults) {
19078
19305
  super({
19306
+ // This must be false, to enable throwing after destroy
19307
+ // It is used for retry logic in Promise API
19079
19308
  autoDestroy: false,
19309
+ // It needs to be zero because we're just proxying the data to another stream
19080
19310
  highWaterMark: 0
19081
19311
  });
19082
19312
  this[kDownloadedSize] = 0;
@@ -19974,6 +20204,7 @@ var require_core = __commonJS({
19974
20204
  }
19975
20205
  }
19976
20206
  }
20207
+ // Node.js 12 has incorrect types, so the encoding must be a string
19977
20208
  _write(chunk, encoding, callback) {
19978
20209
  const write = () => {
19979
20210
  this._writeRequest(chunk, encoding, callback);
@@ -20048,10 +20279,16 @@ var require_core = __commonJS({
20048
20279
  get _isAboutToError() {
20049
20280
  return this[kStopReading];
20050
20281
  }
20282
+ /**
20283
+ The remote IP address.
20284
+ */
20051
20285
  get ip() {
20052
20286
  var _a;
20053
20287
  return (_a = this.socket) === null || _a === void 0 ? void 0 : _a.remoteAddress;
20054
20288
  }
20289
+ /**
20290
+ Indicates whether the request has been aborted or not.
20291
+ */
20055
20292
  get aborted() {
20056
20293
  var _a, _b, _c;
20057
20294
  return ((_b = (_a = this[kRequest]) === null || _a === void 0 ? void 0 : _a.destroyed) !== null && _b !== void 0 ? _b : this.destroyed) && !((_c = this[kOriginalResponse]) === null || _c === void 0 ? void 0 : _c.complete);
@@ -20060,6 +20297,9 @@ var require_core = __commonJS({
20060
20297
  var _a, _b;
20061
20298
  return (_b = (_a = this[kRequest]) === null || _a === void 0 ? void 0 : _a.socket) !== null && _b !== void 0 ? _b : void 0;
20062
20299
  }
20300
+ /**
20301
+ Progress event for downloading (receiving a response).
20302
+ */
20063
20303
  get downloadProgress() {
20064
20304
  let percent;
20065
20305
  if (this[kResponseSize]) {
@@ -20075,6 +20315,9 @@ var require_core = __commonJS({
20075
20315
  total: this[kResponseSize]
20076
20316
  };
20077
20317
  }
20318
+ /**
20319
+ Progress event for uploading (sending a request).
20320
+ */
20078
20321
  get uploadProgress() {
20079
20322
  let percent;
20080
20323
  if (this[kBodySize]) {
@@ -20090,10 +20333,40 @@ var require_core = __commonJS({
20090
20333
  total: this[kBodySize]
20091
20334
  };
20092
20335
  }
20336
+ /**
20337
+ The object contains the following properties:
20338
+
20339
+ - `start` - Time when the request started.
20340
+ - `socket` - Time when a socket was assigned to the request.
20341
+ - `lookup` - Time when the DNS lookup finished.
20342
+ - `connect` - Time when the socket successfully connected.
20343
+ - `secureConnect` - Time when the socket securely connected.
20344
+ - `upload` - Time when the request finished uploading.
20345
+ - `response` - Time when the request fired `response` event.
20346
+ - `end` - Time when the response fired `end` event.
20347
+ - `error` - Time when the request fired `error` event.
20348
+ - `abort` - Time when the request fired `abort` event.
20349
+ - `phases`
20350
+ - `wait` - `timings.socket - timings.start`
20351
+ - `dns` - `timings.lookup - timings.socket`
20352
+ - `tcp` - `timings.connect - timings.lookup`
20353
+ - `tls` - `timings.secureConnect - timings.connect`
20354
+ - `request` - `timings.upload - (timings.secureConnect || timings.connect)`
20355
+ - `firstByte` - `timings.response - timings.upload`
20356
+ - `download` - `timings.end - timings.response`
20357
+ - `total` - `(timings.end || timings.error || timings.abort) - timings.start`
20358
+
20359
+ If something has not been measured yet, it will be `undefined`.
20360
+
20361
+ __Note__: The time is a `number` representing the milliseconds elapsed since the UNIX epoch.
20362
+ */
20093
20363
  get timings() {
20094
20364
  var _a;
20095
20365
  return (_a = this[kRequest]) === null || _a === void 0 ? void 0 : _a.timings;
20096
20366
  }
20367
+ /**
20368
+ Whether the response was retrieved from the cache.
20369
+ */
20097
20370
  get isFromCache() {
20098
20371
  return this[kIsFromCache];
20099
20372
  }
@@ -20740,6 +21013,7 @@ var require_source5 = __commonJS({
20740
21013
  methodRewriting: true,
20741
21014
  ignoreInvalidCookies: false,
20742
21015
  context: {},
21016
+ // TODO: Set this to `true` when Got 12 gets released
20743
21017
  http2: false,
20744
21018
  allowGetBody: false,
20745
21019
  https: void 0,