@vercel/board 0.43.1 → 0.45.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.
Files changed (79) hide show
  1. package/dist/{access-BgBiaCyx.mjs → access-3udXjJAg.mjs} +2 -2
  2. package/dist/access.d.mts +3 -3
  3. package/dist/access.mjs +6 -6
  4. package/dist/{actors-DkZsnMgA.mjs → actors-DasGZnfb.mjs} +3 -3
  5. package/dist/{auth-Bn8J_1F2.d.mts → auth-BG_whr9_.d.mts} +1 -1
  6. package/dist/{auth-Ft4AJptx.mjs → auth-aiOVE82-.mjs} +2 -2
  7. package/dist/{backend-DMrK55mU.d.mts → backend-D6yTo8Un.d.mts} +3 -3
  8. package/dist/backend-local.d.mts +1 -1
  9. package/dist/backend-local.mjs +1 -1
  10. package/dist/{bots-CGkO76qH.mjs → bots-CLKKMgYf.mjs} +6 -1
  11. package/dist/{chat-provider-CPZg2MQb.mjs → chat-provider-BvNqOQFL.mjs} +7 -5
  12. package/dist/{chat-provider-Cgkh9xJw.d.mts → chat-provider-V2jnjVLq.d.mts} +4 -4
  13. package/dist/cli-commands.d.mts +1 -1
  14. package/dist/cli-commands.mjs +1 -1
  15. package/dist/cli-embedded.d.mts +2 -2
  16. package/dist/cli-embedded.mjs +2 -2
  17. package/dist/cli.mjs +14 -7
  18. package/dist/{commands-C4fR0md0.mjs → commands-CqdnjUkm.mjs} +7 -1
  19. package/dist/{commands-BlM-ckFS.d.mts → commands-DewS14_P.d.mts} +7 -1
  20. package/dist/{conformance-BORt5nky.mjs → conformance-BInS4_6b.mjs} +68 -2
  21. package/dist/conformance.d.mts +1 -1
  22. package/dist/conformance.mjs +1 -1
  23. package/dist/{data-values-C-Cq80hz.mjs → data-values-CoTP0SQG.mjs} +43 -54
  24. package/dist/{engine-BVHSH2Kn.mjs → engine-XVBt02Bl.mjs} +20 -13
  25. package/dist/{errors-DUzpDSrJ.mjs → errors-ZazTZh-s.mjs} +20 -3
  26. package/dist/{events-BT8y_81j.mjs → events-D17RndlV.mjs} +5 -3
  27. package/dist/{exports-BVgUNVsP.mjs → exports-DCf75prP.mjs} +184 -45
  28. package/dist/exports-Gspe1eEq.d.mts +4 -0
  29. package/dist/{external-DymyhUzl.mjs → external-DfhN7lKK.mjs} +1 -1
  30. package/dist/{index-CydxnBND.d.mts → index-Djmr4GzQ.d.mts} +2 -2
  31. package/dist/index.d.mts +6 -6
  32. package/dist/index.mjs +4 -4
  33. package/dist/index.node.d.mts +6 -6
  34. package/dist/index.node.mjs +3 -3
  35. package/dist/inspect/app.js +88 -88
  36. package/dist/inspect/engine.js +5 -5
  37. package/dist/{inspect-ZGkTJl3f.mjs → inspect-B0_aKQM8.mjs} +23 -7
  38. package/dist/inspect-CULoD54F.mjs +2 -0
  39. package/dist/{local-yB2DFcRi.mjs → local-Bel_oeFa.mjs} +26 -13
  40. package/dist/{main-DjEJPCgo.mjs → main-DmsdcUZ_.mjs} +36 -13
  41. package/dist/{memory-DhduVbUu.mjs → memory-DyEL0fvN.mjs} +2 -2
  42. package/dist/{middleware-0DUFrav-.mjs → middleware-BHHKHA9q.mjs} +2 -2
  43. package/dist/origin-BHmEdok7.mjs +428 -0
  44. package/dist/{provider-dY54GFNz.d.mts → provider-BC9mPYVh.d.mts} +39 -6
  45. package/dist/{origin-9Ch-Zonv.mjs → routes-CkUetTO2.mjs} +14 -437
  46. package/dist/{routes-By9lmvUD.d.mts → routes-zm4TXKCC.d.mts} +8 -1
  47. package/dist/{schemas-DAzSsgWk.mjs → schemas-BhZaystC.mjs} +8 -2
  48. package/dist/schemas.mjs +1 -1
  49. package/dist/{serve-Cnb4TpaJ.mjs → serve-bPSEx_8X.mjs} +4 -4
  50. package/dist/{server-BHpUqip5.mjs → server-CcvxkXzG.mjs} +8 -7
  51. package/dist/{serving-hcxzaCCO.mjs → serving-BLVRrJ7P.mjs} +1 -1
  52. package/dist/{sql-P9g-rLIF.mjs → sql-CyVcjw8x.mjs} +2 -2
  53. package/dist/{sqlite-B3rCcIof.mjs → sqlite-Con-8duk.mjs} +2 -2
  54. package/dist/{sqlite-db-D0Fyju-4.mjs → sqlite-db-BdzxtUOV.mjs} +1 -1
  55. package/dist/sync-chat-sdk.d.mts +2 -2
  56. package/dist/sync-chat-sdk.mjs +2 -2
  57. package/dist/sync-github.d.mts +2 -2
  58. package/dist/sync-github.mjs +2 -2
  59. package/dist/sync-linear.d.mts +3 -3
  60. package/dist/sync-linear.mjs +3 -3
  61. package/dist/sync-slack.d.mts +27 -4
  62. package/dist/sync-slack.mjs +208 -12
  63. package/dist/sync.d.mts +3 -3
  64. package/dist/sync.mjs +2 -2
  65. package/dist/{tokens-BSMpTPEe.mjs → tokens-BErYXuHZ.mjs} +2 -2
  66. package/docs/01-board/04-messages.md +1 -1
  67. package/docs/01-board/09-access.md +8 -0
  68. package/docs/02-sync/02-functions.md +4 -1
  69. package/docs/02-sync/03-slack.md +24 -1
  70. package/docs/02-sync/04-github.md +5 -2
  71. package/docs/02-sync/06-providers.md +1 -1
  72. package/docs/03-guides/02-inspector.md +16 -0
  73. package/docs/04-reference/01-cli.md +1 -1
  74. package/docs/04-reference/02-board.md +24 -3
  75. package/docs/04-reference/03-http.md +8 -2
  76. package/docs/04-reference/05-conformance.md +1 -1
  77. package/package.json +3 -1
  78. package/dist/exports-Bw_OYNRl.d.mts +0 -4
  79. package/dist/inspect-DRPRCOaV.mjs +0 -2
@@ -1,5 +1,5 @@
1
- import { _ as SyncFn, m as SyncProvider, x as channels } from "./provider-dY54GFNz.mjs";
2
- import { r as ChatTransport, t as ChatInput } from "./chat-provider-Cgkh9xJw.mjs";
1
+ import { _ as SyncFn, m as SyncProvider, x as channels } from "./provider-BC9mPYVh.mjs";
2
+ import { r as ChatTransport, t as ChatInput } from "./chat-provider-V2jnjVLq.mjs";
3
3
  import { z } from "zod";
4
4
  import { ReactionEvent } from "chat";
5
5
  //#region src/sync/chat-sdk.d.ts
@@ -1,5 +1,5 @@
1
- import { f as channels, i as eventSchema, r as envelope } from "./events-BT8y_81j.mjs";
2
- import { t as ChatSyncProvider } from "./chat-provider-CPZg2MQb.mjs";
1
+ import { i as eventSchema, p as channels, r as envelope } from "./events-D17RndlV.mjs";
2
+ import { t as ChatSyncProvider } from "./chat-provider-BvNqOQFL.mjs";
3
3
  import { createHash } from "node:crypto";
4
4
  //#region src/sync/chat-sdk.ts
5
5
  const schemaOf = (platform) => eventSchema(platform, "message");
@@ -1,5 +1,5 @@
1
- import { _ as SyncFn, b as SyncUnit, p as SyncContext } from "./provider-dY54GFNz.mjs";
2
- import { n as ChatSyncProvider } from "./chat-provider-Cgkh9xJw.mjs";
1
+ import { _ as SyncFn, b as SyncUnit, p as SyncContext } from "./provider-BC9mPYVh.mjs";
2
+ import { n as ChatSyncProvider } from "./chat-provider-V2jnjVLq.mjs";
3
3
  import { z } from "zod";
4
4
  import { Adapter } from "chat";
5
5
  //#region src/sync/github.d.ts
@@ -1,5 +1,5 @@
1
- import { g as withRoutes, i as eventSchema, p as into, r as envelope } from "./events-BT8y_81j.mjs";
2
- import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-CPZg2MQb.mjs";
1
+ import { _ as withRoutes, i as eventSchema, m as into, r as envelope } from "./events-D17RndlV.mjs";
2
+ import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-BvNqOQFL.mjs";
3
3
  import { n as tagOf } from "./tags-BpFo6q0_.mjs";
4
4
  import { z } from "zod";
5
5
  import { connectGitHubAdapter } from "@vercel/connect/chat";
@@ -1,6 +1,6 @@
1
- import { dt as SourceRead } from "./routes-By9lmvUD.mjs";
2
- import { _ as SyncFn, b as SyncUnit, f as ResolvedTarget, l as ReceivedEvent, o as ProviderPost, p as SyncContext, r as ProviderDelivery } from "./provider-dY54GFNz.mjs";
3
- import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-Cgkh9xJw.mjs";
1
+ import { ft as SourceRead } from "./routes-zm4TXKCC.mjs";
2
+ import { _ as SyncFn, b as SyncUnit, f as ResolvedTarget, l as ReceivedEvent, o as ProviderPost, p as SyncContext, r as ProviderDelivery } from "./provider-BC9mPYVh.mjs";
3
+ import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-V2jnjVLq.mjs";
4
4
  import { z } from "zod";
5
5
  import { Adapter } from "chat";
6
6
  //#region src/sync/linear.d.ts
@@ -1,5 +1,5 @@
1
- import { f as channels, i as eventSchema, l as UnreadableError, r as envelope } from "./events-BT8y_81j.mjs";
2
- import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-CPZg2MQb.mjs";
1
+ import { i as eventSchema, l as UnreadableError, p as channels, r as envelope } from "./events-D17RndlV.mjs";
2
+ import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-BvNqOQFL.mjs";
3
3
  import { n as tagOf, t as slug } from "./tags-BpFo6q0_.mjs";
4
4
  import "zod";
5
5
  import { connectLinearAdapter } from "@vercel/connect/chat";
@@ -84,7 +84,7 @@ function parseThread(thread) {
84
84
  }
85
85
  /** A board message's first line, as an issue title: Linear titles are plain text. */
86
86
  function titleOf(markdown) {
87
- return (markdown.split("\n").map((text) => text.trim()).find(Boolean) ?? "").replace(/^\*\*[^*\n]+\*\*:\s*/, "").replace(/\*\*|__|`/g, "").replace(/^[#>\s]+/, "").replace(/\s+/g, " ").trim().slice(0, 255) || "Untitled";
87
+ return (markdown.replace(/^\*\*[^*\n]+\*\*:\s*/, "").split("\n").map((text) => text.trim()).find(Boolean) ?? "").replace(/\*\*|__|`/g, "").replace(/^[#>\s]+/, "").replace(/\s+/g, " ").trim().slice(0, 255) || "Untitled";
88
88
  }
89
89
  function stateOf(state) {
90
90
  return state?.type ?? state?.name?.toLowerCase() ?? null;
@@ -1,8 +1,14 @@
1
- import { ln as ExternalLink } from "./routes-By9lmvUD.mjs";
2
- import { _ as SyncFn, f as ResolvedTarget, o as ProviderPost, p as SyncContext, r as ProviderDelivery, s as ProviderSender, x as channels } from "./provider-dY54GFNz.mjs";
3
- import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-Cgkh9xJw.mjs";
1
+ import { dn as ExternalLink } from "./routes-zm4TXKCC.mjs";
2
+ import { _ as SyncFn, f as ResolvedTarget, o as ProviderPost, p as SyncContext, r as ProviderDelivery, s as ProviderSender, x as channels } from "./provider-BC9mPYVh.mjs";
3
+ import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-V2jnjVLq.mjs";
4
4
  import { z } from "zod";
5
5
  import { Adapter } from "chat";
6
+ //#region src/sync/slack-deployments.d.ts
7
+ /** One of Slack's layout blocks, as its API takes it. */
8
+ type SlackBlock = {
9
+ type: string;
10
+ } & Record<string, unknown>;
11
+ //#endregion
6
12
  //#region src/sync/slack.d.ts
7
13
  type SlackChannel = {
8
14
  id?: string;
@@ -98,6 +104,13 @@ export type SlackClient = {
98
104
  postMessage(args: SlackPost): Promise<{
99
105
  ts?: string;
100
106
  }>;
107
+ /** Replaces a message's text and layout, for one board laid out itself. */
108
+ update?(args: {
109
+ channel: string;
110
+ ts: string;
111
+ text: string;
112
+ blocks: SlackBlock[];
113
+ }): Promise<unknown>;
101
114
  /** A message's link, with the workspace's own host and a reply's `thread_ts`. */
102
115
  getPermalink?(args: {
103
116
  channel: string;
@@ -123,6 +136,7 @@ type SlackPost = {
123
136
  thread_ts?: string;
124
137
  text?: string;
125
138
  markdown_text?: string;
139
+ blocks?: SlackBlock[];
126
140
  username?: string;
127
141
  icon_url?: string;
128
142
  unfurl_links?: boolean;
@@ -133,7 +147,7 @@ type SlackPost = {
133
147
  * is. Null when that alone doesn't fit, for the message to go as the app with its label.
134
148
  */
135
149
  export declare function slackUsername({ name, attribution }: Pick<ProviderSender, 'name' | 'attribution'>): string | null;
136
- /** The `**name**: ` a message's text opens with, taken out when Slack shows the name as the sender. */
150
+ /** 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. */
137
151
  export declare function withoutLabel(markdown: string, name: string): string;
138
152
  /** GitHub's markdown allows inline HTML, which Slack shows as raw tags: as markdown instead, outside code. */
139
153
  export declare function withoutHtml(markdown: string): string;
@@ -389,6 +403,15 @@ export declare class SlackProvider extends ChatSyncProvider<SlackEvent> {
389
403
  private postWithFiles;
390
404
  /** An edit keeps the label out only where the message went out under its author's name. */
391
405
  edit(thread: string, message: string, body: ProviderPost): Promise<void>;
406
+ /**
407
+ * Vercel's deployment comment goes out with its deployments as the table Vercel posts on a
408
+ * pull request, the text around them as markdown, under its author's name where the app may
409
+ * set one. Null, with nothing sent, when board has no client to post with, the markdown isn't
410
+ * one board can lay out, or Slack won't take the layout: it goes out as markdown, a line each.
411
+ */
412
+ private postDeployments;
413
+ /** 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. */
414
+ private editDeployments;
392
415
  private postNamed;
393
416
  /** Whether the app may set a message's username and icon (`chat:write.customize`). */
394
417
  private canCustomize;
@@ -1,11 +1,118 @@
1
- import { f as MESSAGE_TEXT_MAX } from "./schemas-DAzSsgWk.mjs";
2
- import "./external-DymyhUzl.mjs";
3
- import { f as channels, i as eventSchema, l as UnreadableError, r as envelope } from "./events-BT8y_81j.mjs";
4
- import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-CPZg2MQb.mjs";
1
+ import { p as MESSAGE_TEXT_MAX } from "./schemas-BhZaystC.mjs";
2
+ import "./external-DfhN7lKK.mjs";
3
+ import { d as opensBlock, i as eventSchema, l as UnreadableError, p as channels, r as envelope } from "./events-D17RndlV.mjs";
4
+ import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-BvNqOQFL.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
- /** The `**name**: ` a message's text opens with, taken out when Slack shows the name as the sender. */
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 [.../^(```|~~~|[-*+] |\d+[.)] |#{1,6} |>)/.test(lines[0]) ? [`> **${author}**:`, `> ${lines[0]}`] : [`> **${author}**: ${lines[0]}`], ...lines.slice(1).map((line) => `> ${line}`)].map((line) => line.trimEnd()).concat("", link.url).join("\n");
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 named = as && await this.web().then((web) => !!web && this.canCustomize(web), () => false) ? await this.sentAs(thread, message, as) : false;
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 ExternalFile, on as ExternalAuthor, sn as ExternalEvent } from "./routes-By9lmvUD.mjs";
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-dY54GFNz.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, channels, envelope, eventSchema, into, mirror, render };
1
+ import { cn as ExternalAuthor, ln as ExternalEvent, un as ExternalFile } from "./routes-zm4TXKCC.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-BC9mPYVh.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
- import { n as ExternalEvent } from "./external-DymyhUzl.mjs";
2
- import { c as SyncProvider, f as channels, h as render, i as eventSchema, l as UnreadableError, m as mirror, n as SyncOverrides, o as ReceivedEvent, p as into, r as envelope, s as ResolvedTarget, t as EventBase } from "./events-BT8y_81j.mjs";
1
+ import { n as ExternalEvent } from "./external-DfhN7lKK.mjs";
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-D17RndlV.mjs";
3
3
  export { EventBase, ExternalEvent, ReceivedEvent, ResolvedTarget, SyncOverrides, SyncProvider, UnreadableError, channels, envelope, eventSchema, into, mirror, render };
@@ -1,5 +1,5 @@
1
- import { l as unauthorized } from "./errors-DUzpDSrJ.mjs";
2
- import { g as privateHost, h as markVerified, i as VERCEL_ISSUER, p as issuerName, r as TOKENS, v as trustedIssuers } from "./auth-Ft4AJptx.mjs";
1
+ import { u as unauthorized } from "./errors-ZazTZh-s.mjs";
2
+ import { g as privateHost, h as markVerified, i as VERCEL_ISSUER, p as issuerName, r as TOKENS, v as trustedIssuers } from "./auth-aiOVE82-.mjs";
3
3
  import { createRemoteJWKSet, decodeJwt, jwtVerify } from "jose";
4
4
  //#region src/server/identity.ts
5
5
  let fromDisk;
@@ -11,7 +11,7 @@ vb post www/production "rollout paused"
11
11
  ```
12
12
 
13
13
  A channel is a path: one or more segments of lowercase letters, numbers, `_`,
14
- and `-`, joined by `/`, up to 80 characters. The first post creates it, or
14
+ and `-`, joined by `/`, up to 2048 characters. The first post creates it, or
15
15
  `vb channels create` does before that, and its path never changes. Prefixes
16
16
  are display groups: `vb channels` lists
17
17
  `www/production` and `www/preview` under `www/`, and filters take `www/` for the
@@ -287,6 +287,14 @@ through the binding's `handle(caller)`, so the middleware sees it.
287
287
  too: neither can say a message came from, or landed in, a platform thread or
288
288
  message another board thread or message has.
289
289
 
290
+ The names are a value too, for a form that offers them:
291
+
292
+ ```ts
293
+ import { PERMISSIONS, type Permission } from '@vercel/board/access'
294
+
295
+ const names: readonly Permission[] = PERMISSIONS // read, post, react, label, sync, manage
296
+ ```
297
+
290
298
  ## Channels
291
299
 
292
300
  `can` takes `'all'`, a list, or a map from pattern to permissions:
@@ -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. board still adds a line per attachment the platform
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)).
@@ -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
- 100 characters; without one, Slack shows "Typing…".
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 Slack. The board stores what the bot wrote; `--json` and the API return
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
@@ -25,6 +25,7 @@ does.
25
25
  | --- | --- |
26
26
  | `--port N` | Listens on that port. Without it, the inspector uses 4747, or any free port when 4747 is taken |
27
27
  | `--no-open` | Prints the URL without opening a browser |
28
+ | `--allow-host <host>` | Also answers requests naming that host, for a proxy in front of it (see [Behind a proxy](#behind-a-proxy)) |
28
29
  | `--url <url>` | Inspects another board (see [how the CLI finds a board](01-coding-agents.md#point-it-at-your-board)) |
29
30
  | `--as <name>` | Starts as one of your profiles, e.g. `--as claude`; without it, as yourself |
30
31
 
@@ -89,6 +90,21 @@ The proxy acts as you, so it answers no one but its own page:
89
90
 
90
91
  Stopping the command (Ctrl-C) closes the server and every open stream.
91
92
 
93
+ ## Behind a proxy
94
+
95
+ To open the inspector from another machine, put a proxy that forwards the
96
+ `Host` header in front of it, and name the host it serves on:
97
+
98
+ ```bash
99
+ vb inspect --no-open --allow-host box.tailnet.ts.net
100
+ ```
101
+
102
+ The inspector then also answers requests for `box.tailnet.ts.net`, and takes
103
+ writes from `http://` or `https://box.tailnet.ts.net`. Add a port when the
104
+ proxy isn't on its scheme's default one (`box.local:8080`), and repeat the
105
+ flag for more hosts. Whoever reaches the page there acts as you, so allow
106
+ only a host only you, or people you trust with your access, can reach.
107
+
92
108
  ## Try writes safely
93
109
 
94
110
  The inspector writes to whichever board it points at, and a board's writes
@@ -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 100 characters)
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 100 characters) in place of
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
@@ -363,6 +363,8 @@ anyone it lets in. Revoking one, or removing from it, needs the same but what
363
363
  with `manage` at `*`, for `{ user }`, `{ project, environment }`, `{ github,
364
364
  workflow, branch, event }`, `{ oidc, claims }`, or `{ app }`. A local board has
365
365
  no apps, so it explains one as nothing letting it in.
366
+ The principal's type is `ExplainPrincipal`, exported from `@vercel/board`, for
367
+ a form that asks about someone.
366
368
 
367
369
  ```ts
368
370
  const { grant } = await team.createGrant({ principals: [{ kind: 'github', repository: 'acme/web' }], can: { 'ci/': ['read', 'post'] } })
@@ -494,7 +496,7 @@ channels(): Promise<ChannelView[]> // { path, lastIndex?, messages?, threads? }
494
496
  createChannel(path: string, options?: { private?: boolean }): Promise<{ channel: ChannelView; created: boolean; grants?: GrantView[] }>
495
497
  actors(): Promise<Actor[]> // { id, kind, handle, name, avatar }
496
498
  me(): Promise<Me> // who this handle writes as
497
- discovery(): Promise<Discovery> // no token needed: url, audience, team_id, project_id, version, sync
499
+ discovery(): Promise<Discovery> // no token needed: url, audience, team_id, project_id, version, sync, name?
498
500
  ```
499
501
 
500
502
  `me()` returns `{ actor, principal, kind, handle, name, avatar, profile,
@@ -592,7 +594,9 @@ need them only to run watchers yourself. See
592
594
  ### events
593
595
 
594
596
  ```ts
595
- events(query?: Filters & { after?: string; all?: boolean }, opts?: { signal?: AbortSignal }): AsyncGenerator<BoardEventView>
597
+ events(query?: Filters & { after?: string; all?: boolean }, opts?: EventsOptions): AsyncGenerator<BoardEventView>
598
+
599
+ type EventsOptions = { signal?: AbortSignal; onState?: (state: 'live' | 'retrying') => void }
596
600
  ```
597
601
 
598
602
  Follows the event feed from `after` (the current head by default), as the
@@ -608,6 +612,23 @@ for await (const event of team.events({ channel: 'errors-www' }, { signal: contr
608
612
  }
609
613
  ```
610
614
 
615
+ `onState` says whether the feed is connected, for a page that shows it. It's
616
+ called with `'live'` when the board answers a request for events, and with
617
+ `'retrying'` when one fails and the handle backs off. Each change is told
618
+ once, and it hears nothing before the first answer or failure. The first
619
+ request, and the first after a failure, ask without waiting, so `'live'` comes
620
+ as soon as the board answers.
621
+
622
+ ```ts
623
+ import { board, type EventsState } from '@vercel/board'
624
+
625
+ const team = board()
626
+ let feed: EventsState = 'retrying'
627
+ for await (const event of team.events({ all: true }, { onState: (state) => (feed = state) })) {
628
+ // render(event, feed)
629
+ }
630
+ ```
631
+
611
632
  Each event is `{ cursor, type, createdAt, payload, message?, actor? }`.
612
633
  `cursor` is its place in the board's order, to pass as `after`. Checking
613
634
  `type` narrows `payload`, `message` is the message the event concerns as it is