@vercel/board 0.45.1 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{access-3udXjJAg.mjs → access-C06pIr0M.mjs} +2 -2
- package/dist/access.d.mts +2 -2
- package/dist/access.mjs +5 -5
- package/dist/{actors-DasGZnfb.mjs → actors-Dkyg-oo0.mjs} +3 -3
- package/dist/{auth-aiOVE82-.mjs → auth-B9-wXQ-x.mjs} +29 -9
- package/dist/{auth-BG_whr9_.d.mts → auth-li3lKwJG.d.mts} +1 -1
- package/dist/{backend-D6yTo8Un.d.mts → backend-i_esjwUS.d.mts} +144 -5
- package/dist/backend-local.d.mts +1 -1
- package/dist/backend-local.mjs +1 -1
- package/dist/{chat-provider-V2jnjVLq.d.mts → chat-provider-BWBGZOZY.d.mts} +4 -2
- package/dist/{chat-provider-BvNqOQFL.mjs → chat-provider-CD7jskh7.mjs} +7 -4
- package/dist/cli-commands.d.mts +1 -1
- package/dist/cli-commands.mjs +1 -1
- package/dist/cli-embedded.d.mts +2 -2
- package/dist/cli-embedded.mjs +3 -2
- package/dist/cli.mjs +46 -15
- package/dist/{commands-DewS14_P.d.mts → commands-CJsOA-hf.d.mts} +60 -0
- package/dist/{commands-CqdnjUkm.mjs → commands-Dk6_cHLS.mjs} +325 -0
- package/dist/{conformance-BInS4_6b.mjs → conformance-CDP8y2Zm.mjs} +1063 -6
- package/dist/conformance.d.mts +6 -5
- package/dist/conformance.mjs +1 -1
- package/dist/{engine-XVBt02Bl.mjs → engine-j2VeNuKG.mjs} +51 -50
- package/dist/{errors-ZazTZh-s.mjs → errors-QhkdzI-o.mjs} +176 -9
- package/dist/{events-D17RndlV.mjs → events-MOcxGpOQ.mjs} +2 -2
- package/dist/{exports-DCxecX15.mjs → exports-CEqS-IPP.mjs} +1417 -84
- package/dist/exports-CF9rKCXd.d.mts +44 -0
- package/dist/{external-DfhN7lKK.mjs → external-BuVTXT1R.mjs} +7 -3
- package/dist/{index-Djmr4GzQ.d.mts → index-ttfx1TZ6.d.mts} +2 -2
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +5 -5
- package/dist/index.node.d.mts +7 -6
- package/dist/index.node.mjs +5 -4
- package/dist/inspect/app.js +215 -115
- package/dist/inspect/engine.js +5 -5
- package/dist/inspect-8YAhl_h3.mjs +2 -0
- package/dist/{inspect-CHsgnf_5.mjs → inspect-vOSrW_g6.mjs} +322 -50
- package/dist/{local-DE9vmanM.mjs → local-0ajWOVhN.mjs} +1673 -98
- package/dist/{main-CF1Me3jg.mjs → main-B8Zkd4Pm.mjs} +1282 -58
- package/dist/{memory-DyEL0fvN.mjs → memory-CMm-Fk_A.mjs} +2 -2
- package/dist/{mentions-DfZGp3B-.mjs → mentions-CnWt9Z5b.mjs} +34 -1
- package/dist/{middleware-BHHKHA9q.mjs → middleware-CT6vMNUc.mjs} +2 -2
- package/dist/{provider-BC9mPYVh.d.mts → provider-Bc3xI90K.d.mts} +199 -6
- package/dist/{routes-CkUetTO2.mjs → routes-ABXf3CKq.mjs} +261 -8
- package/dist/{routes-zm4TXKCC.d.mts → routes-CjA6Mp4D.d.mts} +610 -6
- package/dist/{schemas-BhZaystC.mjs → schemas-7VFdomFB.mjs} +34 -1
- package/dist/serve-BepKXDH3.mjs +285 -0
- package/dist/{server-Bmz0zqYM.mjs → server-4rQL3xuH.mjs} +41 -22
- package/dist/{serving-BLVRrJ7P.mjs → serving-BNdiReQT.mjs} +1 -1
- package/dist/{sql-CyVcjw8x.mjs → sql-IEbO5vXs.mjs} +174 -9
- package/dist/{sqlite-Con-8duk.mjs → sqlite-CVG8XKHm.mjs} +2 -2
- package/dist/{sqlite-db-BdzxtUOV.mjs → sqlite-db-BJjPQYx4.mjs} +1 -1
- package/dist/sync-chat-sdk.d.mts +16 -2
- package/dist/sync-chat-sdk.mjs +2 -2
- package/dist/sync-github.d.mts +16 -2
- package/dist/sync-github.mjs +3 -3
- package/dist/sync-linear.d.mts +17 -3
- package/dist/sync-linear.mjs +2 -2
- package/dist/sync-slack.d.mts +17 -3
- package/dist/sync-slack.mjs +107 -15
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/{origin-BbwhnKrg.mjs → task-batch-BZXm6kOE.mjs} +83 -8
- package/dist/{tokens-BErYXuHZ.mjs → tokens-BCp4EWTQ.mjs} +2 -2
- package/docs/01-board/01-mounting.md +8 -5
- package/docs/01-board/03-identity.md +43 -23
- package/docs/01-board/04-messages.md +3 -2
- package/docs/01-board/06-watchers.md +3 -3
- package/docs/01-board/07-schedules.md +2 -2
- package/docs/01-board/08-middleware.md +7 -0
- package/docs/01-board/09-access.md +6 -4
- package/docs/01-board/10-local.md +4 -1
- package/docs/01-board/11-tasks.md +348 -0
- package/docs/02-sync/01-overview.md +4 -5
- package/docs/02-sync/02-functions.md +2 -2
- package/docs/02-sync/03-slack.md +8 -5
- package/docs/02-sync/06-providers.md +8 -0
- package/docs/03-guides/02-inspector.md +83 -10
- package/docs/03-guides/06-sandboxed-agents.md +7 -5
- package/docs/03-guides/07-build-a-ui.md +210 -0
- package/docs/03-guides/08-tailnet.md +123 -0
- package/docs/04-reference/01-cli.md +272 -23
- package/docs/04-reference/02-board.md +287 -7
- package/docs/04-reference/03-http.md +208 -13
- package/docs/04-reference/05-conformance.md +10 -7
- package/package.json +1 -1
- package/dist/exports-Gspe1eEq.d.mts +0 -4
- package/dist/inspect-C8U3A4jQ.mjs +0 -2
- package/dist/serve-CEMvl0EH.mjs +0 -181
|
@@ -37,7 +37,7 @@ The short samples below act on that `team`, and on `msg`, the message
|
|
|
37
37
|
|
|
38
38
|
In Node, `board()` with no backend is your team's board in Vercel's API, the
|
|
39
39
|
one `name` names (`security`), or with `team`, another team's, with
|
|
40
|
-
|
|
40
|
+
the deployment's OIDC token, or else `BOARD_TOKEN`, then `VERCEL_AUTH_TOKEN` or your `vercel login`, or what
|
|
41
41
|
`board({ fetch })` sends. See [A board by its name](../01-board/01-mounting.md#a-board-by-its-name).
|
|
42
42
|
|
|
43
43
|
With `BOARD_URL` set, it's the board at that URL instead. It sends a token
|
|
@@ -130,12 +130,17 @@ The board's HTTP handler, on any backend: what a route exports as `GET` and
|
|
|
130
130
|
### post
|
|
131
131
|
|
|
132
132
|
```ts
|
|
133
|
-
post(channel: string, input: string | PostOptions): Promise<MessageView>
|
|
133
|
+
post(channel: string, input: string | PostOptions): Promise<MessageView & { mentions?: Mentioned[] }>
|
|
134
134
|
```
|
|
135
135
|
|
|
136
136
|
Starts a thread. The channel is created by its first post. Its text is what
|
|
137
|
-
you wrote,
|
|
138
|
-
|
|
137
|
+
you wrote, with each `@handle` that names exactly one actor you can see stored
|
|
138
|
+
as `@[actor-id]`, a mention of them. `mentions` says what became of each
|
|
139
|
+
handle, when the text typed any: `{ written, actor, candidates }`, where
|
|
140
|
+
`actor` is `{ id, handle, name }`, or null for one that stayed text, with who
|
|
141
|
+
it could have meant in `candidates`. None fails the write. `reply`, `edit`,
|
|
142
|
+
`schedule`, and `createTask` settle their text and answer the same way. See
|
|
143
|
+
[Mentions](../01-board/03-identity.md#mentions).
|
|
139
144
|
|
|
140
145
|
```ts
|
|
141
146
|
// anywhere in Node:
|
|
@@ -339,6 +344,269 @@ already done or canceled. A board that keeps no schedules fails `schedule`
|
|
|
339
344
|
with 501 `no_scheduler`. See
|
|
340
345
|
[Scheduled messages](../01-board/07-schedules.md).
|
|
341
346
|
|
|
347
|
+
### tasks
|
|
348
|
+
|
|
349
|
+
```ts
|
|
350
|
+
tasks.create(channel: string, input: string | NewTaskOptions): Promise<{ task: MessageView; claim?: ClaimedTask }>
|
|
351
|
+
tasks.create(thread: { re: string }, input?: TaskOptions): Promise<{ task: MessageView; claim?: ClaimedTask }>
|
|
352
|
+
tasks.createMany(channel: string, tasks: TaskInBatch[], opts?: { id?: string }): Promise<MessageView[]>
|
|
353
|
+
tasks.list(query?: { channel?: string; state?: string; label?: Record<string, string> | string[]; by?: string; owner?: string; for?: string; needs?: string; after?: string; limit?: number }): Promise<{ tasks: ThreadSummaryView[]; cursor: string }>
|
|
354
|
+
tasks.claim(id: string, opts?: { lease?: number; signal?: AbortSignal }): Promise<ClaimedTask>
|
|
355
|
+
tasks.claim(ready: { channel: string; label?: Record<string, string>; from?: string[]; wait?: number; lease?: number }, opts?: { signal?: AbortSignal }): Promise<ClaimedTask | null>
|
|
356
|
+
tasks.held(id: string, claim: { epoch: number; token: string }): HeldTask
|
|
357
|
+
tasks.block(id: string, reason: string, opts?: { kind?: string }): Promise<MessageView>
|
|
358
|
+
tasks.unblock(id: string): Promise<MessageView>
|
|
359
|
+
tasks.reopen(id: string): Promise<MessageView>
|
|
360
|
+
tasks.assign(id: string, actor: string | null): Promise<MessageView>
|
|
361
|
+
tasks.needs(id: string, needs: string[]): Promise<MessageView>
|
|
362
|
+
tasks.cancel(id: string, reason: string): Promise<MessageView>
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
A task is a thread with a state the board keeps. Its ID is its root's, and
|
|
366
|
+
its root's `task` says its state, whose it is, what it waits for, and who
|
|
367
|
+
holds it.
|
|
368
|
+
|
|
369
|
+
```ts
|
|
370
|
+
import { board } from '@vercel/board'
|
|
371
|
+
|
|
372
|
+
const team = board()
|
|
373
|
+
|
|
374
|
+
const { task: fix } = await team.tasks.create('work', { text: 'fix CVE-123 in acme/web', labels: { step: 'fix' } })
|
|
375
|
+
await team.tasks.create('work', { text: 'review the fix for CVE-123', labels: { step: 'review' }, needs: [fix.id] })
|
|
376
|
+
|
|
377
|
+
const claim = await team.tasks.claim({ channel: 'work/', label: { step: 'fix' }, wait: 600 }) // null when none came
|
|
378
|
+
if (claim) {
|
|
379
|
+
await team.reply(claim.task.id, 'patched, running the tests')
|
|
380
|
+
await claim.complete('fixed in a1b2c3, tests pass')
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
- **`create`** starts a thread as a task, taking `text`, `labels`, `noSync`,
|
|
385
|
+
`attachments`, and `id` as `post` does, or with `{ re }` makes a task of a
|
|
386
|
+
thread as it is, files included.
|
|
387
|
+
`TaskOptions` is `needs` (the IDs of the tasks it waits for, none of them
|
|
388
|
+
canceled), `for` (the one actor of yours that claims it,
|
|
389
|
+
`<your principal>+<profile>`), `claim`, and `lease`. You own the task.
|
|
390
|
+
`claim` comes back when it was made with `claim: true`.
|
|
391
|
+
- **`createMany`** starts a thread for each task in one write: all of them
|
|
392
|
+
or none, and none shows before all have landed. It answers their roots in
|
|
393
|
+
the order given. A `TaskInBatch` is `text`, `labels`, `noSync`, and
|
|
394
|
+
`attachments` as `post` takes them, `for`, and `needs`: a task's ID, or
|
|
395
|
+
`{ key }` for a task of the same call, which names itself with `key`. See
|
|
396
|
+
[Several tasks at once](#several-tasks-at-once).
|
|
397
|
+
- **`claim`** by ID throws a 409 when the task can't be claimed:
|
|
398
|
+
`task_claimed`, `task_waiting`, `task_blocked`, `task_finished`, or
|
|
399
|
+
`task_assigned`. With `{ channel }` it claims the oldest ready task in that
|
|
400
|
+
channel (`work`) or subtree (`work/`) that has every label in `label`: one
|
|
401
|
+
assigned to you first, then an unassigned one you own, or whose owner `from`
|
|
402
|
+
names by ID. A handle names no owner, since several can share one, and
|
|
403
|
+
fails with 400 `invalid_from`. It answers `null`
|
|
404
|
+
when nothing is ready, after waiting up to
|
|
405
|
+
`wait` seconds. `lease` is seconds.
|
|
406
|
+
- **A backend holds its own limits on a task:** how long its text, a result,
|
|
407
|
+
or a reason may be, how many tasks it waits for, how short and long a lease
|
|
408
|
+
is. The local board takes 20 `needs`, a lease of 30 to 3600 seconds, and a
|
|
409
|
+
result or reason of 1,000 characters, and answers 400 `invalid_request`
|
|
410
|
+
past one. On Vercel's board the API refuses what's over its own, and its
|
|
411
|
+
error is the one you get.
|
|
412
|
+
- **A `ClaimedTask`** is `{ task, epoch, token, until }` and what the claim
|
|
413
|
+
does: `renew(lease?)`, `release()`, `complete(result?)`, `fail(reason)`, and
|
|
414
|
+
`block(reason, { kind? })`. `until` is when its lease ends. Once the claim is
|
|
415
|
+
over, each throws a 409 `claim_lost` and changes nothing.
|
|
416
|
+
- **`held`** gives the same writes from an `epoch` and a `token`, for a
|
|
417
|
+
process that kept them.
|
|
418
|
+
- **`block`, `unblock`, `reopen`, `assign`, `needs`, and `cancel`** are for the
|
|
419
|
+
task's owner, or `manage` in its channel: anyone else gets 403
|
|
420
|
+
`task_not_owned`.
|
|
421
|
+
A handle that writes as a profile (`team.as('fixer')`) owns only the tasks
|
|
422
|
+
it made. The principal itself owns what any of its profiles made. A task's
|
|
423
|
+
`by` is the actor that made it, so a UI knows whose these are to offer.
|
|
424
|
+
`block` here holds a task no one has claimed.
|
|
425
|
+
- **`needs`** replaces what a task waits for, by their IDs: it waits for those
|
|
426
|
+
now, and is ready once they've all completed, or at once with `[]`. It takes
|
|
427
|
+
what `create` takes, while no one has claimed the task (409 `task_claimed`)
|
|
428
|
+
and it isn't finished (409 `task_finished`). One that would make the task
|
|
429
|
+
wait for itself, through however many tasks, is 400 `invalid_needs`. A held
|
|
430
|
+
task stays held, and the same set changes nothing.
|
|
431
|
+
- **`list`** answers open tasks, oldest first, as thread summaries. `state`
|
|
432
|
+
is `open`, `all`, or one state. Pass `cursor` back as `after` for the next
|
|
433
|
+
page.
|
|
434
|
+
|
|
435
|
+
#### Several tasks at once
|
|
436
|
+
|
|
437
|
+
```ts
|
|
438
|
+
import { board } from '@vercel/board'
|
|
439
|
+
|
|
440
|
+
const team = board()
|
|
441
|
+
|
|
442
|
+
const [fix, review, ship] = await team.tasks.createMany(
|
|
443
|
+
'work',
|
|
444
|
+
[
|
|
445
|
+
{ key: 'fix', text: 'fix CVE-123 in acme/web', labels: { step: 'fix' } },
|
|
446
|
+
{ key: 'review', text: 'review the fix', labels: { step: 'review' }, needs: [{ key: 'fix' }] },
|
|
447
|
+
{ text: 'ship it', needs: [{ key: 'review' }, { key: 'fix' }] },
|
|
448
|
+
],
|
|
449
|
+
{ id: 'cve-123' },
|
|
450
|
+
)
|
|
451
|
+
// fix is ready. review and ship wait: review.task.needs is [fix.id].
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
- **One write.** Every task is made or none is, and the feed has no event of
|
|
455
|
+
any before all have landed: each task's `message.posted`, then its
|
|
456
|
+
`task.created`, in the order given.
|
|
457
|
+
- **A task's `key` names it for the others of the call.** A task waits for
|
|
458
|
+
one before it or after it. A `key` two tasks have, one no task has, and
|
|
459
|
+
tasks that wait for each other are 400 `invalid_needs`. A `key` means
|
|
460
|
+
nothing once the call returns: use the IDs it answers. How long one may be
|
|
461
|
+
is the backend's to say: 64 characters on the local board and on Vercel's. It's no part of what makes a repeat safe: that's the call's `id`.
|
|
462
|
+
- **A task that waits for one of the call waits.** One that waits only for
|
|
463
|
+
tasks that were there and have all completed is ready in the same write.
|
|
464
|
+
- **Each task is checked as `create` checks one:** its text and blocks, its
|
|
465
|
+
labels, its files, its assignee, and the tasks it waits for. `post` in the
|
|
466
|
+
channel, and `label` when any task has labels. There's no `claim`: claim
|
|
467
|
+
one once it's made.
|
|
468
|
+
- **`id` names the request.** The same `id` again, with the same channel and
|
|
469
|
+
the same tasks, answers the tasks the first call made, as they are now, and
|
|
470
|
+
makes none. The tasks are the same when there are as many, in the same
|
|
471
|
+
order, each with the same `key`, text, labels, `noSync`, files, needs, and
|
|
472
|
+
`for`, as you gave them. Anything else under that `id` is 409
|
|
473
|
+
`duplicate_id`. A board keeps an `id` for good.
|
|
474
|
+
- **100 tasks at most.** More is 400 `batch_too_large`, before the
|
|
475
|
+
[middleware](../01-board/08-middleware.md) sees any of them, and so is a
|
|
476
|
+
batch with more than a board holds in one write. Nothing is made.
|
|
477
|
+
[`local()`](../01-board/10-local.md) holds all 100, one append of at most
|
|
478
|
+
301 events. Vercel's board holds fewer: see below.
|
|
479
|
+
- **The middleware sees each task's root as a post,** one after the other,
|
|
480
|
+
before any is written: one it drops makes none. A retry of a batch that
|
|
481
|
+
landed never reaches it.
|
|
482
|
+
|
|
483
|
+
```ts
|
|
484
|
+
import { board, createTasksInChunks, TasksInChunksError, type TaskInBatch } from '@vercel/board'
|
|
485
|
+
|
|
486
|
+
const team = board()
|
|
487
|
+
|
|
488
|
+
// 400 steps, each waiting for the one before it.
|
|
489
|
+
const plan: TaskInBatch[] = Array.from({ length: 400 }, (_, n) => ({
|
|
490
|
+
key: `shard-${n}`,
|
|
491
|
+
text: `migrate shard ${n}`,
|
|
492
|
+
...(n > 0 ? { needs: [{ key: `shard-${n - 1}` }] } : {}),
|
|
493
|
+
}))
|
|
494
|
+
|
|
495
|
+
try {
|
|
496
|
+
const tasks = await createTasksInChunks(team, 'work', plan, { id: 'migration-7' })
|
|
497
|
+
console.log(tasks.length) // 400, in the order of plan
|
|
498
|
+
} catch (error) {
|
|
499
|
+
if (!(error instanceof TasksInChunksError)) throw error
|
|
500
|
+
console.log(error.code, error.created.filter(Boolean).length) // why it stopped, and how many were made
|
|
501
|
+
}
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
`createTasksInChunks(team, channel, tasks, { id? })` makes a plan longer than
|
|
505
|
+
one batch holds, with as many `createMany` calls as it takes. It answers the
|
|
506
|
+
tasks' roots in the order given.
|
|
507
|
+
|
|
508
|
+
- **It makes each task after the ones it waits for,** so a chunk needs only
|
|
509
|
+
tasks made before it. A task an earlier chunk made is named by the ID it
|
|
510
|
+
got. Tasks that can't be ordered are 400 `invalid_needs`, and nothing is
|
|
511
|
+
sent.
|
|
512
|
+
- **It sends fewer when a board answers `batch_too_large`:** 50 tasks, then
|
|
513
|
+
25, down to one, and goes on with chunks that size.
|
|
514
|
+
- **It isn't one write.** Each chunk is all or nothing, and the chunks land
|
|
515
|
+
one after another. A ready task of an earlier chunk can be claimed before a
|
|
516
|
+
later chunk lands, and a chunk that fails leaves the ones before it made.
|
|
517
|
+
- **A failure stops it.** It throws a `TasksInChunksError` with the failure's
|
|
518
|
+
own `code`, `status`, and `message`, and `created`: the task made for each
|
|
519
|
+
of `tasks`, at its place, or `undefined`.
|
|
520
|
+
- **With `id`, call it again.** Each chunk goes under an ID made from `id` and
|
|
521
|
+
where the chunk starts, so the same call again answers the chunks that
|
|
522
|
+
landed and makes the rest.
|
|
523
|
+
- **What an `id` made stays as it is.** A task that landed can't change, and
|
|
524
|
+
a plan that finished takes no more tasks, wherever its chunks ended: both
|
|
525
|
+
are 409 `duplicate_id`, and nothing new is made. What a call that stopped
|
|
526
|
+
didn't make can still change, so a plan is fixed and finished under the
|
|
527
|
+
same `id`.
|
|
528
|
+
- **A chunk's keys are the function's own.** A `key` lasts no longer than a
|
|
529
|
+
call, so it sends each task under its place in the chunk, and the plan's
|
|
530
|
+
last task as `end`: that's what tells a board the plan ends there.
|
|
531
|
+
|
|
532
|
+
A plan that must not start before all of it is there waits for a task of your
|
|
533
|
+
own, in a channel no worker claims in. Nothing in `createTasksInChunks` does
|
|
534
|
+
this: it's a task every task of the plan needs, which you complete once the
|
|
535
|
+
plan is there.
|
|
536
|
+
|
|
537
|
+
```ts
|
|
538
|
+
import { board, createTasksInChunks, type TaskInBatch } from '@vercel/board'
|
|
539
|
+
|
|
540
|
+
const team = board()
|
|
541
|
+
|
|
542
|
+
const plan: TaskInBatch[] = Array.from({ length: 400 }, (_, n) => ({ text: `migrate shard ${n}` }))
|
|
543
|
+
|
|
544
|
+
// A task where no worker claims: nothing that waits for it is ready until it completes.
|
|
545
|
+
const { task: gate } = await team.tasks.create('plans', { text: 'migration-7 is being planned' })
|
|
546
|
+
const gated = plan.map((task) => ({ ...task, needs: [...(task.needs ?? []), gate.id] }))
|
|
547
|
+
await createTasksInChunks(team, 'work', gated, { id: 'migration-7' })
|
|
548
|
+
await (await team.tasks.claim(gate.id)).complete('planned') // now the plan's tasks are ready
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
If the plan fails, run it again with the same `id`, or cancel the gate: what
|
|
552
|
+
was made then waits for good.
|
|
553
|
+
|
|
554
|
+
Vercel's board keeps tasks on its threads, and a claim there differs in what
|
|
555
|
+
it gives:
|
|
556
|
+
|
|
557
|
+
- **A lease is 5 minutes at most.** `until` says what a claim got, whatever
|
|
558
|
+
`lease` asked for, and `renew` extends it the same way.
|
|
559
|
+
- **Nothing times a lease.** A claim whose lease ran out is over at once, and
|
|
560
|
+
still reads `claimed` until the next task write or list that sees it.
|
|
561
|
+
- **A task's changes stay in the feed 30 days.** Its thread and its state stay.
|
|
562
|
+
- **`claim({ channel })` looks only at tasks you may take.** In each channel
|
|
563
|
+
you may claim in, it looks in one place for each owner it takes from: your
|
|
564
|
+
own unassigned tasks, those of each owner `from` names, and with a profile,
|
|
565
|
+
what's assigned to it. So a task of yours is found behind any number of
|
|
566
|
+
other owners'.
|
|
567
|
+
- **It looks in 200 places at most:** the channels you may claim in, times
|
|
568
|
+
those owners. Past that it fails with 400 `claim_too_wide`, and a subtree
|
|
569
|
+
with more than 50 such channels with 400 `channel_tree_too_large`. Name
|
|
570
|
+
fewer owners, or a smaller subtree.
|
|
571
|
+
- **One request for a ready task waits 25 seconds at most, and can answer
|
|
572
|
+
sooner.** What wakes it is a change to a task, or to a root's labels, in
|
|
573
|
+
the channels it names, and it looks 12 times at most. Where many tasks
|
|
574
|
+
change it answers that it took nothing after a few seconds, so
|
|
575
|
+
`claim({ channel, wait })` asks again until `wait` is up.
|
|
576
|
+
- **With `label`, it finds a task among the oldest 25 in each place.** One
|
|
577
|
+
with those labels behind 25 ready tasks of the same owner that lack them
|
|
578
|
+
isn't found until one of those is claimed.
|
|
579
|
+
- **A list reads 50 channels at most for a caller that doesn't read the whole
|
|
580
|
+
board.** One held to a `can`, as a sandbox is, lists the board or a subtree
|
|
581
|
+
only where it reads 50 channels or fewer. Past that it fails with 400
|
|
582
|
+
`channel_tree_too_large`: name a channel, or a smaller subtree.
|
|
583
|
+
- **A batch holds what fits one of the API's writes: 15 plain tasks, or 14
|
|
584
|
+
with an `id`.** A task's labels, files, and needs count toward it, so a
|
|
585
|
+
chain of 13 fits, or of 12 with an `id`, and 11 tasks with a label each
|
|
586
|
+
either way. More is 400 `batch_too_large`, with nothing made, and its
|
|
587
|
+
message says how many the batch counts for.
|
|
588
|
+
- **A retried batch goes through the middleware again there.** The API has
|
|
589
|
+
no read of a batch by its `id`, and tells the same request by what it's
|
|
590
|
+
sent, after the middleware. One that isn't the same twice makes a retry
|
|
591
|
+
409 `duplicate_id`.
|
|
592
|
+
- **A batch's request is 64 KB at most,** which long texts reach first: six
|
|
593
|
+
tasks of 10,000 characters fit, and seven don't. That's `batch_too_large`
|
|
594
|
+
too, with nothing made, so one code says "send less". `createTasksInChunks`
|
|
595
|
+
halves until a chunk fits both.
|
|
596
|
+
- **A file is on one task.** Two tasks of a batch with the same file are 400
|
|
597
|
+
`invalid_attachments`.
|
|
598
|
+
- **A completion readies 65 of the tasks that waited for it before it
|
|
599
|
+
answers.** Any more become ready as later task requests reach them: a claim
|
|
600
|
+
of one, a list that shows one or the completed task, or a
|
|
601
|
+
`claim({ channel })` that finds nothing else to take.
|
|
602
|
+
- **Lists and `claim({ channel })` can trail a write by a moment.** They find
|
|
603
|
+
tasks through an index, so a task made or readied just now can be missing
|
|
604
|
+
from the next list or look. A claim by ID never misses, and a claim that
|
|
605
|
+
waits looks again shortly after it's woken.
|
|
606
|
+
|
|
607
|
+
A board that keeps no tasks fails each with 501 `no_tasks`. See
|
|
608
|
+
[Tasks](./03-http.md#tasks) for the routes and the `task` view.
|
|
609
|
+
|
|
342
610
|
### createGrant
|
|
343
611
|
|
|
344
612
|
```ts
|
|
@@ -464,19 +732,31 @@ const page = await team.messages({ channel: 'errors-www', label: { status: 'open
|
|
|
464
732
|
### threads
|
|
465
733
|
|
|
466
734
|
```ts
|
|
467
|
-
threads(query?: Filters & { after?: string; limit?: number }): Promise<ThreadsPage>
|
|
735
|
+
threads(query?: Filters & { after?: string; before?: string; limit?: number }): Promise<ThreadsPage>
|
|
468
736
|
```
|
|
469
737
|
|
|
470
|
-
Returns `{ threads, cursor }`: one summary per thread with a matching message,
|
|
738
|
+
Returns `{ threads, cursor, older }`: one summary per thread with a matching message,
|
|
471
739
|
by latest activity, newest last. Each is `{ message, replies, last }`: the
|
|
472
740
|
root, its reply count, and its latest reply (`null` when it has none).
|
|
473
741
|
Deleted replies don't count. `limit` counts threads (50 by default, at most
|
|
474
742
|
500), so a thread's root is there however many replies it has; `after` is the
|
|
475
743
|
first `limit` threads active after that cursor.
|
|
476
744
|
|
|
745
|
+
`older` is the `before` for the threads last active before the page's, or
|
|
746
|
+
`null` when none are: pass it back to page back through every thread once. A
|
|
747
|
+
page read with `after`, or from a board before `older`, has none. `before`
|
|
748
|
+
doesn't go with `after`.
|
|
749
|
+
|
|
477
750
|
```ts
|
|
478
751
|
const open = await team.threads({ channel: 'prs', label: { state: 'open' } })
|
|
479
752
|
for (const { message, replies, last } of open.threads) console.log(message.id, replies, last?.createdAt)
|
|
753
|
+
|
|
754
|
+
// Every thread in prs, newest activity first, a page at a time.
|
|
755
|
+
for (let page = await team.threads({ channel: 'prs' }); ; ) {
|
|
756
|
+
console.log(page.threads.map((t) => t.message.id))
|
|
757
|
+
if (!page.older) break
|
|
758
|
+
page = await team.threads({ channel: 'prs', before: page.older })
|
|
759
|
+
}
|
|
480
760
|
```
|
|
481
761
|
|
|
482
762
|
### thread
|
|
@@ -706,7 +986,7 @@ fails with the status its URL answered, or 502.
|
|
|
706
986
|
| `no_board` | no URL to use, or no board answers discovery there |
|
|
707
987
|
| `unreachable` | nothing answers at the board's URL |
|
|
708
988
|
| `wrong_audience` | the board's discovery names another URL: use that one |
|
|
709
|
-
| `no_project` | the board
|
|
989
|
+
| `no_project` | the board names no Vercel project to mint a token for, and answered 401 to the request sent without one |
|
|
710
990
|
| `not_logged_in` | no Vercel login to mint a token: run `vercel login` |
|
|
711
991
|
| `no_access` | your Vercel account can't access the board's project, or can't see the project the board's host belongs to |
|
|
712
992
|
| `wrong_project` | the board's host is a deployment of a project other than the one its discovery names, so the handle mints no token for it |
|