@vercel/board 0.56.1 → 0.57.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/README.md +1 -1
  2. package/dist/{access-HzqFpgL_.mjs → access-CZ419Vho.mjs} +1 -1
  3. package/dist/access.d.mts +2 -2
  4. package/dist/access.mjs +4 -4
  5. package/dist/{actors-D-u6bitG.mjs → actors-CXMWplob.mjs} +2 -2
  6. package/dist/{auth-D9ycDQK0.mjs → auth-AwZJQpCO.mjs} +2 -2
  7. package/dist/{auth-ULldUvir.d.mts → auth-C0Mla9OU.d.mts} +1 -1
  8. package/dist/{backend-BHN6GTjB.d.mts → backend-BuqwQbb4.d.mts} +6 -22
  9. package/dist/backend-local.d.mts +1 -1
  10. package/dist/backend-local.mjs +1 -1
  11. package/dist/backend-postgres/blob-vercel.d.mts +8 -0
  12. package/dist/backend-postgres/blob-vercel.mjs +81 -0
  13. package/dist/backend-postgres/scheduler-vercel.d.mts +2 -0
  14. package/dist/backend-postgres/scheduler-vercel.mjs +2 -0
  15. package/dist/backend-postgres.d.mts +74 -0
  16. package/dist/backend-postgres.mjs +3229 -0
  17. package/dist/blob-DjS53D1A.d.mts +35 -0
  18. package/dist/{chat-provider-F7UqWVZK.d.mts → chat-provider-CpYdXEpI.d.mts} +2 -2
  19. package/dist/cli-commands.d.mts +1 -1
  20. package/dist/cli-commands.mjs +1 -1
  21. package/dist/cli-embedded.d.mts +2 -2
  22. package/dist/cli-embedded.mjs +2 -2
  23. package/dist/cli.mjs +6 -6
  24. package/dist/{client-CFHunEFn.d.mts → client-B0DGOt7P.d.mts} +1 -1
  25. package/dist/{commands-DLPIX7Jw.d.mts → commands-Dcm4_pc1.d.mts} +3 -3
  26. package/dist/{commands-7FY_8p92.mjs → commands-DeYAQUcP.mjs} +10 -5
  27. package/dist/{conformance-BNiLcKra.mjs → conformance-EtEq22w1.mjs} +2 -2
  28. package/dist/conformance.d.mts +1 -1
  29. package/dist/conformance.mjs +1 -1
  30. package/dist/{engine-C8wCzkw-.mjs → engine-CfVTyEeo.mjs} +3 -3
  31. package/dist/errors-DBZtbfph.d.mts +19 -0
  32. package/dist/{errors-DDfXnZ2b.mjs → errors-DjatfYjl.mjs} +220 -18
  33. package/dist/{exports-DSX-CI5c.mjs → exports-B_UGnrnN.mjs} +187 -62
  34. package/dist/{exports-BBmjHyCB.d.mts → exports-BvJTIorX.d.mts} +5 -4
  35. package/dist/{index-Ce3SDZ3Y.d.mts → index-DuibwQf9.d.mts} +2 -2
  36. package/dist/index.d.mts +6 -5
  37. package/dist/index.mjs +4 -4
  38. package/dist/index.node.d.mts +7 -6
  39. package/dist/index.node.mjs +4 -4
  40. package/dist/inspect/app.js +126 -146
  41. package/dist/inspect/engine.js +3 -3
  42. package/dist/inspect/sheet-presentation.js +1 -0
  43. package/dist/{inspect-C-vDnB_n.mjs → inspect-DfJzHFiE.mjs} +2 -2
  44. package/dist/inspect-H1MISWwN.mjs +2 -0
  45. package/dist/inspect.d.mts +1 -1
  46. package/dist/inspect.mjs +1 -1
  47. package/dist/{internal-CvsrprnU-CEPOUpAv.mjs → internal-CvsrprnU-DhZF6sZK.mjs} +43 -1
  48. package/dist/local-BiG1WJk0.mjs +98 -0
  49. package/dist/{local-B5aZcAwj.mjs → local-D2i5sxuY.mjs} +141 -3957
  50. package/dist/{main-DSlpMoBN.mjs → main-Bbqg3Unf.mjs} +167 -38
  51. package/dist/{memory-wmUDblhm.mjs → memory-BmsyKyHu.mjs} +3 -3
  52. package/dist/{mentions-CnWt9Z5b.mjs → mentions-DBGmqkr2.mjs} +5 -1
  53. package/dist/{middleware-BY4qqIh3.mjs → middleware-D2AGrGj7.mjs} +2 -32
  54. package/dist/{provider-DgGp4Zej.d.mts → provider-BNVyVKtH.d.mts} +2 -2
  55. package/dist/{routes-DNmQSOvQ.d.mts → routes-CSnxZyyb.d.mts} +2 -2
  56. package/dist/{serve-CI3kvpx_.mjs → serve-D06-DMej.mjs} +6 -6
  57. package/dist/{server-55vryxAl.mjs → server-BXbcS-n9.mjs} +27 -12
  58. package/dist/server-DX7mM6nm-Cq1xPyqJ.mjs +3769 -0
  59. package/dist/{serving-C1mhZQqH.mjs → serving-B2BNr4PR.mjs} +1 -1
  60. package/dist/{shell-7nGyF--f.mjs → shell-C8EowDEz.mjs} +15 -7
  61. package/dist/{sql-D0MqINA6.mjs → sql-CvBbb5Ui.mjs} +33 -22
  62. package/dist/{sqlite-Dj2ZEtgy.mjs → sqlite-B9ZLSDUT.mjs} +3 -3
  63. package/dist/{sqlite-db-DjbTlUwN.mjs → sqlite-db-DawFxCk6.mjs} +22 -7
  64. package/dist/store-N8PXxDAS-DWWgv-Vz.mjs +5 -0
  65. package/dist/{store-N8PXxDAS-BdL4Sq-f.mjs → store-codec-pAG2oPgQ-DbEYfF5Y.mjs} +2 -6
  66. package/dist/{store-memory-CKQVEzXN.mjs → store-memory-DOMraCLN.mjs} +3 -2
  67. package/dist/store-memory-XNDFHASI.mjs +2 -0
  68. package/dist/{store-polling-BZt2Rf3D-oh3aU_An.mjs → store-polling-BZt2Rf3D-nlZUQLz2.mjs} +1 -1
  69. package/dist/store-sqlite-Cs8dH9EX.mjs +2 -0
  70. package/dist/{store-sqlite-D6fIszST.mjs → store-sqlite-DUdQnX_6.mjs} +4 -3
  71. package/dist/sync-chat-sdk.d.mts +2 -2
  72. package/dist/sync-github.d.mts +2 -2
  73. package/dist/sync-linear.d.mts +3 -3
  74. package/dist/sync-slack.d.mts +3 -3
  75. package/dist/sync-slack.mjs +1 -1
  76. package/dist/sync.d.mts +2 -2
  77. package/dist/{task-batch-iecHMssy.mjs → task-batch-YMVr_c5R.mjs} +4 -4
  78. package/dist/{tokens-B3gXkQCs.mjs → tokens-CaEPmiG1.mjs} +2 -2
  79. package/dist/vercel-B5FM4uS8.d.mts +21 -0
  80. package/dist/vercel-BUb8II-P.mjs +305 -0
  81. package/dist/{version-gbihG3ui.mjs → version-BRR9FkLa.mjs} +1 -1
  82. package/docs/01-board/01-mounting.md +10 -0
  83. package/docs/01-board/05-reading.md +2 -1
  84. package/docs/01-board/09-access.md +8 -4
  85. package/docs/01-board/11-tasks.md +1 -1
  86. package/docs/01-board/12-postgres.md +222 -0
  87. package/docs/03-guides/02-inspector.md +34 -1
  88. package/docs/03-guides/07-build-a-ui.md +8 -4
  89. package/docs/04-reference/01-cli.md +1 -1
  90. package/docs/04-reference/03-http.md +2 -1
  91. package/docs/index.md +4 -1
  92. package/package.json +32 -3
  93. package/sql/postgres/schema.sql +389 -0
  94. package/dist/inspect-CJ8osLQ-.mjs +0 -2
  95. package/dist/store-memory-OdGsc-t_.mjs +0 -2
  96. package/dist/store-sqlite-CTxAVCcz.mjs +0 -2
@@ -0,0 +1,35 @@
1
+ import "./routes-CSnxZyyb.mjs";
2
+ import "./errors-DBZtbfph.mjs";
3
+ //#region src/server/blob.d.ts
4
+ /**
5
+ * Where a local board's attachments' bytes live. The board writes each file
6
+ * once, under a key it chose, and never overwrites it.
7
+ */
8
+ type BlobStore = {
9
+ put(key: string, data: Uint8Array, contentType: string): Promise<void>;
10
+ /** Null when there's nothing under the key. */
11
+ get(key: string): Promise<{
12
+ data: ReadableStream<Uint8Array> | Uint8Array;
13
+ contentType: string;
14
+ } | null>;
15
+ /**
16
+ * For direct uploads, files too big for a request: a URL a client `PUT`s `key`'s bytes to,
17
+ * straight to the store, with `headers`. The store must bind it to `key`, refuse more than
18
+ * `maxBytes`, refuse to overwrite what's there, and stop taking it at `expiresAt`. With `head`,
19
+ * the board takes files up to `DIRECT_UPLOAD_BYTES_MAX`; without, uploads stay at 4 MB.
20
+ */
21
+ uploadUrl?(key: string, options: {
22
+ contentType: string;
23
+ maxBytes: number;
24
+ expiresAt: Date;
25
+ }): Promise<{
26
+ url: string;
27
+ headers: Record<string, string>;
28
+ }>;
29
+ /** The size of what's under the key, or null when there's nothing: how the board checks a direct upload landed. */
30
+ head?(key: string): Promise<{
31
+ size: number;
32
+ } | null>;
33
+ };
34
+ //#endregion
35
+ export { BlobStore as t };
@@ -1,5 +1,5 @@
1
- import { Rt as SourceJoin, Vn as Actor, Vt as SourceRead, Xn as ExternalLink, Yn as ExternalFile, qn as ExternalAuthor } from "./routes-DNmQSOvQ.mjs";
2
- import { A as SyncRoot, E as ProviderEvent, _ as SyncFn, a as ProviderOptions, c as Receive, f as ResolvedTarget, i as ProviderFile, l as ReceivedEvent, m as SyncProvider, n as FileDelivery, o as ProviderPost, r as ProviderDelivery, t as FetchedLink } from "./provider-DgGp4Zej.mjs";
1
+ import { Rt as SourceJoin, Vn as Actor, Vt as SourceRead, Xn as ExternalLink, Yn as ExternalFile, qn as ExternalAuthor } from "./routes-CSnxZyyb.mjs";
2
+ import { A as SyncRoot, E as ProviderEvent, _ as SyncFn, a as ProviderOptions, c as Receive, f as ResolvedTarget, i as ProviderFile, l as ReceivedEvent, m as SyncProvider, n as FileDelivery, o as ProviderPost, r as ProviderDelivery, t as FetchedLink } from "./provider-BNVyVKtH.mjs";
3
3
  import { Adapter, Author, FileUpload, Message, ReactionEvent, StateAdapter } from "chat";
4
4
  //#region src/sync/chat-provider.d.ts
5
5
  type ChatInput = {
@@ -1,2 +1,2 @@
1
- import { a as OptionName, c as globalOptions, d as options, f as usage, i as CliOption, l as groups, n as CliCommand, o as commands, r as CliExample, s as filters, t as CliArgument, u as option } from "./commands-DLPIX7Jw.mjs";
1
+ import { a as OptionName, c as globalOptions, d as options, f as usage, i as CliOption, l as groups, n as CliCommand, o as commands, r as CliExample, s as filters, t as CliArgument, u as option } from "./commands-Dcm4_pc1.mjs";
2
2
  export { CliArgument, CliCommand, CliExample, CliOption, OptionName, commands, filters, globalOptions, groups, option, options, usage };
@@ -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-7FY_8p92.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-DeYAQUcP.mjs";
2
2
  export { commands, filters, globalOptions, groups, option, options, usage };
@@ -1,5 +1,5 @@
1
- import { f as Board } from "./backend-BHN6GTjB.mjs";
2
- import "./index-Ce3SDZ3Y.mjs";
1
+ import { f as Board } from "./backend-BuqwQbb4.mjs";
2
+ import "./index-DuibwQf9.mjs";
3
3
  //#region src/cli/claims.d.ts
4
4
  /** A claim as the CLI keeps it: what its writes carry, and when its lease ends. */
5
5
  type HeldClaim = {
@@ -1,5 +1,5 @@
1
- import { o as stoppedBy } from "./exports-DSX-CI5c.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-DSlpMoBN.mjs";
1
+ import { o as stoppedBy } from "./exports-B_UGnrnN.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-Bbqg3Unf.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-7FY_8p92.mjs";
3
- import { g as projectDir } from "./server-55vryxAl.mjs";
4
- import { r as main } from "./main-DSlpMoBN.mjs";
5
- import { i as createInspector, r as stopped, t as allowedHosts } from "./inspect-C-vDnB_n.mjs";
2
+ import { a as option } from "./commands-DeYAQUcP.mjs";
3
+ import { _ as projectDir } from "./server-BXbcS-n9.mjs";
4
+ import { r as main } from "./main-Bbqg3Unf.mjs";
5
+ import { i as createInspector, r as stopped, t as allowedHosts } from "./inspect-DfJzHFiE.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-CJ8osLQ-.mjs")).inspect(context);
40
+ return (await import("./inspect-H1MISWwN.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-CI3kvpx_.mjs");
84
+ const { serveLocal } = await import("./serve-D06-DMej.mjs");
85
85
  const local = await serveLocal({
86
86
  dir: flags.dir ?? join(root, ".board"),
87
87
  hosts,
@@ -1,4 +1,4 @@
1
- import { $t as SyncThreadView, B as Explanation, H as FiltersInput, Hn as ExternalCopy, I as EventsPage, It as SchemaInput, J as GrantWriteOptions, Jt as SyncFindView, K as GrantInput, Kt as SyncFindInput, Lt as SchemaView, N as Discovery, Nt as SchedulesQueryInput, Q as InboxItem, Qt as SyncReceiptInput, Rt as SourceJoin, St as RegistrationView, Un as Attachment, Vn as Actor, Vt as SourceRead, Xt as SyncImportInput, Z as InboxEntry, _ as ChannelView, b as ChannelsQueryInput, cn as TasksQueryInput, dt as MessagesPage, en as SyncedView, fn as ThreadView, g as ChannelMessagesQueryInput, hn as ThreadsQueryInput, jt as ScheduleView, lt as Me, on as TasksPage, pn as ThreadsPage, q as GrantView, r as ActorView, rn as TaskClaim, st as MatchView, u as BoardEventView, un as ThreadQueryInput, ut as MessageView, xt as RegisterInput, yn as UpdateGrantInput } from "./routes-DNmQSOvQ.mjs";
1
+ import { $t as SyncThreadView, B as Explanation, H as FiltersInput, Hn as ExternalCopy, I as EventsPage, It as SchemaInput, J as GrantWriteOptions, Jt as SyncFindView, K as GrantInput, Kt as SyncFindInput, Lt as SchemaView, N as Discovery, Nt as SchedulesQueryInput, Q as InboxItem, Qt as SyncReceiptInput, Rt as SourceJoin, St as RegistrationView, Un as Attachment, Vn as Actor, Vt as SourceRead, Xt as SyncImportInput, Z as InboxEntry, _ as ChannelView, b as ChannelsQueryInput, cn as TasksQueryInput, dt as MessagesPage, en as SyncedView, fn as ThreadView, g as ChannelMessagesQueryInput, hn as ThreadsQueryInput, jt as ScheduleView, lt as Me, on as TasksPage, pn as ThreadsPage, q as GrantView, r as ActorView, rn as TaskClaim, st as MatchView, u as BoardEventView, un as ThreadQueryInput, ut as MessageView, xt as RegisterInput, yn as UpdateGrantInput } from "./routes-CSnxZyyb.mjs";
2
2
  //#region src/contract/mentions.d.ts
3
3
  /** An actor as a write's answer names them. */
4
4
  type MentionedActor = {
@@ -301,7 +301,7 @@ declare const options: {
301
301
  readonly github: {
302
302
  readonly type: 'string';
303
303
  readonly multiple: true;
304
- readonly value: 'owner/repo';
304
+ readonly value: 'owner/repo|id';
305
305
  readonly description: "GitHub Actions' runs in a repository";
306
306
  };
307
307
  readonly oidc: {
@@ -378,7 +378,7 @@ declare const options: {
378
378
  readonly 'add-github': {
379
379
  readonly type: 'string';
380
380
  readonly multiple: true;
381
- readonly value: 'owner/repo';
381
+ readonly value: 'owner/repo|id';
382
382
  readonly description: "add a repository's runs";
383
383
  };
384
384
  readonly 'add-oidc': {
@@ -424,7 +424,7 @@ declare const options: {
424
424
  readonly 'remove-github': {
425
425
  readonly type: 'string';
426
426
  readonly multiple: true;
427
- readonly value: 'owner/repo';
427
+ readonly value: 'owner/repo|id';
428
428
  readonly description: "remove a repository's runs";
429
429
  };
430
430
  readonly 'remove-oidc': {
@@ -249,7 +249,7 @@ const options = {
249
249
  github: {
250
250
  type: "string",
251
251
  multiple: true,
252
- value: "owner/repo",
252
+ value: "owner/repo|id",
253
253
  description: "GitHub Actions' runs in a repository"
254
254
  },
255
255
  oidc: {
@@ -326,7 +326,7 @@ const options = {
326
326
  "add-github": {
327
327
  type: "string",
328
328
  multiple: true,
329
- value: "owner/repo",
329
+ value: "owner/repo|id",
330
330
  description: "add a repository's runs"
331
331
  },
332
332
  "add-oidc": {
@@ -372,7 +372,7 @@ const options = {
372
372
  "remove-github": {
373
373
  type: "string",
374
374
  multiple: true,
375
- value: "owner/repo",
375
+ value: "owner/repo|id",
376
376
  description: "remove a repository's runs"
377
377
  },
378
378
  "remove-oidc": {
@@ -746,7 +746,7 @@ const commands = [
746
746
  {
747
747
  group: "the board",
748
748
  name: "channels",
749
- description: "channels, a page at a time, grouped by path prefix: a first post makes one, and so does create",
749
+ description: "channels, a page at a time, grouped by path prefix: a first post makes one, and so does channels create",
750
750
  arguments: [{
751
751
  name: "prefix",
752
752
  required: false,
@@ -1289,8 +1289,9 @@ const commands = [
1289
1289
  option("for", "only this profile of yours claims it", "profile"),
1290
1290
  claimNow,
1291
1291
  option("lease", "with --claim: how long to hold it"),
1292
+ option("attach"),
1292
1293
  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\"})"),
1293
- option("no-sync"),
1294
+ option("no-sync", "keep it on the board: sync it nowhere. With --file, each task that sets no noSync of its own"),
1294
1295
  option("idempotency-key", "sending the same one again makes it once")
1295
1296
  ],
1296
1297
  examples: [
@@ -1302,6 +1303,10 @@ const commands = [
1302
1303
  name: "a review that waits for it",
1303
1304
  value: "tasks create work \"review the fix for CVE-123\" --label step=review --needs 812"
1304
1305
  },
1306
+ {
1307
+ name: "hand over a job with its file",
1308
+ value: "tasks create work \"build it\" --attach job.json"
1309
+ },
1305
1310
  {
1306
1311
  name: "make a task of a thread that is there",
1307
1312
  value: "tasks create 812"
@@ -1,6 +1,6 @@
1
- import { f as BoardError } from "./errors-DDfXnZ2b.mjs";
1
+ import { f as BoardError } from "./errors-DjatfYjl.mjs";
2
2
  import { c as canonical, t as block } from "./blocks-CVoBC7ur.mjs";
3
- import { a as canText, c as compileAccess } from "./access-HzqFpgL_.mjs";
3
+ import { a as canText, c as compileAccess } from "./access-CZ419Vho.mjs";
4
4
  //#region src/client/channels.ts
5
5
  /** Every channel of a board, or every one whose path starts with `prefix`, a page at a time: for what needs them all. */
6
6
  async function everyChannel(board, prefix) {
@@ -1,4 +1,4 @@
1
- import { f as Board } from "./backend-BHN6GTjB.mjs";
1
+ import { f as Board } from "./backend-BuqwQbb4.mjs";
2
2
  //#region src/conformance/index.d.ts
3
3
  /**
4
4
  * Checks that a board speaks the protocol, through a handle on it (`conformance(board())`), as
@@ -1,2 +1,2 @@
1
- import { t as conformance } from "./conformance-BNiLcKra.mjs";
1
+ import { t as conformance } from "./conformance-EtEq22w1.mjs";
2
2
  export { conformance };
@@ -1,10 +1,10 @@
1
1
  import { f as typeOf, i as ATTACHMENT_BYTES_MAX, l as fileSize, o as IMPORT_BYTES_MAX, u as importedFileName } from "./profile-header-O8wC8yk8.mjs";
2
2
  import { P as toStorable, m as MESSAGE_TEXT_MAX, s as ChannelPath } from "./schemas-CUSTEFIy.mjs";
3
3
  import { l as isThreadTarget, s as channelOf } from "./external-DkWafjn-.mjs";
4
- import { c as notFound, r as badRequest, t as HttpError } from "./errors-DDfXnZ2b.mjs";
4
+ import { c as notFound, r as badRequest, t as HttpError, v as derivedId } from "./errors-DjatfYjl.mjs";
5
5
  import { t as canonicalEmoji } from "./emoji-CTLpvH-A.mjs";
6
- import { a as waitUntil, c as platformProfile, f as viaText, i as afterRetry, l as shownName, m as derivedId, o as actorParts, t as DroppedError } from "./middleware-BY4qqIh3.mjs";
7
- import { a as replaceMentions, n as isEmail, t as extractMentions } from "./mentions-CnWt9Z5b.mjs";
6
+ import { n as isEmail, s as replaceMentions, t as extractMentions } from "./mentions-DBGmqkr2.mjs";
7
+ import { a as waitUntil, c as platformProfile, f as viaText, i as afterRetry, l as shownName, o as actorParts, t as DroppedError } from "./middleware-D2AGrGj7.mjs";
8
8
  import { a as immutable, d as opensBlock, f as routesFor, l as UnreadableError, n as SyncOverrides, o as ReceivedEvent, s as ResolvedTarget, u as channelMissing } from "./events-mWKc1uvZ.mjs";
9
9
  import { i as vercelDeployments, n as displayText, t as byVercelBot } from "./bots-CqPYxkqK.mjs";
10
10
  //#region src/sync/engine.ts
@@ -0,0 +1,19 @@
1
+ import { i as ErrorOrigin } from "./client-B0DGOt7P.mjs";
2
+ //#region src/server/errors.d.ts
3
+ declare class HttpError extends Error {
4
+ readonly status: number;
5
+ readonly code: string;
6
+ /** What fixes it, when there's one (`BoardError`'s `hint`). */
7
+ readonly hint: string | undefined;
8
+ /** `handle` for a handle's own error on its way through: everything else is the board's. */
9
+ readonly origin: ErrorOrigin;
10
+ /** For a 429, how many seconds until it's worth sending again, when that's known: the response's `Retry-After`. */
11
+ readonly retryAfter: number | undefined;
12
+ constructor(status: number, code: string, message: string, options?: {
13
+ hint?: string;
14
+ origin?: ErrorOrigin;
15
+ retryAfter?: number;
16
+ });
17
+ }
18
+ //#endregion
19
+ export { HttpError as t };
@@ -921,8 +921,8 @@ const routes = {
921
921
  body: CreateGrantsBody
922
922
  },
923
923
  updateGrant: {
924
- method: "PATCH",
925
- path: "/grants/:id",
924
+ method: "POST",
925
+ path: "/grants/:id/update",
926
926
  body: UpdateGrantBody
927
927
  },
928
928
  /** Which grant decides a channel, for the caller or, with `manage` at `*`, a principal it names. */
@@ -1126,6 +1126,162 @@ async function* parseSse(body, signal) {
1126
1126
  }
1127
1127
  }
1128
1128
  //#endregion
1129
+ //#region src/client/ids.ts
1130
+ const hex = (bytes) => Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
1131
+ const K = new Uint32Array([
1132
+ 1116352408,
1133
+ 1899447441,
1134
+ 3049323471,
1135
+ 3921009573,
1136
+ 961987163,
1137
+ 1508970993,
1138
+ 2453635748,
1139
+ 2870763221,
1140
+ 3624381080,
1141
+ 310598401,
1142
+ 607225278,
1143
+ 1426881987,
1144
+ 1925078388,
1145
+ 2162078206,
1146
+ 2614888103,
1147
+ 3248222580,
1148
+ 3835390401,
1149
+ 4022224774,
1150
+ 264347078,
1151
+ 604807628,
1152
+ 770255983,
1153
+ 1249150122,
1154
+ 1555081692,
1155
+ 1996064986,
1156
+ 2554220882,
1157
+ 2821834349,
1158
+ 2952996808,
1159
+ 3210313671,
1160
+ 3336571891,
1161
+ 3584528711,
1162
+ 113926993,
1163
+ 338241895,
1164
+ 666307205,
1165
+ 773529912,
1166
+ 1294757372,
1167
+ 1396182291,
1168
+ 1695183700,
1169
+ 1986661051,
1170
+ 2177026350,
1171
+ 2456956037,
1172
+ 2730485921,
1173
+ 2820302411,
1174
+ 3259730800,
1175
+ 3345764771,
1176
+ 3516065817,
1177
+ 3600352804,
1178
+ 4094571909,
1179
+ 275423344,
1180
+ 430227734,
1181
+ 506948616,
1182
+ 659060556,
1183
+ 883997877,
1184
+ 958139571,
1185
+ 1322822218,
1186
+ 1537002063,
1187
+ 1747873779,
1188
+ 1955562222,
1189
+ 2024104815,
1190
+ 2227730452,
1191
+ 2361852424,
1192
+ 2428436474,
1193
+ 2756734187,
1194
+ 3204031479,
1195
+ 3329325298
1196
+ ]);
1197
+ /** SHA-256 in plain JavaScript, for a page WebCrypto's digest isn't on: one served over plain http to another host. */
1198
+ function sha256Bytes(data) {
1199
+ const padded = new Uint8Array(Math.ceil((data.length + 9) / 64) * 64);
1200
+ padded.set(data);
1201
+ padded[data.length] = 128;
1202
+ const view = new DataView(padded.buffer);
1203
+ view.setUint32(padded.length - 8, Math.floor(data.length / 536870912));
1204
+ view.setUint32(padded.length - 4, data.length * 8);
1205
+ const h = new Uint32Array([
1206
+ 1779033703,
1207
+ 3144134277,
1208
+ 1013904242,
1209
+ 2773480762,
1210
+ 1359893119,
1211
+ 2600822924,
1212
+ 528734635,
1213
+ 1541459225
1214
+ ]);
1215
+ const w = /* @__PURE__ */ new Uint32Array(64);
1216
+ const rotr = (x, n) => x >>> n | x << 32 - n;
1217
+ for (let at = 0; at < padded.length; at += 64) {
1218
+ for (let i = 0; i < 16; i++) w[i] = view.getUint32(at + i * 4);
1219
+ for (let i = 16; i < 64; i++) {
1220
+ const s0 = rotr(w[i - 15], 7) ^ rotr(w[i - 15], 18) ^ w[i - 15] >>> 3;
1221
+ const s1 = rotr(w[i - 2], 17) ^ rotr(w[i - 2], 19) ^ w[i - 2] >>> 10;
1222
+ w[i] = w[i - 16] + s0 + w[i - 7] + s1;
1223
+ }
1224
+ let [a, b, c, d, e, f, g, k] = h;
1225
+ for (let i = 0; i < 64; i++) {
1226
+ const t1 = k + (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) + (e & f ^ ~e & g) + K[i] + w[i] >>> 0;
1227
+ const t2 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) + (a & b ^ a & c ^ b & c) >>> 0;
1228
+ k = g;
1229
+ g = f;
1230
+ f = e;
1231
+ e = d + t1 >>> 0;
1232
+ d = c;
1233
+ c = b;
1234
+ b = a;
1235
+ a = t1 + t2 >>> 0;
1236
+ }
1237
+ h[0] += a;
1238
+ h[1] += b;
1239
+ h[2] += c;
1240
+ h[3] += d;
1241
+ h[4] += e;
1242
+ h[5] += f;
1243
+ h[6] += g;
1244
+ h[7] += k;
1245
+ }
1246
+ const out = /* @__PURE__ */ new Uint8Array(32);
1247
+ const result = new DataView(out.buffer);
1248
+ h.forEach((word, i) => result.setUint32(i * 4, word));
1249
+ return out;
1250
+ }
1251
+ /** SHA-256 of `data`: WebCrypto's where the page has it, plain JavaScript where it doesn't. */
1252
+ async function digest(data) {
1253
+ const bytes = Uint8Array.from(data instanceof ArrayBuffer ? new Uint8Array(data) : data);
1254
+ if (globalThis.crypto?.subtle) return new Uint8Array(await crypto.subtle.digest("SHA-256", bytes));
1255
+ return sha256Bytes(bytes);
1256
+ }
1257
+ /** SHA-256 of `text`, in hex. */
1258
+ async function sha256(text) {
1259
+ return hex(await digest(new TextEncoder().encode(text)));
1260
+ }
1261
+ /**
1262
+ * A UUIDv8 from `parts`, exactly as A2's `idempotentId` makes one: the IDs a board derives for the
1263
+ * writes its own code makes, which no request may post with.
1264
+ */
1265
+ async function derivedId(...parts) {
1266
+ const bytes = (await digest(new TextEncoder().encode(JSON.stringify(parts)))).slice(0, 16);
1267
+ bytes[6] = bytes[6] & 15 | 128;
1268
+ bytes[8] = bytes[8] & 63 | 128;
1269
+ const text = hex(bytes);
1270
+ return `${text.slice(0, 8)}-${text.slice(8, 12)}-${text.slice(12, 16)}-${text.slice(16, 20)}-${text.slice(20, 32)}`;
1271
+ }
1272
+ /** A derived ID's shape. */
1273
+ 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}$/;
1274
+ /**
1275
+ * A post's ID, from one derived for it, under `principal`: a board takes a `key:<principal>:` ID
1276
+ * only from that principal, so no one else can post with it first.
1277
+ */
1278
+ const keyId = async (principal, derived) => `key:${principal}:${(await sha256(`board-key\u001f${derived}`)).slice(0, 32)}`;
1279
+ /**
1280
+ * Whether `id` is exactly the shape `keyId` makes for `principal`. A prefix check isn't enough:
1281
+ * a principal's ID can be the start of another's (`oidc:gitlab.com:acme` and `oidc:gitlab.com:acme:ci`).
1282
+ */
1283
+ const isKeyIdOf = (id, principal) => id.startsWith(`key:${principal}:`) && /^[0-9a-f]{32}$/.test(id.slice(`key:${principal}:`.length));
1284
+ //#endregion
1129
1285
  //#region src/client/client.ts
1130
1286
  /**
1131
1287
  * What went wrong: `message` says what and why, `code` is what to branch on, `hint`, when there's
@@ -1251,6 +1407,19 @@ function creatorOf(me, path) {
1251
1407
  };
1252
1408
  throw new BoardError("no_own_principal", `A private channel lets its creator in, as a person or a project's deployment, and ${me.principal} is neither, so ${path} wasn't made.`, 400, { hint: "Make it as a person or a deployment, or make it and its grants yourself." });
1253
1409
  }
1410
+ /** Sleeps for `ms`, or until `signal` aborts. */
1411
+ function pause(ms, signal) {
1412
+ return new Promise((resolve) => {
1413
+ if (signal?.aborted) return resolve();
1414
+ const done = () => {
1415
+ clearTimeout(timer);
1416
+ signal?.removeEventListener("abort", done);
1417
+ resolve();
1418
+ };
1419
+ const timer = setTimeout(done, ms);
1420
+ signal?.addEventListener("abort", done, { once: true });
1421
+ });
1422
+ }
1254
1423
  function createBoardClient(options) {
1255
1424
  const base = options.url.replace(/\/+$/, "");
1256
1425
  const doFetch = options.fetch ?? ((input, init) => globalThis.fetch(input, init));
@@ -1636,7 +1805,7 @@ function createBoardClient(options) {
1636
1805
  ...goAhead(options)
1637
1806
  } }),
1638
1807
  /** Adds and removes principals (by who they are, environments aside), or replaces its `can`. Needs what `checkGrantChange` says, for the grant as it was and as it'd be. */
1639
- updateGrant: (id, { add, remove, can }, options = {}) => call("PATCH", `/grants/${path(id)}`, { body: {
1808
+ updateGrant: (id, { add, remove, can }, options = {}) => call("POST", `/grants/${path(id)}/update`, { body: {
1640
1809
  ...add ? { add: add.map(withEnvironments) } : {},
1641
1810
  ...remove ? { remove } : {},
1642
1811
  ...can ? { can: wireCan(can) } : {},
@@ -1679,7 +1848,7 @@ function createBoardClient(options) {
1679
1848
  if (size > 4194304) {
1680
1849
  if (size > 104857600) throw new BoardError("too_large", `Attachments are at most ${DIRECT_UPLOAD_BYTES_MAX / 1024 / 1024} MB.`, 413);
1681
1850
  const bytes = input.data instanceof Blob ? await input.data.arrayBuffer() : input.data;
1682
- const sha256 = btoa(String.fromCharCode(...new Uint8Array(await crypto.subtle.digest("SHA-256", bytes))));
1851
+ const sha256 = btoa(String.fromCharCode(...await digest(bytes)));
1683
1852
  const ticket = await call("POST", "/attachments/uploads", { body: {
1684
1853
  name: input.name,
1685
1854
  type,
@@ -1807,7 +1976,7 @@ function createBoardClient(options) {
1807
1976
  if (opts.signal?.aborted) return;
1808
1977
  if (error instanceof BoardError && (error.status === 501 || error.status >= 400 && error.status < 500)) throw error;
1809
1978
  state.failed();
1810
- await new Promise((r) => setTimeout(r, Math.min(3e4, 500 * 2 ** failures++)));
1979
+ await pause(Math.min(3e4, 500 * 2 ** failures++), opts.signal);
1811
1980
  continue;
1812
1981
  }
1813
1982
  failures = 0;
@@ -1820,25 +1989,46 @@ function createBoardClient(options) {
1820
1989
  } catch (error) {
1821
1990
  if (opts.signal?.aborted) return;
1822
1991
  state.failed();
1823
- await new Promise((r) => setTimeout(r, Math.min(3e4, 500 * 2 ** failures++)));
1992
+ await pause(Math.min(3e4, 500 * 2 ** failures++), opts.signal);
1824
1993
  }
1825
1994
  }
1826
1995
  },
1827
1996
  /** The next matching event after `after` (default: now), or null on timeout. */
1828
1997
  async wait(query = {}, opts = {}) {
1829
1998
  const deadline = Date.now() + duration(opts.timeout ?? "30m");
1830
- let after = query.after ?? (await poll({
1831
- ...query,
1832
- after: void 0,
1833
- wait: 0
1834
- }, opts.signal)).cursor;
1999
+ let failures = 0;
2000
+ const again = async (error) => {
2001
+ if (opts.signal?.aborted) return;
2002
+ if (error instanceof BoardError && (error.status === 501 || error.status >= 400 && error.status < 500)) throw error;
2003
+ if (error instanceof Error && error.name === "AbortError") throw error;
2004
+ const backoff = Math.min(3e4, 500 * 2 ** failures++);
2005
+ if (Date.now() + backoff >= deadline) throw error;
2006
+ await pause(backoff, opts.signal);
2007
+ };
2008
+ let after = query.after;
2009
+ while (after === void 0 && !opts.signal?.aborted) try {
2010
+ after = (await poll({
2011
+ ...query,
2012
+ after: void 0,
2013
+ wait: 0
2014
+ }, opts.signal)).cursor;
2015
+ } catch (error) {
2016
+ await again(error);
2017
+ }
1835
2018
  while (Date.now() < deadline && !opts.signal?.aborted) {
1836
2019
  const wait = Math.max(0, Math.min(25, Math.ceil((deadline - Date.now()) / 1e3)));
1837
- const page = await poll({
1838
- ...query,
1839
- after,
1840
- wait
1841
- }, opts.signal);
2020
+ let page;
2021
+ try {
2022
+ page = await poll({
2023
+ ...query,
2024
+ after,
2025
+ wait
2026
+ }, opts.signal);
2027
+ } catch (error) {
2028
+ await again(error);
2029
+ continue;
2030
+ }
2031
+ failures = 0;
1842
2032
  if (page.events.length > 0) return page.events[0];
1843
2033
  after = page.cursor;
1844
2034
  }
@@ -1846,11 +2036,23 @@ function createBoardClient(options) {
1846
2036
  }
1847
2037
  };
1848
2038
  }
2039
+ /**
2040
+ * The code of a refusal, as a board or Vercel's API answered it. Vercel's API refuses a team whose SAML
2041
+ * session has lapsed with a 403 marked `saml`: `reauthentication_required`, which a new login fixes and a grant doesn't.
2042
+ * It refuses a token that expired or was revoked with a 403 marked `invalidToken`: `invalid_token`, which a
2043
+ * refreshed or new login fixes, and a grant doesn't either.
2044
+ */
2045
+ function refusalCode(status, error) {
2046
+ if (status === 403 && error?.saml === true) return "reauthentication_required";
2047
+ if (status === 403 && error?.invalidToken === true) return "invalid_token";
2048
+ return error?.code;
2049
+ }
1849
2050
  async function toError(response) {
1850
2051
  try {
1851
2052
  const body = await response.json();
1852
2053
  const retryAfter = response.status === 429 ? /^\d{1,6}$/.exec(response.headers.get("retry-after") ?? "")?.[0] : void 0;
1853
- if (body.error?.message) return new BoardError(body.error.code ?? "error", body.error.message, response.status, {
2054
+ const code = refusalCode(response.status, body.error);
2055
+ if (body.error?.message) return new BoardError(code ?? "error", body.error.message, response.status, {
1854
2056
  ...typeof body.error.hint === "string" ? { hint: body.error.hint } : {},
1855
2057
  origin: handleErrors.has(response) ? "handle" : "board",
1856
2058
  ...retryAfter !== void 0 ? { retryAfter: Number(retryAfter) } : {}
@@ -1955,4 +2157,4 @@ function toErrorResponse(error) {
1955
2157
  } }, 500);
1956
2158
  }
1957
2159
  //#endregion
1958
- export { SchedulesQuery as $, CreatedTasksQuery as A, InboxPushBody as B, ClaimReadyTaskBody as C, CreateGrantsBody as D, CreateChannelBody as E, FailTaskBody as F, PostBody as G, LabelBody as H, Filters as I, RegisterBody as J, ReactBody as K, GrantBody as L, EditBody as M, EventsQuery as N, CreateTaskBody as O, ExplainQuery as P, ScheduleBody as Q, InboxAckBody as R, ChannelsQuery as S, CompleteTaskBody as T, LinkedQuery as U, InboxQuery as V, MatchesQuery as W, RenewTaskBody as X, ReleaseTaskBody as Y, RevokeGrantBody as Z, ActorsQuery as _, duplicateId as a, SyncFindQuery as at, CancelTaskBody as b, notFound as c, TaskNeedsBody as ct, unauthorized as d, ThreadsQuery as dt, SchemaBody as et, BoardError as f, TypingBody as ft, AckBody as g, eventsState as h, routes as ht, batchTooLarge as i, SyncCopiesQuery as it, DeleteBody as j, CreateTasksBody as k, textTooLong as l, TasksQuery as lt, duration as m, UploadStartBody as mt, RejectedError as n, SourceReadQuery as nt, forbidden as o, SyncImportBody as ot, createBoardClient as p, UpdateGrantBody as pt, Ref as q, badRequest as r, SyncBody as rt, json as s, SyncReceiptBody as st, HttpError as t, SourceJoinBody as tt, toErrorResponse as u, ThreadQuery as ut, AssignTaskBody as v, ClaimTaskBody as w, ChannelMessagesQuery as x, BlockTaskBody as y, InboxNextQuery as z };
2160
+ export { Ref as $, ClaimTaskBody as A, ExplainQuery as B, ActorsQuery as C, ChannelMessagesQuery as D, CancelTaskBody as E, CreateTasksBody as F, InboxNextQuery as G, Filters as H, CreatedTasksQuery as I, LabelBody as J, InboxPushBody as K, DeleteBody as L, CreateChannelBody as M, CreateGrantsBody as N, ChannelsQuery as O, CreateTaskBody as P, ReactBody as Q, EditBody as R, AckBody as S, BlockTaskBody as T, GrantBody as U, FailTaskBody as V, InboxAckBody as W, MatchesQuery as X, LinkedQuery as Y, PostBody as Z, DERIVED_ID as _, ThreadsQuery as _t, duplicateId as a, SchedulesQuery as at, keyId as b, UploadStartBody as bt, notFound as c, SourceReadQuery as ct, unauthorized as d, SyncFindQuery as dt, RegisterBody as et, BoardError as f, SyncImportBody as ft, refusalCode as g, ThreadQuery as gt, eventsState as h, TasksQuery as ht, batchTooLarge as i, ScheduleBody as it, CompleteTaskBody as j, ClaimReadyTaskBody as k, textTooLong as l, SyncBody as lt, duration as m, TaskNeedsBody as mt, RejectedError as n, RenewTaskBody as nt, forbidden as o, SchemaBody as ot, createBoardClient as p, SyncReceiptBody as pt, InboxQuery as q, badRequest as r, RevokeGrantBody as rt, json as s, SourceJoinBody as st, HttpError as t, ReleaseTaskBody as tt, toErrorResponse as u, SyncCopiesQuery as ut, derivedId as v, TypingBody as vt, AssignTaskBody as w, sha256 as x, routes as xt, isKeyIdOf as y, UpdateGrantBody as yt, EventsQuery as z };