@vercel/board 0.56.1 → 0.57.1

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 (96) hide show
  1. package/README.md +1 -1
  2. package/dist/{access-HzqFpgL_.mjs → access-CZ419Vho.mjs} +1 -1
  3. package/dist/access.d.mts +2 -2
  4. package/dist/access.mjs +4 -4
  5. package/dist/{actors-D-u6bitG.mjs → actors-CXMWplob.mjs} +2 -2
  6. package/dist/{auth-D9ycDQK0.mjs → auth-AwZJQpCO.mjs} +2 -2
  7. package/dist/{auth-ULldUvir.d.mts → auth-C0Mla9OU.d.mts} +1 -1
  8. package/dist/{backend-BHN6GTjB.d.mts → backend-BuqwQbb4.d.mts} +6 -22
  9. package/dist/backend-local.d.mts +1 -1
  10. package/dist/backend-local.mjs +1 -1
  11. package/dist/backend-postgres/blob-vercel.d.mts +8 -0
  12. package/dist/backend-postgres/blob-vercel.mjs +81 -0
  13. package/dist/backend-postgres/scheduler-vercel.d.mts +2 -0
  14. package/dist/backend-postgres/scheduler-vercel.mjs +2 -0
  15. package/dist/backend-postgres.d.mts +74 -0
  16. package/dist/backend-postgres.mjs +3229 -0
  17. package/dist/blob-DjS53D1A.d.mts +35 -0
  18. package/dist/{chat-provider-F7UqWVZK.d.mts → chat-provider-CpYdXEpI.d.mts} +2 -2
  19. package/dist/cli-commands.d.mts +1 -1
  20. package/dist/cli-commands.mjs +1 -1
  21. package/dist/cli-embedded.d.mts +2 -2
  22. package/dist/cli-embedded.mjs +2 -2
  23. package/dist/cli.mjs +6 -6
  24. package/dist/{client-CFHunEFn.d.mts → client-B0DGOt7P.d.mts} +1 -1
  25. package/dist/{commands-DLPIX7Jw.d.mts → commands-Dcm4_pc1.d.mts} +3 -3
  26. package/dist/{commands-7FY_8p92.mjs → commands-DeYAQUcP.mjs} +10 -5
  27. package/dist/{conformance-BNiLcKra.mjs → conformance-EtEq22w1.mjs} +2 -2
  28. package/dist/conformance.d.mts +1 -1
  29. package/dist/conformance.mjs +1 -1
  30. package/dist/{engine-C8wCzkw-.mjs → engine-CfVTyEeo.mjs} +3 -3
  31. package/dist/errors-DBZtbfph.d.mts +19 -0
  32. package/dist/{errors-DDfXnZ2b.mjs → errors-DjatfYjl.mjs} +220 -18
  33. package/dist/{exports-DSX-CI5c.mjs → exports-B_UGnrnN.mjs} +187 -62
  34. package/dist/{exports-BBmjHyCB.d.mts → exports-BvJTIorX.d.mts} +5 -4
  35. package/dist/{index-Ce3SDZ3Y.d.mts → index-DuibwQf9.d.mts} +2 -2
  36. package/dist/index.d.mts +6 -5
  37. package/dist/index.mjs +4 -4
  38. package/dist/index.node.d.mts +7 -6
  39. package/dist/index.node.mjs +4 -4
  40. package/dist/inspect/app.js +126 -146
  41. package/dist/inspect/engine.js +3 -3
  42. package/dist/inspect/sheet-presentation.js +1 -0
  43. package/dist/{inspect-C-vDnB_n.mjs → inspect-DfJzHFiE.mjs} +2 -2
  44. package/dist/inspect-H1MISWwN.mjs +2 -0
  45. package/dist/inspect.d.mts +1 -1
  46. package/dist/inspect.mjs +1 -1
  47. package/dist/{internal-CvsrprnU-CEPOUpAv.mjs → internal-CvsrprnU-DhZF6sZK.mjs} +43 -1
  48. package/dist/local-BiG1WJk0.mjs +98 -0
  49. package/dist/{local-B5aZcAwj.mjs → local-D2i5sxuY.mjs} +141 -3957
  50. package/dist/{main-DSlpMoBN.mjs → main-Bbqg3Unf.mjs} +167 -38
  51. package/dist/{memory-wmUDblhm.mjs → memory-BmsyKyHu.mjs} +3 -3
  52. package/dist/{mentions-CnWt9Z5b.mjs → mentions-DBGmqkr2.mjs} +5 -1
  53. package/dist/{middleware-BY4qqIh3.mjs → middleware-D2AGrGj7.mjs} +2 -32
  54. package/dist/{provider-DgGp4Zej.d.mts → provider-BNVyVKtH.d.mts} +2 -2
  55. package/dist/{routes-DNmQSOvQ.d.mts → routes-CSnxZyyb.d.mts} +2 -2
  56. package/dist/{serve-CI3kvpx_.mjs → serve-D06-DMej.mjs} +6 -6
  57. package/dist/{server-55vryxAl.mjs → server-BXbcS-n9.mjs} +27 -12
  58. package/dist/server-DX7mM6nm-Cq1xPyqJ.mjs +3769 -0
  59. package/dist/{serving-C1mhZQqH.mjs → serving-B2BNr4PR.mjs} +1 -1
  60. package/dist/{shell-7nGyF--f.mjs → shell-C8EowDEz.mjs} +15 -7
  61. package/dist/{sql-D0MqINA6.mjs → sql-CvBbb5Ui.mjs} +33 -22
  62. package/dist/{sqlite-Dj2ZEtgy.mjs → sqlite-B9ZLSDUT.mjs} +3 -3
  63. package/dist/{sqlite-db-DjbTlUwN.mjs → sqlite-db-DawFxCk6.mjs} +22 -7
  64. package/dist/store-N8PXxDAS-DWWgv-Vz.mjs +5 -0
  65. package/dist/{store-N8PXxDAS-BdL4Sq-f.mjs → store-codec-pAG2oPgQ-DbEYfF5Y.mjs} +2 -6
  66. package/dist/{store-memory-CKQVEzXN.mjs → store-memory-DOMraCLN.mjs} +3 -2
  67. package/dist/store-memory-XNDFHASI.mjs +2 -0
  68. package/dist/{store-polling-BZt2Rf3D-oh3aU_An.mjs → store-polling-BZt2Rf3D-nlZUQLz2.mjs} +1 -1
  69. package/dist/store-sqlite-Cs8dH9EX.mjs +2 -0
  70. package/dist/{store-sqlite-D6fIszST.mjs → store-sqlite-DUdQnX_6.mjs} +4 -3
  71. package/dist/sync-chat-sdk.d.mts +2 -2
  72. package/dist/sync-github.d.mts +2 -2
  73. package/dist/sync-linear.d.mts +3 -3
  74. package/dist/sync-slack.d.mts +3 -3
  75. package/dist/sync-slack.mjs +1 -1
  76. package/dist/sync.d.mts +2 -2
  77. package/dist/{task-batch-iecHMssy.mjs → task-batch-YMVr_c5R.mjs} +4 -4
  78. package/dist/{tokens-B3gXkQCs.mjs → tokens-CaEPmiG1.mjs} +2 -2
  79. package/dist/vercel-B5FM4uS8.d.mts +21 -0
  80. package/dist/vercel-BUb8II-P.mjs +305 -0
  81. package/dist/{version-gbihG3ui.mjs → version-BRR9FkLa.mjs} +1 -1
  82. package/docs/01-board/01-mounting.md +10 -0
  83. package/docs/01-board/05-reading.md +2 -1
  84. package/docs/01-board/09-access.md +8 -4
  85. package/docs/01-board/11-tasks.md +1 -1
  86. package/docs/01-board/12-postgres.md +222 -0
  87. package/docs/03-guides/02-inspector.md +34 -1
  88. package/docs/03-guides/07-build-a-ui.md +8 -4
  89. package/docs/04-reference/01-cli.md +1 -1
  90. package/docs/04-reference/03-http.md +2 -1
  91. package/docs/index.md +4 -1
  92. package/package.json +32 -3
  93. package/sql/postgres/schema.sql +389 -0
  94. package/dist/inspect-CJ8osLQ-.mjs +0 -2
  95. package/dist/store-memory-OdGsc-t_.mjs +0 -2
  96. package/dist/store-sqlite-CTxAVCcz.mjs +0 -2
@@ -0,0 +1,305 @@
1
+ import { _ as serverInternals, l as assertSchedulerTargets, t as DRAIN_TIMINGS, u as classifySchedulerSendFailure } from "./internal-CvsrprnU-DhZF6sZK.mjs";
2
+ import { a as retryableLazy, i as deliverSchedulerClear, r as deliverSchedulerAppend } from "./server-DX7mM6nm-Cq1xPyqJ.mjs";
3
+ import { n as SYSTEM_CLOCK } from "./store-N8PXxDAS-DWWgv-Vz.mjs";
4
+ import { createHash } from "node:crypto";
5
+ //#region ../../node_modules/.pnpm/experimental-a2@0.24.0_@upstash+qstash@2.12.0_@vercel+queue@0.7.0_ai@7.0.130_zod@4.6.5__b1e2c243a963f2620a5d202817417c26/node_modules/experimental-a2/dist/scheduler-task-X1SToDjP.js
6
+ const recordOf$1 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
7
+ const validName = (value) => typeof value === "string" && value.length > 0;
8
+ const validDueAt = (value) => typeof value === "number" && Number.isInteger(value) && value % 1e3 === 0;
9
+ const validIndex = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
10
+ const baseTask = (record) => Object.hasOwn(record, "contract") && Object.hasOwn(record, "sessionId") && validName(record["contract"]) && validName(record["sessionId"]) ? {
11
+ contract: record["contract"],
12
+ sessionId: record["sessionId"]
13
+ } : null;
14
+ /**
15
+ * Validate one delivered task.
16
+ * Adapters call this only after their transport authentication has succeeded.
17
+ */
18
+ function normalizeSchedulerTask(value) {
19
+ const record = recordOf$1(value);
20
+ if (!record) return null;
21
+ const base = baseTask(record);
22
+ if (!base) return null;
23
+ if (record["version"] !== 1) return null;
24
+ if (record["kind"] === "drain") {
25
+ const dueAt = record["dueAt"];
26
+ if (!validDueAt(dueAt)) return null;
27
+ return {
28
+ version: 1,
29
+ kind: "drain",
30
+ ...base,
31
+ dueAt
32
+ };
33
+ }
34
+ if (record["kind"] === "clear") {
35
+ const { dueAt, id, ifLastIndex } = record;
36
+ if (!validName(id) || !validDueAt(dueAt) || !validIndex(ifLastIndex)) return null;
37
+ return {
38
+ version: 1,
39
+ kind: "clear",
40
+ id,
41
+ ...base,
42
+ dueAt,
43
+ ifLastIndex
44
+ };
45
+ }
46
+ if (record["kind"] !== "append") return null;
47
+ const { dueAt, events, id, originIndex } = record;
48
+ if (!validName(id) || !validDueAt(dueAt)) return null;
49
+ if (originIndex !== void 0 && (!validIndex(originIndex) || originIndex === 0)) return null;
50
+ if (!Array.isArray(events) || events.length === 0) return null;
51
+ const parsedEvents = [];
52
+ for (const event of events) {
53
+ const item = recordOf$1(event);
54
+ if (!item || typeof item["id"] !== "string" || typeof item["type"] !== "string" || !Object.hasOwn(item, "payload")) return null;
55
+ parsedEvents.push({
56
+ id: item["id"],
57
+ type: item["type"],
58
+ payload: item["payload"]
59
+ });
60
+ }
61
+ if (new Set(parsedEvents.map((event) => event.id)).size !== parsedEvents.length) return null;
62
+ return {
63
+ version: 1,
64
+ kind: "append",
65
+ id,
66
+ ...base,
67
+ dueAt,
68
+ events: parsedEvents,
69
+ ...originIndex === void 0 ? {} : { originIndex }
70
+ };
71
+ }
72
+ //#endregion
73
+ //#region ../../node_modules/.pnpm/experimental-a2@0.24.0_@upstash+qstash@2.12.0_@vercel+queue@0.7.0_ai@7.0.130_zod@4.6.5__b1e2c243a963f2620a5d202817417c26/node_modules/experimental-a2/dist/scheduler-vercel.js
74
+ /**
75
+ * experimental-a2/scheduler-vercel — queue-backed scheduler over Vercel Queues.
76
+ *
77
+ * `vercelQueues()` returns an `A2Scheduler` (a2-implementation.md §9):
78
+ *
79
+ * - drain tasks round the requested watchdog time up to a one-second slot.
80
+ * One message per `(topic, contract, session, dueAt)` coalesces appends,
81
+ * claim renewals and racing callbacks. `DuplicateMessageError` is
82
+ * success because that due-time slot is already durable.
83
+ * - append tasks hash their stable task id with the topic for provider
84
+ * deduplication. Their six-day maximum delay leaves a full day for
85
+ * delivery and retries inside the provider's seven-day retention.
86
+ * Clear tasks follow the same identity and delay rules. All tasks use
87
+ * the configured deployment scope for sending and receiving.
88
+ * - `handler(...servers)` is the delivery route: look up the server for
89
+ * the contract named in the message and drain it. Settled drains ack;
90
+ * contention, consumer failure, and a drain that throws after arming its
91
+ * successor all ack once a later watchdog is durable.
92
+ *
93
+ * `@vercel/queue` is an optional peer dependency, imported lazily. The
94
+ * `transport` option is the injection seam — tests run a real little
95
+ * in-memory queue through the same interface.
96
+ */
97
+ /**
98
+ * The "not settled yet" signal for a drain whose outcome is unknown — an
99
+ * expected state, not a transport failure. The default transport classifies
100
+ * it in `@vercel/queue`'s `retry` option and reschedules the delivery quietly
101
+ * (`{ afterSeconds }` → visibility change → 200 response, no error log)
102
+ * instead of letting it surface as a thrown 500. Busy and stalled deliveries
103
+ * use a fresh watchdog instead. Custom transports should treat this class the
104
+ * same way when their protocol has a polite reschedule.
105
+ */
106
+ var DrainUnsettled = class extends Error {};
107
+ /** Vercel Queues rejects shorter visibility changes. */
108
+ const MIN_VISIBILITY_SECONDS = 30;
109
+ /** Vercel Queues' maximum message retention; its default is a day. */
110
+ const MAX_RETENTION_SECONDS = 604800;
111
+ const TOPIC_PATTERN = /^[A-Za-z0-9_-]+$/;
112
+ const RETRYABLE_HTTP_CLIENT_STATUSES = /* @__PURE__ */ new Set([
113
+ 408,
114
+ 409,
115
+ 425,
116
+ 429
117
+ ]);
118
+ /** The SDK's send path maps these statuses to name-only error instances. */
119
+ const TERMINAL_VERCEL_SEND_ERROR_NAMES = /* @__PURE__ */ new Set([
120
+ "BadRequestError",
121
+ "UnauthorizedError",
122
+ "ForbiddenError"
123
+ ]);
124
+ const recordOf = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
125
+ const httpStatusOf = (error) => {
126
+ try {
127
+ const record = recordOf(error);
128
+ if (!record) return void 0;
129
+ const response = recordOf(record["response"]);
130
+ const statuses = [
131
+ record["status"],
132
+ record["statusCode"],
133
+ response?.["status"]
134
+ ].filter((value) => typeof value === "number" && Number.isInteger(value) && value >= 100 && value <= 599);
135
+ const [status] = statuses;
136
+ if (status === void 0) return void 0;
137
+ return statuses.every((candidate) => candidate === status) ? status : void 0;
138
+ } catch {
139
+ return;
140
+ }
141
+ };
142
+ const errorNameOf = (error) => {
143
+ try {
144
+ const name = recordOf(error)?.["name"];
145
+ return typeof name === "string" ? name : void 0;
146
+ } catch {
147
+ return;
148
+ }
149
+ };
150
+ const classifyVercelSendFailure = (error) => {
151
+ const status = httpStatusOf(error);
152
+ const terminal = status === void 0 ? TERMINAL_VERCEL_SEND_ERROR_NAMES.has(errorNameOf(error) ?? "") : status >= 400 && status < 500 && !RETRYABLE_HTTP_CLIENT_STATUSES.has(status);
153
+ return classifySchedulerSendFailure(error, terminal ? "terminal" : "retryable");
154
+ };
155
+ const digestId = (parts) => `a2_${createHash("sha256").update(JSON.stringify(parts)).digest("hex")}`;
156
+ /** Base of the unsettled redelivery backoff, doubled per delivery. */
157
+ const UNSETTLED_BACKOFF_BASE_SECONDS = 5;
158
+ /** Redelivery backoff for retry states: base, 2×, 4×… bounded. */
159
+ const unsettledBackoffSeconds = (deliveryCount) => Math.min(Math.max(UNSETTLED_BACKOFF_BASE_SECONDS * 2 ** Math.max(deliveryCount - 1, 0), MIN_VISIBILITY_SECONDS), 60);
160
+ const vercelQueueTransport = async (clientOptions) => {
161
+ const queue = await import("@vercel/queue").catch(() => {
162
+ throw classifySchedulerSendFailure(/* @__PURE__ */ new Error("experimental-a2/scheduler-vercel needs the '@vercel/queue' package (optional peer dependency) — install it, or inject a transport"), "terminal");
163
+ });
164
+ const client = new queue.QueueClient(clientOptions);
165
+ return {
166
+ send: (topic, message, options) => client.send(topic, message, options),
167
+ handleCallback: (handler) => client.handleCallback(handler, {
168
+ visibilityTimeoutSeconds: MIN_VISIBILITY_SECONDS,
169
+ retry: (error, metadata) => error instanceof DrainUnsettled ? { afterSeconds: unsettledBackoffSeconds(metadata.deliveryCount) } : void 0
170
+ }),
171
+ isDuplicate: (error) => error instanceof queue.DuplicateMessageError
172
+ };
173
+ };
174
+ function vercelQueues$1(options = {}) {
175
+ const topic = options.topic ?? "a2";
176
+ if (typeof topic !== "string" || !TOPIC_PATTERN.test(topic)) throw new TypeError("vercelQueues() topic must match [A-Za-z0-9_-]+");
177
+ const clock = options.clock ?? SYSTEM_CLOCK;
178
+ const clientOptions = options.deploymentId === void 0 ? {} : { deploymentId: options.deploymentId };
179
+ const transport = retryableLazy(() => options.transport ? Promise.resolve(options.transport) : vercelQueueTransport(clientOptions)).get;
180
+ const sendTask = async (task) => {
181
+ const nowMs = clock.now().getTime();
182
+ const requestedDueAt = task.dueAt;
183
+ if (!Number.isFinite(requestedDueAt)) throw classifySchedulerSendFailure(/* @__PURE__ */ new TypeError("vercel scheduler dueAt must be a finite number"), "terminal");
184
+ const dueAt = requestedDueAt <= nowMs ? Math.floor(nowMs / 1e3) * 1e3 : Math.ceil(requestedDueAt / 1e3) * 1e3;
185
+ const deliveryTargetAt = task.kind === "drain" ? dueAt : requestedDueAt;
186
+ const deliveryDelaySeconds = Math.max(0, Math.ceil((deliveryTargetAt - nowMs) / 1e3));
187
+ const message = {
188
+ ...task,
189
+ dueAt
190
+ };
191
+ const idempotencyKey = task.kind === "drain" ? digestId([
192
+ "a2:scheduler-vercel:drain:v1",
193
+ topic,
194
+ task.contract,
195
+ task.sessionId,
196
+ String(dueAt)
197
+ ]) : task.kind === "append" ? digestId([
198
+ "a2:scheduler-vercel:append:v1",
199
+ topic,
200
+ task.id
201
+ ]) : digestId([
202
+ "a2:scheduler-vercel:clear:v1",
203
+ topic,
204
+ task.id
205
+ ]);
206
+ const t = await transport();
207
+ try {
208
+ await t.send(topic, message, {
209
+ delaySeconds: deliveryDelaySeconds,
210
+ idempotencyKey,
211
+ retentionSeconds: MAX_RETENTION_SECONDS
212
+ });
213
+ } catch (err) {
214
+ if (t.isDuplicate(err)) return;
215
+ throw classifyVercelSendFailure(err);
216
+ }
217
+ };
218
+ const successorDueAt = (message) => {
219
+ const minimumDueAt = clock.now().getTime() + DRAIN_TIMINGS.claimTtlMs + DRAIN_TIMINGS.watchdogGraceMs;
220
+ const beats = Math.max(1, Math.ceil((minimumDueAt - message.dueAt) / DRAIN_TIMINGS.claimHeartbeatMs));
221
+ return message.dueAt + beats * DRAIN_TIMINGS.claimHeartbeatMs;
222
+ };
223
+ return {
224
+ async schedule(task) {
225
+ await sendTask(task);
226
+ },
227
+ handler(...servers) {
228
+ assertSchedulerTargets(servers);
229
+ const byContract = /* @__PURE__ */ new Map();
230
+ for (const server of servers) byContract.set(server.contract.name, server);
231
+ return async (req) => {
232
+ return (await transport()).handleCallback(async (delivered) => {
233
+ const task = normalizeSchedulerTask(delivered);
234
+ if (!task) throw new TypeError("a2 scheduler received an invalid task");
235
+ const server = byContract.get(task.contract);
236
+ if (!server) throw new Error(`a2 scheduler: no server for contract '${task.contract}' — pass it to scheduler.handler(...)`);
237
+ const internals = serverInternals.get(server);
238
+ if (task.kind === "append") {
239
+ await deliverSchedulerAppend(server, task);
240
+ return;
241
+ }
242
+ if (task.kind === "clear") {
243
+ await deliverSchedulerClear(server, task);
244
+ return;
245
+ }
246
+ const nextDueAt = successorDueAt(task);
247
+ const result = internals ? await internals.schedulerDrain(task.sessionId, { watchdogDueAt: nextDueAt }) : {
248
+ ...await server.drain(task.sessionId),
249
+ outcome: "unknown"
250
+ };
251
+ if (result.settled) return;
252
+ if (result.outcome === "busy" || result.outcome === "stalled" || result.outcome === "failed") {
253
+ if (result.schedulerArm) await result.schedulerArm;
254
+ else await sendTask({
255
+ version: 1,
256
+ kind: "drain",
257
+ contract: task.contract,
258
+ sessionId: task.sessionId,
259
+ dueAt: nextDueAt
260
+ });
261
+ return;
262
+ }
263
+ throw new DrainUnsettled(`a2 scheduler: session '${task.sessionId}' of '${task.contract}' not settled yet (${result.outcome}) — rescheduled for redelivery`);
264
+ })(req);
265
+ };
266
+ }
267
+ };
268
+ }
269
+ //#endregion
270
+ //#region src/scheduler/vercel.ts
271
+ const ENGINE = Symbol("board.scheduler.engine");
272
+ const ATTACH = Symbol("board.scheduler.attach");
273
+ /** A scheduler on `engine`, whose route delivers to the board it's passed to. */
274
+ function boardScheduler(engine) {
275
+ let deliver = null;
276
+ const route = async (request) => {
277
+ if (!deliver) return Response.json({ error: {
278
+ code: "no_board",
279
+ message: "this scheduler serves no board yet: pass it to postgres({ scheduler })"
280
+ } }, { status: 500 });
281
+ return deliver(request);
282
+ };
283
+ return Object.assign(route, {
284
+ [ENGINE]: engine,
285
+ [ATTACH]: (to) => {
286
+ if (deliver) throw new Error("this scheduler already serves a board: create one per postgres()");
287
+ deliver = to;
288
+ }
289
+ });
290
+ }
291
+ /** The engine's scheduler behind one `boardScheduler()` made. */
292
+ const engineScheduler = (scheduler) => scheduler[ENGINE];
293
+ /** Points `scheduler`'s route at the board that runs on it. */
294
+ const attachScheduler = (scheduler, deliver) => scheduler[ATTACH](deliver);
295
+ /**
296
+ * Vercel Queues as a board's scheduler (`npm i @vercel/queue`): scheduled messages, leases running
297
+ * out, and watchers' and sync's retries go out on time with nothing running, each to the
298
+ * deployment that armed it. It's also the route the topic calls: mount it as `POST` in a route of
299
+ * its own, which `vercel.json` gives a `queue/v2beta` trigger on the topic.
300
+ */
301
+ function vercelQueues(options = {}) {
302
+ return boardScheduler(vercelQueues$1({ topic: options.topic ?? "board" }));
303
+ }
304
+ //#endregion
305
+ export { engineScheduler as n, vercelQueues as r, attachScheduler as t };
@@ -1,5 +1,5 @@
1
1
  //#endregion
2
2
  //#region src/version.ts
3
- const VERSION = "0.56.1";
3
+ const VERSION = "0.57.1";
4
4
  //#endregion
5
5
  export { VERSION as t };
@@ -35,6 +35,7 @@ of its own, each with a name: see [A board by its name](#a-board-by-its-name).
35
35
  | --- | --- |
36
36
  | none | Your team's board in Vercel's API, the one `name` names. In Node with `BOARD_URL` set, the board at that URL instead: see [A handle on a board elsewhere](#a-handle-on-a-board-elsewhere) |
37
37
  | `local()` | Keeps the board in this process, in SQLite under `.board/` or in memory: for development, `vb serve`, tests, and working offline. See [Local boards](./10-local.md) |
38
+ | `postgres({ blob })` | Keeps the board on Postgres, shared by every instance that serves it, and its files in a blob store: a board you host, on Vercel or any Node server. See [Postgres boards](./12-postgres.md) |
38
39
  | your own | Any object that answers the protocol: see [A backend of your own](#a-backend-of-your-own) |
39
40
 
40
41
  `board()` does the same on every backend. It routes and validates each
@@ -150,10 +151,19 @@ export const acmeGeneral = board({ team: 'acme' })
150
151
  (`team_…`) or its slug. `board()` throws on either that isn't. Without
151
152
  `team`, it's the team the environment finds: in Node, the deployment's,
152
153
  `VERCEL_ORG_ID`, or the linked project's.
154
+ - **A name costs no lookup.** Each request names the board in its path, by
155
+ the name you gave or as General, so a process's first request is the one you
156
+ asked for. Vercel's API takes a name wherever it takes a board's ID, and
157
+ tells them apart by how an ID starts: it refuses a new board named `brd_…`
158
+ with 400 `invalid_board_name`. A name that starts that way, or is `.` or
159
+ `..`, is looked up first, so it's never read as a board's ID or as a step in
160
+ the path.
153
161
  - **`board({ name })` makes the board** the first time anyone uses a name the
154
162
  team has none for: this project's own code, and a person too (`next dev`
155
163
  with a login, a script). Vercel's API grants a project's new board to that
156
164
  project, in the environment it runs in, and anyone on the team can use it.
165
+ That first request is answered 404, the board is found or made, and the
166
+ request goes again, once in a process.
157
167
  - **`ensure: false` only finds one.** A name the team has none for fails with
158
168
  404 `no_board`, `no board named security on this team, or none you can see.`
159
169
  - **`vb` makes one only with `--ensure`,** so a typo at a terminal makes no
@@ -66,7 +66,8 @@ $ vb read 812
66
66
  prints `{ message, replies, cursor, schedules }`. `--after` and `--label` narrow
67
67
  it to the root and the replies that match: `vb read 812 --after 813` shows what
68
68
  came after one of its messages, and `--label status=investigating` the replies
69
- that wear it, or all of them when the root does. The filters that find threads
69
+ that wear it, or all of them when the root does. `--limit 20` keeps the newest
70
+ 20 replies, or with `--after` the first 20 after it. The filters that find threads
70
71
  (`--by`, `--text`, `--mentions`, `--source`) don't narrow one: it's read whole.
71
72
  Each reaction names its first three people and counts the rest
72
73
  (`👀 ada, claude, codex +9`); `--json` has them all.
@@ -286,13 +286,17 @@ through the binding's `handle(caller)`, so the middleware sees it.
286
286
 
287
287
  | Permission | Allows | Implies |
288
288
  | --- | --- | --- |
289
- | `read` | messages, threads, `/events` (tail, wait, poll), schedules, the channel in `vb channels`, attachments on readable messages | |
290
- | `post` | start a thread; create a channel, with `read`; edit and delete your own messages; upload; schedule a root | |
289
+ | `read` | messages, threads, tasks, `/events` (tail, wait, poll), schedules, the channel in `vb channels`, attachments on readable messages | |
290
+ | `post` | start a thread; create a channel, with `read`; edit and delete your own messages; upload; schedule a root; start a task, with `label` when it carries labels or a claim | |
291
291
  | `react` | add and remove reactions | `read` |
292
- | `label` | set and unset labels, including labels on a post | `read` |
292
+ | `label` | set and unset labels, including labels on a post; make a thread a task; claim a task, and renew, release, complete, or fail what you hold | `read` |
293
293
  | `sync` | attach a thread to a Slack or GitHub thread, including `--sync` on a post; speak for platform users there, through [sync's routes](../04-reference/03-http.md#syncs-routes); in every channel, the board's own inbox | `read` |
294
- | `manage` | cancel anyone's schedule there; in every channel, source reads | everything |
294
+ | `manage` | cancel anyone's schedule there; assign, hold, reopen, and cancel anyone's task there; in every channel, source reads | everything |
295
295
 
296
+ - **Tasks need no permission of their own.** `['read', 'post', 'label']`
297
+ makes, claims, and works tasks, and changes the ones it made, with its
298
+ `post` or `label` there; only another owner's take `manage`. See
299
+ [Tasks](./11-tasks.md).
296
300
  - **A reply needs `post` and `read`** in its thread's channel. Addressing a
297
301
  thread you can't read would confirm it exists. So `['post']` alone starts
298
302
  threads and fixes what it wrote, which is what a feedback intake or a CI
@@ -21,7 +21,7 @@ replies are the work log, and the board keeps its state. It's still a thread:
21
21
  on it as on any other.
22
22
 
23
23
  - **`vb tasks create <channel> "<text>"`** starts a thread as a task. It takes
24
- `--label`, `--no-sync`, and `--idempotency-key` as `post` does, and `-` as
24
+ `--label`, `--attach`, `--no-sync`, and `--idempotency-key` as `post` does, and `-` as
25
25
  the text reads it from stdin. Its `--file` is a plan of several.
26
26
  - **`vb tasks create <id>`** makes a task of a thread that's there, as it is:
27
27
  an issue someone filed, a question from Slack. Its text stays its author's.
@@ -0,0 +1,222 @@
1
+ ---
2
+ title: Postgres boards
3
+ description: "`postgres()` keeps a board on Postgres: its log and its tables in one database, shared by every instance that serves it, and its files in a blob store. It's how you bring your own backend, on Vercel or any Node server."
4
+ ---
5
+
6
+ ## A board on your database
7
+
8
+ ```ts app/api/board/[[...path]]/route.ts
9
+ import { board } from '@vercel/board'
10
+ import { postgres } from '@vercel/board/backend-postgres'
11
+ import { vercelBlob } from '@vercel/board/backend-postgres/blob-vercel'
12
+ import { vercelQueues } from '@vercel/board/backend-postgres/scheduler-vercel'
13
+
14
+ // DATABASE_URL's database: the board's log and its tables. Its files: a private Vercel Blob store.
15
+ // Its timers: Vercel Queues, which call the scheduler route below.
16
+ export const scheduler = vercelQueues({ topic: 'board' })
17
+ export const team = board({ backend: postgres({ blob: vercelBlob(), scheduler }) })
18
+ export const GET = team.fetch, POST = team.fetch
19
+ ```
20
+
21
+ ```ts app/api/board-scheduler/route.ts
22
+ export { scheduler as POST } from '@/app/api/board/[[...path]]/route'
23
+ ```
24
+
25
+ ```json vercel.json
26
+ {
27
+ "functions": {
28
+ "app/api/board-scheduler/route.ts": {
29
+ "experimentalTriggers": [{ "type": "queue/v2beta", "topic": "board", "retryAfterSeconds": 30 }]
30
+ }
31
+ }
32
+ }
33
+ ```
34
+
35
+ Install them beside it (`npm i pg @vercel/blob @vercel/queue`). On Vercel,
36
+ connect a Postgres database to the project, from the Marketplace, which sets
37
+ `DATABASE_URL`, and a Blob store: see [Files](#files). The scheduler gets a
38
+ route of its own: see [On Vercel Queues](#on-vercel-queues). Then apply the
39
+ board's tables, before the first deploy:
40
+
41
+ ```bash
42
+ psql "$DATABASE_URL" -f node_modules/@vercel/board/sql/postgres/schema.sql
43
+ ```
44
+
45
+ - **One database is one board.** Every instance that points at it serves the
46
+ same board, so it runs on serverless functions as well as on one server.
47
+ `name` and `team` are ignored.
48
+ - **It creates no tables unless you ask.** [`schema.sql`](#the-tables) does,
49
+ and a database without them fails the board's first call with 500
50
+ `no_store`, which names the file. `autoMigrate: true` has the board apply
51
+ it: see [Migrating on its own](#migrating-on-its-own).
52
+ - **Use the provider's pooled connection URL.** Each instance opens a pool of
53
+ up to 10 connections (`max`), and serverless functions run many instances,
54
+ which can use up a database's direct connections.
55
+ - **Attachments live in `blob`,** which it requires: see [Files](#files).
56
+ - **It passes the whole [conformance](../04-reference/05-conformance.md) kit,**
57
+ schedules, tasks, and attachments included, so `vercel board` works against
58
+ it with `--url` or `BOARD_URL`, and so does `vb`.
59
+
60
+ Who may use it is `board()`'s, as on any board this deployment keeps: on
61
+ Vercel, the team's people and the project's own deployments. Off Vercel, set
62
+ `url`, and say who its callers are: see [Callers of your own](./01-mounting.md#callers-of-your-own).
63
+
64
+ ## Options
65
+
66
+ | Option | What it does |
67
+ | --- | --- |
68
+ | `connectionString` | The database. Default `DATABASE_URL`, or else `POSTGRES_URL` |
69
+ | `pool` | A `pg` Pool you made, instead: for a password from a callback, say. The board leaves it open |
70
+ | `max` | Connections the pool it makes may open. Default 10 |
71
+ | `blob` | Required. Where attachments live: `vercelBlob()`, or any store. See [Files](#files) |
72
+ | `autoMigrate` | Apply `schema.sql` on the first call when the database doesn't have this release's. Default false: see [Migrating on its own](#migrating-on-its-own) |
73
+ | `scheduler` | What runs its timers: `vercelQueues()`, see [On Vercel Queues](#on-vercel-queues). Default: timers in this process |
74
+
75
+ `close()` stops its timers and ends the pool it made, as a test does at its
76
+ end.
77
+
78
+ `tables()` says which version of `schema.sql` the database has, `applied`
79
+ (null when it has none), and this release's, `current`, without opening the
80
+ board: `applied < current` is behind, and `applied > current` is a later
81
+ release's. `migrate()` applies this release's when the database is behind, as
82
+ `autoMigrate` does. Together they make a setup page's step: show what's
83
+ missing, and a button that migrates.
84
+
85
+ ```ts
86
+ const { applied, current } = await backend.tables()
87
+ if (applied === null || applied < current) await backend.migrate()
88
+ ```
89
+
90
+ ## Timers
91
+
92
+ Scheduled messages, leases running out, and watchers' and sync's retries run
93
+ on timers. Without a `scheduler`, they run in the process: on one server, a
94
+ restart drops what's pending, as on [`local()`](./10-local.md). On Vercel, each
95
+ instance arms the pending ones again on its first call, so a send that came
96
+ due while nothing ran goes out with the next request. With `vercelQueues()`,
97
+ the timers outlive the instance: a deployment arms the pending ones once, when
98
+ it takes over from the last, and after that each instance arms only those an
99
+ earlier deployment created since.
100
+
101
+ ## On Vercel Queues
102
+
103
+ `vercelQueues()` sends each timer through Vercel Queues (`npm i @vercel/queue`),
104
+ so it goes out on time with nothing running:
105
+
106
+ ```ts app/api/board/[[...path]]/route.ts
107
+ import { board } from '@vercel/board'
108
+ import { postgres } from '@vercel/board/backend-postgres'
109
+ import { vercelBlob } from '@vercel/board/backend-postgres/blob-vercel'
110
+ import { vercelQueues } from '@vercel/board/backend-postgres/scheduler-vercel'
111
+
112
+ export const scheduler = vercelQueues({ topic: 'board' })
113
+ export const team = board({ backend: postgres({ blob: vercelBlob(), scheduler }) })
114
+ export const GET = team.fetch, POST = team.fetch
115
+ ```
116
+
117
+ Mount the scheduler as `POST` in a route of its own, which the topic
118
+ triggers: it's the route the queue calls, and delivers to the board it's
119
+ passed to.
120
+
121
+ ```ts app/api/board-scheduler/route.ts
122
+ export { scheduler as POST } from '@/app/api/board/[[...path]]/route'
123
+ ```
124
+
125
+ ```json vercel.json
126
+ {
127
+ "functions": {
128
+ "app/api/board-scheduler/route.ts": {
129
+ "experimentalTriggers": [{ "type": "queue/v2beta", "topic": "board", "retryAfterSeconds": 30 }]
130
+ }
131
+ }
132
+ }
133
+ ```
134
+
135
+ Keep it out of the board's catch-all route: a queue trigger makes its function
136
+ private, and the board's routes must stay public, for people, CI, and platform
137
+ webhooks.
138
+
139
+ ## The tables
140
+
141
+ `sql/postgres/schema.sql`, in the package, is every table the
142
+ board needs, in one file. Each statement creates only what's missing and leaves
143
+ existing data alone, so it's safe to apply again, and a breakpoint comment
144
+ after each one splits it for migration tools that send one statement per
145
+ query: copy it into your migrations as it is. Apply it again when a release's
146
+ changelog says the tables changed.
147
+
148
+ Apply it as the role the board connects with. A board that connects as another
149
+ role needs to read and write the tables, and to call `a2_batch`, which every
150
+ write goes through and the file keeps to the role that applied it:
151
+
152
+ ```bash
153
+ # board_app: the role the board connects with
154
+ psql "$DATABASE_URL" \
155
+ -c 'grant select, insert, update, delete on all tables in schema public to board_app' \
156
+ -c 'grant execute on function a2_batch(text[], jsonb) to board_app'
157
+ ```
158
+
159
+ Without the second, every write fails with 500 `no_store`, which says what to
160
+ grant.
161
+
162
+ ## Migrating on its own
163
+
164
+ With `autoMigrate: true`, the board applies `schema.sql` itself: on a new
165
+ database, and after an upgrade whose file changed. Then a Deploy needs no step
166
+ of yours:
167
+
168
+ ```ts app/api/board/[[...path]]/route.ts
169
+ import { board } from '@vercel/board'
170
+ import { postgres } from '@vercel/board/backend-postgres'
171
+ import { vercelBlob } from '@vercel/board/backend-postgres/blob-vercel'
172
+
173
+ export const team = board({ backend: postgres({ blob: vercelBlob(), autoMigrate: true }) })
174
+ export const GET = team.fetch, POST = team.fetch
175
+ ```
176
+
177
+ - **The file records its version,** a number in `board_meta` that goes up
178
+ with each release whose tables changed. Each instance's first call reads it,
179
+ and applies the file only when the database is behind, so one that's up to
180
+ date costs one read. A database on a later release's tables is left alone,
181
+ since they only add to these, and applying an earlier release's file never
182
+ moves the number back.
183
+ - **Without `autoMigrate`, a database that's behind fails the first call,**
184
+ with 500 `no_store`, which says which file to apply.
185
+ - **Instances that start together apply it once:** the one that applies it
186
+ holds a Postgres advisory lock, and the others wait for it, then find it
187
+ done.
188
+ - **The file only adds, from one release to the next:** tables, columns with
189
+ a default or none, and indexes. A deployment still on the last release keeps
190
+ working while the next one rolls out, and a rollback to it does too.
191
+ - **Its role needs to create tables** in the database. It's the role that
192
+ applied them, so it needs no other grant: see [The tables](#the-tables) for
193
+ what a role that didn't needs.
194
+
195
+ ## Files
196
+
197
+ A board's attachments live in its blob store, `blob`, and only their records
198
+ in the database. `vercelBlob()` is a private
199
+ [Vercel Blob](https://vercel.com/docs/vercel-blob) store (`npm i @vercel/blob`),
200
+ and it signs uploads, so files go straight to it, up to 100 MB each. Connect a
201
+ Blob store to the project: the SDK finds it through `BLOB_READ_WRITE_TOKEN`, or
202
+ the project's OIDC token and `BLOB_STORE_ID`. `prefix` keeps one board's files
203
+ under a path of their own in a shared store.
204
+
205
+ For development, pull a Blob store's token with `vercel env pull`. For tests,
206
+ any object with `put` and `get` will do:
207
+
208
+ ```ts
209
+ import { postgres, type BlobStore } from '@vercel/board/backend-postgres'
210
+
211
+ const files = new Map<string, { data: Uint8Array; contentType: string }>()
212
+ const blob: BlobStore = {
213
+ put: async (key, data, contentType) => void files.set(key, { data, contentType }),
214
+ get: async (key) => files.get(key) ?? null,
215
+ }
216
+ const backend = postgres({ blob })
217
+ ```
218
+
219
+ - **Any object with `put` and `get` is a store,** `BlobStore` its type. With
220
+ `uploadUrl` and `head` too, it takes files over 4 MB; without, up to 4 MB.
221
+ - **Changing stores leaves the old one's files where they are.** The board
222
+ reads each file from the store it has now.
@@ -55,7 +55,7 @@ Everything you can do from the CLI, with the board laid out:
55
55
  unset labels, and edit or delete your own messages. A toggle keeps a post on
56
56
  the board instead of syncing it, and the clock
57
57
  [sends it later](../01-board/07-schedules.md), once or on a repeat.
58
- - **Files.** Attach files, or paste them into the composer. Images and video
58
+ - **Files.** Attach files, or paste or drop them into the composer. Images and video
59
59
  show inline, in a fixed frame so loading one doesn't move the page; other
60
60
  files are chips that download.
61
61
  - **Work tasks.** A root that's a [task](../04-reference/02-board.md#tasks)
@@ -79,6 +79,39 @@ platform messages quoted under them, any platform a message didn't reach, and
79
79
  whether a schedule sent them. A thread's pane lists where it's synced, with a
80
80
  link to its copy on each platform, and what's scheduled to reply in it.
81
81
 
82
+ ## Notifications
83
+
84
+ While the page is open, a new message that mentions you shows a browser
85
+ notification, in a background tab too. A mention is what
86
+ [`--mentions me`](../01-board/03-identity.md#mentions) matches: your ID or your
87
+ handle, outside code. It's you as a person, whichever profile the page posts
88
+ as: with `--as claude`, claude's `@julian` notifies you, and `@julian/claude`
89
+ doesn't.
90
+
91
+ The notification says who wrote it, in which channel, and its first line.
92
+ Clicking it focuses the tab and opens the thread at that message
93
+ (`?thread=812&message=815`), which the pane scrolls to and marks for a moment.
94
+
95
+ The page asks for permission on a click or keypress. Firefox and Safari show
96
+ the prompt only then, and a key like Esc doesn't count, so the page asks again
97
+ on your next gesture until you answer. Once you say no, it doesn't ask again.
98
+ Your system has to let the browser show notifications too: on macOS, that's
99
+ System Settings > Notifications > your browser.
100
+
101
+ New posts notify, edits don't, and neither do the messages the page loaded
102
+ with. Your own posts don't: the ones you write as yourself anywhere, and the
103
+ ones you write in this tab as any profile. A post one of your profiles writes
104
+ elsewhere, such as an agent's reply, does. Two tabs on one board each notify,
105
+ with the same tag, so the second notification replaces the first.
106
+
107
+ > [!NOTE]
108
+ > Browsers show notifications only in a secure context (https, or this
109
+ > machine), so a page at a plain `http://` host behind a proxy shows none. Most
110
+ > mobile browsers show them only from a service worker, which the page doesn't
111
+ > have, so it shows none there either. A page served from your app
112
+ > (`@vercel/board/inspect`) acts as the app, not as whoever's visiting, so it
113
+ > doesn't notify.
114
+
82
115
  ## Tasks
83
116
 
84
117
  What a task's pane offers depends on its state and on you: