@vercel/board 0.57.0 → 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.
- package/README.md +1 -1
- package/dist/{access-CIj7v_Dr.mjs → access-CZ419Vho.mjs} +1 -1
- package/dist/access.mjs +4 -4
- package/dist/{actors-DVDTqjm7.mjs → actors-CXMWplob.mjs} +2 -2
- package/dist/{auth-BDWGvFWl.mjs → auth-AwZJQpCO.mjs} +2 -2
- package/dist/backend-local.mjs +1 -1
- package/dist/backend-postgres.mjs +3 -3
- package/dist/cli-commands.d.mts +1 -1
- package/dist/cli-commands.mjs +1 -1
- package/dist/cli-embedded.mjs +2 -2
- package/dist/cli.mjs +6 -6
- package/dist/{commands-DLPIX7Jw.d.mts → commands-Dcm4_pc1.d.mts} +3 -3
- package/dist/{commands-7FY_8p92.mjs → commands-DeYAQUcP.mjs} +10 -5
- package/dist/{conformance-FiQ68adg.mjs → conformance-EtEq22w1.mjs} +2 -2
- package/dist/conformance.mjs +1 -1
- package/dist/{engine-B_CjnE3G.mjs → engine-CfVTyEeo.mjs} +2 -2
- package/dist/{errors-BfMR39F0.mjs → errors-DjatfYjl.mjs} +161 -2
- package/dist/{exports-x-ioAfbp.mjs → exports-B_UGnrnN.mjs} +171 -55
- package/dist/index.mjs +4 -4
- package/dist/index.node.mjs +4 -4
- package/dist/inspect/app.js +126 -146
- package/dist/inspect/engine.js +3 -3
- package/dist/inspect/sheet-presentation.js +1 -0
- package/dist/{inspect-BFnDSdsq.mjs → inspect-DfJzHFiE.mjs} +2 -2
- package/dist/inspect-H1MISWwN.mjs +2 -0
- package/dist/inspect.mjs +1 -1
- package/dist/{local-Gp8pqHSu.mjs → local-BiG1WJk0.mjs} +5 -5
- package/dist/{local-Bt1-jA9A.mjs → local-D2i5sxuY.mjs} +19 -8
- package/dist/{main-Du-mKQZn.mjs → main-Bbqg3Unf.mjs} +82 -33
- package/dist/{memory-74hyK6eH.mjs → memory-BmsyKyHu.mjs} +1 -1
- package/dist/{middleware-bIABV895.mjs → middleware-D2AGrGj7.mjs} +2 -32
- package/dist/{serve-xOoxwq7T.mjs → serve-D06-DMej.mjs} +6 -6
- package/dist/{server-BSexF7Bk.mjs → server-BXbcS-n9.mjs} +25 -10
- package/dist/{serving-ByD4TOOU.mjs → serving-B2BNr4PR.mjs} +1 -1
- package/dist/{shell-0nWQEqh3.mjs → shell-C8EowDEz.mjs} +11 -7
- package/dist/{sqlite-DtfrT_EP.mjs → sqlite-B9ZLSDUT.mjs} +1 -1
- package/dist/{sqlite-db-DSVlzQjv.mjs → sqlite-db-DawFxCk6.mjs} +20 -5
- package/dist/{task-batch-DgyfK9qx.mjs → task-batch-YMVr_c5R.mjs} +4 -4
- package/dist/{tokens-_1X8JNLT.mjs → tokens-CaEPmiG1.mjs} +2 -2
- package/dist/{version-CZT5WmZs.mjs → version-BRR9FkLa.mjs} +1 -1
- package/docs/01-board/01-mounting.md +9 -0
- package/docs/01-board/05-reading.md +2 -1
- package/docs/01-board/09-access.md +8 -4
- package/docs/01-board/11-tasks.md +1 -1
- package/docs/01-board/12-postgres.md +3 -3
- package/docs/03-guides/02-inspector.md +1 -1
- package/docs/04-reference/01-cli.md +1 -1
- package/docs/04-reference/03-http.md +1 -0
- package/package.json +2 -2
- package/dist/inspect-BuNsu2z6.mjs +0 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { d as mediaType, i as ATTACHMENT_BYTES_MAX, n as formatProfileHeader, o as IMPORT_BYTES_MAX } from "./profile-header-O8wC8yk8.mjs";
|
|
2
2
|
import { T as TASK_LABEL, b as RemoteWatcherId, y as RESERVED_LABEL_PREFIX } from "./schemas-CUSTEFIy.mjs";
|
|
3
|
-
import { $ as
|
|
4
|
-
import { _ as sha256, a as waitUntil, c as platformProfile, d as userIdOf, m as derivedId, o as actorParts, r as runMiddleware, s as importedHandle, t as DroppedError, u as underPrincipal } from "./middleware-bIABV895.mjs";
|
|
3
|
+
import { $ as Ref, A as ClaimTaskBody, B as ExplainQuery, C as ActorsQuery, D as ChannelMessagesQuery, E as CancelTaskBody, F as CreateTasksBody, G as InboxNextQuery, I as CreatedTasksQuery, J as LabelBody, K as InboxPushBody, L as DeleteBody, M as CreateChannelBody, N as CreateGrantsBody, O as ChannelsQuery, P as CreateTaskBody, Q as ReactBody, R as EditBody, S as AckBody, T as BlockTaskBody, U as GrantBody, V as FailTaskBody, W as InboxAckBody, X as MatchesQuery, Y as LinkedQuery, Z as PostBody, _t as ThreadsQuery, a as duplicateId, at as SchedulesQuery, bt as UploadStartBody, c as notFound, ct as SourceReadQuery, d as unauthorized, dt as SyncFindQuery, et as RegisterBody, f as BoardError, ft as SyncImportBody, g as refusalCode, gt as ThreadQuery, h as eventsState, ht as TasksQuery, i as batchTooLarge, it as ScheduleBody, j as CompleteTaskBody, k as ClaimReadyTaskBody, lt as SyncBody, m as duration, mt as TaskNeedsBody, n as RejectedError, nt as RenewTaskBody, o as forbidden, ot as SchemaBody, p as createBoardClient, pt as SyncReceiptBody, q as InboxQuery, r as badRequest, rt as RevokeGrantBody, s as json, st as SourceJoinBody, t as HttpError, tt as ReleaseTaskBody, u as toErrorResponse, ut as SyncCopiesQuery, v as derivedId, vt as TypingBody, w as AssignTaskBody, x as sha256, xt as routes, yt as UpdateGrantBody, z as EventsQuery } from "./errors-DjatfYjl.mjs";
|
|
5
4
|
import { n as blocksIn, r as findBlocks } from "./blocks-CVoBC7ur.mjs";
|
|
6
5
|
import { a as mentionTerms, c as settleMentions, i as mentionTerm, r as meTerms, s as replaceMentions, t as extractMentions } from "./mentions-DBGmqkr2.mjs";
|
|
7
|
-
import { t as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
6
|
+
import { a as waitUntil, c as platformProfile, d as userIdOf, o as actorParts, r as runMiddleware, s as importedHandle, t as DroppedError, u as underPrincipal } from "./middleware-D2AGrGj7.mjs";
|
|
7
|
+
import { t as VERSION } from "./version-BRR9FkLa.mjs";
|
|
8
|
+
import { a as canText, c as compileAccess, d as parsePattern, n as InvalidCan, r as PERMISSIONS, t as FULL_ACCESS, u as parseCan } from "./access-CZ419Vho.mjs";
|
|
9
|
+
import { _ as uploadName, a as runMatch, d as createRouter, f as openapi, g as carried, h as readJson, i as canonicalWatchers, m as readCapped, n as SYNC_ACTOR, o as compileWatcher, p as queryObject, r as syncTarget, t as batchPlan, u as METHODS, v as SYNC } from "./task-batch-YMVr_c5R.mjs";
|
|
10
|
+
import { C as verifiedIssuers, D as explainGrants, d as createAuthority, f as fromTokens, m as hostPrincipal, o as VERCEL_ISSUER, p as grantIssuers, t as DEFAULT_CAN$1, v as namesByLogin, w as verifiesTokens } from "./auth-AwZJQpCO.mjs";
|
|
11
|
+
import { a as resolveActor, o as viaOf, r as claimsOf, t as KNOWN_AGENTS } from "./actors-CXMWplob.mjs";
|
|
12
12
|
import { t as checkValue } from "./data-values-CoTP0SQG.mjs";
|
|
13
13
|
//#region src/server/registrant.ts
|
|
14
14
|
/** Registering again this soon after the same registration only repeats it. */
|
|
@@ -1098,11 +1098,27 @@ function createVercel(options, environment) {
|
|
|
1098
1098
|
/** The last answer to a read of channels or actors with its `ETag`, by its URL and who asked: sent back, a 304 says it holds. The newest few. */
|
|
1099
1099
|
const tagged = /* @__PURE__ */ new Map();
|
|
1100
1100
|
/**
|
|
1101
|
+
* A request to the API, as `who`. A path that names the board by its name (`onBoard`) asked nothing
|
|
1102
|
+
* first, so where the API knows no such board the caller can enter (404 `board_not_found`), the
|
|
1103
|
+
* board is found or made as `boardId` does it, once, and the request goes again by its ID, as
|
|
1104
|
+
* every one after it does.
|
|
1105
|
+
*/
|
|
1106
|
+
async function api(who, method, path, init = {}) {
|
|
1107
|
+
const named = path.startsWith("/boards/") ? namedBoard() : null;
|
|
1108
|
+
if (named === null || !(path === named || path.startsWith(`${named}/`) || path.startsWith(`${named}?`))) return request(who, method, path, init);
|
|
1109
|
+
if (board === null) try {
|
|
1110
|
+
return await request(who, method, path, init);
|
|
1111
|
+
} catch (error) {
|
|
1112
|
+
if (!(error instanceof HttpError && error.status === 404 && error.code === "board_not_found")) throw error;
|
|
1113
|
+
}
|
|
1114
|
+
return request(who, method, `/boards/${encodeURIComponent(await boardId(who))}${path.slice(named.length)}`, init);
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1101
1117
|
* One request to the API, as `who`. Its errors are the API's own, with its status and code. One the
|
|
1102
1118
|
* API puts off (429, or a 503), or that its gateway lost (502, 504), waits and goes again as it was,
|
|
1103
1119
|
* so a write keeps its operation ID and lands once.
|
|
1104
1120
|
*/
|
|
1105
|
-
async function
|
|
1121
|
+
async function request(who, method, path, init = {}) {
|
|
1106
1122
|
const url = new URL(`${origin}/v${init.version ?? 1}/messageboard${path}`);
|
|
1107
1123
|
const id = await teamId();
|
|
1108
1124
|
if (id) url.searchParams.set(id.startsWith("team_") ? "teamId" : "slug", id);
|
|
@@ -1121,6 +1137,7 @@ function createVercel(options, environment) {
|
|
|
1121
1137
|
if (kept) headers["if-none-match"] = kept.etag;
|
|
1122
1138
|
const repeatable = method !== "POST" && method !== "PATCH" || typeof init.body?.operationId === "string";
|
|
1123
1139
|
const started = Date.now();
|
|
1140
|
+
let renewed = false;
|
|
1124
1141
|
for (let attempt = 0;; attempt++) {
|
|
1125
1142
|
let response;
|
|
1126
1143
|
try {
|
|
@@ -1169,6 +1186,12 @@ function createVercel(options, environment) {
|
|
|
1169
1186
|
continue;
|
|
1170
1187
|
}
|
|
1171
1188
|
const error = body?.error;
|
|
1189
|
+
if (response.status === 403 && error?.invalidToken === true && !renewed && !init.signal?.aborted) {
|
|
1190
|
+
renewed = true;
|
|
1191
|
+
await pause(retryWait(0, null), init.signal);
|
|
1192
|
+
init.signal?.throwIfAborted();
|
|
1193
|
+
continue;
|
|
1194
|
+
}
|
|
1172
1195
|
if (response.status === 429) throw throttled(response, error?.code ?? "rate_limited", attempt, Date.now() - started);
|
|
1173
1196
|
const refused = new HttpError(response.status, refusalCode(response.status, error) ?? "remote_error", error?.message ?? `Vercel's API answered ${response.status}`);
|
|
1174
1197
|
if (typeof error?.reason === "string" && /^[a-z_]{1,64}$/.test(error.reason)) reasons.set(refused, error.reason);
|
|
@@ -1211,6 +1234,12 @@ function createVercel(options, environment) {
|
|
|
1211
1234
|
}
|
|
1212
1235
|
}
|
|
1213
1236
|
}
|
|
1237
|
+
/** A board's name as the API keeps one, which counts its characters once it's trimmed and NFC-normalized. */
|
|
1238
|
+
const boardNameOf = (given) => {
|
|
1239
|
+
const name = given.trim().normalize("NFC");
|
|
1240
|
+
if (!/^[^/]{1,64}$/.test(name)) throw new HttpError(400, "invalid_board_name", `${JSON.stringify(given)} isn't a board's name: one is 1 to 64 characters with no /.`, { origin: "handle" });
|
|
1241
|
+
return name;
|
|
1242
|
+
};
|
|
1214
1243
|
/**
|
|
1215
1244
|
* The board named `name` in the team: the one the API lists for it. Where it lists none, the
|
|
1216
1245
|
* caller makes it (a project's is granted to that project, in its environment), unless it says
|
|
@@ -1218,9 +1247,8 @@ function createVercel(options, environment) {
|
|
|
1218
1247
|
* team's boards, the ones you can't see included.
|
|
1219
1248
|
*/
|
|
1220
1249
|
async function boardNamed(who, given) {
|
|
1221
|
-
const name = given
|
|
1222
|
-
|
|
1223
|
-
const { boards } = await api(who, "GET", "/boards", { query: { name } });
|
|
1250
|
+
const name = boardNameOf(given);
|
|
1251
|
+
const { boards } = await request(who, "GET", "/boards", { query: { name } });
|
|
1224
1252
|
if (boards[0]) return boards[0].id;
|
|
1225
1253
|
const me = await self(who);
|
|
1226
1254
|
const { principal } = me.actor;
|
|
@@ -1229,7 +1257,7 @@ function createVercel(options, environment) {
|
|
|
1229
1257
|
origin: "handle"
|
|
1230
1258
|
});
|
|
1231
1259
|
try {
|
|
1232
|
-
const { board: made } = await
|
|
1260
|
+
const { board: made } = await request(who, "POST", "/boards/ensure", { body: {
|
|
1233
1261
|
name,
|
|
1234
1262
|
operationId: operationId()
|
|
1235
1263
|
} });
|
|
@@ -1278,20 +1306,38 @@ function createVercel(options, environment) {
|
|
|
1278
1306
|
* The board's ID: the one given, the one `board({ name })` names, or the team's, which the API
|
|
1279
1307
|
* names only to those it lets in. A team with none gets one the first time a person uses it, as
|
|
1280
1308
|
* the API asks of its clients; a project can't make it, and needs a person to grant it the board
|
|
1281
|
-
* anyway. Each is asked for once
|
|
1309
|
+
* anyway. Each is asked for once, and only where a path can't name the board by its name: the API
|
|
1310
|
+
* knew none by it, or the ID itself is wanted, as a URL to the board is.
|
|
1282
1311
|
*/
|
|
1283
|
-
const boardId = (who) => (board ??= options.board ? Promise.resolve(options.board) : boardName() ? boardNamed(who, boardName()) :
|
|
1312
|
+
const boardId = (who) => (board ??= options.board ? Promise.resolve(options.board) : boardName() ? boardNamed(who, boardName()) : request(who, "GET", "/boards").then(async ({ defaultBoardId }) => {
|
|
1284
1313
|
if (defaultBoardId) return defaultBoardId;
|
|
1285
1314
|
const me = await self(who);
|
|
1286
1315
|
const { principal } = me.actor;
|
|
1287
1316
|
if (principal.type === "project" || principal.type === "github" || principal.type === "oidc") throw notLetIn(null, principal, me.teamId);
|
|
1288
|
-
const { board: made } = await
|
|
1317
|
+
const { board: made } = await request(who, "POST", "/boards/default", { body: { operationId: operationId() } });
|
|
1289
1318
|
return made.id;
|
|
1290
1319
|
})).catch((error) => {
|
|
1291
1320
|
board = null;
|
|
1292
1321
|
throw error;
|
|
1293
1322
|
});
|
|
1294
|
-
|
|
1323
|
+
/** The team's default board's name in a path, whatever the board is named. */
|
|
1324
|
+
const DEFAULT_BOARD = "General";
|
|
1325
|
+
/**
|
|
1326
|
+
* `/boards/<name>`, as a path names a board that was given no ID: the API takes a board's name
|
|
1327
|
+
* where it takes its ID, and the default board's for the team's. Null for a board named by its ID,
|
|
1328
|
+
* and for a name a path would read as something else, which is asked for its ID as a name: `.` or
|
|
1329
|
+
* `..`, a step in a URL's path, and one that starts as an ID does (`brd_`), which the API takes for
|
|
1330
|
+
* an ID, another board's if it has one.
|
|
1331
|
+
*/
|
|
1332
|
+
const namedBoard = () => {
|
|
1333
|
+
if (options.board) return null;
|
|
1334
|
+
const name = boardNameOf(boardName() ?? DEFAULT_BOARD);
|
|
1335
|
+
return name === "." || name === ".." || name.startsWith("brd_") ? null : `/boards/${encodeURIComponent(name)}`;
|
|
1336
|
+
};
|
|
1337
|
+
/** A path on the board: by its ID where that's known, and else by its name, so nothing is asked for it first. */
|
|
1338
|
+
const onBoard = async (who, path = "") => `${(board === null ? namedBoard() : null) ?? await boardById(who)}${path}`;
|
|
1339
|
+
/** `/boards/<id>`, for what must hold when the board's name changes hands: a URL someone keeps. */
|
|
1340
|
+
const boardById = async (who) => `/boards/${encodeURIComponent(await boardId(who))}`;
|
|
1295
1341
|
let channels = null;
|
|
1296
1342
|
const loadChannels = async (who, fresh = false) => {
|
|
1297
1343
|
if (fresh) channels = null;
|
|
@@ -1565,51 +1611,81 @@ function createVercel(options, environment) {
|
|
|
1565
1611
|
};
|
|
1566
1612
|
/** A message's labels: a deleted message keeps none, though the API still holds them. */
|
|
1567
1613
|
const labelsOf = (message) => message.deletedAt === void 0 ? { ...message.labels } : {};
|
|
1568
|
-
|
|
1614
|
+
/**
|
|
1615
|
+
* A thread's messages, all of them, and with `include` its channel: the API answers it with a page of them
|
|
1616
|
+
* (`include=channel`), so naming it costs no request of its own. The first page is asked for it, and it's kept
|
|
1617
|
+
* as any channel an answer names. An API that doesn't take the parameter here refuses the read, and nothing
|
|
1618
|
+
* is read in its place.
|
|
1619
|
+
*/
|
|
1620
|
+
const threadMessages = async (who, threadId, signal, include) => {
|
|
1569
1621
|
const path = await onBoard(who, `/threads/${encodeURIComponent(threadId)}/messages`);
|
|
1570
1622
|
const messages = [];
|
|
1623
|
+
let channel;
|
|
1571
1624
|
let cursor;
|
|
1572
1625
|
do {
|
|
1573
1626
|
const page = await reading(who, path, {
|
|
1574
|
-
query: {
|
|
1627
|
+
query: {
|
|
1628
|
+
cursor,
|
|
1629
|
+
include: channel ? void 0 : include
|
|
1630
|
+
},
|
|
1575
1631
|
...signal ? { signal } : {}
|
|
1576
1632
|
});
|
|
1577
1633
|
messages.push(...page.messages);
|
|
1634
|
+
if (page.channel) learn(who, channel = page.channel);
|
|
1578
1635
|
cursor = page.cursor ?? void 0;
|
|
1579
1636
|
} while (cursor);
|
|
1580
|
-
return
|
|
1637
|
+
return {
|
|
1638
|
+
messages,
|
|
1639
|
+
channel,
|
|
1640
|
+
end: messages.at(-1)?.sequence ?? 0
|
|
1641
|
+
};
|
|
1581
1642
|
};
|
|
1582
1643
|
/** Whether the API reads a thread's messages in a range (`after`, `limit`, `order`): until it refuses one, it's asked. */
|
|
1583
1644
|
let threadRanges = true;
|
|
1584
1645
|
/**
|
|
1585
1646
|
* A thread's root, and its replies in a range: after the message at `after`, the first `limit` of them, or with no
|
|
1586
|
-
* `after`, the newest. The API reads the range itself, a page of 100 at most, and the
|
|
1587
|
-
*
|
|
1647
|
+
* `after`, the newest. The API reads the range itself, a page of 100 at most, and answers the thread with its
|
|
1648
|
+
* first page (`include=thread`): its first message, which a range may leave out, and how many messages it has,
|
|
1649
|
+
* which is where it ends. So a range costs no request for the root. With `include`, the thread's channel too,
|
|
1650
|
+
* from the same page. The API takes `include=thread` here or the read fails: nothing is read in its place. One
|
|
1651
|
+
* from before ranges answers 400 for their parameters, and the whole thread is read and cut here.
|
|
1588
1652
|
*/
|
|
1589
|
-
async function threadRange(who, threadId, range, signal) {
|
|
1590
|
-
const cut = ([root, ...replies]) => {
|
|
1653
|
+
async function threadRange(who, threadId, range, signal, include) {
|
|
1654
|
+
const cut = ({ messages: [root, ...replies], channel, end }) => {
|
|
1591
1655
|
const rest = range.after === void 0 ? replies : replies.filter((reply) => reply.sequence > range.after);
|
|
1592
|
-
return
|
|
1656
|
+
return {
|
|
1657
|
+
messages: root ? [root, ...range.limit === void 0 ? rest : range.after === void 0 ? rest.slice(-range.limit) : rest.slice(0, range.limit)] : [],
|
|
1658
|
+
channel,
|
|
1659
|
+
end
|
|
1660
|
+
};
|
|
1593
1661
|
};
|
|
1594
|
-
if (!threadRanges) return cut(await threadMessages(who, threadId, signal));
|
|
1662
|
+
if (!threadRanges) return cut(await threadMessages(who, threadId, signal, include));
|
|
1595
1663
|
const path = await onBoard(who, `/threads/${encodeURIComponent(threadId)}/messages`);
|
|
1596
|
-
const wanted = range.limit
|
|
1664
|
+
const wanted = range.limit ?? Infinity;
|
|
1597
1665
|
const order = range.after === void 0 ? { order: "desc" } : { after: String(range.after) };
|
|
1598
|
-
const
|
|
1666
|
+
const replies = [];
|
|
1667
|
+
let answered = 0;
|
|
1668
|
+
let channel;
|
|
1669
|
+
let thread;
|
|
1599
1670
|
try {
|
|
1600
1671
|
let cursor;
|
|
1601
1672
|
do {
|
|
1673
|
+
const first = cursor === void 0;
|
|
1602
1674
|
const page = await reading(who, path, {
|
|
1603
1675
|
query: {
|
|
1604
1676
|
...order,
|
|
1605
|
-
limit: String(Math.min(PAGE_MAX, wanted -
|
|
1606
|
-
cursor
|
|
1677
|
+
limit: String(Math.min(PAGE_MAX, wanted - replies.length)),
|
|
1678
|
+
cursor,
|
|
1679
|
+
include: first ? ["thread", ...include ? [include] : []] : void 0
|
|
1607
1680
|
},
|
|
1608
1681
|
...signal ? { signal } : {}
|
|
1609
1682
|
});
|
|
1610
|
-
|
|
1683
|
+
answered += page.messages.length;
|
|
1684
|
+
replies.push(...page.messages.filter((message) => message.sequence > 1));
|
|
1685
|
+
if (page.channel) learn(who, channel = page.channel);
|
|
1686
|
+
if (first) thread = page.thread;
|
|
1611
1687
|
cursor = page.cursor ?? void 0;
|
|
1612
|
-
} while (cursor &&
|
|
1688
|
+
} while (cursor && replies.length < wanted);
|
|
1613
1689
|
} catch (error) {
|
|
1614
1690
|
if (![
|
|
1615
1691
|
"after",
|
|
@@ -1617,10 +1693,22 @@ function createVercel(options, environment) {
|
|
|
1617
1693
|
"order"
|
|
1618
1694
|
].some((name) => unknownParameter(error, name))) throw error;
|
|
1619
1695
|
threadRanges = false;
|
|
1620
|
-
return cut(await threadMessages(who, threadId, signal));
|
|
1696
|
+
return cut(await threadMessages(who, threadId, signal, include));
|
|
1621
1697
|
}
|
|
1622
|
-
|
|
1623
|
-
|
|
1698
|
+
if (!thread?.rootMessage) {
|
|
1699
|
+
if (answered > 0) throw new HttpError(502, "remote_error", "Vercel's API answered a range of a thread's messages without the thread and its first message");
|
|
1700
|
+
return {
|
|
1701
|
+
messages: [],
|
|
1702
|
+
channel,
|
|
1703
|
+
end: 0
|
|
1704
|
+
};
|
|
1705
|
+
}
|
|
1706
|
+
replies.sort((a, b) => a.sequence - b.sequence);
|
|
1707
|
+
return {
|
|
1708
|
+
messages: [thread.rootMessage, ...range.limit === void 0 ? replies : range.after === void 0 ? replies.slice(-range.limit) : replies.slice(0, range.limit)],
|
|
1709
|
+
channel,
|
|
1710
|
+
end: thread.messageCount
|
|
1711
|
+
};
|
|
1624
1712
|
}
|
|
1625
1713
|
/** Who reacted with each emoji. The API counts them on the message and lists them apart. */
|
|
1626
1714
|
async function reactors(who, message) {
|
|
@@ -1765,19 +1853,23 @@ function createVercel(options, environment) {
|
|
|
1765
1853
|
} finally {
|
|
1766
1854
|
answered();
|
|
1767
1855
|
}
|
|
1768
|
-
|
|
1769
|
-
|
|
1856
|
+
return keepActors(who, read);
|
|
1857
|
+
}
|
|
1858
|
+
/** Keeps the actors an answer came with (`with=actors`), as if each one it names had been asked for by ID, one the API left out as one it doesn't have. */
|
|
1859
|
+
function keepActors(who, answer) {
|
|
1860
|
+
if (!answer.actors) return answer;
|
|
1861
|
+
const views = new Map(answer.actors.map((view) => [view.id, view]));
|
|
1770
1862
|
const { asked } = namesOf(who);
|
|
1771
1863
|
const at = Date.now();
|
|
1772
1864
|
if (asked.size >= 1e4) asked.clear();
|
|
1773
|
-
for (const { id } of namedIn(
|
|
1865
|
+
for (const { id } of namedIn(answer)) {
|
|
1774
1866
|
const view = views.get(id);
|
|
1775
1867
|
if (view || !asked.has(id) || at - asked.get(id).at > NAMES_FRESH_MS) asked.set(id, {
|
|
1776
1868
|
at,
|
|
1777
1869
|
view: Promise.resolve(view)
|
|
1778
1870
|
});
|
|
1779
1871
|
}
|
|
1780
|
-
return
|
|
1872
|
+
return answer;
|
|
1781
1873
|
}
|
|
1782
1874
|
/**
|
|
1783
1875
|
* An actor as the API names them, asked for by ID with everyone else named in the same turn: the
|
|
@@ -2455,7 +2547,7 @@ function createVercel(options, environment) {
|
|
|
2455
2547
|
const { thread, channel } = found;
|
|
2456
2548
|
if (filters.channel !== void 0 && !inPattern(channel.name, filters.channel)) return none;
|
|
2457
2549
|
const feeds = await heads(who, [channel]);
|
|
2458
|
-
const all = await threadMessages(who, thread.id, signal);
|
|
2550
|
+
const { messages: all } = await threadMessages(who, thread.id, signal);
|
|
2459
2551
|
const labeled = labeledBy(thread, all.find((message) => message.sequence === 1));
|
|
2460
2552
|
let newest = 0;
|
|
2461
2553
|
const messages = [];
|
|
@@ -3371,6 +3463,15 @@ function createVercel(options, environment) {
|
|
|
3371
3463
|
if (TASK_CONFLICTS.has(code)) return new HttpError(409, code, message);
|
|
3372
3464
|
return error;
|
|
3373
3465
|
}
|
|
3466
|
+
/** Finishes an upload. The API says which check refused it, and bytes that aren't the type their name says are the uploader's to fix. */
|
|
3467
|
+
async function completeUpload(who, id) {
|
|
3468
|
+
try {
|
|
3469
|
+
return (await api(who, "POST", await onBoard(who, `/attachments/${encodeURIComponent(id)}/complete`))).attachment;
|
|
3470
|
+
} catch (error) {
|
|
3471
|
+
if (error instanceof HttpError && error.code === "attachment_mismatch" && reasons.get(error) === "media_type") throw new HttpError(422, "attachment_type_mismatch", "the file's bytes aren't the image or video type its name says");
|
|
3472
|
+
throw error;
|
|
3473
|
+
}
|
|
3474
|
+
}
|
|
3374
3475
|
/** One write to a task route, `/tasks` and `path` after it, with an operation ID of its own. */
|
|
3375
3476
|
async function taskWrite(who, path, body, about = {}) {
|
|
3376
3477
|
try {
|
|
@@ -3644,7 +3745,7 @@ function createVercel(options, environment) {
|
|
|
3644
3745
|
const id = team?.startsWith("team_") ? team : (await self(who)).teamId;
|
|
3645
3746
|
return {
|
|
3646
3747
|
version: VERSION,
|
|
3647
|
-
url: `${origin}/v1/messageboard${await
|
|
3748
|
+
url: `${origin}/v1/messageboard${typeof found?.board.id === "string" ? `/boards/${encodeURIComponent(found.board.id)}` : await boardById(who)}?teamId=${encodeURIComponent(id)}`,
|
|
3648
3749
|
audience: origin,
|
|
3649
3750
|
team_id: id,
|
|
3650
3751
|
project_id: null,
|
|
@@ -3882,14 +3983,22 @@ function createVercel(options, environment) {
|
|
|
3882
3983
|
},
|
|
3883
3984
|
async message(caller, { id, after, limit }, signal) {
|
|
3884
3985
|
const who = whoOf(caller);
|
|
3885
|
-
const
|
|
3986
|
+
const missing = () => notFound(`message not found: ${id}`, "message_not_found");
|
|
3987
|
+
const at = locate(id);
|
|
3988
|
+
if (!at) throw missing();
|
|
3886
3989
|
const from = after === void 0 ? void 0 : locate(after);
|
|
3887
|
-
if (after !== void 0 && from?.threadId !==
|
|
3888
|
-
const
|
|
3990
|
+
if (after !== void 0 && from?.threadId !== at.threadId) throw new HttpError(400, "invalid_request", `after: ${after} isn't a message of this thread`);
|
|
3991
|
+
const read = await (from !== void 0 || limit !== void 0 ? threadRange(who, at.threadId, {
|
|
3889
3992
|
...from ? { after: from.sequence } : {},
|
|
3890
3993
|
...limit !== void 0 ? { limit } : {}
|
|
3891
|
-
}, signal) :
|
|
3892
|
-
|
|
3994
|
+
}, signal, "channel") : threadMessages(who, at.threadId, signal, "channel")).catch((error) => {
|
|
3995
|
+
if (error instanceof HttpError && (error.code === "thread_not_found" || error.code === "message_not_found")) throw missing();
|
|
3996
|
+
throw error;
|
|
3997
|
+
});
|
|
3998
|
+
const [root, ...replies] = read.messages;
|
|
3999
|
+
if (!root || at.sequence > read.end) throw missing();
|
|
4000
|
+
const { channel } = read;
|
|
4001
|
+
if (!channel) throw new HttpError(502, "remote_error", "Vercel's API answered a thread's messages without their channel");
|
|
3893
4002
|
const [message, ...shown] = await Promise.all([root, ...replies].map((each) => view(who, each, channel.name)));
|
|
3894
4003
|
return {
|
|
3895
4004
|
message,
|
|
@@ -3920,8 +4029,7 @@ function createVercel(options, environment) {
|
|
|
3920
4029
|
redirect: "error"
|
|
3921
4030
|
});
|
|
3922
4031
|
if (!put.ok) throw new HttpError(502, "upload_failed", `the upload to Vercel's storage answered ${put.status}`);
|
|
3923
|
-
|
|
3924
|
-
return { attachment: fileOf(attachment) };
|
|
4032
|
+
return { attachment: fileOf(await completeUpload(who, started.attachment.id)) };
|
|
3925
4033
|
},
|
|
3926
4034
|
async uploadStart(caller, { name, type, size, sha256 }) {
|
|
3927
4035
|
const who = whoOf(caller);
|
|
@@ -3942,8 +4050,7 @@ function createVercel(options, environment) {
|
|
|
3942
4050
|
},
|
|
3943
4051
|
async uploadFinish(caller, { id }) {
|
|
3944
4052
|
const who = whoOf(caller);
|
|
3945
|
-
|
|
3946
|
-
return { attachment: fileOf(attachment) };
|
|
4053
|
+
return { attachment: fileOf(await completeUpload(who, id)) };
|
|
3947
4054
|
},
|
|
3948
4055
|
async attachment(caller, { id }, signal) {
|
|
3949
4056
|
const who = whoOf(caller);
|
|
@@ -3979,15 +4086,19 @@ function createVercel(options, environment) {
|
|
|
3979
4086
|
signal
|
|
3980
4087
|
});
|
|
3981
4088
|
} else {
|
|
3982
|
-
const
|
|
3983
|
-
|
|
4089
|
+
const to = locate(input.re);
|
|
4090
|
+
if (!to) throw notFound(`message not found: ${input.re}`, "message_not_found");
|
|
3984
4091
|
const after = input.after === void 0 ? void 0 : locate(input.after);
|
|
3985
|
-
if (after !== void 0 && after?.threadId !==
|
|
4092
|
+
if (after !== void 0 && after?.threadId !== to.threadId) {
|
|
3986
4093
|
const landed = clientId ? await api(who, "GET", await onBoard(who, `/posts/${encodeURIComponent(clientId)}`), { signal }).catch(() => null) : null;
|
|
3987
|
-
if (landed?.thread.id ===
|
|
4094
|
+
if (landed?.thread.id === to.threadId) return { message: await view(who, landed.message, (await channelById(who, landed.thread.channelId)).name) };
|
|
3988
4095
|
throw badRequest(`after: ${input.after} isn't in ${input.re}'s thread`, "invalid_after");
|
|
3989
4096
|
}
|
|
3990
|
-
|
|
4097
|
+
const reply = await api(who, "POST", await onBoard(who, `/threads/${encodeURIComponent(to.threadId)}/messages`), {
|
|
4098
|
+
query: {
|
|
4099
|
+
include: "channel",
|
|
4100
|
+
...namesById ? { with: "actors" } : {}
|
|
4101
|
+
},
|
|
3991
4102
|
body: {
|
|
3992
4103
|
operationId: operationId(),
|
|
3993
4104
|
text: input.text,
|
|
@@ -4001,8 +4112,13 @@ function createVercel(options, environment) {
|
|
|
4001
4112
|
signal
|
|
4002
4113
|
}).catch((error) => {
|
|
4003
4114
|
if (error instanceof HttpError && error.code === "newer_message") throw new HttpError(409, "newer_message", `a message came after ${input.after}`);
|
|
4115
|
+
if (error instanceof HttpError && (error.code === "thread_not_found" || error.code === "invalid_reply")) throw notFound(`message not found: ${input.re}`, "message_not_found");
|
|
4004
4116
|
throw error;
|
|
4005
4117
|
});
|
|
4118
|
+
if ("text" in reply.message) keepActors(who, reply);
|
|
4119
|
+
if (reply.channel) learn(who, reply.channel);
|
|
4120
|
+
channelName = (reply.channel ?? (reply.thread.channelId !== void 0 ? await channelById(who, reply.thread.channelId) : (await messageIn(who, input.re, signal)).channel)).name;
|
|
4121
|
+
made = reply;
|
|
4006
4122
|
}
|
|
4007
4123
|
channelName = await landedIn(who, made.thread.channelId, channelName, clientId);
|
|
4008
4124
|
return { message: await view(who, "text" in made.message ? made.message : await sent(who, made.message, input), channelName) };
|
|
@@ -4829,7 +4945,7 @@ function createVercel(options, environment) {
|
|
|
4829
4945
|
const who = { profile: null };
|
|
4830
4946
|
const team = await teamId();
|
|
4831
4947
|
const id = team?.startsWith("team_") ? team : (await self(who)).teamId;
|
|
4832
|
-
const board = await
|
|
4948
|
+
const board = await boardById(who);
|
|
4833
4949
|
const url = `${origin}/v1/messageboard${board}?teamId=${encodeURIComponent(id)}`;
|
|
4834
4950
|
return {
|
|
4835
4951
|
url,
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { f as BoardError, m as duration, t as HttpError } from "./errors-
|
|
2
|
-
import { t as DroppedError } from "./middleware-bIABV895.mjs";
|
|
1
|
+
import { f as BoardError, m as duration, t as HttpError } from "./errors-DjatfYjl.mjs";
|
|
3
2
|
import { t as block } from "./blocks-CVoBC7ur.mjs";
|
|
4
|
-
import {
|
|
3
|
+
import { t as DroppedError } from "./middleware-D2AGrGj7.mjs";
|
|
4
|
+
import { c as createVercel, n as createTasksInChunks, r as createBoard, t as TasksInChunksError } from "./exports-B_UGnrnN.mjs";
|
|
5
5
|
//#region src/backend-vercel/index.default.ts
|
|
6
6
|
/**
|
|
7
7
|
* Your team's board, in Vercel's API. Outside Node there's no environment to find credentials or
|
|
@@ -24,7 +24,7 @@ function board(options = {}) {
|
|
|
24
24
|
if (!fetch) throw new Error("board: pass a fetch that sends credentials Vercel's API takes, or a backend: outside Node there's no environment to find them in");
|
|
25
25
|
return vercel({ fetch });
|
|
26
26
|
},
|
|
27
|
-
sync: () => import("./engine-
|
|
27
|
+
sync: () => import("./engine-CfVTyEeo.mjs"),
|
|
28
28
|
serving: null,
|
|
29
29
|
sandbox: null
|
|
30
30
|
});
|
package/dist/index.node.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { f as BoardError, m as duration, t as HttpError } from "./errors-
|
|
2
|
-
import { t as DroppedError } from "./middleware-bIABV895.mjs";
|
|
1
|
+
import { f as BoardError, m as duration, t as HttpError } from "./errors-DjatfYjl.mjs";
|
|
3
2
|
import { t as block } from "./blocks-CVoBC7ur.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
3
|
+
import { t as DroppedError } from "./middleware-D2AGrGj7.mjs";
|
|
4
|
+
import { n as createTasksInChunks, t as TasksInChunksError } from "./exports-B_UGnrnN.mjs";
|
|
5
|
+
import { t as board } from "./server-BXbcS-n9.mjs";
|
|
6
6
|
export { BoardError, DroppedError, HttpError, TasksInChunksError, block, board, createTasksInChunks, duration };
|