@vercel/board 0.54.0 → 0.55.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.
@@ -1,2 +1,2 @@
1
- import { t as local } from "./local-RoMUU6QX.mjs";
1
+ import { t as local } from "./local-Dn0vv-1e.mjs";
2
2
  export { local };
@@ -1,2 +1,2 @@
1
- import { a as option, i as groups, n as filters, o as options, r as globalOptions, s as usage, t as commands } from "./commands-B5SXeo4W.mjs";
1
+ import { a as option, i as groups, n as filters, o as options, r as globalOptions, s as usage, t as commands } from "./commands-CZUxX6HF.mjs";
2
2
  export { commands, filters, globalOptions, groups, option, options, usage };
@@ -1,5 +1,5 @@
1
- import { o as stoppedBy } from "./exports-JUhj5Bl3.mjs";
2
- import { a as commandLine, c as failureLines, i as mainWith, l as formatFailure, n as commandWord, o as exitCode, r as main, s as failureDocument, t as Failed } from "./main-B_gzTjBR.mjs";
1
+ import { o as stoppedBy } from "./exports-FRbxGU5M.mjs";
2
+ import { a as commandLine, c as failureLines, i as mainWith, l as formatFailure, n as commandWord, o as exitCode, r as main, s as failureDocument, t as Failed } from "./main-CSuYOx6C.mjs";
3
3
  //#region src/cli/embedded.ts
4
4
  /**
5
5
  * Board's CLI as `appName` names it in help, usage, and errors (`vercel board`). With no board
package/dist/cli.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { a as option } from "./commands-B5SXeo4W.mjs";
3
- import { g as projectDir } from "./server-CdBXNUxf.mjs";
4
- import { r as main } from "./main-B_gzTjBR.mjs";
5
- import { i as createInspector, r as stopped, t as allowedHosts } from "./inspect-CrVs-iEi.mjs";
2
+ import { a as option } from "./commands-CZUxX6HF.mjs";
3
+ import { g as projectDir } from "./server-24oEf9i9.mjs";
4
+ import { r as main } from "./main-CSuYOx6C.mjs";
5
+ import { i as createInspector, r as stopped, t as allowedHosts } from "./inspect-Aomn2jXK.mjs";
6
6
  import { appendFile, readFile } from "node:fs/promises";
7
7
  import { join } from "node:path";
8
8
  //#region src/cli/local.ts
@@ -37,7 +37,7 @@ const local = {
37
37
  },
38
38
  async run(args, context) {
39
39
  if (args.length > 0) throw context.usage("inspect takes no arguments: pass its port with --port.");
40
- return (await import("./inspect-BN7V9e-M.mjs")).inspect(context);
40
+ return (await import("./inspect-CGLv6b5v.mjs")).inspect(context);
41
41
  }
42
42
  },
43
43
  serve: {
@@ -81,7 +81,7 @@ const local = {
81
81
  }, "tailscale");
82
82
  if (tailscale.length > 0 && hosts.length > 0) throw usage("--tailscale takes Tailscale's word for who's calling, which another proxy in front could forge: it doesn't go with --allow-host.");
83
83
  const root = projectDir();
84
- const { serveLocal } = await import("./serve-Cz1NynhG.mjs");
84
+ const { serveLocal } = await import("./serve-_qRPIp-J.mjs");
85
85
  const local = await serveLocal({
86
86
  dir: flags.dir ?? join(root, ".board"),
87
87
  hosts,
@@ -728,6 +728,32 @@ const commands = [
728
728
  }
729
729
  ]
730
730
  },
731
+ {
732
+ group: "the board",
733
+ name: "boards",
734
+ description: "the team's boards you can use, in Vercel's API: the names --name takes",
735
+ arguments: [],
736
+ options: [],
737
+ runsWithoutSubcommand: true,
738
+ examples: [{
739
+ name: "list the team's boards",
740
+ value: "boards"
741
+ }, {
742
+ name: "another team's",
743
+ value: "boards --scope acme"
744
+ }],
745
+ subcommands: [{
746
+ name: "list",
747
+ default: true,
748
+ description: "the team's boards you can use, and which is its default",
749
+ arguments: [],
750
+ options: [],
751
+ examples: [{
752
+ name: "list the team's boards",
753
+ value: "boards list"
754
+ }]
755
+ }]
756
+ },
731
757
  {
732
758
  group: "the board",
733
759
  name: "channels",
@@ -1274,7 +1300,7 @@ const commands = [
1274
1300
  option("for", "only this profile of yours claims it", "profile"),
1275
1301
  claimNow,
1276
1302
  option("lease", "with --claim: how long to hold it"),
1277
- option("file", "a plan, from a JSON file (- reads stdin): an array of tasks, each { key?, text, labels?, needs?, for?, noSync?, attachments? }, all made, in as many writes as it takes"),
1303
+ option("file", "a plan, from a JSON file (- reads stdin): an array of tasks, each { key?, text, labels?, needs?, for?, noSync?, attachments? }, all made, in as many writes as it takes. needs takes a key of the plan (\"fix\" or {\"key\": \"fix\"}) or a task that's there by its ID (\"812\" or {\"id\": \"812\"})"),
1278
1304
  option("no-sync"),
1279
1305
  option("idempotency-key", "sending the same one again makes it once")
1280
1306
  ],
@@ -434,6 +434,37 @@ const CHECKS = [
434
434
  check((await ctx.board.thread(root.id)).replies.some((m) => m.id === reply.id), `the thread's replies should include ${reply.id}`);
435
435
  }
436
436
  },
437
+ {
438
+ group: "core",
439
+ name: "posts a reply with its labels, so its message.posted event carries them",
440
+ run: async (ctx) => {
441
+ const root = await post(ctx, "conformance: a thread for a labeled reply");
442
+ const { cursor } = await ctx.board.poll({
443
+ channel: ctx.channel,
444
+ label: ctx.labels
445
+ });
446
+ const labels = {
447
+ ...ctx.labels,
448
+ reply: ctx.labels.conformance
449
+ };
450
+ const labeled = await ctx.board.reply(root.id, {
451
+ text: "conformance: a labeled reply",
452
+ labels,
453
+ noSync: true
454
+ });
455
+ ctx.posted.push(labeled.id);
456
+ same(labeled.labels.reply, labels.reply, "the labeled reply's label, as posted");
457
+ const page = await ctx.board.poll({
458
+ channel: ctx.channel,
459
+ after: cursor
460
+ });
461
+ const posted = page.events.find((event) => event.type === "message.posted" && event.message?.id === labeled.id);
462
+ check(posted, `the events should include ${labeled.id} being posted`);
463
+ same(posted.message?.labels.reply, labels.reply, "the label on the labeled reply's message.posted");
464
+ const relabeled = page.events.filter((event) => event.type === "labels.changed" && event.message?.id === labeled.id);
465
+ check(relabeled.length === 0, `a reply's labels should be written with it, not in ${relabeled.length} labels.changed after its message.posted`);
466
+ }
467
+ },
437
468
  {
438
469
  group: "core",
439
470
  name: "replies after a message only while it's the thread's newest, one of any that race",
@@ -1,2 +1,2 @@
1
- import { t as conformance } from "./conformance-CyQG0jky.mjs";
1
+ import { t as conformance } from "./conformance-BNiLcKra.mjs";
2
2
  export { conformance };
@@ -4,9 +4,9 @@ import { $ as SchedulesQuery, A as CreatedTasksQuery, B as InboxPushBody, C as C
4
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-BY4qqIh3.mjs";
5
5
  import { n as blocksIn, r as findBlocks } from "./blocks-CVoBC7ur.mjs";
6
6
  import { a as replaceMentions, i as mentionTerms, o as settleMentions, r as mentionTerm, t as extractMentions } from "./mentions-CnWt9Z5b.mjs";
7
- import { t as VERSION } from "./version-DBaKHEZS.mjs";
7
+ import { t as VERSION } from "./version-1dDjcBkK.mjs";
8
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-HzqFpgL_.mjs";
9
- import { _ as SYNC, a as runMatch, d as openapi, f as queryObject, g as uploadName, h as carried, i as canonicalWatchers, l as METHODS, m as readJson, n as SYNC_ACTOR, o as compileWatcher, p as readCapped, r as syncTarget, t as batchPlan, u as createRouter } from "./task-batch-CVamHB-W.mjs";
9
+ import { _ as SYNC, a as runMatch, d as openapi, f as queryObject, g as uploadName, h as carried, i as canonicalWatchers, l as METHODS, m as readJson, n as SYNC_ACTOR, o as compileWatcher, p as readCapped, r as syncTarget, t as batchPlan, u as createRouter } from "./task-batch-BSJ3ihpF.mjs";
10
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-D9ycDQK0.mjs";
11
11
  import { a as resolveActor, o as viaOf, r as claimsOf, t as KNOWN_AGENTS } from "./actors-D-u6bitG.mjs";
12
12
  import { t as checkValue } from "./data-values-CoTP0SQG.mjs";
@@ -614,6 +614,12 @@ const CLIENT_ID = /^[A-Za-z0-9_.:-]{1,128}$/;
614
614
  const MESSAGE_ID = /^msg_([0-9a-f-]{36})_([1-9]\d*)$/;
615
615
  /** Whether `value` is a message ID Vercel's API hands out (`msg_<thread>_<n>`): the CLI takes one as a message, even where a channel has its name. */
616
616
  const isApiMessageId = (value) => MESSAGE_ID.test(value);
617
+ const THREAD_ID = /^thr_([0-9a-f-]{36})$/;
618
+ /** A thread ID Vercel's API hands out (`thr_<thread>`, a message's `thread`) as its root's message ID, or null for one that isn't. */
619
+ const apiThreadRoot = (value) => {
620
+ const found = THREAD_ID.exec(value);
621
+ return found ? `msg_${found[1]}_1` : null;
622
+ };
617
623
  /** A cursor this backend made: a time, then the position it names, in base 36. */
618
624
  const CURSOR = /^([0-9a-z]+)(?:\.([0-9a-z]+))?$/;
619
625
  /** The API's own cursor for one channel, which its message list and feed share, and any process resumes. */
@@ -1121,6 +1127,11 @@ function createVercel(options, environment) {
1121
1127
  });
1122
1128
  } catch (error) {
1123
1129
  if (error instanceof HttpError || error instanceof Error && error.name === "AbortError") throw error;
1130
+ if (attempt < RETRIES && repeatable && !init.signal?.aborted) {
1131
+ await pause(retryWait(attempt, null), init.signal);
1132
+ init.signal?.throwIfAborted();
1133
+ continue;
1134
+ }
1124
1135
  throw new HttpError(502, "unreachable", `Vercel's API didn't answer: ${error instanceof Error ? error.message : String(error)}`);
1125
1136
  }
1126
1137
  if (response.status === 304 && kept) {
@@ -2207,6 +2218,8 @@ function createVercel(options, environment) {
2207
2218
  }
2208
2219
  /** Whether the API lists threads with their first and newest messages (`include=messages`): until it refuses the parameter, it's asked. */
2209
2220
  let threadsWithMessages = true;
2221
+ /** Whether the API lists tasks with their newest messages (`include=messages`): until it refuses the parameter, it's asked. */
2222
+ let tasksWithMessages = true;
2210
2223
  /** Whether the API takes how many threads a page holds (`limit`): until it refuses the parameter, it's asked. */
2211
2224
  let threadsByLimit = true;
2212
2225
  /** Whether a page of threads was answered, so what the thread list takes is known: until one is, reads of it wait for the first. */
@@ -3390,6 +3403,7 @@ function createVercel(options, environment) {
3390
3403
  messageCount: task.messageCount,
3391
3404
  lastActivityAt: task.lastActivityAt,
3392
3405
  ...task.lastMessage ? { lastMessage: task.lastMessage } : {},
3406
+ ...task.latestMessage ? { latestMessage: task.latestMessage } : {},
3393
3407
  createdAt: task.message.createdAt,
3394
3408
  createdBy: task.message.createdBy,
3395
3409
  rootMessage: firstOf(task)
@@ -3964,10 +3978,11 @@ function createVercel(options, environment) {
3964
3978
  if (landed?.thread.id === thread.id) return { message: await view(who, landed.message, channel.name) };
3965
3979
  throw badRequest(`after: ${input.after} isn't in ${input.re}'s thread`, "invalid_after");
3966
3980
  }
3967
- const reply = await api(who, "POST", await onBoard(who, `/threads/${encodeURIComponent(thread.id)}/messages`), {
3981
+ made = await api(who, "POST", await onBoard(who, `/threads/${encodeURIComponent(thread.id)}/messages`), {
3968
3982
  body: {
3969
3983
  operationId: operationId(),
3970
3984
  text: input.text,
3985
+ ...input.labels && Object.keys(input.labels).length ? { labels: input.labels } : {},
3971
3986
  ...to.sequence > 1 ? { replyTo: to.sequence } : {},
3972
3987
  ...clientId ? { clientId } : {},
3973
3988
  ...input.attachments?.length ? { attachments: input.attachments } : {},
@@ -3979,21 +3994,6 @@ function createVercel(options, environment) {
3979
3994
  if (error instanceof HttpError && error.code === "newer_message") throw new HttpError(409, "newer_message", `a message came after ${input.after}`);
3980
3995
  throw error;
3981
3996
  });
3982
- if (input.labels && Object.keys(input.labels).length) {
3983
- const labeled = await api(who, "POST", await onBoard(who, `/threads/${encodeURIComponent(thread.id)}/messages/${reply.message.sequence}/labels`), {
3984
- body: {
3985
- operationId: operationId(),
3986
- set: input.labels
3987
- },
3988
- signal
3989
- });
3990
- reply.message = {
3991
- ...reply.message,
3992
- ...labeled.meta.labels ? { labels: labeled.meta.labels } : {},
3993
- version: labeled.meta.version
3994
- };
3995
- }
3996
- made = reply;
3997
3997
  }
3998
3998
  channelName = await landedIn(who, made.thread.channelId, channelName, clientId);
3999
3999
  return { message: await view(who, "text" in made.message ? made.message : await sent(who, made.message, input), channelName) };
@@ -4252,16 +4252,23 @@ function createVercel(options, environment) {
4252
4252
  const found = [];
4253
4253
  let from = after !== void 0 ? { after } : {};
4254
4254
  while (query.latest || found.length < limit) {
4255
+ const including = tasksWithMessages && !query.latest;
4255
4256
  const page = await api(who, "GET", path, {
4256
4257
  version: 2,
4257
4258
  query: {
4258
4259
  ...asked,
4259
- ...from
4260
+ ...from,
4261
+ ...including ? { include: "messages" } : {}
4260
4262
  },
4261
4263
  signal
4262
4264
  }).catch((error) => {
4265
+ if (including && unknownParameter(error, "include")) {
4266
+ tasksWithMessages = false;
4267
+ return null;
4268
+ }
4263
4269
  throw taskRefusal(error);
4264
4270
  });
4271
+ if (!page) continue;
4265
4272
  for (const task of page.tasks) if ((query.latest || found.length < limit) && matching(task)) found.push(task);
4266
4273
  if (!page.cursor) break;
4267
4274
  from = { cursor: page.cursor };
@@ -4830,6 +4837,26 @@ function createVercel(options, environment) {
4830
4837
  }]
4831
4838
  };
4832
4839
  },
4840
+ /**
4841
+ * The team's boards this backend's credentials may use, every page of them, and the ID of the
4842
+ * team's default board where it has one the caller may use: `GET /boards`, as `vb boards` lists them.
4843
+ */
4844
+ async boards() {
4845
+ const who = { profile: null };
4846
+ const boards = [];
4847
+ let defaultBoardId = null;
4848
+ let cursor;
4849
+ do {
4850
+ const page = await api(who, "GET", "/boards", { query: { cursor } });
4851
+ boards.push(...page.boards);
4852
+ defaultBoardId ??= page.defaultBoardId ?? null;
4853
+ cursor = page.cursor ?? void 0;
4854
+ } while (cursor);
4855
+ return {
4856
+ boards,
4857
+ defaultBoardId
4858
+ };
4859
+ },
4833
4860
  sendsSchedulesHere: false,
4834
4861
  syncedHere: holds,
4835
4862
  bind(next) {
@@ -6793,4 +6820,4 @@ async function createTasksInChunks(board, channel, tasks, options = {}) {
6793
6820
  return created;
6794
6821
  }
6795
6822
  //#endregion
6796
- export { isBoardName as a, isApiMessageId as c, tailWatchers as d, deployedOnVercel as f, hostCheckedBy as i, PROTOCOL_ROUTES as l, createTasksInChunks as n, stoppedBy as o, createBoard as r, createVercel as s, TasksInChunksError as t, withoutToken as u };
6823
+ export { isBoardName as a, createVercel as c, withoutToken as d, tailWatchers as f, hostCheckedBy as i, isApiMessageId as l, createTasksInChunks as n, stoppedBy as o, deployedOnVercel as p, createBoard as r, apiThreadRoot as s, TasksInChunksError as t, PROTOCOL_ROUTES as u };
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { f as BoardError, m as duration, t as HttpError } from "./errors-DDfXnZ2b.mjs";
2
2
  import { t as DroppedError } from "./middleware-BY4qqIh3.mjs";
3
3
  import { t as block } from "./blocks-CVoBC7ur.mjs";
4
- import { n as createTasksInChunks, r as createBoard, s as createVercel, t as TasksInChunksError } from "./exports-JUhj5Bl3.mjs";
4
+ import { c as createVercel, n as createTasksInChunks, r as createBoard, t as TasksInChunksError } from "./exports-FRbxGU5M.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
@@ -1,6 +1,6 @@
1
1
  import { f as BoardError, m as duration, t as HttpError } from "./errors-DDfXnZ2b.mjs";
2
2
  import { t as DroppedError } from "./middleware-BY4qqIh3.mjs";
3
3
  import { t as block } from "./blocks-CVoBC7ur.mjs";
4
- import { n as createTasksInChunks, t as TasksInChunksError } from "./exports-JUhj5Bl3.mjs";
5
- import { t as board } from "./server-CdBXNUxf.mjs";
4
+ import { n as createTasksInChunks, t as TasksInChunksError } from "./exports-FRbxGU5M.mjs";
5
+ import { t as board } from "./server-24oEf9i9.mjs";
6
6
  export { BoardError, DroppedError, HttpError, TasksInChunksError, block, board, createTasksInChunks, duration };