@desplega.ai/slack-mock 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -1
- package/dist/block-limits.d.ts +2 -0
- package/dist/cli.js +19 -2
- package/dist/http-delivery.d.ts +61 -0
- package/dist/{index-z58p5wkc.js → index-5hsxaq74.js} +474 -25
- package/dist/index.d.ts +2 -0
- package/dist/index.js +10 -2
- package/dist/server.d.ts +8 -0
- package/dist/socket-mode.d.ts +1 -0
- package/package.json +1 -1
- package/src/block-limits.ts +170 -0
- package/src/cli.ts +21 -0
- package/src/http-delivery.ts +240 -0
- package/src/index.ts +7 -0
- package/src/render/blocks.ts +165 -1
- package/src/render/index.ts +20 -0
- package/src/server.ts +33 -14
- package/src/socket-mode.ts +1 -1
- package/src/web-api.ts +3 -4
|
@@ -424,7 +424,7 @@ function richElement(v, ctx) {
|
|
|
424
424
|
return `<span class="sm-pill">@${escapeHtml(str(el.range) || "channel")}</span>`;
|
|
425
425
|
case "emoji": {
|
|
426
426
|
const char = emojiChar(str(el.name)) ?? (el.unicode ? emojiFromUnicode(str(el.unicode)) : undefined);
|
|
427
|
-
return char
|
|
427
|
+
return char ? escapeHtml(char) : `<span class="sm-emoji-name">:${escapeHtml(str(el.name))}:</span>`;
|
|
428
428
|
}
|
|
429
429
|
case "date":
|
|
430
430
|
return plainTextToHtml(str(el.fallback) || str(el.timestamp));
|
|
@@ -505,6 +505,113 @@ function videoBlock(block, ctx) {
|
|
|
505
505
|
const inner = `${thumb ? `<img class="sm-video-thumb" src="${thumb}" alt="${escapeHtml(str(block.alt_text))}">` : ""}<div class="sm-video-title">\u25B6 ${title}</div>`;
|
|
506
506
|
return `<div class="sm-block sm-video">${url ? `<a class="sm-video-link" href="${url}" target="_blank" rel="noopener">${inner}</a>` : inner}</div>`;
|
|
507
507
|
}
|
|
508
|
+
function tableCell(v, ctx) {
|
|
509
|
+
const cell = rec(v);
|
|
510
|
+
if (!cell)
|
|
511
|
+
return "";
|
|
512
|
+
if (str(cell.type) === "rich_text")
|
|
513
|
+
return arr(cell.elements).map((e) => richSection(e, ctx)).join("");
|
|
514
|
+
if (str(cell.type) === "action_cell") {
|
|
515
|
+
const el = rec(cell.element);
|
|
516
|
+
return el && str(el.type) === "button" ? button(el, ctx) : tableCell(cell.fallback, ctx);
|
|
517
|
+
}
|
|
518
|
+
return plainTextToHtml(str(cell.text) || (cell.value === undefined ? "" : String(cell.value)));
|
|
519
|
+
}
|
|
520
|
+
function tableBlock(block, ctx) {
|
|
521
|
+
const settings = arr(block.column_settings).map(rec);
|
|
522
|
+
const rows = arr(block.rows).map(arr);
|
|
523
|
+
const ps = Number(block.page_size);
|
|
524
|
+
const pageSize = block.type === "data_table" ? Number.isInteger(ps) && ps >= 1 ? ps : 5 : 0;
|
|
525
|
+
const head = block.type === "data_table" ? 1 : 0;
|
|
526
|
+
const body = rows.slice(head);
|
|
527
|
+
const per = pageSize || body.length || 1;
|
|
528
|
+
const pages = [];
|
|
529
|
+
for (let i = 0;i < body.length || i === 0; i += per)
|
|
530
|
+
pages.push(body.slice(i, i + per));
|
|
531
|
+
const row = (cells, tag) => `<tr>${cells.map((c, i) => {
|
|
532
|
+
const align = str(settings[i]?.align);
|
|
533
|
+
const cls = [
|
|
534
|
+
align === "center" || align === "right" ? `sm-ta-${align}` : "",
|
|
535
|
+
settings[i]?.is_wrapped === true ? "sm-td-wrap" : ""
|
|
536
|
+
].filter(Boolean);
|
|
537
|
+
return `<${tag}${cls.length ? ` class="${cls.join(" ")}"` : ""}>${tableCell(c, ctx)}</${tag}>`;
|
|
538
|
+
}).join("")}</tr>`;
|
|
539
|
+
const caption = str(block.caption) ? `<div class="sm-table-caption">${plainTextToHtml(str(block.caption))}</div>` : "";
|
|
540
|
+
const paged = pages.length > 1;
|
|
541
|
+
const range = (p) => `${p * per + 1}\u2013${p * per + (pages[p]?.length ?? 0)} of ${body.length}`;
|
|
542
|
+
const pager = paged ? `<div class="sm-table-pager"><button type="button" class="sm-pager-btn" data-step="-1" aria-label="Previous page" disabled>\u2039</button><span class="sm-pager-label">${range(0)}</span><button type="button" class="sm-pager-btn" data-step="1" aria-label="Next page">\u203A</button></div>` : "";
|
|
543
|
+
const tbodies = pages.map((pg, p) => `<tbody${paged ? ` data-range="${range(p)}"` : ""}${p ? " hidden" : ""}>${pg.map((r) => row(r, "td")).join("")}</tbody>`).join("");
|
|
544
|
+
return `<div class="sm-block sm-table-block">${caption}<div class="sm-table-wrap"><table class="sm-bk-table">${head && rows.length ? `<thead>${row(rows[0] ?? [], "th")}</thead>` : ""}${tbodies}</table></div>${pager}</div>`;
|
|
545
|
+
}
|
|
546
|
+
var CHART_COLORS = ["#1264a3", "#2eb67d", "#ecb22e", "#e01e5a", "#36c5f0", "#7c3085"];
|
|
547
|
+
var color = (i) => CHART_COLORS[i % CHART_COLORS.length];
|
|
548
|
+
var num = (v) => Number.isFinite(Number(v)) ? Number(v) : 0;
|
|
549
|
+
var svgText = (x, y, text, attrs = "") => `<text x="${x}" y="${y}" ${attrs}>${escapeHtml(text)}</text>`;
|
|
550
|
+
function legend(labels) {
|
|
551
|
+
return `<div class="sm-chart-legend">${labels.map((l, i) => `<span class="sm-chart-key"><i style="background:${color(i)}"></i>${escapeHtml(l)}</span>`).join("")}</div>`;
|
|
552
|
+
}
|
|
553
|
+
function pieChart(chart) {
|
|
554
|
+
const segments = arr(chart.segments).map(rec);
|
|
555
|
+
const total = segments.reduce((t, s) => t + Math.max(0, num(s?.value)), 0) || 1;
|
|
556
|
+
let angle = -Math.PI / 2;
|
|
557
|
+
const slices = segments.map((s, i) => {
|
|
558
|
+
const frac = Math.max(0, num(s?.value)) / total;
|
|
559
|
+
if (frac >= 0.9999)
|
|
560
|
+
return `<circle cx="100" cy="100" r="90" fill="${color(i)}"/>`;
|
|
561
|
+
const a0 = angle;
|
|
562
|
+
angle += frac * 2 * Math.PI;
|
|
563
|
+
const p = (a) => `${100 + 90 * Math.cos(a)} ${100 + 90 * Math.sin(a)}`;
|
|
564
|
+
return `<path d="M100 100 L${p(a0)} A90 90 0 ${frac > 0.5 ? 1 : 0} 1 ${p(angle)} Z" fill="${color(i)}"/>`;
|
|
565
|
+
});
|
|
566
|
+
return `<svg class="sm-chart-svg" viewBox="0 0 200 200" width="200" height="200">${slices.join("")}</svg>${legend(segments.map((s) => `${str(s?.label)} (${num(s?.value)})`))}`;
|
|
567
|
+
}
|
|
568
|
+
function seriesChart(chart, type) {
|
|
569
|
+
const axis = rec(chart.axis_config) ?? {};
|
|
570
|
+
const series = arr(chart.series).map((s) => rec(s) ?? {});
|
|
571
|
+
const categories = arr(axis.categories).map(str);
|
|
572
|
+
const valueAt = (s, c) => num(rec(arr(s.data).find((p) => rec(p)?.label === c))?.value);
|
|
573
|
+
const values = series.flatMap((s) => categories.map((c) => valueAt(s, c)));
|
|
574
|
+
const min = Math.min(0, ...values);
|
|
575
|
+
const max = Math.max(min < 0 ? 0 : 1, ...values);
|
|
576
|
+
const [W, H, L, T, B] = [480, 220, 44, 10, 30];
|
|
577
|
+
const plotW = W - L - 10;
|
|
578
|
+
const plotH = H - T - B;
|
|
579
|
+
const y = (v) => T + plotH - (v - min) / (max - min) * plotH;
|
|
580
|
+
const zero = y(0);
|
|
581
|
+
const step = plotW / Math.max(1, categories.length);
|
|
582
|
+
const parts = [];
|
|
583
|
+
for (let k = 0;k <= 4; k++) {
|
|
584
|
+
const v = min + (max - min) * k / 4;
|
|
585
|
+
parts.push(`<line x1="${L}" x2="${W - 10}" y1="${y(v)}" y2="${y(v)}" stroke="#e8e8e8"/>`, svgText(L - 6, y(v) + 4, String(Math.round(v * 100) / 100), 'text-anchor="end"'));
|
|
586
|
+
}
|
|
587
|
+
categories.forEach((c, i) => {
|
|
588
|
+
parts.push(svgText(L + step * (i + 0.5), H - B + 16, c, 'text-anchor="middle"'));
|
|
589
|
+
});
|
|
590
|
+
series.forEach((s, si) => {
|
|
591
|
+
if (type === "bar") {
|
|
592
|
+
const bw = step * 0.7 / Math.max(1, series.length);
|
|
593
|
+
categories.forEach((c, i) => {
|
|
594
|
+
const v = valueAt(s, c);
|
|
595
|
+
parts.push(`<rect x="${L + step * i + step * 0.15 + bw * si}" y="${Math.min(zero, y(v))}" width="${bw}" height="${Math.abs(zero - y(v))}" fill="${color(si)}"/>`);
|
|
596
|
+
});
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
const pts = categories.map((c, i) => `${L + step * (i + 0.5)},${y(valueAt(s, c))}`);
|
|
600
|
+
if (type === "area" && pts.length)
|
|
601
|
+
parts.push(`<polygon points="${L + step * 0.5},${zero} ${pts.join(" ")} ${L + step * (categories.length - 0.5)},${zero}" fill="${color(si)}" fill-opacity=".25"/>`);
|
|
602
|
+
parts.push(`<polyline points="${pts.join(" ")}" fill="none" stroke="${color(si)}" stroke-width="2"/>`);
|
|
603
|
+
});
|
|
604
|
+
const xLabel = str(axis.x_label);
|
|
605
|
+
const yLabel = str(axis.y_label);
|
|
606
|
+
const labels = `${yLabel ? `<div class="sm-chart-axis">${plainTextToHtml(yLabel)} \u2191</div>` : ""}`;
|
|
607
|
+
return `${labels}<svg class="sm-chart-svg" viewBox="0 0 ${W} ${H}" width="${W}" height="${H}">${parts.join("")}<line x1="${L}" x2="${W - 10}" y1="${zero}" y2="${zero}" stroke="#bbb"/></svg>${xLabel ? `<div class="sm-chart-axis sm-chart-axis-x">${plainTextToHtml(xLabel)} \u2192</div>` : ""}${legend(series.map((s) => str(s.name)))}`;
|
|
608
|
+
}
|
|
609
|
+
function dataVisualizationBlock(block) {
|
|
610
|
+
const chart = rec(block.chart) ?? {};
|
|
611
|
+
const type = str(chart.type);
|
|
612
|
+
const body = type === "pie" ? pieChart(chart) : type === "bar" || type === "line" || type === "area" ? seriesChart(chart, type) : unsupported(`chart ${type}`);
|
|
613
|
+
return `<div class="sm-block sm-chart" data-chart="${escapeHtml(type)}"><div class="sm-chart-title">${plainTextToHtml(str(block.title))}</div>${body}</div>`;
|
|
614
|
+
}
|
|
508
615
|
function renderBlock(v, ctx) {
|
|
509
616
|
const block = rec(v);
|
|
510
617
|
if (!block)
|
|
@@ -532,6 +639,11 @@ function renderBlock(v, ctx) {
|
|
|
532
639
|
return videoBlock(block, ctx);
|
|
533
640
|
case "markdown":
|
|
534
641
|
return `<div class="sm-block sm-markdown">${markdownToHtml(str(block.text), ctx)}</div>`;
|
|
642
|
+
case "table":
|
|
643
|
+
case "data_table":
|
|
644
|
+
return tableBlock(block, ctx);
|
|
645
|
+
case "data_visualization":
|
|
646
|
+
return dataVisualizationBlock(block);
|
|
535
647
|
default:
|
|
536
648
|
return `<div class="sm-block">${unsupported(str(block.type))}</div>`;
|
|
537
649
|
}
|
|
@@ -798,6 +910,25 @@ a:hover{text-decoration:underline}
|
|
|
798
910
|
.sm-video-title{font-size:14px;font-weight:700;margin-top:4px}
|
|
799
911
|
.sm-unsupported{display:inline-block;background:#f4f4f4;border:1px solid #ddd;border-radius:4px;padding:4px 8px;font-size:12px;color:#616061;font-family:Monaco,Menlo,monospace}
|
|
800
912
|
.sm-rt-section{margin:2px 0}
|
|
913
|
+
.sm-table-caption{font-size:13px;font-weight:700;color:#454245;margin-bottom:4px}
|
|
914
|
+
.sm-table-wrap{width:fit-content;overflow-x:auto;border:1px solid #ddd;border-radius:6px;max-width:100%}
|
|
915
|
+
.sm-bk-table{border-collapse:collapse;font-size:14px;line-height:20px}
|
|
916
|
+
.sm-bk-table th,.sm-bk-table td{padding:6px 12px;text-align:left;border-bottom:1px solid #e8e8e8;white-space:nowrap;vertical-align:top}
|
|
917
|
+
.sm-bk-table th{font-weight:700;background:#f8f8f8}
|
|
918
|
+
.sm-bk-table tr:last-child td{border-bottom:0}
|
|
919
|
+
.sm-bk-table .sm-ta-center{text-align:center}
|
|
920
|
+
.sm-bk-table .sm-ta-right{text-align:right}
|
|
921
|
+
.sm-bk-table .sm-td-wrap{white-space:normal}
|
|
922
|
+
.sm-table-pager{display:flex;align-items:center;gap:6px;font-size:12px;color:#616061;margin-top:4px}
|
|
923
|
+
.sm-pager-btn{border:1px solid #ddd;border-radius:4px;background:#fff;color:#1d1c1d;font-size:14px;line-height:16px;padding:0 6px;cursor:pointer}
|
|
924
|
+
.sm-pager-btn:disabled{color:#bbb;cursor:default}
|
|
925
|
+
.sm-chart{border:1px solid #ddd;border-radius:6px;padding:10px 12px;max-width:520px}
|
|
926
|
+
.sm-chart-title{font-size:14px;font-weight:700;margin-bottom:6px}
|
|
927
|
+
.sm-chart-svg{display:block;max-width:100%;height:auto;font-size:11px;fill:#616061}
|
|
928
|
+
.sm-chart-axis{font-size:11px;color:#616061}
|
|
929
|
+
.sm-chart-axis-x{text-align:center}
|
|
930
|
+
.sm-chart-legend{display:flex;flex-wrap:wrap;gap:4px 12px;font-size:12px;color:#454245;margin-top:6px}
|
|
931
|
+
.sm-chart-key i{display:inline-block;width:10px;height:10px;border-radius:2px;margin-right:4px;vertical-align:-1px}
|
|
801
932
|
|
|
802
933
|
.sm-atts{margin-top:4px}
|
|
803
934
|
.sm-att{border-left:4px solid #ddd;border-radius:2px;padding:2px 0 2px 12px;margin:6px 0;max-width:600px}
|
|
@@ -1284,6 +1415,7 @@ function fitViewport(){if(viewport&&viewport.scale!==1)return;var style=document
|
|
|
1284
1415
|
fitViewport();addEventListener("resize",fitViewport);
|
|
1285
1416
|
if(viewport){viewport.addEventListener("resize",fitViewport);viewport.addEventListener("scroll",fitViewport)}
|
|
1286
1417
|
document.addEventListener("change",function(e){if(e.target.classList.contains("sm-channel-switch"))location.href=e.target.value});
|
|
1418
|
+
document.addEventListener("click",function(e){var b=e.target.closest(".sm-pager-btn");if(!b)return;var block=b.closest(".sm-table-block"),pages=block.querySelectorAll("tbody"),cur=0;pages.forEach(function(t,i){if(!t.hidden)cur=i});var next=Math.min(Math.max(cur+Number(b.dataset.step),0),pages.length-1);pages.forEach(function(t,i){t.hidden=i!==next});block.querySelector(".sm-pager-label").textContent=pages[next].dataset.range;var btns=block.querySelectorAll(".sm-pager-btn");btns[0].disabled=next===0;btns[1].disabled=next===pages.length-1});
|
|
1287
1419
|
var W="sm-panel-w",DEF=${JSON.stringify(panelWidth(opts))},FIXED=${opts.panelWidth ? "true" : "false"};
|
|
1288
1420
|
${autoScroll ? `function scroll(){document.querySelectorAll(".sm-scroll").forEach(function(el){el.scrollTop=el.scrollHeight})}
|
|
1289
1421
|
scroll();addEventListener("load",scroll);` : ""}
|
|
@@ -1586,7 +1718,7 @@ function str2(args, key) {
|
|
|
1586
1718
|
const v = args[key];
|
|
1587
1719
|
return typeof v === "string" ? v : v == null ? undefined : String(v);
|
|
1588
1720
|
}
|
|
1589
|
-
function
|
|
1721
|
+
function num2(args, key, fallback) {
|
|
1590
1722
|
const v = args[key];
|
|
1591
1723
|
const n = typeof v === "number" ? v : typeof v === "string" ? Number.parseInt(v, 10) : Number.NaN;
|
|
1592
1724
|
return Number.isFinite(n) ? n : fallback;
|
|
@@ -2372,6 +2504,9 @@ function viewSubmissionPayload(store, input) {
|
|
|
2372
2504
|
};
|
|
2373
2505
|
}
|
|
2374
2506
|
|
|
2507
|
+
// src/http-delivery.ts
|
|
2508
|
+
import { createHmac } from "crypto";
|
|
2509
|
+
|
|
2375
2510
|
// src/socket-mode.ts
|
|
2376
2511
|
class SocketModeClosedError extends Error {
|
|
2377
2512
|
}
|
|
@@ -2546,6 +2681,318 @@ class SocketModeHub {
|
|
|
2546
2681
|
}
|
|
2547
2682
|
}
|
|
2548
2683
|
|
|
2684
|
+
// src/http-delivery.ts
|
|
2685
|
+
function slackSignature2(secret, timestamp, body) {
|
|
2686
|
+
return `v0=${createHmac("sha256", secret).update(`v0:${timestamp}:${body}`).digest("hex")}`;
|
|
2687
|
+
}
|
|
2688
|
+
|
|
2689
|
+
class HttpDeliveryError2 extends Error {
|
|
2690
|
+
}
|
|
2691
|
+
|
|
2692
|
+
class HttpDeliveryStoppedError2 extends HttpDeliveryError2 {
|
|
2693
|
+
constructor() {
|
|
2694
|
+
super("mock stopped");
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
class HttpDelivery2 {
|
|
2699
|
+
history = [];
|
|
2700
|
+
opts;
|
|
2701
|
+
stopController = new AbortController;
|
|
2702
|
+
retryTimers = new Set;
|
|
2703
|
+
constructor(opts) {
|
|
2704
|
+
this.opts = {
|
|
2705
|
+
eventsUrl: opts.eventsUrl,
|
|
2706
|
+
interactivityUrl: opts.interactivityUrl ?? opts.eventsUrl,
|
|
2707
|
+
commandsUrl: opts.commandsUrl ?? opts.eventsUrl,
|
|
2708
|
+
signingSecret: opts.signingSecret,
|
|
2709
|
+
retryDelaysMs: opts.retryDelaysMs ?? [60000, 300000, 1800000],
|
|
2710
|
+
timeoutMs: opts.timeoutMs ?? 3000,
|
|
2711
|
+
log: opts.log ?? (() => {})
|
|
2712
|
+
};
|
|
2713
|
+
}
|
|
2714
|
+
shutdown() {
|
|
2715
|
+
this.stopController.abort();
|
|
2716
|
+
for (const t of this.retryTimers) {
|
|
2717
|
+
clearTimeout(t.timer);
|
|
2718
|
+
t.wake();
|
|
2719
|
+
}
|
|
2720
|
+
this.retryTimers.clear();
|
|
2721
|
+
}
|
|
2722
|
+
get stopped() {
|
|
2723
|
+
return this.stopController.signal.aborted;
|
|
2724
|
+
}
|
|
2725
|
+
waitToRetry(ms) {
|
|
2726
|
+
return new Promise((resolve) => {
|
|
2727
|
+
const entry = {
|
|
2728
|
+
timer: setTimeout(() => {
|
|
2729
|
+
this.retryTimers.delete(entry);
|
|
2730
|
+
resolve();
|
|
2731
|
+
}, ms),
|
|
2732
|
+
wake: resolve
|
|
2733
|
+
};
|
|
2734
|
+
this.retryTimers.add(entry);
|
|
2735
|
+
});
|
|
2736
|
+
}
|
|
2737
|
+
get connectionCount() {
|
|
2738
|
+
return 1;
|
|
2739
|
+
}
|
|
2740
|
+
waitForConnection() {
|
|
2741
|
+
return Promise.resolve();
|
|
2742
|
+
}
|
|
2743
|
+
async verifyUrl() {
|
|
2744
|
+
const challenge = crypto.randomUUID();
|
|
2745
|
+
const body = JSON.stringify({
|
|
2746
|
+
token: "mock-verification-token",
|
|
2747
|
+
challenge,
|
|
2748
|
+
type: "url_verification"
|
|
2749
|
+
});
|
|
2750
|
+
const res = await this.post(this.opts.eventsUrl, body, "application/json", {});
|
|
2751
|
+
if (!res.ok)
|
|
2752
|
+
return false;
|
|
2753
|
+
return res.payload?.challenge === challenge || res.text === challenge;
|
|
2754
|
+
}
|
|
2755
|
+
async send(type, payload, _acceptsResponsePayload = false) {
|
|
2756
|
+
if (this.stopped)
|
|
2757
|
+
throw new HttpDeliveryStoppedError2;
|
|
2758
|
+
const record = {
|
|
2759
|
+
envelope_id: crypto.randomUUID(),
|
|
2760
|
+
type,
|
|
2761
|
+
name: envelopeName(type, payload),
|
|
2762
|
+
sentAt: new Date().toISOString(),
|
|
2763
|
+
attempts: 0,
|
|
2764
|
+
acked: false
|
|
2765
|
+
};
|
|
2766
|
+
this.history.push(record);
|
|
2767
|
+
const { url, body, contentType } = this.encode(type, payload);
|
|
2768
|
+
const delays = type === "events_api" ? this.opts.retryDelaysMs : [];
|
|
2769
|
+
let retry;
|
|
2770
|
+
for (let attempt = 0;; attempt++) {
|
|
2771
|
+
record.attempts = attempt + 1;
|
|
2772
|
+
const res = await this.post(url, body, contentType, retry ? this.retryHeaders(retry) : {});
|
|
2773
|
+
if (this.stopped)
|
|
2774
|
+
throw new HttpDeliveryStoppedError2;
|
|
2775
|
+
if (res.ok) {
|
|
2776
|
+
record.acked = true;
|
|
2777
|
+
record.ackPayload = res.payload;
|
|
2778
|
+
return { envelope_id: record.envelope_id, payload: res.payload, attempts: record.attempts };
|
|
2779
|
+
}
|
|
2780
|
+
const delay = delays[attempt];
|
|
2781
|
+
if (delay === undefined) {
|
|
2782
|
+
throw new HttpDeliveryError2(`${record.name} not acknowledged (${res.reason}) after ${record.attempts} attempt(s)`);
|
|
2783
|
+
}
|
|
2784
|
+
this.opts.log(`${record.name} to ${url}: ${res.reason}; retry ${attempt + 1} in ${delay}ms`);
|
|
2785
|
+
await this.waitToRetry(delay);
|
|
2786
|
+
if (this.stopped)
|
|
2787
|
+
throw new HttpDeliveryStoppedError2;
|
|
2788
|
+
retry = { num: attempt + 1, reason: res.reason };
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
retryHeaders(retry) {
|
|
2792
|
+
return { "X-Slack-Retry-Num": String(retry.num), "X-Slack-Retry-Reason": retry.reason };
|
|
2793
|
+
}
|
|
2794
|
+
encode(type, payload) {
|
|
2795
|
+
if (type === "events_api") {
|
|
2796
|
+
return {
|
|
2797
|
+
url: this.opts.eventsUrl,
|
|
2798
|
+
body: JSON.stringify(payload),
|
|
2799
|
+
contentType: "application/json"
|
|
2800
|
+
};
|
|
2801
|
+
}
|
|
2802
|
+
const form = new URLSearchParams;
|
|
2803
|
+
if (type === "interactive") {
|
|
2804
|
+
form.set("payload", JSON.stringify(payload));
|
|
2805
|
+
} else {
|
|
2806
|
+
for (const [key, value] of Object.entries(payload)) {
|
|
2807
|
+
if (value !== undefined && value !== null)
|
|
2808
|
+
form.set(key, String(value));
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
return {
|
|
2812
|
+
url: type === "interactive" ? this.opts.interactivityUrl : this.opts.commandsUrl,
|
|
2813
|
+
body: form.toString(),
|
|
2814
|
+
contentType: "application/x-www-form-urlencoded"
|
|
2815
|
+
};
|
|
2816
|
+
}
|
|
2817
|
+
async post(url, body, contentType, extraHeaders) {
|
|
2818
|
+
if (this.stopped)
|
|
2819
|
+
return { ok: false, reason: "stopped" };
|
|
2820
|
+
const timestamp = Math.floor(Date.now() / 1000);
|
|
2821
|
+
try {
|
|
2822
|
+
const res = await fetch(url, {
|
|
2823
|
+
method: "POST",
|
|
2824
|
+
headers: {
|
|
2825
|
+
"Content-Type": contentType,
|
|
2826
|
+
"X-Slack-Request-Timestamp": String(timestamp),
|
|
2827
|
+
"X-Slack-Signature": slackSignature2(this.opts.signingSecret, timestamp, body),
|
|
2828
|
+
"User-Agent": "Slackbot 1.0 (+https://api.slack.com/robots)",
|
|
2829
|
+
...extraHeaders
|
|
2830
|
+
},
|
|
2831
|
+
body,
|
|
2832
|
+
signal: AbortSignal.any([
|
|
2833
|
+
AbortSignal.timeout(this.opts.timeoutMs),
|
|
2834
|
+
this.stopController.signal
|
|
2835
|
+
])
|
|
2836
|
+
});
|
|
2837
|
+
if (!res.ok) {
|
|
2838
|
+
await res.body?.cancel();
|
|
2839
|
+
return { ok: false, reason: "http_error" };
|
|
2840
|
+
}
|
|
2841
|
+
const text = await res.text();
|
|
2842
|
+
let payload;
|
|
2843
|
+
try {
|
|
2844
|
+
payload = text ? JSON.parse(text) : undefined;
|
|
2845
|
+
} catch {
|
|
2846
|
+
payload = undefined;
|
|
2847
|
+
}
|
|
2848
|
+
return { ok: true, payload, text };
|
|
2849
|
+
} catch (e) {
|
|
2850
|
+
const timedOut = e instanceof Error && (e.name === "TimeoutError" || e.name === "AbortError");
|
|
2851
|
+
return { ok: false, reason: timedOut ? "http_timeout" : "connection_failed" };
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
|
|
2856
|
+
// src/block-limits.ts
|
|
2857
|
+
var rec2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v) ? v : undefined;
|
|
2858
|
+
var arr2 = (v) => Array.isArray(v) ? v : [];
|
|
2859
|
+
var str3 = (v) => typeof v === "string" ? v : "";
|
|
2860
|
+
function cellChars(v) {
|
|
2861
|
+
const cell = rec2(v);
|
|
2862
|
+
if (!cell)
|
|
2863
|
+
return 0;
|
|
2864
|
+
if (cell.type === "action_cell")
|
|
2865
|
+
return str3(rec2(rec2(cell.element)?.text)?.text).length;
|
|
2866
|
+
if (typeof cell.text === "string")
|
|
2867
|
+
return cell.text.length;
|
|
2868
|
+
return arr2(cell.elements).reduce((n, e) => n + cellChars(e), 0);
|
|
2869
|
+
}
|
|
2870
|
+
function tableIssues(b, at, data) {
|
|
2871
|
+
const out = [];
|
|
2872
|
+
const rows = arr2(b.rows);
|
|
2873
|
+
const [minRows, maxRows, maxChars] = data ? [2, 201, 20000] : [1, 100, 1e4];
|
|
2874
|
+
if (rows.length < minRows || rows.length > maxRows)
|
|
2875
|
+
out.push(`rows must have between ${minRows} and ${maxRows} items [json-pointer:${at}/rows]`);
|
|
2876
|
+
const cellTypes = data ? ["raw_text", "raw_number", "rich_text", "action_cell"] : ["raw_text", "raw_number", "rich_text"];
|
|
2877
|
+
let chars = 0;
|
|
2878
|
+
rows.forEach((r, i) => {
|
|
2879
|
+
const cells = arr2(r);
|
|
2880
|
+
if (!Array.isArray(r) || cells.length < 1 || cells.length > 20)
|
|
2881
|
+
out.push(`row must have between 1 and 20 cells [json-pointer:${at}/rows/${i}]`);
|
|
2882
|
+
if (data && cells.length !== arr2(rows[0]).length)
|
|
2883
|
+
out.push(`all rows must have the same number of cells [json-pointer:${at}/rows/${i}]`);
|
|
2884
|
+
cells.forEach((c, j) => {
|
|
2885
|
+
const type = str3(rec2(c)?.type);
|
|
2886
|
+
if (!cellTypes.includes(type) || data && i === 0 && type === "rich_text")
|
|
2887
|
+
out.push(`invalid cell type "${type}" [json-pointer:${at}/rows/${i}/${j}]`);
|
|
2888
|
+
else if (type === "action_cell" && str3(rec2(rec2(c)?.element)?.type) !== "button")
|
|
2889
|
+
out.push(`action_cell element must be a button [json-pointer:${at}/rows/${i}/${j}/element]`);
|
|
2890
|
+
chars += cellChars(c);
|
|
2891
|
+
});
|
|
2892
|
+
});
|
|
2893
|
+
if (chars > maxChars)
|
|
2894
|
+
out.push(`cells must have at most ${maxChars} characters in total [json-pointer:${at}/rows]`);
|
|
2895
|
+
if (data) {
|
|
2896
|
+
if (!str3(b.caption))
|
|
2897
|
+
out.push(`caption is required [json-pointer:${at}/caption]`);
|
|
2898
|
+
const page = b.page_size;
|
|
2899
|
+
if (page !== undefined && !(Number.isInteger(page) && page >= 1 && page <= 100))
|
|
2900
|
+
out.push(`page_size must be an integer between 1 and 100 [json-pointer:${at}/page_size]`);
|
|
2901
|
+
} else if (arr2(b.column_settings).length > 20) {
|
|
2902
|
+
out.push(`column_settings must have at most 20 items [json-pointer:${at}/column_settings]`);
|
|
2903
|
+
}
|
|
2904
|
+
return { out, chars };
|
|
2905
|
+
}
|
|
2906
|
+
var label = (v) => str3(v).length >= 1 && str3(v).length <= 20;
|
|
2907
|
+
function chartIssues(b, at) {
|
|
2908
|
+
const out = [];
|
|
2909
|
+
const title = str3(b.title);
|
|
2910
|
+
if (title.length < 1 || title.length > 50)
|
|
2911
|
+
out.push(`title must have between 1 and 50 characters [json-pointer:${at}/title]`);
|
|
2912
|
+
const chart = rec2(b.chart);
|
|
2913
|
+
const type = str3(chart?.type);
|
|
2914
|
+
if (type === "pie") {
|
|
2915
|
+
const segments = arr2(chart?.segments);
|
|
2916
|
+
if (segments.length < 1 || segments.length > 12)
|
|
2917
|
+
out.push(`segments must have between 1 and 12 items [json-pointer:${at}/chart/segments]`);
|
|
2918
|
+
segments.forEach((s, i) => {
|
|
2919
|
+
const seg = rec2(s);
|
|
2920
|
+
if (!label(seg?.label) || !(typeof seg?.value === "number" && seg.value > 0))
|
|
2921
|
+
out.push(`segment needs a 1-20 character label and a value above 0 [json-pointer:${at}/chart/segments/${i}]`);
|
|
2922
|
+
});
|
|
2923
|
+
return out;
|
|
2924
|
+
}
|
|
2925
|
+
if (!["bar", "line", "area"].includes(type))
|
|
2926
|
+
return [...out, `chart type must be pie, bar, line or area [json-pointer:${at}/chart/type]`];
|
|
2927
|
+
const axis = rec2(chart?.axis_config);
|
|
2928
|
+
const categories = arr2(axis?.categories).map(str3);
|
|
2929
|
+
if (!categories.length)
|
|
2930
|
+
out.push(`axis_config.categories is required [json-pointer:${at}/chart/axis_config]`);
|
|
2931
|
+
categories.forEach((c, i) => {
|
|
2932
|
+
if (c.length > 20)
|
|
2933
|
+
out.push(`category must have at most 20 characters [json-pointer:${at}/chart/axis_config/categories/${i}]`);
|
|
2934
|
+
});
|
|
2935
|
+
for (const k of ["x_label", "y_label"])
|
|
2936
|
+
if (str3(axis?.[k]).length > 50)
|
|
2937
|
+
out.push(`${k} must have at most 50 characters [json-pointer:${at}/chart/axis_config/${k}]`);
|
|
2938
|
+
const series = arr2(chart?.series);
|
|
2939
|
+
if (series.length < 1 || series.length > 12)
|
|
2940
|
+
out.push(`series must have between 1 and 12 items [json-pointer:${at}/chart/series]`);
|
|
2941
|
+
const names = new Set;
|
|
2942
|
+
series.forEach((s, i) => {
|
|
2943
|
+
const sr = rec2(s);
|
|
2944
|
+
const name = str3(sr?.name);
|
|
2945
|
+
if (!label(name) || names.has(name))
|
|
2946
|
+
out.push(`series name must be unique and 1-20 characters [json-pointer:${at}/chart/series/${i}/name]`);
|
|
2947
|
+
names.add(name);
|
|
2948
|
+
const data = arr2(sr?.data).map((p) => rec2(p));
|
|
2949
|
+
const labels = data.map((p) => str3(p?.label));
|
|
2950
|
+
if (data.length < 1 || data.length > 20)
|
|
2951
|
+
out.push(`data must have between 1 and 20 items [json-pointer:${at}/chart/series/${i}/data]`);
|
|
2952
|
+
if (data.some((p) => !label(p?.label) || typeof p?.value !== "number"))
|
|
2953
|
+
out.push(`data points need a 1-20 character label and a number value [json-pointer:${at}/chart/series/${i}/data]`);
|
|
2954
|
+
const count = (c) => labels.filter((l) => l === c).length;
|
|
2955
|
+
if (labels.some((l) => !categories.includes(l)) || categories.some((c) => count(c) !== 1))
|
|
2956
|
+
out.push(`data labels must match axis_config.categories [json-pointer:${at}/chart/series/${i}/data]`);
|
|
2957
|
+
});
|
|
2958
|
+
return out;
|
|
2959
|
+
}
|
|
2960
|
+
function validateBlocks(blocks) {
|
|
2961
|
+
if (!blocks)
|
|
2962
|
+
return;
|
|
2963
|
+
const issues = [];
|
|
2964
|
+
if (blocks.length > 50)
|
|
2965
|
+
issues.push("must have at most 50 blocks");
|
|
2966
|
+
let charts = 0;
|
|
2967
|
+
const budget = { table: 0, data_table: 0 };
|
|
2968
|
+
blocks.forEach((v, i) => {
|
|
2969
|
+
const b = rec2(v);
|
|
2970
|
+
const at = `/blocks/${i}`;
|
|
2971
|
+
switch (str3(b?.type)) {
|
|
2972
|
+
case "table":
|
|
2973
|
+
case "data_table": {
|
|
2974
|
+
const t = tableIssues(b, at, b?.type === "data_table");
|
|
2975
|
+
issues.push(...t.out);
|
|
2976
|
+
budget[b?.type] += t.chars;
|
|
2977
|
+
break;
|
|
2978
|
+
}
|
|
2979
|
+
case "data_visualization":
|
|
2980
|
+
if (++charts > 2)
|
|
2981
|
+
issues.push(`at most 2 data_visualization blocks per message [json-pointer:${at}]`);
|
|
2982
|
+
issues.push(...chartIssues(b, at));
|
|
2983
|
+
break;
|
|
2984
|
+
}
|
|
2985
|
+
});
|
|
2986
|
+
if (budget.table > 1e4)
|
|
2987
|
+
issues.push("table cells must have at most 10000 characters in total per message");
|
|
2988
|
+
if (budget.data_table > 20000)
|
|
2989
|
+
issues.push("data_table cells must have at most 20000 characters in total per message");
|
|
2990
|
+
if (issues.length)
|
|
2991
|
+
throw new SlackApiError2("invalid_blocks", {
|
|
2992
|
+
response_metadata: { messages: issues.map((m) => `[ERROR] ${m}`) }
|
|
2993
|
+
});
|
|
2994
|
+
}
|
|
2995
|
+
|
|
2549
2996
|
// src/web-api.ts
|
|
2550
2997
|
function required(args, key) {
|
|
2551
2998
|
const v = str2(args, key);
|
|
@@ -2600,10 +3047,7 @@ function messageContent(args) {
|
|
|
2600
3047
|
const attachments = Array.isArray(args.attachments) ? args.attachments : undefined;
|
|
2601
3048
|
if (!text && !blocks?.length && !attachments?.length)
|
|
2602
3049
|
throw new SlackApiError2("no_text");
|
|
2603
|
-
|
|
2604
|
-
throw new SlackApiError2("invalid_blocks", {
|
|
2605
|
-
response_metadata: { messages: ["[ERROR] must have at most 50 blocks"] }
|
|
2606
|
-
});
|
|
3050
|
+
validateBlocks(blocks);
|
|
2607
3051
|
const metadata = args.metadata && typeof args.metadata === "object" ? args.metadata : undefined;
|
|
2608
3052
|
return {
|
|
2609
3053
|
text,
|
|
@@ -2720,6 +3164,7 @@ var handlers = {
|
|
|
2720
3164
|
}
|
|
2721
3165
|
if (args.blocks !== undefined) {
|
|
2722
3166
|
patch.blocks = Array.isArray(args.blocks) ? args.blocks : undefined;
|
|
3167
|
+
validateBlocks(patch.blocks);
|
|
2723
3168
|
if (existing.streaming_state !== undefined)
|
|
2724
3169
|
patch.stream_replaced = true;
|
|
2725
3170
|
}
|
|
@@ -2805,7 +3250,7 @@ var handlers = {
|
|
|
2805
3250
|
return types.has("private_channel");
|
|
2806
3251
|
return types.has("public_channel");
|
|
2807
3252
|
});
|
|
2808
|
-
const limit =
|
|
3253
|
+
const limit = num2(args, "limit", 100);
|
|
2809
3254
|
const start = cursorOffset(str2(args, "cursor"));
|
|
2810
3255
|
const slice = all.slice(start, start + limit);
|
|
2811
3256
|
const hasMore = start + limit < all.length;
|
|
@@ -2885,7 +3330,7 @@ var handlers = {
|
|
|
2885
3330
|
oldest: str2(args, "oldest"),
|
|
2886
3331
|
latest: str2(args, "latest"),
|
|
2887
3332
|
inclusive: bool(args, "inclusive"),
|
|
2888
|
-
limit:
|
|
3333
|
+
limit: num2(args, "limit", 100),
|
|
2889
3334
|
cursor: str2(args, "cursor")
|
|
2890
3335
|
});
|
|
2891
3336
|
return {
|
|
@@ -2905,7 +3350,7 @@ var handlers = {
|
|
|
2905
3350
|
oldest: str2(args, "oldest"),
|
|
2906
3351
|
latest: str2(args, "latest"),
|
|
2907
3352
|
inclusive: bool(args, "inclusive"),
|
|
2908
|
-
limit:
|
|
3353
|
+
limit: num2(args, "limit", 1000),
|
|
2909
3354
|
cursor: str2(args, "cursor")
|
|
2910
3355
|
});
|
|
2911
3356
|
return {
|
|
@@ -2954,7 +3399,7 @@ var handlers = {
|
|
|
2954
3399
|
},
|
|
2955
3400
|
"files.getUploadURLExternal": (ctx, args) => {
|
|
2956
3401
|
const filename = required(args, "filename");
|
|
2957
|
-
const length =
|
|
3402
|
+
const length = num2(args, "length", -1);
|
|
2958
3403
|
if (length < 0)
|
|
2959
3404
|
throw new SlackApiError2("invalid_arguments", {
|
|
2960
3405
|
response_metadata: { messages: ["[ERROR] missing required field: length"] }
|
|
@@ -3181,6 +3626,7 @@ var DEFAULT_EVENTS = [
|
|
|
3181
3626
|
class SlackMock2 {
|
|
3182
3627
|
store;
|
|
3183
3628
|
hub;
|
|
3629
|
+
delivery;
|
|
3184
3630
|
opts;
|
|
3185
3631
|
server;
|
|
3186
3632
|
triggerIds = new Map;
|
|
@@ -3208,6 +3654,7 @@ class SlackMock2 {
|
|
|
3208
3654
|
maxRetries: opts.maxRetries,
|
|
3209
3655
|
log: this.log
|
|
3210
3656
|
});
|
|
3657
|
+
this.delivery = opts.httpDelivery ? new HttpDelivery2({ log: this.log, ...opts.httpDelivery }) : this.hub;
|
|
3211
3658
|
this.subscribed = new Set(opts.subscribedEvents ?? manifest?.settings?.event_subscriptions?.bot_events ?? DEFAULT_EVENTS);
|
|
3212
3659
|
if (manifest?.features?.slash_commands)
|
|
3213
3660
|
this.commands = new Set(manifest.features.slash_commands.map((c) => c.command));
|
|
@@ -3301,20 +3748,22 @@ class SlackMock2 {
|
|
|
3301
3748
|
SLACK_BOT_TOKEN: this.store.bot.token,
|
|
3302
3749
|
SLACK_APP_TOKEN: this.store.bot.appToken,
|
|
3303
3750
|
SLACK_API_URL: this.apiUrl,
|
|
3304
|
-
SLACK_SIGNING_SECRET: "mock-signing-secret"
|
|
3751
|
+
SLACK_SIGNING_SECRET: this.opts.httpDelivery?.signingSecret ?? "mock-signing-secret"
|
|
3305
3752
|
};
|
|
3306
3753
|
}
|
|
3307
3754
|
get bot() {
|
|
3308
3755
|
return this.store.bot;
|
|
3309
3756
|
}
|
|
3310
3757
|
get connectionCount() {
|
|
3311
|
-
return this.
|
|
3758
|
+
return this.delivery.connectionCount;
|
|
3312
3759
|
}
|
|
3313
3760
|
get team() {
|
|
3314
3761
|
return this.store.team;
|
|
3315
3762
|
}
|
|
3316
3763
|
async stop() {
|
|
3317
3764
|
this.hub.shutdown();
|
|
3765
|
+
if (this.delivery instanceof HttpDelivery2)
|
|
3766
|
+
this.delivery.shutdown();
|
|
3318
3767
|
await Promise.allSettled([...this.inflight]);
|
|
3319
3768
|
this.server.stop(true);
|
|
3320
3769
|
}
|
|
@@ -3556,7 +4005,7 @@ class SlackMock2 {
|
|
|
3556
4005
|
const opts = {
|
|
3557
4006
|
screenshot,
|
|
3558
4007
|
refreshSec: Number.isFinite(refresh) && refresh > 0 ? refresh : undefined,
|
|
3559
|
-
connections: this.
|
|
4008
|
+
connections: this.delivery.connectionCount,
|
|
3560
4009
|
panelWidth: panel ? /^\d+$/.test(panel) ? `${panel}%` : /^\d+(px|%|vw|rem)$/.test(panel) ? panel : undefined : undefined,
|
|
3561
4010
|
threadView: url.searchParams.has("full") ? "full" : "panel",
|
|
3562
4011
|
live: url.searchParams.get("live") !== "0",
|
|
@@ -3632,7 +4081,7 @@ data: ${JSON.stringify(data)}
|
|
|
3632
4081
|
}
|
|
3633
4082
|
track(p) {
|
|
3634
4083
|
const wrapped = p.then(() => {}, (e) => {
|
|
3635
|
-
if (!(e instanceof SocketModeClosedError))
|
|
4084
|
+
if (!(e instanceof SocketModeClosedError || e instanceof HttpDeliveryStoppedError2))
|
|
3636
4085
|
this.log(`delivery failed: ${e instanceof Error ? e.message : e}`);
|
|
3637
4086
|
});
|
|
3638
4087
|
this.inflight.add(wrapped);
|
|
@@ -3640,14 +4089,14 @@ data: ${JSON.stringify(data)}
|
|
|
3640
4089
|
return wrapped;
|
|
3641
4090
|
}
|
|
3642
4091
|
push(event) {
|
|
3643
|
-
if (this.
|
|
4092
|
+
if (this.delivery.connectionCount === 0) {
|
|
3644
4093
|
this.log(`dropping ${event.type}${event.subtype ? `/${event.subtype}` : ""} event: no app connected`);
|
|
3645
4094
|
return Promise.resolve();
|
|
3646
4095
|
}
|
|
3647
4096
|
const send = async () => {
|
|
3648
4097
|
if (this.opts.eventDelayMs)
|
|
3649
4098
|
await Bun.sleep(this.opts.eventDelayMs);
|
|
3650
|
-
await this.
|
|
4099
|
+
await this.delivery.send("events_api", eventCallback(this.store, event));
|
|
3651
4100
|
};
|
|
3652
4101
|
return this.track(send());
|
|
3653
4102
|
}
|
|
@@ -3848,7 +4297,7 @@ data: ${JSON.stringify(data)}
|
|
|
3848
4297
|
responseUrl,
|
|
3849
4298
|
triggerId: this.issueTriggerId()
|
|
3850
4299
|
});
|
|
3851
|
-
const ack = await this.
|
|
4300
|
+
const ack = await this.delivery.send("slash_commands", payload, true);
|
|
3852
4301
|
let response;
|
|
3853
4302
|
const body = ack.payload;
|
|
3854
4303
|
if (body && (body.text || body.blocks)) {
|
|
@@ -3897,7 +4346,7 @@ data: ${JSON.stringify(data)}
|
|
|
3897
4346
|
}
|
|
3898
4347
|
]
|
|
3899
4348
|
});
|
|
3900
|
-
const ack = await this.
|
|
4349
|
+
const ack = await this.delivery.send("interactive", payload, true);
|
|
3901
4350
|
await this.flush();
|
|
3902
4351
|
return ack;
|
|
3903
4352
|
}
|
|
@@ -3914,7 +4363,7 @@ data: ${JSON.stringify(data)}
|
|
|
3914
4363
|
values: input.values,
|
|
3915
4364
|
triggerId: this.issueTriggerId()
|
|
3916
4365
|
});
|
|
3917
|
-
const ack = await this.
|
|
4366
|
+
const ack = await this.delivery.send("interactive", payload, true);
|
|
3918
4367
|
const response = ack.payload ?? {};
|
|
3919
4368
|
if (response.response_action === "errors") {
|
|
3920
4369
|
view.state = { values: input.values };
|
|
@@ -3960,14 +4409,14 @@ data: ${JSON.stringify(data)}
|
|
|
3960
4409
|
});
|
|
3961
4410
|
const threadTs = root.ts;
|
|
3962
4411
|
if (this.isSubscribed("assistant_thread_started")) {
|
|
3963
|
-
await this.track(this.
|
|
4412
|
+
await this.track(this.delivery.send("events_api", eventCallback(this.store, assistantThreadStartedEvent(this.store, dm, user.id, threadTs, input.context))));
|
|
3964
4413
|
}
|
|
3965
4414
|
return { channel: dm.id, thread_ts: threadTs };
|
|
3966
4415
|
}
|
|
3967
4416
|
async changeAssistantContext(input) {
|
|
3968
4417
|
const user = input.user ? this.user(input.user) : this.defaultHuman();
|
|
3969
4418
|
const dm = this.resolveChannel(input.channel);
|
|
3970
|
-
await this.track(this.
|
|
4419
|
+
await this.track(this.delivery.send("events_api", eventCallback(this.store, assistantThreadContextChangedEvent(this.store, dm, user.id, input.thread_ts, input.context))));
|
|
3971
4420
|
}
|
|
3972
4421
|
assistantThread(channel, thread_ts) {
|
|
3973
4422
|
return this.store.assistantThreads.get(`${this.resolveChannel(channel).id}:${thread_ts}`) ?? {};
|
|
@@ -3986,7 +4435,7 @@ data: ${JSON.stringify(data)}
|
|
|
3986
4435
|
this.faults.push({ ...fault, remaining: fault.times ?? 1 });
|
|
3987
4436
|
}
|
|
3988
4437
|
deliveries(name) {
|
|
3989
|
-
return name ? this.
|
|
4438
|
+
return name ? this.delivery.history.filter((d) => d.name === name) : [...this.delivery.history];
|
|
3990
4439
|
}
|
|
3991
4440
|
apiCalls(method) {
|
|
3992
4441
|
return method ? this.store.apiCalls.filter((c) => c.method === method) : [...this.store.apiCalls];
|
|
@@ -4055,7 +4504,7 @@ data: ${JSON.stringify(data)}
|
|
|
4055
4504
|
});
|
|
4056
4505
|
}
|
|
4057
4506
|
waitForConnection(timeoutMs = 15000) {
|
|
4058
|
-
return this.
|
|
4507
|
+
return this.delivery.waitForConnection(timeoutMs);
|
|
4059
4508
|
}
|
|
4060
4509
|
disconnectSockets(reason) {
|
|
4061
4510
|
this.hub.disconnectAll(reason);
|
|
@@ -4074,7 +4523,7 @@ data: ${JSON.stringify(data)}
|
|
|
4074
4523
|
team: this.store.team,
|
|
4075
4524
|
app: this.store.app,
|
|
4076
4525
|
bot: { userId: this.store.bot.userId, botId: this.store.bot.botId },
|
|
4077
|
-
connections: this.
|
|
4526
|
+
connections: this.delivery.connectionCount,
|
|
4078
4527
|
users: [...this.store.users.values()],
|
|
4079
4528
|
channels: [...this.store.channels.values()]
|
|
4080
4529
|
});
|
|
@@ -4236,4 +4685,4 @@ async function frames2(opts) {
|
|
|
4236
4685
|
}
|
|
4237
4686
|
}
|
|
4238
4687
|
|
|
4239
|
-
export { SlackApiError2, Store2, SlackMock2, frames2 };
|
|
4688
|
+
export { SlackApiError2, Store2, slackSignature2, HttpDeliveryError2, HttpDeliveryStoppedError2, HttpDelivery2, SlackMock2, frames2 };
|