@vercel/board 0.43.0 → 0.44.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/dist/access.d.mts +2 -2
- package/dist/{auth-Bn8J_1F2.d.mts → auth-C8jxty0C.d.mts} +1 -1
- package/dist/{backend-DMrK55mU.d.mts → backend-_3W_5g6y.d.mts} +3 -3
- package/dist/backend-local.d.mts +1 -1
- package/dist/backend-local.mjs +1 -1
- package/dist/{bots-CGkO76qH.mjs → bots-CLKKMgYf.mjs} +6 -1
- package/dist/{chat-provider-CPZg2MQb.mjs → chat-provider-DZ4DsAZ7.mjs} +6 -4
- package/dist/{chat-provider-Cgkh9xJw.d.mts → chat-provider-HQo68RWL.d.mts} +4 -4
- package/dist/cli-commands.d.mts +1 -1
- package/dist/cli-commands.mjs +1 -1
- package/dist/cli-embedded.d.mts +2 -2
- package/dist/cli-embedded.mjs +2 -2
- package/dist/cli.mjs +6 -6
- package/dist/{commands-C4fR0md0.mjs → commands-B75pBXIV.mjs} +1 -1
- package/dist/{commands-BlM-ckFS.d.mts → commands-DHGZWeSZ.d.mts} +1 -1
- package/dist/{conformance-BORt5nky.mjs → conformance-CHqXZoGe.mjs} +66 -0
- package/dist/conformance.d.mts +1 -1
- package/dist/conformance.mjs +1 -1
- package/dist/{data-values-C-Cq80hz.mjs → data-values-CoTP0SQG.mjs} +43 -54
- package/dist/{engine-BVHSH2Kn.mjs → engine-D07DTYSi.mjs} +16 -9
- package/dist/{events-BT8y_81j.mjs → events-voButVQW.mjs} +3 -1
- package/dist/{exports-S2AJNE_O.mjs → exports-BNk4w-b2.mjs} +10 -12
- package/dist/exports-DFwXKst5.d.mts +4 -0
- package/dist/{index-CydxnBND.d.mts → index-CwOOIT0e.d.mts} +2 -2
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +2 -2
- package/dist/index.node.d.mts +6 -6
- package/dist/index.node.mjs +1 -1
- package/dist/inspect/app.js +94 -94
- package/dist/inspect/engine.js +5 -5
- package/dist/inspect-DBLdh9NM.mjs +2 -0
- package/dist/{inspect-ByIt7CxV.mjs → inspect-dtQlHBcq.mjs} +1 -1
- package/dist/{local-0TVbQkzW.mjs → local-CnGNTReZ.mjs} +3 -1
- package/dist/{main-CM0_uZ7w.mjs → main-CpsAmpEy.mjs} +22 -37
- package/dist/origin-D4ER_Tze.mjs +428 -0
- package/dist/{provider-dY54GFNz.d.mts → provider-CVI-DlWl.d.mts} +27 -2
- package/dist/{routes-By9lmvUD.d.mts → routes-CErTwlSZ.d.mts} +3 -1
- package/dist/{origin-DoRR9yql.mjs → routes-DrByOCc1.mjs} +4 -426
- package/dist/schemas.mjs +1 -1
- package/dist/{serve-p_KKFTWm.mjs → serve-BQT5quKD.mjs} +2 -2
- package/dist/{server-CD7qe_Pl.mjs → server-FlDE6BDt.mjs} +4 -3
- package/dist/sync-chat-sdk.d.mts +2 -2
- package/dist/sync-chat-sdk.mjs +2 -2
- package/dist/sync-github.d.mts +2 -2
- package/dist/sync-github.mjs +2 -2
- package/dist/sync-linear.d.mts +3 -3
- package/dist/sync-linear.mjs +3 -3
- package/dist/sync-slack.d.mts +27 -4
- package/dist/sync-slack.mjs +206 -10
- package/dist/sync.d.mts +3 -3
- package/dist/sync.mjs +1 -1
- package/docs/02-sync/02-functions.md +4 -1
- package/docs/02-sync/03-slack.md +24 -1
- package/docs/02-sync/04-github.md +5 -2
- package/docs/02-sync/06-providers.md +1 -1
- package/docs/04-reference/01-cli.md +2 -2
- package/docs/04-reference/02-board.md +1 -1
- package/docs/04-reference/03-http.md +9 -3
- package/docs/04-reference/05-conformance.md +2 -3
- package/package.json +3 -1
- package/dist/exports-Bw_OYNRl.d.mts +0 -4
- package/dist/inspect-BjDlPHjE.mjs +0 -2
package/dist/sync-slack.mjs
CHANGED
|
@@ -1,11 +1,118 @@
|
|
|
1
1
|
import { f as MESSAGE_TEXT_MAX } from "./schemas-DAzSsgWk.mjs";
|
|
2
2
|
import "./external-DymyhUzl.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-
|
|
3
|
+
import { d as opensBlock, i as eventSchema, l as UnreadableError, p as channels, r as envelope } from "./events-voButVQW.mjs";
|
|
4
|
+
import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-DZ4DsAZ7.mjs";
|
|
5
|
+
import { r as formatVercelDeployments } from "./bots-CLKKMgYf.mjs";
|
|
5
6
|
import { z } from "zod";
|
|
6
7
|
import { stringifyMarkdown } from "chat";
|
|
7
8
|
import { createSlackAdapter } from "@chat-adapter/slack";
|
|
8
9
|
import { connectSlackAdapter } from "@vercel/connect/chat";
|
|
10
|
+
//#region src/sync/slack-deployments.ts
|
|
11
|
+
/** The most text Slack takes across a message's `markdown` blocks. */
|
|
12
|
+
const MARKDOWN_MAX = 12e3;
|
|
13
|
+
/** The most notification text Slack takes: an edit over 4,000 characters is refused. */
|
|
14
|
+
const TEXT_MAX = 3900;
|
|
15
|
+
/** The most rows Slack shows on a table's page, which is all of ours. */
|
|
16
|
+
const ROWS_MAX = 100;
|
|
17
|
+
const raw = (text) => ({
|
|
18
|
+
type: "raw_text",
|
|
19
|
+
text: text || " "
|
|
20
|
+
});
|
|
21
|
+
/** A cell of formatted text: an emoji, a link, a date. */
|
|
22
|
+
const rich = (...elements) => ({
|
|
23
|
+
type: "rich_text",
|
|
24
|
+
elements: [{
|
|
25
|
+
type: "rich_text_section",
|
|
26
|
+
elements
|
|
27
|
+
}]
|
|
28
|
+
});
|
|
29
|
+
const link = (text, url) => ({
|
|
30
|
+
type: "link",
|
|
31
|
+
text,
|
|
32
|
+
url
|
|
33
|
+
});
|
|
34
|
+
/** The dot Vercel shows beside a deployment's status, as the emoji Slack has for it. One it doesn't know is white. */
|
|
35
|
+
const DOT = {
|
|
36
|
+
ready: "large_green_circle",
|
|
37
|
+
building: "large_yellow_circle",
|
|
38
|
+
initializing: "large_yellow_circle",
|
|
39
|
+
error: "red_circle",
|
|
40
|
+
failed: "red_circle",
|
|
41
|
+
canceled: "black_circle"
|
|
42
|
+
};
|
|
43
|
+
const dot = (status) => DOT[status.toLowerCase()] ?? "white_circle";
|
|
44
|
+
/** A deployment Vercel didn't build: its comment folds those away under the table. */
|
|
45
|
+
const skippedBy = (deployment) => deployment.skipped || deployment.status.toLowerCase() === "ignored";
|
|
46
|
+
const markdownLink = (text, url) => url ? `[${text}](${url})` : text;
|
|
47
|
+
/**
|
|
48
|
+
* A message that lists Vercel's deployments, for Slack, with the list as the table Vercel posts
|
|
49
|
+
* on a pull request: Project, Deployment (its status beside its color, linking to its page),
|
|
50
|
+
* Actions (its preview), and Updated (how long ago). The text around the list stays markdown in
|
|
51
|
+
* its place, the deployments Vercel skipped are a line under the table, and `text` says it all in
|
|
52
|
+
* plain words, which is what a notification shows.
|
|
53
|
+
*
|
|
54
|
+
* Null when the markdown doesn't have the list as board writes it (a renderer wrote its own), when
|
|
55
|
+
* Vercel built none of them, or when it's more than Slack takes: it goes out as that markdown.
|
|
56
|
+
*/
|
|
57
|
+
function deploymentsLayout(markdown, deployments, as = {}) {
|
|
58
|
+
const list = formatVercelDeployments(deployments);
|
|
59
|
+
const at = markdown.indexOf(list);
|
|
60
|
+
const built = deployments.filter((deployment) => !skippedBy(deployment));
|
|
61
|
+
const skipped = deployments.filter(skippedBy);
|
|
62
|
+
if (at === -1 || built.length === 0 || built.length > ROWS_MAX) return null;
|
|
63
|
+
const dated = built.some((deployment) => deployment.updatedAt || deployment.updated);
|
|
64
|
+
const rows = [[
|
|
65
|
+
raw("Project"),
|
|
66
|
+
raw("Deployment"),
|
|
67
|
+
raw("Actions"),
|
|
68
|
+
...dated ? [raw("Updated")] : []
|
|
69
|
+
], ...built.map((deployment) => [
|
|
70
|
+
deployment.projectUrl ? rich(link(deployment.project, deployment.projectUrl)) : raw(deployment.project),
|
|
71
|
+
rich({
|
|
72
|
+
type: "emoji",
|
|
73
|
+
name: dot(deployment.status)
|
|
74
|
+
}, {
|
|
75
|
+
type: "text",
|
|
76
|
+
text: " "
|
|
77
|
+
}, deployment.deploymentUrl ? link(deployment.status, deployment.deploymentUrl) : {
|
|
78
|
+
type: "text",
|
|
79
|
+
text: deployment.status
|
|
80
|
+
}),
|
|
81
|
+
deployment.previewUrl ? rich(link("Preview", deployment.previewUrl)) : raw(""),
|
|
82
|
+
...dated ? [deployment.updatedAt ? rich({
|
|
83
|
+
type: "date",
|
|
84
|
+
timestamp: Math.floor(Date.parse(deployment.updatedAt) / 1e3),
|
|
85
|
+
format: "{ago}",
|
|
86
|
+
fallback: deployment.updated ?? deployment.updatedAt
|
|
87
|
+
}) : raw(deployment.updated ?? "")] : []
|
|
88
|
+
])];
|
|
89
|
+
const before = markdown.slice(0, at).trim();
|
|
90
|
+
const after = [skipped.length ? `${skipped.length} skipped: ${skipped.map((deployment) => markdownLink(deployment.project, deployment.projectUrl)).join(", ")}` : "", markdown.slice(at + list.length).trim()].filter(Boolean).join("\n\n");
|
|
91
|
+
if (before.length + after.length > MARKDOWN_MAX) return null;
|
|
92
|
+
const prose = (text) => text ? [{
|
|
93
|
+
type: "markdown",
|
|
94
|
+
text: as.markdown?.(text) ?? text
|
|
95
|
+
}] : [];
|
|
96
|
+
const said = Array.from([
|
|
97
|
+
before && (as.mrkdwn?.(before) ?? before),
|
|
98
|
+
built.map((deployment) => `${deployment.project}: ${deployment.status}`).join(", "),
|
|
99
|
+
after && (as.mrkdwn?.(after) ?? after)
|
|
100
|
+
].filter(Boolean).join("\n"));
|
|
101
|
+
return {
|
|
102
|
+
text: said.length > TEXT_MAX ? `${said.slice(0, 3899).join("")}…` : said.join(""),
|
|
103
|
+
blocks: [
|
|
104
|
+
...prose(before),
|
|
105
|
+
{
|
|
106
|
+
type: "data_table",
|
|
107
|
+
caption: "Vercel deployments",
|
|
108
|
+
page_size: built.length,
|
|
109
|
+
rows
|
|
110
|
+
},
|
|
111
|
+
...prose(after)
|
|
112
|
+
]
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
9
116
|
//#region src/sync/slack.ts
|
|
10
117
|
/** The most characters Slack shows of a message's username. */
|
|
11
118
|
const USERNAME_MAX = 80;
|
|
@@ -24,9 +131,29 @@ function slackUsername({ name, attribution = "" }) {
|
|
|
24
131
|
}
|
|
25
132
|
return `${cut.trimEnd()}…${attribution}`;
|
|
26
133
|
}
|
|
27
|
-
/**
|
|
134
|
+
/**
|
|
135
|
+
* Text as the adapter gives it to Slack, so the text around a table reads as it does in any
|
|
136
|
+
* message (a bare `@name` a mention, an emoji by its Slack name): markdown as the adapter posts
|
|
137
|
+
* it, and its older mrkdwn, which a message's notification text is.
|
|
138
|
+
*/
|
|
139
|
+
const textOf = (adapter) => ({
|
|
140
|
+
markdown: (markdown) => {
|
|
141
|
+
const payload = adapter.formatConverter?.toSlackPayload?.call(adapter.formatConverter, { markdown });
|
|
142
|
+
return payload && "markdown_text" in payload ? payload.markdown_text : markdown;
|
|
143
|
+
},
|
|
144
|
+
mrkdwn: (markdown) => adapter.formatConverter?.toResponseUrlText?.call(adapter.formatConverter, { markdown }) ?? markdown
|
|
145
|
+
});
|
|
146
|
+
/** Slack's answers that mean "not this layout", before anything is sent or changed: the message goes out as markdown instead. */
|
|
147
|
+
const LAYOUT_REFUSED = /* @__PURE__ */ new Set([
|
|
148
|
+
"invalid_blocks",
|
|
149
|
+
"invalid_blocks_format",
|
|
150
|
+
"msg_blocks_too_long",
|
|
151
|
+
"block_mismatch"
|
|
152
|
+
]);
|
|
153
|
+
const layoutRefused = (error) => LAYOUT_REFUSED.has(error?.data?.error ?? "");
|
|
154
|
+
/** The `**name**: ` a message's text opens with (on a line of its own before a block), taken out when Slack shows the name as the sender. */
|
|
28
155
|
function withoutLabel(markdown, name) {
|
|
29
|
-
const label = new RegExp(`^\\*\\*${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\*\\*: `);
|
|
156
|
+
const label = new RegExp(`^\\*\\*${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\*\\*:(?: |\n\n)`);
|
|
30
157
|
return markdown.replace(label, "");
|
|
31
158
|
}
|
|
32
159
|
/** HTML elements GitHub renders in comments; anything else in angle brackets (`<@U123>`, `<https://…>`, `a < b`) is left alone. */
|
|
@@ -167,7 +294,7 @@ function forwardText(links) {
|
|
|
167
294
|
return links.filter((link) => link.snapshot).map((link) => {
|
|
168
295
|
const { author, text } = link.snapshot;
|
|
169
296
|
const lines = text.trim() ? text.trim().split("\n") : [""];
|
|
170
|
-
return [
|
|
297
|
+
return [...opensBlock(lines[0]) ? [`> **${author}**:`, `> ${lines[0]}`] : [`> **${author}**: ${lines[0]}`], ...lines.slice(1).map((line) => `> ${line}`)].map((line) => line.trimEnd()).concat("", link.url).join("\n");
|
|
171
298
|
}).join("\n\n");
|
|
172
299
|
}
|
|
173
300
|
/** Slack's answers that mean "no files from this app", not "try again". */
|
|
@@ -676,11 +803,15 @@ var SlackProvider = class extends ChatSyncProvider {
|
|
|
676
803
|
* the app, label and all.
|
|
677
804
|
*/
|
|
678
805
|
async post(target, kind, body) {
|
|
679
|
-
const { as, ...given } = body;
|
|
806
|
+
const { as, deployments, ...given } = body;
|
|
680
807
|
const post = {
|
|
681
808
|
...given,
|
|
682
809
|
markdown: withoutHtml(given.markdown)
|
|
683
810
|
};
|
|
811
|
+
if (deployments && !post.files?.length) {
|
|
812
|
+
const laidOut = await this.postDeployments(target, as, post.markdown, deployments);
|
|
813
|
+
if (laidOut) return laidOut;
|
|
814
|
+
}
|
|
684
815
|
if (kind === "channel" && post.files?.length && post.markdown.trim()) {
|
|
685
816
|
const sent = await this.postWithFiles(target, post.markdown, post.files);
|
|
686
817
|
if (sent) return sent;
|
|
@@ -743,16 +874,81 @@ var SlackProvider = class extends ChatSyncProvider {
|
|
|
743
874
|
}
|
|
744
875
|
/** An edit keeps the label out only where the message went out under its author's name. */
|
|
745
876
|
async edit(thread, message, body) {
|
|
746
|
-
const { as, ...given } = body;
|
|
877
|
+
const { as, deployments, ...given } = body;
|
|
747
878
|
const post = {
|
|
748
879
|
...given,
|
|
749
880
|
markdown: withoutHtml(given.markdown)
|
|
750
881
|
};
|
|
751
|
-
const
|
|
752
|
-
await super.edit(thread, message, named && as ? {
|
|
882
|
+
const edited = (as && await this.web().then((web) => !!web && this.canCustomize(web), () => false) ? await this.sentAs(thread, message, as) : false) && as ? {
|
|
753
883
|
...post,
|
|
754
884
|
markdown: withoutLabel(post.markdown, as.name)
|
|
755
|
-
} : post
|
|
885
|
+
} : post;
|
|
886
|
+
if (deployments && !edited.files && await this.editDeployments(thread, message, edited.markdown, deployments)) return;
|
|
887
|
+
await super.edit(thread, message, edited);
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* Vercel's deployment comment goes out with its deployments as the table Vercel posts on a
|
|
891
|
+
* pull request, the text around them as markdown, under its author's name where the app may
|
|
892
|
+
* set one. Null, with nothing sent, when board has no client to post with, the markdown isn't
|
|
893
|
+
* one board can lay out, or Slack won't take the layout: it goes out as markdown, a line each.
|
|
894
|
+
*/
|
|
895
|
+
async postDeployments(target, as, markdown, deployments) {
|
|
896
|
+
if (!deploymentsLayout(markdown, deployments)) return null;
|
|
897
|
+
const adapter = await this.ready();
|
|
898
|
+
const web = await this.web().catch(() => void 0);
|
|
899
|
+
if (!web?.chat) return null;
|
|
900
|
+
const username = as ? slackUsername(as) : null;
|
|
901
|
+
const named = as && username !== null && await this.canCustomize(web) ? {
|
|
902
|
+
username,
|
|
903
|
+
icon: slackIcon(as.avatar),
|
|
904
|
+
name: as.name
|
|
905
|
+
} : null;
|
|
906
|
+
const threadId = this.toChat(target);
|
|
907
|
+
const { channel, threadTs } = adapter.decodeThreadId(threadId);
|
|
908
|
+
const message = { markdown: named ? withoutLabel(markdown, named.name) : markdown };
|
|
909
|
+
const layout = deploymentsLayout((await adapter.resolveMessageMentions?.(message, threadId) ?? message).markdown, deployments, textOf(adapter));
|
|
910
|
+
if (!layout) return null;
|
|
911
|
+
const sent = await web.chat.postMessage({
|
|
912
|
+
channel,
|
|
913
|
+
...threadTs ? { thread_ts: threadTs } : {},
|
|
914
|
+
...layout,
|
|
915
|
+
unfurl_links: false,
|
|
916
|
+
unfurl_media: false,
|
|
917
|
+
...named ? {
|
|
918
|
+
username: named.username,
|
|
919
|
+
...named.icon ? { icon_url: named.icon } : {}
|
|
920
|
+
} : {}
|
|
921
|
+
}).catch((error) => {
|
|
922
|
+
if (layoutRefused(error)) return null;
|
|
923
|
+
throw error;
|
|
924
|
+
});
|
|
925
|
+
if (!sent) return null;
|
|
926
|
+
if (!sent.ts) throw new Error("slack: chat.postMessage returned no ts");
|
|
927
|
+
return {
|
|
928
|
+
thread: this.toNative(`${adapter.name}:${channel}:${threadTs || sent.ts}`),
|
|
929
|
+
message: sent.ts
|
|
930
|
+
};
|
|
931
|
+
}
|
|
932
|
+
/** An edit to that comment: its text and table, replaced. False, with nothing changed, where a post would be null, or board's client can't edit. */
|
|
933
|
+
async editDeployments(thread, message, markdown, deployments) {
|
|
934
|
+
if (!deploymentsLayout(markdown, deployments)) return false;
|
|
935
|
+
const adapter = await this.ready();
|
|
936
|
+
const web = await this.web().catch(() => void 0);
|
|
937
|
+
if (!web?.chat?.update) return false;
|
|
938
|
+
const threadId = this.toChat(thread);
|
|
939
|
+
const layout = deploymentsLayout((await adapter.resolveMessageMentions?.({ markdown }, threadId) ?? { markdown }).markdown, deployments, textOf(adapter));
|
|
940
|
+
if (!layout) return false;
|
|
941
|
+
try {
|
|
942
|
+
await web.chat.update({
|
|
943
|
+
channel: adapter.decodeThreadId(threadId).channel,
|
|
944
|
+
ts: message,
|
|
945
|
+
...layout
|
|
946
|
+
});
|
|
947
|
+
} catch (error) {
|
|
948
|
+
if (layoutRefused(error)) return false;
|
|
949
|
+
throw error;
|
|
950
|
+
}
|
|
951
|
+
return true;
|
|
756
952
|
}
|
|
757
953
|
async postNamed(target, as, markdown) {
|
|
758
954
|
const adapter = await this.ready();
|
package/dist/sync.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { A as SyncRoot, C as mirror, D as RootOverride, E as ProviderEvent, M as eventSchema, O as SyncOverrides, S as into, T as EventBase, _ as SyncFn, a as ProviderOptions, b as SyncUnit, c as Receive, d as Renderer, f as ResolvedTarget, g as Sync, h as UnreadableError, i as ProviderFile, j as envelope, k as SyncResult, l as ReceivedEvent, m as SyncProvider, n as FileDelivery, o as ProviderPost, p as SyncContext, r as ProviderDelivery, u as RenderInput, v as SyncIn, w as render, x as channels, y as SyncOut } from "./provider-
|
|
3
|
-
export { EventBase, type ExternalAuthor, ExternalEvent, type ExternalFile, type FileDelivery, type ProviderDelivery, type ProviderEvent, type ProviderFile, type ProviderOptions, type ProviderPost, type Receive, ReceivedEvent, type RenderInput, type Renderer, ResolvedTarget, type RootOverride, type Sync, type SyncContext, type SyncFn, type SyncIn, type SyncOut, SyncOverrides, SyncProvider, type SyncResult, type SyncRoot, type SyncUnit, UnreadableError, channels, envelope, eventSchema, into, mirror, render };
|
|
1
|
+
import { cn as ExternalEvent, ln as ExternalFile, sn as ExternalAuthor } from "./routes-CErTwlSZ.mjs";
|
|
2
|
+
import { A as SyncRoot, C as mirror, D as RootOverride, E as ProviderEvent, M as eventSchema, N as VercelDeployment, O as SyncOverrides, S as into, T as EventBase, _ as SyncFn, a as ProviderOptions, b as SyncUnit, c as Receive, d as Renderer, f as ResolvedTarget, g as Sync, h as UnreadableError, i as ProviderFile, j as envelope, k as SyncResult, l as ReceivedEvent, m as SyncProvider, n as FileDelivery, o as ProviderPost, p as SyncContext, r as ProviderDelivery, u as RenderInput, v as SyncIn, w as render, x as channels, y as SyncOut } from "./provider-CVI-DlWl.mjs";
|
|
3
|
+
export { EventBase, type ExternalAuthor, ExternalEvent, type ExternalFile, type FileDelivery, type ProviderDelivery, type ProviderEvent, type ProviderFile, type ProviderOptions, type ProviderPost, type Receive, ReceivedEvent, type RenderInput, type Renderer, ResolvedTarget, type RootOverride, type Sync, type SyncContext, type SyncFn, type SyncIn, type SyncOut, SyncOverrides, SyncProvider, type SyncResult, type SyncRoot, type SyncUnit, UnreadableError, type VercelDeployment, channels, envelope, eventSchema, into, mirror, render };
|
package/dist/sync.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { n as ExternalEvent } from "./external-DymyhUzl.mjs";
|
|
2
|
-
import { c as SyncProvider,
|
|
2
|
+
import { c as SyncProvider, g as render, h as mirror, i as eventSchema, l as UnreadableError, m as into, n as SyncOverrides, o as ReceivedEvent, p as channels, r as envelope, s as ResolvedTarget, t as EventBase } from "./events-voButVQW.mjs";
|
|
3
3
|
export { EventBase, ExternalEvent, ReceivedEvent, ResolvedTarget, SyncOverrides, SyncProvider, UnreadableError, channels, envelope, eventSchema, into, mirror, render };
|
|
@@ -324,7 +324,10 @@ slack('slack/acme', render(({ message }) => message.text, channels({ '#prs': 'pr
|
|
|
324
324
|
The default is `**${label}**: ${message.text}`, where the label is the author's
|
|
325
325
|
name, through their principal when they have a profile, and the platform a message
|
|
326
326
|
came from: `claude via julian`, `ada (slack)`, or `Malte via support (slack)` for
|
|
327
|
-
a platform user another sync speaks for.
|
|
327
|
+
a platform user another sync speaks for. A text that opens a block (a code
|
|
328
|
+
block, a list, a heading, a quote, or a table) goes on a line of its own under
|
|
329
|
+
that label, where it's still one, and under yours when your renderer opens with
|
|
330
|
+
the same label. board still adds a line per attachment the platform
|
|
328
331
|
didn't take, and resolves mentions to the platform's own form after your
|
|
329
332
|
renderer runs, against this sync's own users
|
|
330
333
|
([mentions](../01-board/03-identity.md#mentions)).
|
package/docs/02-sync/03-slack.md
CHANGED
|
@@ -101,7 +101,7 @@ most once a minute, while the other channels sync.
|
|
|
101
101
|
- **Typing:** `team.typing('812', 'running tests…')`, or
|
|
102
102
|
`vb typing 812 running tests…`, sets the thread's status in Slack, under the
|
|
103
103
|
thread, until the app posts or about two minutes pass. The status is at most
|
|
104
|
-
|
|
104
|
+
50 characters; without one, Slack shows "Typing…".
|
|
105
105
|
|
|
106
106
|
## Messages post under their author's name
|
|
107
107
|
|
|
@@ -138,6 +138,29 @@ thread whose root carries files, since a file upload can't set a sender. An
|
|
|
138
138
|
edit leaves the label out only where Slack shows the message under its
|
|
139
139
|
author's name, which it asks Slack only on an app that may name senders.
|
|
140
140
|
|
|
141
|
+
## Vercel's deployments show as a table
|
|
142
|
+
|
|
143
|
+
When [GitHub syncs too](./04-github.md#vercels-deployment-comment), Vercel's
|
|
144
|
+
deployment comment on a pull request shows in Slack as the table Vercel posts
|
|
145
|
+
on GitHub:
|
|
146
|
+
|
|
147
|
+
| Column | Shows |
|
|
148
|
+
| --- | --- |
|
|
149
|
+
| Project | The project, linking to its page on Vercel |
|
|
150
|
+
| Deployment | Its status beside its color (green for Ready, yellow for Building, red for Error), linking to the deployment's page |
|
|
151
|
+
| Actions | A link to the preview, when there is one |
|
|
152
|
+
| Updated | How long ago, which Slack keeps current |
|
|
153
|
+
|
|
154
|
+
It's one message per pull request. Vercel edits its comment as builds move
|
|
155
|
+
from Building to Ready, and the table is replaced in place. The deployments
|
|
156
|
+
Vercel skipped are a line under it (`1 skipped: docs`), and a notification
|
|
157
|
+
says the same in plain words (`web: Ready, docs: Building`).
|
|
158
|
+
|
|
159
|
+
The message goes out as a line per deployment instead, as it does on other
|
|
160
|
+
platforms, when Slack won't take the table, when a
|
|
161
|
+
[renderer](./02-functions.md#render) of yours writes the deployments its
|
|
162
|
+
own way, or when it goes out with files.
|
|
163
|
+
|
|
141
164
|
## Files
|
|
142
165
|
|
|
143
166
|
**From Slack:** a file posted in a synced thread becomes a board attachment. When
|
|
@@ -167,8 +167,11 @@ failed fetch retries the event. A [function](./02-functions.md) that doesn't cal
|
|
|
167
167
|
`vercel[bot]`'s deployment comment, which it edits as builds move from Building to
|
|
168
168
|
Ready, shows as one line per deployment: status, project, preview link, and when
|
|
169
169
|
it was updated. That form appears in `vb read`, `vb tail`, and the copies sync
|
|
170
|
-
posts to
|
|
171
|
-
it unchanged.
|
|
170
|
+
posts to other platforms. The board stores what the bot wrote; `--json` and the
|
|
171
|
+
API return it unchanged.
|
|
172
|
+
|
|
173
|
+
In Slack it's [Vercel's own table](./03-slack.md#vercels-deployments-show-as-a-table),
|
|
174
|
+
one message that follows the comment's edits.
|
|
172
175
|
|
|
173
176
|
## botUserId
|
|
174
177
|
|
|
@@ -207,7 +207,7 @@ sync: {
|
|
|
207
207
|
| `receive(key, request, emit)` | Authenticates the request, then emits normalized `{ event, raw, dedupe }` records, and answers what the platform expects. |
|
|
208
208
|
| `resolveChannel(name)` | Turns a channel's name (`'#prs'`, `'support'`) into the platform's channel ID: what `sync.resolve` and `channels` use. Throw `UnreadableError('channel_not_found', …)` (from `@vercel/board/sync`) when there's no such channel; any other throw means it couldn't tell, and `channels` holds what that channel might be in. |
|
|
209
209
|
| `resolveTarget(target)` | Turns a sync target into `{ target, channel, kind }`, where `kind` is `channel` or `thread`. |
|
|
210
|
-
| `post(target, kind, body)` | Posts `body` (`{ markdown, files?, as? }`) and returns `{ thread, message, files? }`. `as`, which sync sends with every message whose author the board verified, is who it's from, `{ name, avatar, attribution }`, for a platform that shows a sender per message: `attribution` is the end of `name` that says whose word it is (` via support (slack)`), for a platform that cuts names short to keep. `markdown` opens with `**name**: ` unless a renderer left it out. |
|
|
210
|
+
| `post(target, kind, body)` | Posts `body` (`{ markdown, files?, as?, deployments? }`) and returns `{ thread, message, files? }`. `deployments` comes with [Vercel's deployment comment](./04-github.md#vercels-deployment-comment), whose `markdown` already lists them a line each, for a platform that lays them out itself. `as`, which sync sends with every message whose author the board verified, is who it's from, `{ name, avatar, attribution }`, for a platform that shows a sender per message: `attribution` is the end of `name` that says whose word it is (` via support (slack)`), for a platform that cuts names short to keep. `markdown` opens with `**name**: ` unless a renderer left it out. |
|
|
211
211
|
| `event(context)` | Builds the typed envelope sync functions read as `sync.event`, usually `envelope(…)` parsed by an `eventSchema`. |
|
|
212
212
|
|
|
213
213
|
**IDs.** Incoming locations (`channel`, `thread`, `subthread`) carry the entry's key
|
|
@@ -27,7 +27,7 @@ The CLI makes no HTTP calls of its own: every command goes through
|
|
|
27
27
|
does. Help, usage, and errors use the name it's given. It has every command but
|
|
28
28
|
[`inspect`](#inspect) and [`serve`](#serve), which run something on this
|
|
29
29
|
machine, so an app that bundles it brings neither the inspector nor a local
|
|
30
|
-
board.
|
|
30
|
+
board.
|
|
31
31
|
|
|
32
32
|
```ts
|
|
33
33
|
import { createApp } from '@vercel/board/cli'
|
|
@@ -864,7 +864,7 @@ vb typing <id> [status]
|
|
|
864
864
|
```
|
|
865
865
|
|
|
866
866
|
Shows typing in every platform thread the message's thread is synced to,
|
|
867
|
-
through the sync the board runs. Slack shows the status (up to
|
|
867
|
+
through the sync the board runs. Slack shows the status (up to 50 characters)
|
|
868
868
|
in place of "Typing…". Nothing is written to the log.
|
|
869
869
|
`--json` prints the threads that took it.
|
|
870
870
|
|
|
@@ -309,7 +309,7 @@ typing(id: string, status?: string): Promise<string[]>
|
|
|
309
309
|
Shows typing in the platform threads the message's thread is synced to, and
|
|
310
310
|
returns the threads that took it. The board that keeps the log shows it through
|
|
311
311
|
the sync it runs, so the CLI's handle shows it on the board it links. It needs
|
|
312
|
-
`post` where the thread is. Slack shows `status` (up to
|
|
312
|
+
`post` where the thread is. Slack shows `status` (up to 50 characters) in place of
|
|
313
313
|
"Typing…". Nothing goes in the log.
|
|
314
314
|
|
|
315
315
|
### schedule
|
|
@@ -462,11 +462,17 @@ const [found] = findBlocks(text)
|
|
|
462
462
|
const problem = found.problem ?? checkValue(definition, found.data) // 'id must be a string'
|
|
463
463
|
```
|
|
464
464
|
|
|
465
|
+
`checkValue` takes what Vercel's API takes, so a value gets one answer on
|
|
466
|
+
every board. A format is read as ajv-formats 2.1.1 reads it in its full mode:
|
|
467
|
+
a `uri` is RFC 3986's, an `ipv4` address may have a leading zero, and a
|
|
468
|
+
`time`'s leap second is the day's last. It also reads `items` as a list of
|
|
469
|
+
schemas, one for each place, which Vercel's registry holds.
|
|
470
|
+
|
|
465
471
|
Anyone the board lets in reads the schemas, whatever channels they read.
|
|
466
472
|
Registering needs `manage` at `*`. On Vercel's board, schemas are the team's:
|
|
467
|
-
every board on the team shares one registry, people and apps whose team
|
|
468
|
-
is owner, member, or developer register
|
|
469
|
-
|
|
473
|
+
every board on the team shares one registry, and people and apps whose team
|
|
474
|
+
role is owner, member, or developer register. A deployment's own credentials
|
|
475
|
+
read them and register none. It checks a
|
|
470
476
|
definition more strictly: it also refuses a `required` name the schema's
|
|
471
477
|
`properties` don't declare, and a keyword for one type, such as `minLength`,
|
|
472
478
|
with no `type` that says it.
|
|
@@ -144,15 +144,14 @@ Then the rest, a group each in the report:
|
|
|
144
144
|
| `schemas` | lists the built-in schemas first and reads `git-commit@1` by its ID, with 404 `schema_not_found` and 400 `invalid_schema_id` for one that isn't there and an ID that names none. Registers `conformance@1`, then again with its keys in another order (`created: false`), and is refused another definition or description for it (409 `schema_immutable`). Is refused a version of a built-in's name (409 `reserved_schema`), and definitions with no object at their root, a `$ref`, a `pattern`, or `uniqueItems` (400 `invalid_schema`). Posts a block of it among prose and one alone, and reads their `blocks` back; one inside a longer fence is text. Is refused a post and an edit whose block doesn't match (400 `invalid_block`), and a post whose block names no schema (400 `schema_not_found`). A caller narrowed to the channel reads them and registers none. The checks that register are skipped for a token that can't |
|
|
145
145
|
| `attachments` | uploads a file, posts it, and downloads it |
|
|
146
146
|
| `watchers` | registers a tail, pulls the match for a post, and acks it. Skipped when the token already has watchers or a sync registered there, since registering replaces them, and on credentials Vercel's API takes no watchers from: anything but a deployment's own (403 `watchers_need_project`) |
|
|
147
|
-
| `sync` | imports a message as a platform user of its own (`conformance:user:<id>`), finds it by its platform IDs, imports it again to the same message, refuses a second root from the same platform thread, records a receipt and reads the copy back, lists where the thread is synced with it, answers 404 for a link no sync there knows, and deletes it. Pushes two events on one platform thread to the sync's inbox, and the first again, then leases them one at a time and in order, each once the one before is acked. Pulls the sync's `@sync` match for a post. Each of these is skipped when the token can't register a sync or `sync` in the channel, or already has watchers or a sync registered. Then, registering nothing: reads a post's and a reply's `noSync` back |
|
|
147
|
+
| `sync` | imports a message as a platform user of its own (`conformance:user:<id>`), finds it by its platform IDs, imports it again to the same message, refuses a second root from the same platform thread, records a receipt and reads the copy back, lists where the thread is synced with it, answers 404 for a link no sync there knows, and deletes it. Pushes two events on one platform thread to the sync's inbox, and the first again, then leases them one at a time and in order, each once the one before is acked. Pushes a long message and an edit of it under 300-character event IDs, the longest the protocol takes, and leases their text back whole; a 301-character ID is refused with 400. Pulls the sync's `@sync` match for a post. Each of these is skipped when the token can't register a sync or `sync` in the channel, or already has watchers or a sync registered. Then, registering nothing: reads a post's and a reply's `noSync` back |
|
|
148
148
|
|
|
149
149
|
Every board answers all of them: see
|
|
150
150
|
[the whole protocol](./03-http.md#the-whole-protocol). A board may keep no
|
|
151
151
|
schedules, grants, schemas, or files, and say so: one that answers
|
|
152
152
|
one of those groups' checks with a 501 has it skipped, `not kept here`, with
|
|
153
153
|
what the board said. A board that's meant to keep them and doesn't yet answers
|
|
154
|
-
otherwise, and fails
|
|
155
|
-
on Vercel's boards until its API lets a project read its team's schemas.
|
|
154
|
+
otherwise, and fails.
|
|
156
155
|
Vercel's API reads who writes as boards did before, so a run there fails two
|
|
157
156
|
core checks until it reads `x-board-profile` as a structured header and its
|
|
158
157
|
avatar from there alone: the profile it shows is the whole header, and the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/board",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"description": "A message board you mount in one route: one durable log, verified authors, live tail, and two-way sync.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -93,6 +93,8 @@
|
|
|
93
93
|
"@types/react-dom": "^19.3.0",
|
|
94
94
|
"@vercel/connect": "^2.3.4",
|
|
95
95
|
"ai": "^7.0.130",
|
|
96
|
+
"ajv": "8.17.1",
|
|
97
|
+
"ajv-formats": "2.1.1",
|
|
96
98
|
"chat": "^4.41.1",
|
|
97
99
|
"experimental-a2": "0.24.0",
|
|
98
100
|
"github-slugger": "^2.0.0",
|