@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.
- package/dist/{access-BgBiaCyx.mjs → access-3udXjJAg.mjs} +2 -2
- package/dist/access.d.mts +3 -3
- package/dist/access.mjs +6 -6
- package/dist/{actors-DkZsnMgA.mjs → actors-DasGZnfb.mjs} +3 -3
- package/dist/{auth-Bn8J_1F2.d.mts → auth-BG_whr9_.d.mts} +1 -1
- package/dist/{auth-Ft4AJptx.mjs → auth-aiOVE82-.mjs} +2 -2
- package/dist/{backend-DMrK55mU.d.mts → backend-D6yTo8Un.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-BvNqOQFL.mjs} +7 -5
- package/dist/{chat-provider-Cgkh9xJw.d.mts → chat-provider-V2jnjVLq.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 +14 -7
- package/dist/{commands-C4fR0md0.mjs → commands-CqdnjUkm.mjs} +7 -1
- package/dist/{commands-BlM-ckFS.d.mts → commands-DewS14_P.d.mts} +7 -1
- package/dist/{conformance-BORt5nky.mjs → conformance-BInS4_6b.mjs} +68 -2
- 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-XVBt02Bl.mjs} +20 -13
- package/dist/{errors-DUzpDSrJ.mjs → errors-ZazTZh-s.mjs} +20 -3
- package/dist/{events-BT8y_81j.mjs → events-D17RndlV.mjs} +5 -3
- package/dist/{exports-BVgUNVsP.mjs → exports-DCf75prP.mjs} +184 -45
- package/dist/exports-Gspe1eEq.d.mts +4 -0
- package/dist/{external-DymyhUzl.mjs → external-DfhN7lKK.mjs} +1 -1
- package/dist/{index-CydxnBND.d.mts → index-Djmr4GzQ.d.mts} +2 -2
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +4 -4
- package/dist/index.node.d.mts +6 -6
- package/dist/index.node.mjs +3 -3
- package/dist/inspect/app.js +88 -88
- package/dist/inspect/engine.js +5 -5
- package/dist/{inspect-ZGkTJl3f.mjs → inspect-B0_aKQM8.mjs} +23 -7
- package/dist/inspect-CULoD54F.mjs +2 -0
- package/dist/{local-yB2DFcRi.mjs → local-Bel_oeFa.mjs} +26 -13
- package/dist/{main-DjEJPCgo.mjs → main-DmsdcUZ_.mjs} +36 -13
- package/dist/{memory-DhduVbUu.mjs → memory-DyEL0fvN.mjs} +2 -2
- package/dist/{middleware-0DUFrav-.mjs → middleware-BHHKHA9q.mjs} +2 -2
- package/dist/origin-BHmEdok7.mjs +428 -0
- package/dist/{provider-dY54GFNz.d.mts → provider-BC9mPYVh.d.mts} +39 -6
- package/dist/{origin-9Ch-Zonv.mjs → routes-CkUetTO2.mjs} +14 -437
- package/dist/{routes-By9lmvUD.d.mts → routes-zm4TXKCC.d.mts} +8 -1
- package/dist/{schemas-DAzSsgWk.mjs → schemas-BhZaystC.mjs} +8 -2
- package/dist/schemas.mjs +1 -1
- package/dist/{serve-Cnb4TpaJ.mjs → serve-bPSEx_8X.mjs} +4 -4
- package/dist/{server-BHpUqip5.mjs → server-CcvxkXzG.mjs} +8 -7
- package/dist/{serving-hcxzaCCO.mjs → serving-BLVRrJ7P.mjs} +1 -1
- package/dist/{sql-P9g-rLIF.mjs → sql-CyVcjw8x.mjs} +2 -2
- package/dist/{sqlite-B3rCcIof.mjs → sqlite-Con-8duk.mjs} +2 -2
- package/dist/{sqlite-db-D0Fyju-4.mjs → sqlite-db-BdzxtUOV.mjs} +1 -1
- 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 +208 -12
- package/dist/sync.d.mts +3 -3
- package/dist/sync.mjs +2 -2
- package/dist/{tokens-BSMpTPEe.mjs → tokens-BErYXuHZ.mjs} +2 -2
- package/docs/01-board/04-messages.md +1 -1
- package/docs/01-board/09-access.md +8 -0
- 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/03-guides/02-inspector.md +16 -0
- package/docs/04-reference/01-cli.md +1 -1
- package/docs/04-reference/02-board.md +24 -3
- package/docs/04-reference/03-http.md +8 -2
- package/docs/04-reference/05-conformance.md +1 -1
- package/package.json +3 -1
- package/dist/exports-Bw_OYNRl.d.mts +0 -4
- package/dist/inspect-DRPRCOaV.mjs +0 -2
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
import { _ as ATTACHMENT_BYTES_MAX, r as badRequest, t as HttpError } from "./errors-ZazTZh-s.mjs";
|
|
2
|
+
import "./schemas-BhZaystC.mjs";
|
|
3
|
+
import { l as isThreadTarget } from "./external-DfhN7lKK.mjs";
|
|
4
|
+
import { F as routes, s as Filters } from "./routes-CkUetTO2.mjs";
|
|
5
|
+
import { i as afterRetry } from "./middleware-BHHKHA9q.mjs";
|
|
6
|
+
import { o as options } from "./commands-CqdnjUkm.mjs";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/version.ts
|
|
10
|
+
const VERSION = "0.45.0";
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/server/backend.ts
|
|
13
|
+
/** The subscription sync's outbound runs on, in `BoardBinding.subscriptions`. No watcher's ID starts with `@`. */
|
|
14
|
+
const SYNC = "@sync";
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/server/routing.ts
|
|
17
|
+
/** board()'s own routes: the files it serves, and sync's, which run where board() does. */
|
|
18
|
+
const BOARD_ROUTES = [
|
|
19
|
+
"avatar",
|
|
20
|
+
"openapi",
|
|
21
|
+
"webhook",
|
|
22
|
+
"sync"
|
|
23
|
+
];
|
|
24
|
+
/** Every protocol method, by the route it's served at. */
|
|
25
|
+
const METHODS = [
|
|
26
|
+
"discovery",
|
|
27
|
+
"me",
|
|
28
|
+
"channels",
|
|
29
|
+
"createChannel",
|
|
30
|
+
"actors",
|
|
31
|
+
"messages",
|
|
32
|
+
"threads",
|
|
33
|
+
"message",
|
|
34
|
+
"post",
|
|
35
|
+
"posted",
|
|
36
|
+
"edit",
|
|
37
|
+
"delete",
|
|
38
|
+
"react",
|
|
39
|
+
"label",
|
|
40
|
+
"schedule",
|
|
41
|
+
"schedules",
|
|
42
|
+
"cancelSchedule",
|
|
43
|
+
"grants",
|
|
44
|
+
"createGrant",
|
|
45
|
+
"updateGrant",
|
|
46
|
+
"explain",
|
|
47
|
+
"revokeGrant",
|
|
48
|
+
"schemas",
|
|
49
|
+
"schema",
|
|
50
|
+
"createSchema",
|
|
51
|
+
"upload",
|
|
52
|
+
"attachment",
|
|
53
|
+
"uploadStart",
|
|
54
|
+
"uploadFinish",
|
|
55
|
+
"watchers",
|
|
56
|
+
"register",
|
|
57
|
+
"matches",
|
|
58
|
+
"ack",
|
|
59
|
+
"events",
|
|
60
|
+
"syncImport",
|
|
61
|
+
"syncReceipt",
|
|
62
|
+
"syncThread",
|
|
63
|
+
"syncFind",
|
|
64
|
+
"syncCopies",
|
|
65
|
+
"inboxPush",
|
|
66
|
+
"inboxNext",
|
|
67
|
+
"inboxAck",
|
|
68
|
+
"inbox",
|
|
69
|
+
"typing",
|
|
70
|
+
"readSource",
|
|
71
|
+
"joinSource",
|
|
72
|
+
"synced",
|
|
73
|
+
"linked"
|
|
74
|
+
];
|
|
75
|
+
const escape = (literal) => literal.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
76
|
+
function compile(method, path, target, own) {
|
|
77
|
+
const parts = path.split("/").filter(Boolean);
|
|
78
|
+
const source = parts.map((part) => part.startsWith(":") ? "/([^/]+)" : `/${escape(part)}`).join("");
|
|
79
|
+
return {
|
|
80
|
+
method,
|
|
81
|
+
pattern: new RegExp(`${source}$`),
|
|
82
|
+
names: parts.filter((part) => part.startsWith(":")).map((part) => part.slice(1)),
|
|
83
|
+
target,
|
|
84
|
+
segments: parts.length,
|
|
85
|
+
literals: parts.filter((part) => !part.startsWith(":")).length,
|
|
86
|
+
own
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The routes a board answers, most specific first: each is matched as a suffix of the request's
|
|
91
|
+
* path, so `/api/board/messages/12` is `GET /messages/:id` under `/api/board`. A backend's own
|
|
92
|
+
* route at a protocol path takes its place. Discovery is the mount itself.
|
|
93
|
+
*/
|
|
94
|
+
function createRouter(backendRoutes, basePath) {
|
|
95
|
+
const patterns = [
|
|
96
|
+
...BOARD_ROUTES.map((name) => compile(routes[name].method, routes[name].path, {
|
|
97
|
+
kind: "board",
|
|
98
|
+
name
|
|
99
|
+
}, false)),
|
|
100
|
+
...METHODS.filter((name) => name !== "discovery").map((name) => compile(routes[name].method, routes[name].path, {
|
|
101
|
+
kind: "protocol",
|
|
102
|
+
name
|
|
103
|
+
}, false)),
|
|
104
|
+
...backendRoutes.map((route) => compile(route.method, route.path, {
|
|
105
|
+
kind: "backend",
|
|
106
|
+
route
|
|
107
|
+
}, true))
|
|
108
|
+
].sort((a, b) => b.segments - a.segments || b.literals - a.literals || Number(b.own) - Number(a.own));
|
|
109
|
+
/** A segment that isn't URI-encoded names nothing: no route. */
|
|
110
|
+
const found = (candidate, base, values) => {
|
|
111
|
+
const params = {};
|
|
112
|
+
try {
|
|
113
|
+
candidate.names.forEach((name, i) => params[name] = decodeURIComponent(values[i]));
|
|
114
|
+
} catch {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
const first = candidate.names[0];
|
|
118
|
+
return {
|
|
119
|
+
target: candidate.target,
|
|
120
|
+
base,
|
|
121
|
+
param: first === void 0 ? null : params[first],
|
|
122
|
+
params
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
const discovery = (base) => ({
|
|
126
|
+
target: {
|
|
127
|
+
kind: "protocol",
|
|
128
|
+
name: "discovery"
|
|
129
|
+
},
|
|
130
|
+
base,
|
|
131
|
+
param: null,
|
|
132
|
+
params: {},
|
|
133
|
+
root: true
|
|
134
|
+
});
|
|
135
|
+
return function route(method, pathname) {
|
|
136
|
+
const path = pathname.length > 1 ? pathname.replace(/\/+$/, "") : pathname;
|
|
137
|
+
if (basePath !== void 0) {
|
|
138
|
+
const base = basePath.replace(/\/+$/, "");
|
|
139
|
+
if (path !== base && !path.startsWith(`${base}/`)) return null;
|
|
140
|
+
const rest = path.slice(base.length) || "/";
|
|
141
|
+
if (rest === "/") return method === "GET" ? discovery(base) : null;
|
|
142
|
+
for (const candidate of patterns) {
|
|
143
|
+
const hit = candidate.method === method ? rest.match(new RegExp(`^${candidate.pattern.source}`)) : null;
|
|
144
|
+
if (hit) return found(candidate, base, hit.slice(1));
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
for (const candidate of patterns) {
|
|
149
|
+
if (candidate.method !== method) continue;
|
|
150
|
+
const hit = path.match(candidate.pattern);
|
|
151
|
+
if (hit) return found(candidate, path.slice(0, hit.index), hit.slice(1));
|
|
152
|
+
}
|
|
153
|
+
return method === "GET" ? discovery(path === "/" ? "" : path) : null;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function queryObject(url) {
|
|
157
|
+
const out = {};
|
|
158
|
+
for (const key of new Set(url.searchParams.keys())) {
|
|
159
|
+
const values = url.searchParams.getAll(key);
|
|
160
|
+
out[key] = values.length > 1 ? values : values[0];
|
|
161
|
+
}
|
|
162
|
+
return out;
|
|
163
|
+
}
|
|
164
|
+
async function readJson(request) {
|
|
165
|
+
const text = await request.text();
|
|
166
|
+
if (text.trim() === "") return void 0;
|
|
167
|
+
try {
|
|
168
|
+
return JSON.parse(text);
|
|
169
|
+
} catch {
|
|
170
|
+
throw badRequest("request body is not valid JSON");
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const tooLarge = () => new HttpError(413, "too_large", `attachments are at most ${ATTACHMENT_BYTES_MAX / 1024 / 1024} MB`);
|
|
174
|
+
/** The body, refused as soon as it's past `max`: with or without a `content-length`, it never reads more. */
|
|
175
|
+
async function readCapped(request, max) {
|
|
176
|
+
if (Number(request.headers.get("content-length") ?? 0) > max) throw tooLarge();
|
|
177
|
+
const chunks = [];
|
|
178
|
+
let size = 0;
|
|
179
|
+
for await (const chunk of request.body ?? []) {
|
|
180
|
+
size += chunk.byteLength;
|
|
181
|
+
if (size > max) throw tooLarge();
|
|
182
|
+
chunks.push(chunk);
|
|
183
|
+
}
|
|
184
|
+
const body = new Uint8Array(size);
|
|
185
|
+
let at = 0;
|
|
186
|
+
for (const chunk of chunks) {
|
|
187
|
+
body.set(chunk, at);
|
|
188
|
+
at += chunk.byteLength;
|
|
189
|
+
}
|
|
190
|
+
return body;
|
|
191
|
+
}
|
|
192
|
+
function openapi() {
|
|
193
|
+
const paths = {};
|
|
194
|
+
for (const [name, definition] of Object.entries(routes)) {
|
|
195
|
+
const path = definition.path.replace(/:(\w+)/g, "{$1}");
|
|
196
|
+
const operation = { operationId: name };
|
|
197
|
+
if ("query" in definition) operation["x-query-schema"] = z.toJSONSchema(definition.query, { io: "input" });
|
|
198
|
+
if ("body" in definition) operation.requestBody = { content: { "application/json": { schema: z.toJSONSchema(definition.body, { io: "input" }) } } };
|
|
199
|
+
(paths[path] ??= {})[definition.method.toLowerCase()] = operation;
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
openapi: "3.1.0",
|
|
203
|
+
info: {
|
|
204
|
+
title: "board",
|
|
205
|
+
version: VERSION
|
|
206
|
+
},
|
|
207
|
+
paths
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region src/api/tail.ts
|
|
212
|
+
/** The filter flags `read`, `tail`, and `wait` share, and that a watcher's `tail` accepts. */
|
|
213
|
+
const FILTER_FLAGS = {
|
|
214
|
+
re: options.re,
|
|
215
|
+
by: options.by,
|
|
216
|
+
mentions: options.mentions,
|
|
217
|
+
label: options.label,
|
|
218
|
+
source: options.source,
|
|
219
|
+
text: options.text
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* What `--mentions` takes as its value when it's the next word: `@ada`, `ada@vercel.com`, or `me`.
|
|
223
|
+
* A channel never has an `@`, and a flag (`--text=a@b`) is never the value.
|
|
224
|
+
*/
|
|
225
|
+
const mentionValue = (word) => word !== void 0 && !word.startsWith("-") && (word === "me" || word.includes("@"));
|
|
226
|
+
/**
|
|
227
|
+
* `--mentions` alone means mentions of me; `--mentions @ada`, mentions of ada; `--mentions
|
|
228
|
+
* ada@vercel.com`, of the user with that email. Nothing after `--` is a flag.
|
|
229
|
+
*/
|
|
230
|
+
function withMentions(args) {
|
|
231
|
+
const out = [];
|
|
232
|
+
for (let i = 0; i < args.length; i++) {
|
|
233
|
+
const arg = args[i];
|
|
234
|
+
if (arg === "--") {
|
|
235
|
+
out.push(...args.slice(i));
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
if (arg !== "--mentions") out.push(arg);
|
|
239
|
+
else if (mentionValue(args[i + 1])) out.push(`--mentions=${args[++i]}`);
|
|
240
|
+
else out.push("--mentions=me");
|
|
241
|
+
}
|
|
242
|
+
return out;
|
|
243
|
+
}
|
|
244
|
+
/** Splits an expression the way a shell would: whitespace separates, quotes group, `\` escapes. */
|
|
245
|
+
function words(expression) {
|
|
246
|
+
const out = [];
|
|
247
|
+
let word = null;
|
|
248
|
+
let quote = null;
|
|
249
|
+
for (let i = 0; i < expression.length; i++) {
|
|
250
|
+
const char = expression[i];
|
|
251
|
+
if (quote) {
|
|
252
|
+
if (char === quote) quote = null;
|
|
253
|
+
else if (char === "\\" && quote === "\"" && i + 1 < expression.length) word += expression[++i];
|
|
254
|
+
else word += char;
|
|
255
|
+
} else if (/\s/.test(char)) {
|
|
256
|
+
if (word !== null) out.push(word);
|
|
257
|
+
word = null;
|
|
258
|
+
} else if (char === "\"" || char === "'") {
|
|
259
|
+
quote = char;
|
|
260
|
+
word ??= "";
|
|
261
|
+
} else if (char === "\\" && i + 1 < expression.length) word = (word ?? "") + expression[++i];
|
|
262
|
+
else word = (word ?? "") + char;
|
|
263
|
+
}
|
|
264
|
+
if (quote) throw new Error(`unterminated ${quote}`);
|
|
265
|
+
if (word !== null) out.push(word);
|
|
266
|
+
return out;
|
|
267
|
+
}
|
|
268
|
+
/** A watcher's tail takes the filters and `--all`, which shows receipts as it does in `vb tail`. */
|
|
269
|
+
const TAIL_FLAGS = {
|
|
270
|
+
...FILTER_FLAGS,
|
|
271
|
+
all: { type: "boolean" }
|
|
272
|
+
};
|
|
273
|
+
/**
|
|
274
|
+
* Parses filter flags as the CLI's parser does (Node's `parseArgs`, strict), written out so a tail
|
|
275
|
+
* parses wherever board() runs, a browser included.
|
|
276
|
+
*/
|
|
277
|
+
function parseFilterFlags(args) {
|
|
278
|
+
const values = {};
|
|
279
|
+
const positionals = [];
|
|
280
|
+
for (let i = 0; i < args.length; i++) {
|
|
281
|
+
const arg = args[i];
|
|
282
|
+
if (arg === "--") {
|
|
283
|
+
positionals.push(...args.slice(i + 1));
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
if (!arg.startsWith("-") || arg === "-") {
|
|
287
|
+
positionals.push(arg);
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
const eq = arg.indexOf("=");
|
|
291
|
+
const name = arg.startsWith("--") ? arg.slice(2, eq === -1 ? void 0 : eq) : null;
|
|
292
|
+
const spec = name !== null && Object.hasOwn(TAIL_FLAGS, name) ? TAIL_FLAGS[name] : null;
|
|
293
|
+
if (!spec) throw new Error(`${name !== null ? `--${name}` : arg.slice(0, 2)} isn't a filter`);
|
|
294
|
+
if (spec.type === "boolean") {
|
|
295
|
+
if (eq !== -1) throw new Error(`--${name} takes no value`);
|
|
296
|
+
values[name] = true;
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
let value;
|
|
300
|
+
if (eq !== -1) value = arg.slice(eq + 1);
|
|
301
|
+
else {
|
|
302
|
+
const next = args[i + 1];
|
|
303
|
+
if (next === void 0 || next.length > 1 && next.startsWith("-")) throw new Error(`--${name} needs a value`);
|
|
304
|
+
value = next;
|
|
305
|
+
i++;
|
|
306
|
+
}
|
|
307
|
+
if ("multiple" in spec) values[name] = [...values[name] ?? [], value];
|
|
308
|
+
else values[name] = value;
|
|
309
|
+
}
|
|
310
|
+
return {
|
|
311
|
+
values,
|
|
312
|
+
positionals
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
/** A watcher's `tail`: its filters, and whether `--all` shows it receipts too. */
|
|
316
|
+
function parseWatchTail(expression) {
|
|
317
|
+
const { values, positionals } = parseFilterFlags(withMentions(words(expression)));
|
|
318
|
+
if (positionals.length > 1) throw new Error(`expected one channel, got: ${positionals.join(" ")}`);
|
|
319
|
+
const channel = positionals[0];
|
|
320
|
+
const parsed = Filters.safeParse({
|
|
321
|
+
...channel ? { channel } : {},
|
|
322
|
+
...values.re ? { re: values.re.replace(/^#/, "") } : {},
|
|
323
|
+
...values.by ? { by: values.by.replace(/^@/, "") } : {},
|
|
324
|
+
...values.mentions ? { mentions: values.mentions.replace(/^@/, "") } : {},
|
|
325
|
+
...values.label?.length ? { label: values.label } : {},
|
|
326
|
+
...values.source ? { from: values.source } : {},
|
|
327
|
+
...values.text ? { text: values.text } : {}
|
|
328
|
+
});
|
|
329
|
+
if (!parsed.success) {
|
|
330
|
+
const issue = parsed.error.issues[0];
|
|
331
|
+
throw new Error(`${issue?.path.length ? `--${String(issue.path[0])}: ` : ""}${issue?.message ?? "invalid filters"}`);
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
filters: parsed.data,
|
|
335
|
+
all: values.all === true
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
//#endregion
|
|
339
|
+
//#region src/server/watch-spec.ts
|
|
340
|
+
/** Whether filters narrow anything: a view a message can enter. */
|
|
341
|
+
const hasCriteria = (filters) => filters.channel !== void 0 || filters.re !== void 0 || filters.by !== void 0 || filters.mentions !== void 0 || filters.from !== void 0 || filters.text !== void 0 || (filters.label?.length ?? 0) > 0;
|
|
342
|
+
/** A watcher's tail, checked the way a boot checks it: errors name the watcher. */
|
|
343
|
+
function compileWatcher(id, spec) {
|
|
344
|
+
let filters;
|
|
345
|
+
let all;
|
|
346
|
+
try {
|
|
347
|
+
({filters, all} = parseWatchTail(spec.tail));
|
|
348
|
+
} catch (error) {
|
|
349
|
+
throw new Error(`watch ${id}: ${error.message}`);
|
|
350
|
+
}
|
|
351
|
+
if (filters.mentions === "me") throw new Error(`watch ${id}: a watcher has no "me": use --mentions @handle`);
|
|
352
|
+
return {
|
|
353
|
+
filters,
|
|
354
|
+
criteria: hasCriteria(filters),
|
|
355
|
+
all
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/server/watch-run.ts
|
|
360
|
+
/**
|
|
361
|
+
* A2 dead-letters an event after 10 failures, and a dead letter stops its
|
|
362
|
+
* lane, which is the thread's: the watcher would never run on that thread
|
|
363
|
+
* again. So `run` gets a few tries, then the failure is recorded and the
|
|
364
|
+
* thread moves on.
|
|
365
|
+
*/
|
|
366
|
+
const RUN_ATTEMPTS = 5;
|
|
367
|
+
/**
|
|
368
|
+
* A run that's killed (a timeout, out of memory) never throws. A2 counts it
|
|
369
|
+
* toward the 10 failures when the next attempt takes over, and dead-letters
|
|
370
|
+
* the event at that takeover instead of running it: the 10th attempt is the
|
|
371
|
+
* last one a watcher sees. Throws give up at RUN_ATTEMPTS, so getting this far
|
|
372
|
+
* means runs keep dying, and the 10th records the failure without running.
|
|
373
|
+
*/
|
|
374
|
+
const KILLED_ATTEMPTS = 10;
|
|
375
|
+
const describe = (error) => ((error instanceof Error ? error.message : String(error)) || "unknown error").slice(0, 500);
|
|
376
|
+
/**
|
|
377
|
+
* One match, on its thread's lane: `run`, retried while it fails (by A2 on a local board, by the
|
|
378
|
+
* tail on a person's Vercel board), then given up on and recorded so the thread's next event runs.
|
|
379
|
+
*/
|
|
380
|
+
async function runMatch(input) {
|
|
381
|
+
const { watcher, match, attempt } = input;
|
|
382
|
+
const event = match.payload.event;
|
|
383
|
+
const giveUp = async (error) => {
|
|
384
|
+
console.error(`[board] watcher ${watcher.id} gave up on event #${event.cursor} after ${attempt} tries:`, error);
|
|
385
|
+
await input.record({
|
|
386
|
+
matched: match.id,
|
|
387
|
+
thread: match.payload.thread,
|
|
388
|
+
error
|
|
389
|
+
});
|
|
390
|
+
};
|
|
391
|
+
const early = !afterRetry(attempt);
|
|
392
|
+
if (early && attempt >= KILLED_ATTEMPTS) return giveUp(`its run was cut short ${attempt - 1} times (a timeout, or out of memory)`);
|
|
393
|
+
try {
|
|
394
|
+
await watcher.run(event);
|
|
395
|
+
} catch (error) {
|
|
396
|
+
if (!early || attempt < RUN_ATTEMPTS) throw error;
|
|
397
|
+
await giveUp(describe(error));
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
//#endregion
|
|
401
|
+
//#region src/server/watchers-hash.ts
|
|
402
|
+
/** By UTF-16 code unit, as `sort()` orders strings: the same in every locale and runtime. */
|
|
403
|
+
const byCodeUnit = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
404
|
+
/**
|
|
405
|
+
* What `watchersHash` hashes, the same on both ends: a board on `http()` hashes its watchers, and
|
|
406
|
+
* whether its sync subscribes, and the board it uses hashes what it holds.
|
|
407
|
+
*/
|
|
408
|
+
function canonicalWatchers(watch, sync = []) {
|
|
409
|
+
const canonical = Object.keys(watch).sort(byCodeUnit).map((id) => [id, watch[id].tail]);
|
|
410
|
+
if (sync.length > 0) canonical.push(["sync", [...sync].sort((a, b) => byCodeUnit(a.key, b.key)).map((entry) => [entry.key, entry.platform])]);
|
|
411
|
+
return JSON.stringify(canonical);
|
|
412
|
+
}
|
|
413
|
+
//#endregion
|
|
414
|
+
//#region src/server/targets.ts
|
|
415
|
+
/** A target as a post or a receipt names it, resolved: a plain one's kind goes by its shape. */
|
|
416
|
+
const syncTarget = (target) => typeof target === "string" ? {
|
|
417
|
+
target,
|
|
418
|
+
kind: isThreadTarget(target) ? "thread" : "channel"
|
|
419
|
+
} : target;
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region src/server/origin.ts
|
|
422
|
+
/**
|
|
423
|
+
* Sync in board() itself, on a board whose log is in this deployment (`local()`): it checked each
|
|
424
|
+
* platform event itself, so what it imports is by the platform user, not a profile of anyone.
|
|
425
|
+
*/
|
|
426
|
+
const SYNC_ACTOR = "board:sync";
|
|
427
|
+
//#endregion
|
|
428
|
+
export { compileWatcher as a, METHODS as c, queryObject as d, readCapped as f, VERSION as h, runMatch as i, createRouter as l, SYNC as m, syncTarget as n, hasCriteria as o, readJson as p, canonicalWatchers as r, withMentions as s, SYNC_ACTOR as t, openapi as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { At as ThreadsQueryInput, Ct as SyncReceiptInput, Dt as ThreadView, F as Me, I as MessageView, L as MessagesPage, N as MatchView, Ot as ThreadsPage, Pt as UpdateGrantInput, T as InboxItem, Tt as SyncedView, X as RegistrationView, Y as RegisterInput, _ as FiltersInput, _t as SyncFindInput, a as BoardEventView, b as GrantInput, cn as ExternalAuthor, ct as SchemaView, dn as ExternalLink, f as EventsPage, fn as Link, ft as SourceRead, g as Explanation, in as Attachment, it as SchedulesQueryInput, ln as ExternalEvent, lt as SourceJoin, n as ActorView, nn as Actor, nt as ScheduleView, rn as ExternalCopy, s as ChannelView, st as SchemaInput, u as Discovery, un as ExternalFile, w as InboxEntry, wt as SyncThreadView, x as GrantView, xt as SyncImportInput, yt as SyncFindView, z as MessagesQueryInput } from "./routes-zm4TXKCC.mjs";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region src/client/client.d.ts
|
|
4
4
|
/**
|
|
@@ -84,6 +84,16 @@ type UploadInput = {
|
|
|
84
84
|
/** A MIME type; a `Blob`'s own type, or one from the name's extension, otherwise. */
|
|
85
85
|
type?: string;
|
|
86
86
|
};
|
|
87
|
+
/** Whether live events are flowing: `live` once the board has answered a request for them, `retrying` once one failed and it's backing off. */
|
|
88
|
+
type EventsState = 'live' | 'retrying';
|
|
89
|
+
/**
|
|
90
|
+
* What following events takes: a `signal` that stops it, and `onState`, told each time the feed
|
|
91
|
+
* goes live or starts retrying. It hears nothing before the first answer or failure.
|
|
92
|
+
*/
|
|
93
|
+
type EventsOptions = {
|
|
94
|
+
signal?: AbortSignal;
|
|
95
|
+
onState?: (state: EventsState) => void;
|
|
96
|
+
};
|
|
87
97
|
type WaitOptions = {
|
|
88
98
|
/** `'30s'`, `'10m'`, `'1h'`, or milliseconds. Default `'30m'`. */
|
|
89
99
|
timeout?: string | number;
|
|
@@ -355,19 +365,36 @@ declare function createBoardClient(options: ClientOptions): {
|
|
|
355
365
|
}) => Promise<{
|
|
356
366
|
ok: true;
|
|
357
367
|
}>;
|
|
358
|
-
/** Live events. Reconnects from the last seen index whenever the stream closes. */
|
|
368
|
+
/** Live events. Reconnects from the last seen index whenever the stream closes, and tells `onState` whether it's live or retrying. */
|
|
359
369
|
events(query?: Filters & {
|
|
360
370
|
after?: string;
|
|
361
371
|
all?: boolean;
|
|
362
|
-
}, opts?:
|
|
363
|
-
signal?: AbortSignal;
|
|
364
|
-
}): AsyncGenerator<BoardEventView>;
|
|
372
|
+
}, opts?: EventsOptions): AsyncGenerator<BoardEventView>;
|
|
365
373
|
/** The next matching event after `after` (default: now), or null on timeout. */
|
|
366
374
|
wait(query?: Filters & {
|
|
367
375
|
after?: string;
|
|
368
376
|
}, opts?: WaitOptions): Promise<BoardEventView | null>;
|
|
369
377
|
};
|
|
370
378
|
//#endregion
|
|
379
|
+
//#region src/contract/bots.d.ts
|
|
380
|
+
/**
|
|
381
|
+
* Known bot messages, shown in a form people can read. The board keeps what the
|
|
382
|
+
* bot wrote (`--json` and the API return it as is); `displayText` is what a
|
|
383
|
+
* person sees in `vb read`, inspect, and the copies on other platforms.
|
|
384
|
+
*/
|
|
385
|
+
type VercelDeployment = {
|
|
386
|
+
project: string;
|
|
387
|
+
projectUrl: string | null;
|
|
388
|
+
status: string;
|
|
389
|
+
deploymentUrl: string | null;
|
|
390
|
+
previewUrl: string | null;
|
|
391
|
+
/** As Vercel wrote it, e.g. `Oct 6, 2026 8:30pm UTC`. */
|
|
392
|
+
updated: string | null;
|
|
393
|
+
/** The same as a time, e.g. `2026-10-06T20:30:32.400Z`, when Vercel's comment carries one. */
|
|
394
|
+
updatedAt: string | null;
|
|
395
|
+
skipped: boolean;
|
|
396
|
+
};
|
|
397
|
+
//#endregion
|
|
371
398
|
//#region src/sync/events.d.ts
|
|
372
399
|
declare const EventBase: z.ZodObject<{
|
|
373
400
|
channel: z.ZodString;
|
|
@@ -826,10 +853,16 @@ type ProviderSender = {
|
|
|
826
853
|
avatar: string | null;
|
|
827
854
|
attribution?: string;
|
|
828
855
|
};
|
|
856
|
+
/**
|
|
857
|
+
* What a platform is asked to post or edit: markdown, which it converts to its own format.
|
|
858
|
+
* `deployments` comes with Vercel's deployment comment, whose markdown lists them a line each,
|
|
859
|
+
* for a platform that lays them out itself (Slack's table).
|
|
860
|
+
*/
|
|
829
861
|
type ProviderPost = {
|
|
830
862
|
markdown: string;
|
|
831
863
|
files?: ProviderFile[];
|
|
832
864
|
as?: ProviderSender;
|
|
865
|
+
deployments?: VercelDeployment[];
|
|
833
866
|
};
|
|
834
867
|
type ProviderDelivery = {
|
|
835
868
|
thread: string;
|
|
@@ -1034,4 +1067,4 @@ declare abstract class SyncProvider<E extends ProviderEvent = ProviderEvent> {
|
|
|
1034
1067
|
render(input: RenderInput): string;
|
|
1035
1068
|
}
|
|
1036
1069
|
//#endregion
|
|
1037
|
-
export { SyncRoot as A,
|
|
1070
|
+
export { SyncRoot as A, Filters as B, mirror as C, RootOverride as D, ProviderEvent as E, BoardError as F, ScheduleTiming as G, ProfileOption as H, ErrorOrigin as I, duration as J, UploadInput as K, EventsOptions as L, eventSchema as M, VercelDeployment as N, SyncOverrides as O, BoardClient as P, EventsState as R, into as S, EventBase as T, ReplyOptions as U, PostOptions as V, ScheduleOptions as W, SyncFn as _, ProviderOptions as a, SyncUnit as b, Receive as c, Renderer as d, ResolvedTarget as f, Sync as g, UnreadableError as h, ProviderFile as i, envelope as j, SyncResult as k, ReceivedEvent as l, SyncProvider as m, FileDelivery as n, ProviderPost as o, SyncContext as p, WaitOptions as q, ProviderDelivery as r, ProviderSender as s, FetchedLink as t, RenderInput as u, SyncIn as v, render as w, channels as x, SyncOut as y, ExplainPrincipal as z };
|