@vercel/board 0.32.0 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +25 -20
  2. package/dist/{access-CY5xVMIK.mjs → access-N3XmkKXg.mjs} +3 -3
  3. package/dist/access.d.mts +4 -5
  4. package/dist/access.mjs +5 -5
  5. package/dist/{actors-Bm-ojWWT.mjs → actors-ihyN47OV.mjs} +3 -3
  6. package/dist/{auth-K8dY1nBY.d.mts → auth-D6z3rMNj.d.mts} +7 -93
  7. package/dist/{auth-8pRZnF1M.mjs → auth-r-_PeZyw.mjs} +32 -148
  8. package/dist/{backend-DxE9wGKm.d.mts → backend-CWpyR1A7.d.mts} +81 -51
  9. package/dist/backend-local.d.mts +28 -0
  10. package/dist/backend-local.mjs +2 -0
  11. package/dist/{chat-provider-DkFp2hrh.mjs → chat-provider-9hCT654s.mjs} +2 -2
  12. package/dist/{chat-provider-BChYrrA7.d.mts → chat-provider-DJpFUaFv.d.mts} +2 -3
  13. package/dist/cli-commands.d.mts +1 -1
  14. package/dist/cli-commands.mjs +1 -1
  15. package/dist/cli-embedded.d.mts +2 -2
  16. package/dist/cli-embedded.mjs +1 -1
  17. package/dist/cli.mjs +6 -6
  18. package/dist/{commands-CpyPV_tk.d.mts → commands-BOBQHVqM.d.mts} +9 -0
  19. package/dist/{commands-DsnQKTdB.mjs → commands-CHoMl06v.mjs} +12 -1
  20. package/dist/{conformance-3RBKxwbp.mjs → conformance-qKmGLTAT.mjs} +5 -5
  21. package/dist/conformance.d.mts +1 -1
  22. package/dist/conformance.mjs +1 -1
  23. package/dist/{engine-DurYIRt8.mjs → engine-JxgZiikU.mjs} +6 -8
  24. package/dist/{errors-CJXhhzvT.mjs → errors-Pk0XV1hK.mjs} +56 -2
  25. package/dist/{events-lujPA3gQ.mjs → events-IQg0k281.mjs} +2 -2
  26. package/dist/exports-BuKjVq2t.d.mts +4 -0
  27. package/dist/exports-gHDHlg0i.mjs +3207 -0
  28. package/dist/{external-D3p5T57R.mjs → external-CYe424fO.mjs} +1 -1
  29. package/dist/{folds-DLUzfibJ.d.mts → folds-DjFTiqIM.d.mts} +38 -44
  30. package/dist/index-CXvvYNYj.d.mts +11 -0
  31. package/dist/index.d.mts +9 -8
  32. package/dist/index.mjs +21 -8
  33. package/dist/index.node.d.mts +5 -6
  34. package/dist/index.node.mjs +3 -3
  35. package/dist/inspect/app.js +95 -95
  36. package/dist/{internal-CvsrprnU-zZMpDiRY.mjs → internal-CvsrprnU-CEPOUpAv.mjs} +63 -43
  37. package/dist/local-BbLjA5vI.mjs +8818 -0
  38. package/dist/{main-CcYDo9Hb.mjs → main-CQpCZJFw.mjs} +91 -23
  39. package/dist/{backend-a2/store-memory.mjs → memory-7RRnLa4X.mjs} +3 -3
  40. package/dist/middleware-BU7rVi9F.mjs +103 -0
  41. package/dist/{client-COfYrgfV.d.mts → provider-BlzUvcM9.d.mts} +665 -5
  42. package/dist/{schemas-DBmUO6pr.mjs → schemas-BG205xds.mjs} +2 -5
  43. package/dist/{serve-Bplieh0C.mjs → serve-D8_W4UN6.mjs} +33 -24
  44. package/dist/{node-BgeGcwX0.mjs → server-BiIUXWbU.mjs} +419 -6
  45. package/dist/{serving-Y7s7VDjB.mjs → serving-D7rcUtSC.mjs} +1 -1
  46. package/dist/{sql-E1K5g_ih.mjs → sql-BQzKUqQt.mjs} +349 -114
  47. package/dist/sqlite-DCtZFEVm.mjs +30 -0
  48. package/dist/{sqlite-db-CzcD_FW8.mjs → sqlite-db-qLTs52Ny.mjs} +2 -3
  49. package/dist/{store-codec-pAG2oPgQ-SqDXlPBR.mjs → store-N8PXxDAS-BdL4Sq-f.mjs} +6 -2
  50. package/dist/{store-memory-B0PkVSuQ.mjs → store-memory-CKQVEzXN.mjs} +2 -4
  51. package/dist/store-memory-OdGsc-t_.mjs +2 -0
  52. package/dist/{store-polling-BZt2Rf3D-Div-bJ_D.mjs → store-polling-BZt2Rf3D-oh3aU_An.mjs} +1 -1
  53. package/dist/store-sqlite-CTxAVCcz.mjs +2 -0
  54. package/dist/{store-sqlite-D85t3tE7.mjs → store-sqlite-D6fIszST.mjs} +3 -4
  55. package/dist/sync-chat-sdk.d.mts +2 -2
  56. package/dist/sync-chat-sdk.mjs +2 -2
  57. package/dist/sync-github.d.mts +2 -2
  58. package/dist/sync-github.mjs +2 -2
  59. package/dist/sync-linear.d.mts +2 -3
  60. package/dist/sync-linear.mjs +2 -2
  61. package/dist/sync-slack.d.mts +3 -3
  62. package/dist/sync-slack.mjs +4 -4
  63. package/dist/sync.d.mts +2 -2
  64. package/dist/sync.mjs +2 -2
  65. package/dist/{watchers-hash-CurCzwhe.mjs → targets-CknPGGVi.mjs} +40 -10
  66. package/dist/{tokens-C7kYyrAG.mjs → tokens-DPKjl3jf.mjs} +15 -43
  67. package/docs/01-board/01-mounting.md +243 -288
  68. package/docs/01-board/03-identity.md +41 -50
  69. package/docs/01-board/04-messages.md +15 -14
  70. package/docs/01-board/05-reading.md +3 -3
  71. package/docs/01-board/06-watchers.md +58 -105
  72. package/docs/01-board/07-schedules.md +21 -41
  73. package/docs/01-board/08-middleware.md +11 -17
  74. package/docs/01-board/09-access.md +76 -313
  75. package/docs/01-board/10-local.md +81 -0
  76. package/docs/01-quickstart.md +49 -126
  77. package/docs/02-sync/01-overview.md +25 -80
  78. package/docs/02-sync/02-functions.md +10 -16
  79. package/docs/02-sync/03-slack.md +13 -26
  80. package/docs/02-sync/04-github.md +8 -20
  81. package/docs/02-sync/07-linear.md +6 -10
  82. package/docs/03-guides/02-inspector.md +3 -3
  83. package/docs/03-guides/03-ci.md +88 -128
  84. package/docs/03-guides/04-triage.md +7 -15
  85. package/docs/03-guides/05-agent-factory.md +30 -36
  86. package/docs/04-reference/01-cli.md +104 -22
  87. package/docs/04-reference/02-board.md +60 -74
  88. package/docs/04-reference/03-http.md +119 -57
  89. package/docs/04-reference/05-conformance.md +31 -45
  90. package/docs/index.md +41 -65
  91. package/package.json +12 -83
  92. package/dist/a2-DiDc77Uf.mjs +0 -4238
  93. package/dist/access-DPcrKIH_.d.mts +0 -37
  94. package/dist/backend-a2/blob-vercel.d.mts +0 -8
  95. package/dist/backend-a2/blob-vercel.mjs +0 -81
  96. package/dist/backend-a2/contract.d.mts +0 -828
  97. package/dist/backend-a2/contract.mjs +0 -5
  98. package/dist/backend-a2/scheduler-local.d.mts +0 -11
  99. package/dist/backend-a2/scheduler-local.mjs +0 -2
  100. package/dist/backend-a2/scheduler-qstash.d.mts +0 -79
  101. package/dist/backend-a2/scheduler-qstash.mjs +0 -522
  102. package/dist/backend-a2/scheduler-vercel.d.mts +0 -38
  103. package/dist/backend-a2/scheduler-vercel.mjs +0 -204
  104. package/dist/backend-a2/store-memory.d.mts +0 -11
  105. package/dist/backend-a2/store-postgres.d.mts +0 -38
  106. package/dist/backend-a2/store-postgres.mjs +0 -2977
  107. package/dist/backend-a2/store-redis-http.d.mts +0 -17
  108. package/dist/backend-a2/store-redis-http.mjs +0 -520
  109. package/dist/backend-a2/store-redis.d.mts +0 -31
  110. package/dist/backend-a2/store-redis.mjs +0 -88
  111. package/dist/backend-a2/store-sqlite.d.mts +0 -12
  112. package/dist/backend-a2/store-sqlite.mjs +0 -31
  113. package/dist/backend-a2.d.mts +0 -2633
  114. package/dist/backend-a2.mjs +0 -3
  115. package/dist/backend-http-CaN06CaD.d.mts +0 -672
  116. package/dist/backend-http-CoaCghuJ.mjs +0 -18
  117. package/dist/backend-http-l5A8UmL-.mjs +0 -585
  118. package/dist/backend-http.d.mts +0 -10
  119. package/dist/backend-http.mjs +0 -2
  120. package/dist/backend-http.node.d.mts +0 -10
  121. package/dist/backend-http.node.mjs +0 -2
  122. package/dist/backend-vercel-BE65okBC.mjs +0 -86
  123. package/dist/backend-vercel-CVxoTNF2.mjs +0 -1744
  124. package/dist/backend-vercel-jg-6PAgD.d.mts +0 -674
  125. package/dist/backend-vercel.d.mts +0 -9
  126. package/dist/backend-vercel.mjs +0 -11
  127. package/dist/backend-vercel.node.d.mts +0 -17
  128. package/dist/backend-vercel.node.mjs +0 -2
  129. package/dist/blob-Bx8QPWEd.d.mts +0 -40
  130. package/dist/blob-WbB2DJKn.mjs +0 -201
  131. package/dist/errors-2vGs49Db.d.mts +0 -16
  132. package/dist/exports-BnUZuRm9.mjs +0 -1389
  133. package/dist/exports-u5mApVvn.d.mts +0 -5
  134. package/dist/files-SniSmeEr.mjs +0 -47
  135. package/dist/folds-DsWfIftc.mjs +0 -208
  136. package/dist/index-UXpTPWNc.d.mts +0 -11
  137. package/dist/index.default-Dp8gexln.mjs +0 -12
  138. package/dist/local-C76Fy5ad.mjs +0 -44
  139. package/dist/middleware-BavYSDUa.mjs +0 -62
  140. package/dist/platform-B4TnJtWu-Do3agKr5.mjs +0 -32
  141. package/dist/project-4Vl7_uy5.mjs +0 -124
  142. package/dist/provider-gynDUoyW.d.mts +0 -665
  143. package/dist/redis-tables-BFRj_SEJ.mjs +0 -3895
  144. package/dist/reducer-Bswr11ar-P324o9vn.mjs +0 -74
  145. package/dist/reducer-CYPHsSmd-BXjGiptm.d.mts +0 -170
  146. package/dist/reducers-DQVSP3kk.mjs +0 -538
  147. package/dist/retryable-lazy-DZWmHpii-DpTc5PIP.mjs +0 -19
  148. package/dist/scheduler-task-X1SToDjP-D2Il2rln.mjs +0 -69
  149. package/dist/server-B9gu0qi1-DI1WvcVK.d.mts +0 -391
  150. package/dist/server-DX7mM6nm-D7N_7bug.mjs +0 -3611
  151. package/dist/server-wIpAEjpX.mjs +0 -17
  152. package/dist/session-clear-XJYpmUpg-2q8l_FJR.mjs +0 -63
  153. package/dist/store-DEzcHZOA-B-5vhxef.d.mts +0 -540
  154. package/dist/store-N8PXxDAS-DWWgv-Vz.mjs +0 -5
  155. package/dist/store-memory-4IBl0Ztu.mjs +0 -2
  156. package/dist/store-presence-polling-JuAy2Ck2-Dh-g_KYM.mjs +0 -109
  157. package/dist/store-sqlite-iBTYYKBj.mjs +0 -2
  158. package/dist/stream-buffer-DrTyiIuo-Be10yOBR.mjs +0 -53
  159. package/dist/targets-Cgjs29T0.mjs +0 -33
  160. package/dist/types-CmrFjpml.d.mts +0 -102
  161. package/dist/wait-until-Dw4XrIDQ.mjs +0 -42
  162. package/docs/01-board/02-database.md +0 -258
  163. package/docs/04-reference/04-log.md +0 -247
  164. package/sql/postgres/board.sql +0 -145
  165. package/sql/postgres/notifications.sql +0 -24
  166. package/sql/postgres/schema.sql +0 -451
@@ -1,16 +1,12 @@
1
- import { i as fileSize, n as DIRECT_UPLOAD_BYTES_MAX } from "./files-SniSmeEr.mjs";
2
- import { a as AttachmentId, m as MESSAGE_TEXT_MAX } from "./schemas-DBmUO6pr.mjs";
3
- import { d as VERSION, i as withMentions } from "./watchers-hash-CurCzwhe.mjs";
1
+ import { _ as fileSize, m as DIRECT_UPLOAD_BYTES_MAX, u as BoardError } from "./errors-Pk0XV1hK.mjs";
2
+ import { d as MESSAGE_TEXT_MAX, r as AttachmentId } from "./schemas-BG205xds.mjs";
3
+ import { h as VERSION, s as withMentions } from "./targets-CknPGGVi.mjs";
4
4
  import { n as displayEmoji, r as normalizeEmoji } from "./emoji-CTLpvH-A.mjs";
5
- import { u as BoardError } from "./errors-CJXhhzvT.mjs";
6
- import { i as groups, n as filters$1, o as options, r as globalOptions, s as usage$1, t as commands } from "./commands-DsnQKTdB.mjs";
7
- import { i as parseScope } from "./access-CY5xVMIK.mjs";
8
- import { a as handFetch, d as vercelProjectFile, n as boardUrl, o as handLogin, r as connect } from "./node-BgeGcwX0.mjs";
9
- import { t as http } from "./backend-http-CoaCghuJ.mjs";
10
- import { t as board } from "./server-wIpAEjpX.mjs";
11
- import { t as conformance } from "./conformance-3RBKxwbp.mjs";
12
- import { n as isApiMessageId } from "./backend-vercel-CVxoTNF2.mjs";
13
- import { n as handTeam, r as vercel, t as credentialSource } from "./backend-vercel-BE65okBC.mjs";
5
+ import { o as parseScope } from "./access-N3XmkKXg.mjs";
6
+ import { i as isApiMessageId, n as isBoardName } from "./exports-gHDHlg0i.mjs";
7
+ import { i as groups, n as filters$1, o as options, r as globalOptions, s as usage$1, t as commands } from "./commands-CHoMl06v.mjs";
8
+ import { a as http, c as handFetch, f as vercelProjectFile, i as vercel, l as handLogin, n as credentialSource, o as boardUrl, r as handTeam, s as connect, t as board } from "./server-BiIUXWbU.mjs";
9
+ import { t as conformance } from "./conformance-qKmGLTAT.mjs";
14
10
  import { t as displayText } from "./bots-CGkO76qH.mjs";
15
11
  import { spawn } from "node:child_process";
16
12
  import { readFile, stat, writeFile } from "node:fs/promises";
@@ -362,7 +358,7 @@ function writeConfig(path, config) {
362
358
  renameSync(`${path}.board-tmp`, path);
363
359
  }
364
360
  /** An event's entries without ours; a group left with no hooks goes too. */
365
- function without(entries, shape) {
361
+ function without$1(entries, shape) {
366
362
  if (shape === "flat") return entries.filter((entry) => !ours(entry));
367
363
  return entries.map((group) => ({
368
364
  ...group,
@@ -378,7 +374,7 @@ function uninstallHook(agent) {
378
374
  if (spec.shape === "extension") return unlinkSync(spec.file()), true;
379
375
  const config = readConfig(spec.file());
380
376
  const hooks = { ...config.hooks };
381
- const kept = without(hooks[spec.event] ?? [], spec.shape);
377
+ const kept = without$1(hooks[spec.event] ?? [], spec.shape);
382
378
  if (kept.length > 0) hooks[spec.event] = kept;
383
379
  else delete hooks[spec.event];
384
380
  if (Object.keys(config).filter((key) => key !== "hooks" && key !== "version").length === 0 && Object.keys(hooks).length === 0) unlinkSync(spec.file());
@@ -495,7 +491,7 @@ function rootHelp(app, version) {
495
491
  const pad = padOf(listedSections.flat());
496
492
  for (const section of listedSections) lines.push("", ...rows(section, pad));
497
493
  const everywhere = shown(globalOptions).filter((option) => option.name !== "help" && option.name !== "version");
498
- lines.push("", ...labeled("filters:", shown(filters$1).map(flag).join(" "), " "), ...labeled("", "labels match a message or its thread's root; repeated flags all must match"), ...labeled("global:", everywhere.map(flag).join(" "), " "), ...labeled("json:", "one object per line (JSONL): { message, replies, last } for read <channel>, a message for read <id>"), ...labeled("text:", "pass \"-\" to read it from stdin; it may be left out when you --attach"), ...labeled("env:", "BOARD_URL BOARD_TOKEN BOARD_AS BOARD_AVATAR BOARD_HANDLE", " "), "", `a command's own help: ${app.name} <command> --help`);
494
+ lines.push("", ...labeled("filters:", shown(filters$1).map(flag).join(" "), " "), ...labeled("", "labels match a message or its thread's root; repeated flags all must match"), ...labeled("global:", everywhere.map(flag).join(" "), " "), ...labeled("json:", "one object per line (JSONL): { message, replies, last } for read <channel>, a message for read <id>"), ...labeled("text:", "pass \"-\" to read it from stdin; it may be left out when you --attach"), ...labeled("env:", "BOARD_URL BOARD_NAME BOARD_TOKEN BOARD_AS BOARD_AVATAR BOARD_HANDLE", " "), "", `a command's own help: ${app.name} <command> --help`);
499
495
  return lines.join("\n");
500
496
  }
501
497
  /** One command's page: its usage, what it does, and its arguments, subcommands, options, and examples. */
@@ -652,6 +648,22 @@ function rerun(...extra) {
652
648
  ...typed.slice(at)
653
649
  ]];
654
650
  }
651
+ /** A command line without `options` and their values. */
652
+ const without = (argv, ...options) => argv.filter((arg, at) => !options.some((option) => arg === option || argv[at - 1] === option || arg.startsWith(`${option}=`)));
653
+ /**
654
+ * This run's command line without `options`, with `extra` in their place: both before any `--`,
655
+ * since what follows it is text, which a way out mustn't change or add options to.
656
+ */
657
+ function rerunWithout(options, ...extra) {
658
+ const at = typed.indexOf("--");
659
+ const before = at === -1 ? typed : typed.slice(0, at);
660
+ return [
661
+ ...cli(),
662
+ ...without(before, ...options),
663
+ ...extra,
664
+ ...at === -1 ? [] : typed.slice(at)
665
+ ];
666
+ }
655
667
  /** What the parser accepts: every option, by name (`commands.ts`). */
656
668
  const OPTIONS = options;
657
669
  /** Options by their short letter: `n` is `limit`. */
@@ -724,7 +736,7 @@ function removedCommand(word) {
724
736
  "<TEXT>"
725
737
  ]
726
738
  }]),
727
- stuck: () => gone([], " A board on a2() keeps its dead letters in A2, on the backend's `servers`."),
739
+ stuck: () => gone([]),
728
740
  link: () => gone(url),
729
741
  use: () => gone(url)
730
742
  };
@@ -1153,7 +1165,13 @@ function failureOf(error) {
1153
1165
  case "protected": return own("permission", "deployment_protected");
1154
1166
  case "no_project": return own("platform", "no_project");
1155
1167
  case "no_token": return own("auth", "token_unavailable");
1156
- case "no_board": return own("not_found", "board_not_found");
1168
+ case "no_board": return own("not_found", "board_not_found", [{
1169
+ instruction: "Check the name, or make it",
1170
+ argv: rerun("--ensure")
1171
+ }]);
1172
+ case "board_name_taken": return own("conflict", "board_name_taken");
1173
+ case "board_not_granted": return own("permission", "board_not_granted");
1174
+ case "invalid_board_name": return own("usage", "invalid_arguments", [helpRecovery()]);
1157
1175
  case "too_many_redirects": return own("network", "network_error");
1158
1176
  case "invalid_duration": return own("usage", "invalid_arguments", [helpRecovery()]);
1159
1177
  case "wrong_audience":
@@ -1299,12 +1317,19 @@ function profileFlag() {
1299
1317
  function connection(url = flags.url, options = {}) {
1300
1318
  const profile = profileFlag();
1301
1319
  const team = flags.scope ?? flags.team;
1302
- const configured = url ?? (team === void 0 ? configuredUrl() : null);
1320
+ const name = boardNameFlag(url, team);
1321
+ const configured = url ?? (team === void 0 && name === void 0 ? configuredUrl() : null);
1303
1322
  if (configured === null) {
1304
- const board$1 = board({ backend: vercel({
1305
- ...team !== void 0 ? { team } : {},
1306
- ...sending(options.token)
1307
- }) });
1323
+ const board$1 = board({
1324
+ backend: vercel({
1325
+ ...team !== void 0 ? { team } : {},
1326
+ ...sending(options.token)
1327
+ }),
1328
+ ...name !== void 0 ? {
1329
+ name,
1330
+ ensure: flags.ensure === true
1331
+ } : {}
1332
+ });
1308
1333
  return {
1309
1334
  url: null,
1310
1335
  transport: { source: credentialSource },
@@ -1337,6 +1362,37 @@ function connection(url = flags.url, options = {}) {
1337
1362
  board: profile !== void 0 ? board$2.as(profile) : board$2
1338
1363
  };
1339
1364
  }
1365
+ /**
1366
+ * The team's board this run names: `--name`, or `BOARD_NAME`, on `--scope`'s team or the one the
1367
+ * environment finds. A URL names a board itself, its team included. `BOARD_NAME` is read only
1368
+ * where it picks the board: beside `BOARD_URL`, which names another, nothing says which one.
1369
+ */
1370
+ function boardNameFlag(url, team) {
1371
+ if (flags.name !== void 0 && flags.url !== void 0) throw usage("--name names a team's board, and --url a board by its URL: pass one of them.", { reason: "conflicting_options" });
1372
+ if (team !== void 0 && flags.url !== void 0) throw usage("--url names its board, its team included, and --scope a team's board: pass one of them.", { reason: "conflicting_options" });
1373
+ if (flags.ensure && flags.url !== void 0) throw usage("--ensure makes a team's board by its name, and --url names a board by its URL: pass one of them.", { reason: "conflicting_options" });
1374
+ if (url !== void 0) return void 0;
1375
+ const named = process.env.BOARD_NAME || void 0;
1376
+ if (flags.name === void 0 && team === void 0 && named !== void 0 && process.env.BOARD_URL?.trim()) throw usage("BOARD_NAME names a team's board, and BOARD_URL a board by its URL: unset one.", { reason: "conflicting_options" });
1377
+ const given = flags.name ?? named;
1378
+ if (given === void 0 && flags.ensure) throw usage("--ensure makes the board --name names: pass --name too.", { reason: "missing_arguments" });
1379
+ if (given === void 0) return void 0;
1380
+ const from = flags.name !== void 0 ? "--name" : "BOARD_NAME";
1381
+ if (given.includes("/")) {
1382
+ const [owner, ...rest] = given.split("/");
1383
+ const argv = rerunWithout([
1384
+ "--name",
1385
+ "--scope",
1386
+ "--team"
1387
+ ], "--scope", owner || "<TEAM>", "--name", rest.join("/") || "<NAME>");
1388
+ throw usage(`${from} takes a board's name alone, not its team's.`, { next: [flags.name !== void 0 ? {
1389
+ instruction: "Pass its team with --scope",
1390
+ argv
1391
+ } : { instruction: "Set BOARD_NAME to the name alone, and pass its team with --scope" }] });
1392
+ }
1393
+ if (!isBoardName(given)) throw usage(`${from} ${given} isn't a board's name: one is 1 to 64 characters.`);
1394
+ return given;
1395
+ }
1340
1396
  /** For Vercel's API, `token` in place of your own credentials: a board token's secret. */
1341
1397
  function sending(token) {
1342
1398
  if (token === void 0) return {};
@@ -1465,6 +1521,17 @@ async function run(command, args) {
1465
1521
  }
1466
1522
  case "conformance": {
1467
1523
  if (args.length > 0) throw usage("conformance takes no arguments: pass its channel with --channel.");
1524
+ const named = flags.name !== void 0 || flags.url !== void 0 || Boolean(process.env.BOARD_URL?.trim()) || Boolean(process.env.BOARD_NAME);
1525
+ if (!io.board && !named) throw usage("conformance posts and changes grants, so name a scratch board for it.", {
1526
+ reason: "needs_scratch_board",
1527
+ next: [{
1528
+ instruction: "Check a scratch board on this team, by its name",
1529
+ argv: rerun("--name", "<BOARD>")
1530
+ }, {
1531
+ instruction: "Or a board by its URL",
1532
+ argv: rerun("--url", "<URL>")
1533
+ }]
1534
+ });
1468
1535
  const withToken = io.board ? {} : { withToken: (secret) => connection(flags.url, { token: secret }).board };
1469
1536
  const report = await conformance(client(), {
1470
1537
  ...flags.channel ? { channel: flags.channel } : {},
@@ -2034,7 +2101,8 @@ async function runOnce(argv, options) {
2034
2101
  args
2035
2102
  };
2036
2103
  if (io.board) {
2037
- if (flags.url || flags.handle) throw usage(`--${flags.url ? "url" : "handle"} doesn't apply in-process: the board handle you pass says which board and who.`, { next: [] });
2104
+ const given = flags.url ? "url" : flags.name !== void 0 ? "name" : flags.ensure ? "ensure" : flags.handle ? "handle" : null;
2105
+ if (given) throw usage(`--${given} doesn't apply in-process: the board handle you pass says which board and who.`, { next: [] });
2038
2106
  if (command !== void 0 && MACHINE.has(command)) throw usage(`${command} isn't available in-process: it's about the machine ${named()} runs on.`, {
2039
2107
  reason: "not_available",
2040
2108
  next: []
@@ -1,6 +1,6 @@
1
- import { r as sqlTables } from "../sql-E1K5g_ih.mjs";
2
- import { t as sqliteDb } from "../sqlite-db-CzcD_FW8.mjs";
3
- import { t as memory$1 } from "../store-memory-B0PkVSuQ.mjs";
1
+ import { r as sqlTables } from "./sql-BQzKUqQt.mjs";
2
+ import { t as memory$1 } from "./store-memory-CKQVEzXN.mjs";
3
+ import { t as sqliteDb } from "./sqlite-db-qLTs52Ny.mjs";
4
4
  //#region src/store/memory.ts
5
5
  /**
6
6
  * A board that lives in memory, for tests: its log in A2's memory store, its
@@ -0,0 +1,103 @@
1
+ import { t as HttpError } from "./errors-Pk0XV1hK.mjs";
2
+ import { d as MESSAGE_TEXT_MAX, u as Labels } from "./schemas-BG205xds.mjs";
3
+ import { z } from "zod";
4
+ //#region src/client/ids.ts
5
+ const hex = (bytes) => Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
6
+ /** SHA-256 of `text`, in hex. */
7
+ async function sha256(text) {
8
+ return hex(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(text))));
9
+ }
10
+ /**
11
+ * A UUIDv8 from `parts`, exactly as A2's `idempotentId` makes one: the IDs a board derives for the
12
+ * writes its own code makes, which no request may post with.
13
+ */
14
+ async function derivedId(...parts) {
15
+ const bytes = new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(JSON.stringify(parts)))).slice(0, 16);
16
+ bytes[6] = bytes[6] & 15 | 128;
17
+ bytes[8] = bytes[8] & 63 | 128;
18
+ const text = hex(bytes);
19
+ return `${text.slice(0, 8)}-${text.slice(8, 12)}-${text.slice(12, 16)}-${text.slice(16, 20)}-${text.slice(20, 32)}`;
20
+ }
21
+ /** A derived ID's shape. */
22
+ const DERIVED_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-8[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
23
+ /**
24
+ * A post's ID, from one derived for it, under `principal`: a board takes a `key:<principal>:` ID
25
+ * only from that principal, so no one else can post with it first.
26
+ */
27
+ const keyId = async (principal, derived) => `key:${principal}:${(await sha256(`board-key\u001f${derived}`)).slice(0, 32)}`;
28
+ /**
29
+ * Whether `id` is exactly the shape `keyId` makes for `principal`. A prefix check isn't enough:
30
+ * a principal's ID can be the start of another's (`oidc:gitlab.com:acme` and `oidc:gitlab.com:acme:ci`).
31
+ */
32
+ const isKeyIdOf = (id, principal) => id.startsWith(`key:${principal}:`) && /^[0-9a-f]{32}$/.test(id.slice(`key:${principal}:`.length));
33
+ //#endregion
34
+ //#region src/server/wait-until.ts
35
+ /**
36
+ * Keeps `task` running after the response, where the platform offers it: Vercel's request context, as A2
37
+ * reads it too. Elsewhere it runs on in the process.
38
+ */
39
+ function waitUntil(task) {
40
+ try {
41
+ Reflect.get(globalThis, Symbol.for("@vercel/request-context"))?.get?.()?.waitUntil?.(task);
42
+ } catch {}
43
+ }
44
+ //#endregion
45
+ //#region src/server/middleware.ts
46
+ /** A write the middleware didn't let through: the API answers 422 with what it responded. */
47
+ var DroppedError = class extends HttpError {
48
+ /** What the middleware responded, in order: none when it dropped the write without a word. */
49
+ responses;
50
+ constructor(responses) {
51
+ super(422, "dropped", responses.join("\n") || "the board dropped this message");
52
+ this.responses = responses;
53
+ }
54
+ };
55
+ const Patch = z.object({
56
+ text: z.string().max(MESSAGE_TEXT_MAX).optional(),
57
+ labels: Labels.optional()
58
+ }).strict();
59
+ const MIDDLEWARE_ACTOR = "board:middleware";
60
+ /**
61
+ * Runs `write` through `middleware` in order, then `commit`s what the last one
62
+ * passed on. Throws `DroppedError` when one doesn't call `next`.
63
+ */
64
+ async function runMiddleware(middleware, input, commit) {
65
+ const responses = [];
66
+ let committed = null;
67
+ const step = async (i, write) => {
68
+ if (i === middleware.length) {
69
+ if (write.text.trim() === "" && (write.kind === "edit" || write.attachments.length === 0)) return;
70
+ committed = { value: await commit(write) };
71
+ return;
72
+ }
73
+ let next = null;
74
+ await middleware[i]({
75
+ write: Object.freeze({ ...write }),
76
+ author: Object.freeze({ ...input.author }),
77
+ source: Object.freeze({ ...input.source }),
78
+ board: input.board(),
79
+ respond: async (text) => {
80
+ responses.push(text);
81
+ },
82
+ next: (patch = {}) => {
83
+ if (next) throw new Error("next() was already called");
84
+ const { text, labels } = Patch.parse(patch);
85
+ next = step(i + 1, {
86
+ ...write,
87
+ ...text !== void 0 ? { text } : {},
88
+ ...write.kind === "post" && labels ? { labels: {
89
+ ...write.labels,
90
+ ...labels
91
+ } } : {}
92
+ });
93
+ return next;
94
+ }
95
+ });
96
+ if (next) await next;
97
+ };
98
+ await step(0, input.write);
99
+ if (!committed) throw new DroppedError(responses);
100
+ return committed.value;
101
+ }
102
+ //#endregion
103
+ export { DERIVED_ID as a, keyId as c, waitUntil as i, sha256 as l, MIDDLEWARE_ACTOR as n, derivedId as o, runMiddleware as r, isKeyIdOf as s, DroppedError as t };