@vercel/board 0.52.0 → 0.54.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/README.md +4 -3
- package/dist/{access-DdojoPZm.mjs → access-HzqFpgL_.mjs} +1 -1
- package/dist/access.d.mts +3 -3
- package/dist/access.mjs +5 -5
- package/dist/{actors-CDkNgWUL.mjs → actors-D-u6bitG.mjs} +2 -2
- package/dist/{auth-zPqFJocD.mjs → auth-D9ycDQK0.mjs} +34 -12
- package/dist/{auth-C4VxPLYz.d.mts → auth-ULldUvir.d.mts} +8 -2
- package/dist/{backend-Da_YEltI.d.mts → backend-BHN6GTjB.d.mts} +8 -7
- package/dist/backend-local.d.mts +1 -1
- package/dist/backend-local.mjs +1 -1
- package/dist/{chat-provider-BHyX6H8H.d.mts → chat-provider-F7UqWVZK.d.mts} +2 -2
- package/dist/cli-commands.d.mts +1 -1
- package/dist/cli-commands.mjs +1 -1
- package/dist/cli-embedded.d.mts +32 -3
- package/dist/cli-embedded.mjs +4 -2
- package/dist/cli.mjs +6 -6
- package/dist/{client-C4-r10SA.d.mts → client-CFHunEFn.d.mts} +16 -4
- package/dist/{commands-B_gbi2sU.mjs → commands-B5SXeo4W.mjs} +14 -9
- package/dist/{commands-B6pgzwTI.d.mts → commands-DLPIX7Jw.d.mts} +3 -1
- package/dist/{conformance-DW4-9Dwf.mjs → conformance-CyQG0jky.mjs} +56 -4
- package/dist/conformance.d.mts +3 -4
- package/dist/conformance.mjs +1 -1
- package/dist/{engine-D8YAsQS_.mjs → engine-C8wCzkw-.mjs} +2 -2
- package/dist/errors-DDfXnZ2b.mjs +1958 -0
- package/dist/{exports-BUtR_AHa.d.mts → exports-BBmjHyCB.d.mts} +4 -4
- package/dist/{exports-DI-MtN01.mjs → exports-JUhj5Bl3.mjs} +127 -77
- package/dist/{index-BTuTaBaK.d.mts → index-Ce3SDZ3Y.d.mts} +2 -2
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +4 -4
- package/dist/index.node.d.mts +7 -7
- package/dist/index.node.mjs +4 -4
- package/dist/inspect/app.js +69 -69
- package/dist/inspect/engine.js +3 -3
- package/dist/inspect-BN7V9e-M.mjs +2 -0
- package/dist/{inspect-BJR-BsUv.mjs → inspect-CrVs-iEi.mjs} +2 -2
- package/dist/inspect.d.mts +1 -1
- package/dist/inspect.mjs +1 -1
- package/dist/{local-B376y9u3.mjs → local-RoMUU6QX.mjs} +39 -23
- package/dist/{main-DfJNxck4.mjs → main-B_gzTjBR.mjs} +370 -102
- package/dist/{middleware-iVTNf5Su.mjs → middleware-BY4qqIh3.mjs} +1 -1
- package/dist/{provider-CGicSMdu.d.mts → provider-DgGp4Zej.d.mts} +2 -2
- package/dist/{routes-ChGBn0K3.d.mts → routes-DNmQSOvQ.d.mts} +36 -3
- package/dist/{serve-D8j7O2Tc.mjs → serve-Cz1NynhG.mjs} +6 -6
- package/dist/{server--BLSj6fd.mjs → server-CdBXNUxf.mjs} +68 -11
- package/dist/{serving-aOQsBok0.mjs → serving-C1mhZQqH.mjs} +1 -1
- package/dist/{shell-qrJL3Z_R.mjs → shell-Cqn38XUs.mjs} +1 -1
- package/dist/sync-chat-sdk.d.mts +2 -2
- package/dist/sync-github.d.mts +2 -2
- package/dist/sync-linear.d.mts +3 -3
- package/dist/sync-slack.d.mts +3 -3
- package/dist/sync.d.mts +2 -2
- package/dist/{task-batch-6UHphYfl.mjs → task-batch-CVamHB-W.mjs} +4 -5
- package/dist/{tokens-C-T0B1uF.mjs → tokens-B3gXkQCs.mjs} +2 -2
- package/dist/{version-NfsFHDfg.mjs → version-DBaKHEZS.mjs} +1 -1
- package/docs/01-board/01-mounting.md +8 -6
- package/docs/01-board/03-identity.md +1 -1
- package/docs/01-board/05-reading.md +34 -7
- package/docs/01-board/06-watchers.md +2 -1
- package/docs/01-board/09-access.md +11 -2
- package/docs/01-board/11-tasks.md +28 -5
- package/docs/01-quickstart.md +19 -5
- package/docs/03-guides/03-ci.md +71 -43
- package/docs/03-guides/04-triage.md +4 -4
- package/docs/04-reference/01-cli.md +84 -22
- package/docs/04-reference/02-board.md +19 -10
- package/docs/04-reference/03-http.md +14 -5
- package/docs/04-reference/05-conformance.md +1 -1
- package/docs/index.md +7 -5
- package/package.json +2 -2
- package/dist/errors-DbCKqGXp.mjs +0 -851
- package/dist/inspect-CYfZ0vva.mjs +0 -2
- package/dist/routes-C85Sbhtm.mjs +0 -1067
package/dist/routes-C85Sbhtm.mjs
DELETED
|
@@ -1,1067 +0,0 @@
|
|
|
1
|
-
import { a as DIRECT_UPLOAD_BYTES_MAX } from "./profile-header-O8wC8yk8.mjs";
|
|
2
|
-
import { C as SentTaskNote, M as platformAvatar, N as storable, S as SentTaskHoldKind, _ as NewLabels, c as EDITED_HOLD, d as LabelKey, f as LabelValue, g as MessageText, k as TaskState, l as Emoji, m as MESSAGE_TEXT_MAX, o as CHANNEL_PATTERN_MAX, p as Labels, r as AttachmentId, s as ChannelPath, t as ActorId, w as SentText } from "./schemas-CUSTEFIy.mjs";
|
|
3
|
-
import { a as Link, i as ExternalTarget, n as ExternalEvent, o as Origin, t as ExternalAuthor } from "./external-DkWafjn-.mjs";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
//#region src/api/routes.ts
|
|
6
|
-
/**
|
|
7
|
-
* A message's, schedule's, or cursor's ID: a string clients pass back as they got it, and never
|
|
8
|
-
* parse, compare, or count with. Each backend picks its own; a board on `local()` writes decimals,
|
|
9
|
-
* and `s12` for a schedule.
|
|
10
|
-
*/
|
|
11
|
-
const Ref = z.string().min(1).max(128);
|
|
12
|
-
/** The message's `revision` as it was read: if it's been edited or deleted since, 409 `revision_conflict`. */
|
|
13
|
-
const Revision = z.number().int().positive();
|
|
14
|
-
const id = Ref;
|
|
15
|
-
/** A boolean query parameter: `true` or `1`, `false` or `0`. */
|
|
16
|
-
const flag = z.enum([
|
|
17
|
-
"true",
|
|
18
|
-
"false",
|
|
19
|
-
"1",
|
|
20
|
-
"0"
|
|
21
|
-
]).transform((value) => value === "true" || value === "1");
|
|
22
|
-
const repeated = z.union([z.string(), z.array(z.string())]).transform((value) => Array.isArray(value) ? value : [value]);
|
|
23
|
-
/**
|
|
24
|
-
* `pr` → `['pr', null]` (has the label), `status=open` → `['status', ['open']]`,
|
|
25
|
-
* `state=open|draft` → either value.
|
|
26
|
-
*/
|
|
27
|
-
const LabelFilter = z.string().regex(/^[a-z0-9][a-z0-9_.-]*(=.*)?$/, "label filters look like key, key=value, or key=a|b").transform((value) => {
|
|
28
|
-
const at = value.indexOf("=");
|
|
29
|
-
return at === -1 ? [value, null] : [value.slice(0, at), value.slice(at + 1).split("|")];
|
|
30
|
-
});
|
|
31
|
-
/** A sync target as the board that syncs it resolved it: a platform channel to start a thread in, or a thread to join. */
|
|
32
|
-
const ResolvedSyncTarget = z.object({
|
|
33
|
-
target: ExternalTarget,
|
|
34
|
-
kind: z.enum(["channel", "thread"])
|
|
35
|
-
});
|
|
36
|
-
/** Shared by `/threads` and `/events`. */
|
|
37
|
-
const Filters = z.object({
|
|
38
|
-
channel: z.string().optional(),
|
|
39
|
-
re: id.optional(),
|
|
40
|
-
by: z.string().optional(),
|
|
41
|
-
mentions: z.string().optional(),
|
|
42
|
-
label: repeated.pipe(z.array(LabelFilter)).optional(),
|
|
43
|
-
/**
|
|
44
|
-
* Where messages came from: a sync key such as `slack`, or `board` for the board itself. On Vercel's board, another
|
|
45
|
-
* project's key is `<project>/<key>`, by its name (up to 100 characters) or its ID.
|
|
46
|
-
*/
|
|
47
|
-
from: z.string().min(1).max(165).optional(),
|
|
48
|
-
/** Case-insensitive words the text contains. */
|
|
49
|
-
text: z.string().min(1).max(200).optional()
|
|
50
|
-
});
|
|
51
|
-
/**
|
|
52
|
-
* One channel's messages across its threads, oldest first: the newest `limit`, or with `after`, a cursor a read of
|
|
53
|
-
* this channel answered, the ones posted since. The channel is one channel by its whole name, never a pattern: a board
|
|
54
|
-
* lists no messages across channels.
|
|
55
|
-
*/
|
|
56
|
-
const ChannelMessagesQuery = z.strictObject({
|
|
57
|
-
channel: ChannelPath,
|
|
58
|
-
after: Ref.optional(),
|
|
59
|
-
limit: z.coerce.number().int().min(1).max(500).optional()
|
|
60
|
-
});
|
|
61
|
-
/**
|
|
62
|
-
* A page of the board's channels: those whose path starts with `prefix` (`dev/` is every channel under `dev`, and
|
|
63
|
-
* not `dev` itself), `limit` of them, after a page's `next`.
|
|
64
|
-
*/
|
|
65
|
-
const ChannelsQuery = z.strictObject({
|
|
66
|
-
prefix: z.string().min(1).max(501).optional(),
|
|
67
|
-
after: z.string().min(1).max(1024).optional(),
|
|
68
|
-
limit: z.coerce.number().int().min(1).max(500).optional()
|
|
69
|
-
});
|
|
70
|
-
/**
|
|
71
|
-
* A thread read in part: the root, and of its replies the ones after one of its messages (`after`), `limit` of
|
|
72
|
-
* them. With `after` they're the first after it, to read on from; without, the newest.
|
|
73
|
-
*/
|
|
74
|
-
const ThreadQuery = z.strictObject({
|
|
75
|
-
after: id.optional(),
|
|
76
|
-
limit: z.coerce.number().int().min(1).max(500).optional()
|
|
77
|
-
});
|
|
78
|
-
/**
|
|
79
|
-
* `limit` counts threads: each thread with a matching message, by its latest reply. `before` is a page's
|
|
80
|
-
* `older`, for the threads last active before it; it pages backward, so it takes no `after`.
|
|
81
|
-
*/
|
|
82
|
-
const ThreadsQuery = Filters.extend({
|
|
83
|
-
after: Ref.optional(),
|
|
84
|
-
before: z.string().min(1).max(1024).optional(),
|
|
85
|
-
limit: z.coerce.number().int().min(1).max(500).optional()
|
|
86
|
-
}).refine((query) => query.before === void 0 || query.after === void 0, {
|
|
87
|
-
message: "`before` pages back from a page's `older`, and `after` reads forward: pass one",
|
|
88
|
-
path: ["before"]
|
|
89
|
-
});
|
|
90
|
-
/**
|
|
91
|
-
* A read of the feed after `after`, or from now. `last` reads its newest events instead, oldest first, with the
|
|
92
|
-
* feed's end as the cursor: it answers at once, so it takes no `after` or `wait`.
|
|
93
|
-
*/
|
|
94
|
-
const EventsQuery = Filters.extend({
|
|
95
|
-
after: Ref.optional(),
|
|
96
|
-
wait: z.coerce.number().min(0).max(300).optional(),
|
|
97
|
-
all: flag.optional(),
|
|
98
|
-
last: z.coerce.number().int().min(1).max(100).optional()
|
|
99
|
-
}).refine((query) => query.last === void 0 || query.after === void 0 && query.wait === void 0, {
|
|
100
|
-
message: "`last` reads the newest events at once: it takes no `after` or `wait`",
|
|
101
|
-
path: ["last"]
|
|
102
|
-
});
|
|
103
|
-
const PostBody = z.object({
|
|
104
|
-
channel: ChannelPath.optional(),
|
|
105
|
-
re: Ref.optional(),
|
|
106
|
-
/** May be empty when the message has attachments. */
|
|
107
|
-
text: z.string().default(""),
|
|
108
|
-
labels: NewLabels.optional(),
|
|
109
|
-
noSync: z.boolean().optional(),
|
|
110
|
-
/**
|
|
111
|
-
* External targets a new thread starts with: `slack:#incidents`, `github:owner/repo:12`. The
|
|
112
|
-
* board that syncs a target resolves it to `{ target, kind }`, which a board elsewhere takes as is.
|
|
113
|
-
*/
|
|
114
|
-
sync: z.array(z.union([z.string().min(3).max(300), ResolvedSyncTarget])).max(10).optional(),
|
|
115
|
-
id: z.string().min(1).max(200).refine(storable, "id has a NUL character or a lone surrogate").optional(),
|
|
116
|
-
/** IDs from `POST /attachments`. */
|
|
117
|
-
attachments: z.array(AttachmentId).optional(),
|
|
118
|
-
/**
|
|
119
|
-
* A reply's precondition: a message in its thread, the newest as the caller read it. If another
|
|
120
|
-
* has come after it, nothing is posted, and the board answers 409 `newer_message`.
|
|
121
|
-
*/
|
|
122
|
-
after: Ref.optional()
|
|
123
|
-
}).refine((body) => body.text.trim().length > 0 || (body.attachments?.length ?? 0) > 0, {
|
|
124
|
-
message: "message text is empty",
|
|
125
|
-
path: ["text"]
|
|
126
|
-
}).refine((body) => body.channel === void 0 !== (body.re === void 0), { message: "a post needs `channel`; a reply needs `re`" }).refine((body) => !(body.noSync && body.sync?.length), { message: "`noSync` and `sync` contradict each other" }).refine((body) => body.after === void 0 || body.re !== void 0, {
|
|
127
|
-
message: "`after` is for replies: it names the newest message in `re`'s thread",
|
|
128
|
-
path: ["after"]
|
|
129
|
-
});
|
|
130
|
-
/** `30m`, `1d`: a number and a unit, `s`, `m`, `h`, or `d`. */
|
|
131
|
-
const Duration = z.string().regex(/^\d+(\.\d+)?(s|m|h|d)$/, "durations look like 30s, 30m, 12h, or 1d");
|
|
132
|
-
const Instant = z.string().datetime({ offset: true });
|
|
133
|
-
/**
|
|
134
|
-
* A message to post later, as the caller: once (`in` or `at`), or repeating
|
|
135
|
-
* (`every`, starting `at` or `in` from now, or one `every` from now), until
|
|
136
|
-
* `until`, `for` after the first send, or `times` sends. A repeat with no stop
|
|
137
|
-
* runs until it's canceled.
|
|
138
|
-
*/
|
|
139
|
-
const ScheduleBody = z.object({
|
|
140
|
-
channel: ChannelPath.optional(),
|
|
141
|
-
re: Ref.optional(),
|
|
142
|
-
text: z.string().default(""),
|
|
143
|
-
labels: NewLabels.optional(),
|
|
144
|
-
noSync: z.boolean().optional(),
|
|
145
|
-
attachments: z.array(AttachmentId).optional(),
|
|
146
|
-
in: Duration.optional(),
|
|
147
|
-
at: Instant.optional(),
|
|
148
|
-
every: Duration.optional(),
|
|
149
|
-
until: Instant.optional(),
|
|
150
|
-
for: Duration.optional(),
|
|
151
|
-
times: z.number().int().positive().optional()
|
|
152
|
-
}).refine((body) => body.text.trim().length > 0 || (body.attachments?.length ?? 0) > 0, {
|
|
153
|
-
message: "message text is empty",
|
|
154
|
-
path: ["text"]
|
|
155
|
-
}).refine((body) => body.channel === void 0 !== (body.re === void 0), { message: "a schedule needs `channel` for a new thread, or `re` for a reply" }).refine((body) => body.in !== void 0 || body.at !== void 0 || body.every !== void 0, { message: "say when: `in`, `at`, or `every`" }).refine((body) => !(body.in !== void 0 && body.at !== void 0), { message: "`in` and `at` contradict each other" }).refine((body) => [
|
|
156
|
-
body.until,
|
|
157
|
-
body.for,
|
|
158
|
-
body.times
|
|
159
|
-
].filter((v) => v !== void 0).length <= 1, { message: "pick one stop: `until`, `for`, or `times`" }).refine((body) => body.every !== void 0 || body.until === void 0 && body.for === void 0 && body.times === void 0, { message: "`until`, `for`, and `times` stop a repeat: add `every`" });
|
|
160
|
-
const SchedulesQuery = z.object({
|
|
161
|
-
/** Any message in a thread: the schedules that reply in it. */
|
|
162
|
-
re: id.optional(),
|
|
163
|
-
channel: z.string().optional(),
|
|
164
|
-
/** An actor ID or handle: the schedules it created. */
|
|
165
|
-
by: z.string().optional(),
|
|
166
|
-
/** Include done and canceled schedules. */
|
|
167
|
-
all: flag.optional()
|
|
168
|
-
});
|
|
169
|
-
/** A channel, or with a trailing `/` it and every channel under it: `work`, `work/`. As long as a grant's pattern for either. */
|
|
170
|
-
const ChannelOrSubtree = z.string().max(CHANNEL_PATTERN_MAX).regex(/^[a-z0-9][a-z0-9_-]*(?:\/[a-z0-9][a-z0-9_-]*)*\/?$/, "name a channel, or a channel and its subtree (work/)");
|
|
171
|
-
/**
|
|
172
|
-
* How long a claim holds its task, in seconds, 900 when left out. How short and how long one may
|
|
173
|
-
* be is the backend's to say: the local board takes 30 to 3600, and a board gives what's asked up
|
|
174
|
-
* to its own cap, never under 300.
|
|
175
|
-
*/
|
|
176
|
-
const Lease = z.number();
|
|
177
|
-
/** What a claim's own writes carry: the `epoch` and `token` its claim answered. */
|
|
178
|
-
const Claimed = {
|
|
179
|
-
epoch: z.number().int().positive(),
|
|
180
|
-
token: z.string().min(1).max(128)
|
|
181
|
-
};
|
|
182
|
-
/**
|
|
183
|
-
* A new thread that's a task (`channel` and `text`, with `labels`, `noSync`, `attachments`, and an
|
|
184
|
-
* `id` as a post takes them), or the thread `re` roots made one. `needs` are the tasks it waits for,
|
|
185
|
-
* `for` the one actor of its owner's that claims it, and `claim` claims it in the same write, for
|
|
186
|
-
* `lease` seconds.
|
|
187
|
-
*/
|
|
188
|
-
const CreateTaskBody = z.object({
|
|
189
|
-
channel: ChannelPath.optional(),
|
|
190
|
-
re: Ref.optional(),
|
|
191
|
-
/** As long as a post's text may be: the backend says how long that is. */
|
|
192
|
-
text: z.string().optional(),
|
|
193
|
-
labels: NewLabels.optional(),
|
|
194
|
-
noSync: z.boolean().optional(),
|
|
195
|
-
/** IDs from `POST /attachments`, as a post takes them. */
|
|
196
|
-
attachments: z.array(AttachmentId).optional(),
|
|
197
|
-
/** How many tasks one may wait for is the backend's to say. */
|
|
198
|
-
needs: z.array(Ref).optional(),
|
|
199
|
-
for: ActorId.nullable().optional(),
|
|
200
|
-
claim: z.boolean().optional(),
|
|
201
|
-
lease: Lease.optional(),
|
|
202
|
-
id: z.string().min(1).max(200).refine(storable, "id has a NUL character or a lone surrogate").optional()
|
|
203
|
-
}).refine((body) => body.channel === void 0 !== (body.re === void 0), { message: "a task needs `channel` and `text` for a new thread, or `re` for a thread that's there" }).refine((body) => body.channel === void 0 || (body.text ?? "").trim().length > 0 || (body.attachments?.length ?? 0) > 0, {
|
|
204
|
-
message: "message text is empty",
|
|
205
|
-
path: ["text"]
|
|
206
|
-
}).refine((body) => body.text === void 0 || storable(body.text), {
|
|
207
|
-
message: "message text has a NUL character or a lone surrogate",
|
|
208
|
-
path: ["text"]
|
|
209
|
-
}).refine((body) => body.re === void 0 || body.text === void 0 && body.labels === void 0 && body.noSync === void 0 && body.attachments === void 0 && body.id === void 0, { message: "`text`, `labels`, `noSync`, `attachments`, and `id` are a new thread's: `re` makes a task of a thread as it is" }).refine((body) => body.lease === void 0 || body.claim === true, {
|
|
210
|
-
message: "`lease` goes with `claim`",
|
|
211
|
-
path: ["lease"]
|
|
212
|
-
});
|
|
213
|
-
/** A digest of what a batch asks for: what tells the same request under an `id` from another. */
|
|
214
|
-
const BatchRequest = z.string().min(1).max(64);
|
|
215
|
-
/** A task another task of the same batch waits for, by the `key` it goes by there. */
|
|
216
|
-
const TaskKey = z.string().min(1).refine(storable, "key has a NUL character or a lone surrogate");
|
|
217
|
-
/**
|
|
218
|
-
* Several new threads in one channel, each a task, made in one write: all of them or none. A task is
|
|
219
|
-
* what `POST /tasks` starts a thread with, less `claim`. `key` names it for the batch's others, and
|
|
220
|
-
* `needs` takes a task's ID, or `{ key }` for one of the batch, before or after it. `id` names the
|
|
221
|
-
* batch: a retry with it answers the same tasks. At most `TASK_BATCH_MAX` tasks, 400
|
|
222
|
-
* `batch_too_large` past that, which a board that holds fewer in one write answers too.
|
|
223
|
-
*/
|
|
224
|
-
const CreateTasksBody = z.object({
|
|
225
|
-
channel: ChannelPath,
|
|
226
|
-
tasks: z.array(z.object({
|
|
227
|
-
key: TaskKey.optional(),
|
|
228
|
-
/** May be empty when the task's root has attachments. As long as a post's text may be: the backend says how long that is. */
|
|
229
|
-
text: z.string(),
|
|
230
|
-
labels: NewLabels.optional(),
|
|
231
|
-
noSync: z.boolean().optional(),
|
|
232
|
-
/** IDs from `POST /attachments`, as a post takes them. */
|
|
233
|
-
attachments: z.array(AttachmentId).optional(),
|
|
234
|
-
/** How many tasks one may wait for is the backend's to say. */
|
|
235
|
-
needs: z.array(z.union([Ref, z.object({ key: TaskKey }).strict()])).optional(),
|
|
236
|
-
for: ActorId.nullable().optional()
|
|
237
|
-
}).refine((task) => task.text.trim().length > 0 || (task.attachments?.length ?? 0) > 0, {
|
|
238
|
-
message: "message text is empty",
|
|
239
|
-
path: ["text"]
|
|
240
|
-
}).refine((task) => storable(task.text), {
|
|
241
|
-
message: "message text has a NUL character or a lone surrogate",
|
|
242
|
-
path: ["text"]
|
|
243
|
-
})).min(1).max(100),
|
|
244
|
-
id: z.string().min(1).max(200).refine(storable, "id has a NUL character or a lone surrogate").optional(),
|
|
245
|
-
/**
|
|
246
|
-
* From a board in front of this one: its digest of what the batch asked for as it was given, before
|
|
247
|
-
* its own middleware changed anything, so both boards tell a repeat by the same request. A board
|
|
248
|
-
* with none in front makes its own. It says nothing of who writes or what: a caller that sends one
|
|
249
|
-
* changes only which of its own requests its own `id` answers.
|
|
250
|
-
*/
|
|
251
|
-
request: BatchRequest.optional()
|
|
252
|
-
});
|
|
253
|
-
/**
|
|
254
|
-
* `request` is a board's digest of what a batch asked for, as it was given: with it, the batch
|
|
255
|
-
* answers only that request, and any other under the `id` is 409 `duplicate_id`.
|
|
256
|
-
*/
|
|
257
|
-
const CreatedTasksQuery = z.object({ request: BatchRequest.optional() });
|
|
258
|
-
/** Which tasks to list: open ones unless `state` says `all` or names one. A claim whose lease has run out counts as `ready`. */
|
|
259
|
-
const TasksQuery = z.object({
|
|
260
|
-
channel: z.string().optional(),
|
|
261
|
-
state: z.union([z.enum(["open", "all"]), TaskState]).optional(),
|
|
262
|
-
label: repeated.pipe(z.array(LabelFilter)).optional(),
|
|
263
|
-
/** Who wrote the root: a handle or an actor ID, as on `/messages`. */
|
|
264
|
-
by: z.string().optional(),
|
|
265
|
-
/** Whose task it is: a handle or a principal ID. */
|
|
266
|
-
owner: z.string().optional(),
|
|
267
|
-
/** The actor it's assigned to: a handle or an actor ID. */
|
|
268
|
-
for: z.string().optional(),
|
|
269
|
-
/** A task's ID: the tasks that wait for it. */
|
|
270
|
-
needs: Ref.optional(),
|
|
271
|
-
/** A `cursor` an earlier page reported. */
|
|
272
|
-
after: Ref.optional(),
|
|
273
|
-
limit: z.coerce.number().int().min(1).max(500).optional()
|
|
274
|
-
});
|
|
275
|
-
const ClaimTaskBody = z.object({ lease: Lease.optional() }).optional();
|
|
276
|
-
/**
|
|
277
|
-
* Claims the oldest ready task in `channel` that has every label in `label`: one assigned to the
|
|
278
|
-
* caller first, then an unassigned one it owns, or whose owner `from` names by ID. `wait`
|
|
279
|
-
* holds the request up to that many seconds for one.
|
|
280
|
-
*/
|
|
281
|
-
const ClaimReadyTaskBody = z.object({
|
|
282
|
-
channel: ChannelOrSubtree,
|
|
283
|
-
label: Labels.optional(),
|
|
284
|
-
/** How many owners one claim takes from is the backend's to say. */
|
|
285
|
-
from: z.array(z.string().min(1).max(256)).optional(),
|
|
286
|
-
lease: Lease.optional(),
|
|
287
|
-
wait: z.number().min(0).max(300).optional()
|
|
288
|
-
});
|
|
289
|
-
const RenewTaskBody = z.object({
|
|
290
|
-
...Claimed,
|
|
291
|
-
lease: Lease.optional()
|
|
292
|
-
});
|
|
293
|
-
const ReleaseTaskBody = z.object(Claimed);
|
|
294
|
-
const CompleteTaskBody = z.object({
|
|
295
|
-
...Claimed,
|
|
296
|
-
result: SentTaskNote.optional()
|
|
297
|
-
});
|
|
298
|
-
const FailTaskBody = z.object({
|
|
299
|
-
...Claimed,
|
|
300
|
-
reason: SentTaskNote
|
|
301
|
-
});
|
|
302
|
-
/** A hold for a person. A claimed task's comes from its claim, with the claim's `epoch` and `token`. Kind `edited` is the board's own, so none asks for it. */
|
|
303
|
-
const BlockTaskBody = z.object({
|
|
304
|
-
reason: SentTaskNote,
|
|
305
|
-
kind: SentTaskHoldKind.refine((kind) => kind !== EDITED_HOLD, "`edited` is the board's own kind, for a task whose root someone else edited: name another").optional(),
|
|
306
|
-
epoch: Claimed.epoch.optional(),
|
|
307
|
-
token: Claimed.token.optional()
|
|
308
|
-
}).refine((body) => body.epoch === void 0 === (body.token === void 0), { message: "a claim is its `epoch` and its `token`: pass both, or neither" });
|
|
309
|
-
/** The one actor of its owner's that claims the task, or null for anyone who may. */
|
|
310
|
-
const AssignTaskBody = z.object({ for: ActorId.nullable() });
|
|
311
|
-
/** The tasks it waits for now, in place of what it waited for: none, for a task that waits for nothing. How many it may wait for is the backend's to say. */
|
|
312
|
-
const TaskNeedsBody = z.object({ needs: z.array(Ref) });
|
|
313
|
-
const CancelTaskBody = z.object({ reason: SentTaskNote });
|
|
314
|
-
const CanGrant = z.union([z.literal("all"), z.array(z.string().min(1).max(16)).max(8)]);
|
|
315
|
-
const ClaimValue = z.string().min(1).max(1e3);
|
|
316
|
-
const Environments = z.array(z.string().min(1).max(100)).min(1).max(16);
|
|
317
|
-
/**
|
|
318
|
-
* Who a grant names, as people write it: a user by email (or, where the board can't look one up,
|
|
319
|
-
* by ID), a project by name or ID, a repository by `owner/name`. The board resolves names and keeps
|
|
320
|
-
* IDs; a board that verifies tokens itself takes IDs only. A `user` names `email` or `userId`.
|
|
321
|
-
* Nothing else: a key it doesn't know (a misspelled `workflows`, say) is a 400, never dropped,
|
|
322
|
-
* since dropping it would name more than was meant.
|
|
323
|
-
*/
|
|
324
|
-
const PrincipalInput = z.discriminatedUnion("kind", [
|
|
325
|
-
z.strictObject({
|
|
326
|
-
kind: z.literal("user"),
|
|
327
|
-
email: z.string().min(3).max(320).optional(),
|
|
328
|
-
userId: z.string().min(1).max(200).optional()
|
|
329
|
-
}),
|
|
330
|
-
z.strictObject({
|
|
331
|
-
kind: z.literal("project"),
|
|
332
|
-
project: z.string().min(1).max(200),
|
|
333
|
-
environments: Environments.optional()
|
|
334
|
-
}),
|
|
335
|
-
z.strictObject({
|
|
336
|
-
kind: z.literal("github"),
|
|
337
|
-
repository: z.string().min(3).max(200),
|
|
338
|
-
workflow: z.string().min(1).max(300).optional(),
|
|
339
|
-
branch: z.string().min(1).max(255).optional(),
|
|
340
|
-
event: z.string().min(1).max(64).optional()
|
|
341
|
-
}),
|
|
342
|
-
z.strictObject({
|
|
343
|
-
kind: z.literal("oidc"),
|
|
344
|
-
issuer: z.string().min(1).max(1e3),
|
|
345
|
-
claims: z.record(z.string().min(1).max(200), z.union([ClaimValue, z.array(ClaimValue).min(1).max(32)]))
|
|
346
|
-
}),
|
|
347
|
-
z.strictObject({ kind: z.literal("all-users") }),
|
|
348
|
-
z.strictObject({
|
|
349
|
-
kind: z.literal("all-projects"),
|
|
350
|
-
environments: Environments.optional()
|
|
351
|
-
}),
|
|
352
|
-
z.strictObject({
|
|
353
|
-
kind: z.literal("app"),
|
|
354
|
-
app: z.string().min(1).max(200)
|
|
355
|
-
}),
|
|
356
|
-
z.strictObject({ kind: z.literal("all-apps") }),
|
|
357
|
-
z.strictObject({ kind: z.literal("everyone") })
|
|
358
|
-
]);
|
|
359
|
-
/** What a grant lets its principals do: a map from channel pattern to `'all'` or a list, `[]` for none. Kept as written. */
|
|
360
|
-
const GrantCan = z.record(z.string().min(1).max(CHANNEL_PATTERN_MAX), CanGrant);
|
|
361
|
-
/**
|
|
362
|
-
* Says to go ahead with a grant change its caller couldn't take back: one that takes their own
|
|
363
|
-
* `manage` at a pattern it names, which is 409 `grant_lockout` without it.
|
|
364
|
-
*/
|
|
365
|
-
const LockMeOut = z.boolean().optional();
|
|
366
|
-
/** A grant: who it names, and one `can` for all of them. The same principals again are another grant. */
|
|
367
|
-
const GrantSpec = z.strictObject({
|
|
368
|
-
principals: z.array(PrincipalInput).min(1).max(32),
|
|
369
|
-
can: GrantCan
|
|
370
|
-
});
|
|
371
|
-
/** What `POST /grants` takes: a grant, and `lockMeOut` to make one its caller couldn't take back. */
|
|
372
|
-
const GrantBody = GrantSpec.extend({ lockMeOut: LockMeOut });
|
|
373
|
-
/**
|
|
374
|
-
* Several grants made in one write, all of them or none, judged together: each by the grants as
|
|
375
|
-
* they are, and what it leaves its caller with by the grants as they'd be with all of them. So a
|
|
376
|
-
* lock and the grant that keeps its maker in go in one request, in any order.
|
|
377
|
-
*/
|
|
378
|
-
const CreateGrantsBody = z.strictObject({
|
|
379
|
-
grants: z.array(GrantSpec).min(1).max(16),
|
|
380
|
-
lockMeOut: LockMeOut
|
|
381
|
-
});
|
|
382
|
-
/** What revoking a grant takes: nothing, or `lockMeOut`. */
|
|
383
|
-
const RevokeGrantBody = z.strictObject({ lockMeOut: LockMeOut }).optional();
|
|
384
|
-
/**
|
|
385
|
-
* Which grant decides a channel, and what it gives, for the caller or a principal it names: a
|
|
386
|
-
* `user` (by email, or by ID where the board can't look one up), a `project` in one `environment`
|
|
387
|
-
* (production by default), a `github` repository's run (with its `workflow`, `branch`, and
|
|
388
|
-
* `event`), or an `oidc` issuer's token with each `claim` as `name=value`.
|
|
389
|
-
*/
|
|
390
|
-
const ExplainQuery = z.object({
|
|
391
|
-
channel: ChannelPath,
|
|
392
|
-
user: z.string().min(1).max(320).optional(),
|
|
393
|
-
project: z.string().min(1).max(200).optional(),
|
|
394
|
-
environment: z.string().min(1).max(100).optional(),
|
|
395
|
-
github: z.string().min(3).max(200).optional(),
|
|
396
|
-
workflow: z.string().min(1).max(300).optional(),
|
|
397
|
-
branch: z.string().min(1).max(255).optional(),
|
|
398
|
-
event: z.string().min(1).max(64).optional(),
|
|
399
|
-
oidc: z.string().min(1).max(1e3).optional(),
|
|
400
|
-
claim: repeated.optional(),
|
|
401
|
-
app: z.string().min(1).max(200).optional()
|
|
402
|
-
}).refine((query) => [
|
|
403
|
-
query.user,
|
|
404
|
-
query.project,
|
|
405
|
-
query.github,
|
|
406
|
-
query.oidc,
|
|
407
|
-
query.app
|
|
408
|
-
].filter((value) => value !== void 0).length <= 1, "name one principal: user, project, github, oidc, or app").refine((query) => query.environment === void 0 || query.project !== void 0, "environment goes with project").refine((query) => query.workflow === void 0 && query.branch === void 0 && query.event === void 0 || query.github !== void 0, "workflow, branch, and event go with github").refine((query) => query.claim === void 0 || query.oidc !== void 0, "claim goes with oidc");
|
|
409
|
-
/** A grant's change: principals to add and to remove, and a `can` to replace its own. */
|
|
410
|
-
const UpdateGrantBody = z.strictObject({
|
|
411
|
-
add: z.array(PrincipalInput).min(1).max(32).optional(),
|
|
412
|
-
remove: z.array(PrincipalInput).min(1).max(32).optional(),
|
|
413
|
-
can: GrantCan.optional(),
|
|
414
|
-
lockMeOut: LockMeOut
|
|
415
|
-
}).refine((body) => body.add !== void 0 || body.remove !== void 0 || body.can !== void 0, "name principals to add or remove, or a can");
|
|
416
|
-
/**
|
|
417
|
-
* A schema version to register, for good: `name` and `version` are its ID (`sandbox@1`), and
|
|
418
|
-
* `schema` is a JSON Schema for an object, in structural keywords only, which the board checks.
|
|
419
|
-
* Strict, so a board that doesn't know a field refuses it: what it kept could never be changed.
|
|
420
|
-
*/
|
|
421
|
-
const SchemaBody = z.strictObject({
|
|
422
|
-
name: z.string().regex(/^[a-z][a-z0-9._-]*$/, "a schema name is lowercase letters, numbers, and ._-, starting with a letter"),
|
|
423
|
-
version: z.number().int().min(1),
|
|
424
|
-
description: z.string().min(1).refine(storable, "a description has a NUL character or a lone surrogate").optional(),
|
|
425
|
-
schema: z.record(z.string(), z.unknown())
|
|
426
|
-
});
|
|
427
|
-
const SyncBody = z.object({ target: z.string().min(3).max(300) });
|
|
428
|
-
const InboxQuery = z.object({
|
|
429
|
-
channel: z.string().optional(),
|
|
430
|
-
limit: z.coerce.number().int().min(1).max(500).optional()
|
|
431
|
-
});
|
|
432
|
-
/** What every registration carries: its watchers' tails, and its sync entries. */
|
|
433
|
-
const Registering = z.object({
|
|
434
|
-
watch: z.record(z.string().max(100), z.object({ tail: z.string().max(1e3) })).refine((watch) => Object.keys(watch).length <= 32, `a board registers at most 32 watchers`),
|
|
435
|
-
/**
|
|
436
|
-
* Its sync entries: its sync subscribes too, to every post, change, and thread sync in the channels
|
|
437
|
-
* where it may sync, and the board lists the entries.
|
|
438
|
-
*/
|
|
439
|
-
sync: z.array(z.object({
|
|
440
|
-
key: z.string().min(1).max(64),
|
|
441
|
-
platform: z.string().min(1).max(64)
|
|
442
|
-
})).max(32).optional()
|
|
443
|
-
});
|
|
444
|
-
/**
|
|
445
|
-
* What a board on `http()` registers with the board it uses: its watchers, and where to wake it,
|
|
446
|
-
* at a URL or at a path on its own project, never both.
|
|
447
|
-
*/
|
|
448
|
-
const RegisterBody = z.union([Registering.extend({
|
|
449
|
-
/** Without one, the board pulls on its own instead of being woken. */
|
|
450
|
-
url: z.string().url().max(500).refine((url) => /^https:\/\//.test(url), "wake-ups go over https").transform((url) => url.replace(/\/+$/, "")).nullable().optional(),
|
|
451
|
-
path: z.null({ error: "register a url or a path, not both" }).optional(),
|
|
452
|
-
branch: z.null({ error: "a branch goes with a path" }).optional()
|
|
453
|
-
}), Registering.extend({
|
|
454
|
-
url: z.null({ error: "register a url or a path, not both" }).optional(),
|
|
455
|
-
/**
|
|
456
|
-
* Where to wake the caller on its own Vercel project, on a board whose discovery says
|
|
457
|
-
* `wake_by_path`. The board takes the project and environment from the caller's token and
|
|
458
|
-
* finds the deployment, so a project can only register itself, and anyone else gets 403
|
|
459
|
-
* `not_a_project`.
|
|
460
|
-
*/
|
|
461
|
-
path: z.string().max(300).regex(/^\/[^?#]*$/, "a path starts with / and has no query or fragment").transform((path) => path.replace(/(.)\/+$/, "$1")),
|
|
462
|
-
/**
|
|
463
|
-
* From a preview: the branch whose latest ready preview is woken, since a token says which
|
|
464
|
-
* project and environment called but not which deployment. Production names none.
|
|
465
|
-
*/
|
|
466
|
-
branch: z.string().min(1).max(255).nullable().optional()
|
|
467
|
-
})]);
|
|
468
|
-
/** A pull of the caller's matches: at most `limit`, waiting up to `wait` seconds for one. */
|
|
469
|
-
const MatchesQuery = z.object({
|
|
470
|
-
limit: z.coerce.number().int().min(1).max(50).optional(),
|
|
471
|
-
wait: z.coerce.number().min(0).max(25).optional()
|
|
472
|
-
});
|
|
473
|
-
/** How a pulled match went: its lease, and an error to try again, or `skip` to drop it. */
|
|
474
|
-
const AckBody = z.object({
|
|
475
|
-
lease: z.string().min(1).max(64),
|
|
476
|
-
error: z.string().min(1).max(500).optional(),
|
|
477
|
-
skip: z.boolean().optional()
|
|
478
|
-
});
|
|
479
|
-
/**
|
|
480
|
-
* What to read from a platform without syncing it: a channel (`#name` or an ID),
|
|
481
|
-
* a thread (`C0123:1727000000.123456`), or a message permalink (its thread).
|
|
482
|
-
*/
|
|
483
|
-
const SourceReadQuery = z.object({
|
|
484
|
-
target: z.string().min(1).max(4e3),
|
|
485
|
-
limit: z.coerce.number().int().min(1).max(200).optional(),
|
|
486
|
-
/** Where the last read left off: its `next`. */
|
|
487
|
-
after: z.string().min(1).max(400).optional()
|
|
488
|
-
});
|
|
489
|
-
/** A channel to add the board's app to, so it can be read on demand: `#name`, an ID, or a link into it. */
|
|
490
|
-
const SourceJoinBody = z.object({ target: z.string().min(1).max(4e3) });
|
|
491
|
-
/** A platform's link to a message or thread, such as a Slack permalink or a GitHub comment's URL. */
|
|
492
|
-
const LinkedQuery = z.object({ url: z.string().url().max(4e3) });
|
|
493
|
-
/** A sync entry's key: `slack`, `github`. */
|
|
494
|
-
const SyncKey = z.string().min(1).max(64);
|
|
495
|
-
/** A platform message an import changes, by its platform thread and ID; without a message, the root of the board thread the platform thread belongs to. */
|
|
496
|
-
const ImportOrigin = z.object({
|
|
497
|
-
thread: ExternalTarget,
|
|
498
|
-
message: z.string().min(1).max(300).optional()
|
|
499
|
-
});
|
|
500
|
-
/** A link as an import carries it: a board message it names is a ref. */
|
|
501
|
-
const ImportLink = Link.extend({ message: Ref.nullable() });
|
|
502
|
-
/**
|
|
503
|
-
* A platform user, as sync names them to the board. Their avatar shows wherever they do, so one
|
|
504
|
-
* that isn't an https URL is dropped, never refused: the write lands without it.
|
|
505
|
-
*/
|
|
506
|
-
const PlatformUser = ExternalAuthor.extend({ avatar: z.string().nullable().transform(platformAvatar) });
|
|
507
|
-
/**
|
|
508
|
-
* Who wrote it on the platform, and the sync key it came through: null for a write a sync callback
|
|
509
|
-
* makes as that user, which syncs out to every platform like one written on the board.
|
|
510
|
-
*/
|
|
511
|
-
const Imported = {
|
|
512
|
-
author: PlatformUser,
|
|
513
|
-
from: SyncKey.nullable()
|
|
514
|
-
};
|
|
515
|
-
/**
|
|
516
|
-
* The platform's users a text mentions as `@[<their id>]`. One the board hasn't met becomes known
|
|
517
|
-
* to it, as one who wrote does: named, and seen where the message is. One the text doesn't mention
|
|
518
|
-
* is left out.
|
|
519
|
-
*/
|
|
520
|
-
const Mentioned = z.array(PlatformUser).max(50).optional();
|
|
521
|
-
/**
|
|
522
|
-
* Where the platform event an import comes from is: its sync entry, platform channel, and thread.
|
|
523
|
-
* The middleware is told, and answers there when it drops the write.
|
|
524
|
-
*/
|
|
525
|
-
const ImportSource = z.object({
|
|
526
|
-
key: SyncKey,
|
|
527
|
-
channel: ExternalTarget,
|
|
528
|
-
thread: ExternalTarget
|
|
529
|
-
});
|
|
530
|
-
/** The message a change is about: by its platform IDs (`origin`), or by its board ID (`message`), one or the other. */
|
|
531
|
-
const Changed = {
|
|
532
|
-
origin: ImportOrigin.optional(),
|
|
533
|
-
message: Ref.optional()
|
|
534
|
-
};
|
|
535
|
-
/**
|
|
536
|
-
* A platform's write, as its platform author, with where it came from: only a caller with `sync` in
|
|
537
|
-
* the channel it lands in may make one. Posts are idempotent by `id`, derived from the platform
|
|
538
|
-
* event; every other op finds the message it changes from its `origin`.
|
|
539
|
-
*/
|
|
540
|
-
const SyncImportBody = z.discriminatedUnion("op", [
|
|
541
|
-
z.object({
|
|
542
|
-
op: z.literal("post"),
|
|
543
|
-
...Imported,
|
|
544
|
-
/** Where it is on the platform. Null for a write a sync callback makes itself. */
|
|
545
|
-
origin: Origin.nullable().default(null),
|
|
546
|
-
source: ImportSource.optional(),
|
|
547
|
-
channel: ChannelPath.optional(),
|
|
548
|
-
re: Ref.optional(),
|
|
549
|
-
text: z.string().max(MESSAGE_TEXT_MAX).default(""),
|
|
550
|
-
labels: NewLabels.optional(),
|
|
551
|
-
noSync: z.boolean().optional(),
|
|
552
|
-
attachments: z.array(AttachmentId).max(10).optional(),
|
|
553
|
-
links: z.array(ImportLink).max(10).optional(),
|
|
554
|
-
mentioned: Mentioned,
|
|
555
|
-
id: z.string().min(1).max(200).refine(storable, "id has a NUL character or a lone surrogate").optional(),
|
|
556
|
-
/** A reply's precondition, as a post's: a sync callback's reply after the newest message it read. */
|
|
557
|
-
after: Ref.optional()
|
|
558
|
-
}),
|
|
559
|
-
z.object({
|
|
560
|
-
op: z.literal("edit"),
|
|
561
|
-
...Imported,
|
|
562
|
-
...Changed,
|
|
563
|
-
text: MessageText,
|
|
564
|
-
source: ImportSource.optional(),
|
|
565
|
-
revision: Revision.optional(),
|
|
566
|
-
mentioned: Mentioned
|
|
567
|
-
}),
|
|
568
|
-
z.object({
|
|
569
|
-
op: z.literal("delete"),
|
|
570
|
-
...Imported,
|
|
571
|
-
...Changed,
|
|
572
|
-
revision: Revision.optional()
|
|
573
|
-
}),
|
|
574
|
-
z.object({
|
|
575
|
-
op: z.literal("react"),
|
|
576
|
-
...Imported,
|
|
577
|
-
...Changed,
|
|
578
|
-
emoji: Emoji,
|
|
579
|
-
remove: z.boolean().optional()
|
|
580
|
-
}),
|
|
581
|
-
z.object({
|
|
582
|
-
op: z.literal("labels"),
|
|
583
|
-
...Imported,
|
|
584
|
-
...Changed,
|
|
585
|
-
set: NewLabels.optional(),
|
|
586
|
-
unset: z.array(LabelKey).optional(),
|
|
587
|
-
/** As a label write's: what the labels must be now, a value or null for none. */
|
|
588
|
-
if: z.record(LabelKey, LabelValue.nullable()).optional()
|
|
589
|
-
}),
|
|
590
|
-
z.object({
|
|
591
|
-
op: z.literal("links"),
|
|
592
|
-
...Imported,
|
|
593
|
-
...Changed,
|
|
594
|
-
links: z.array(ImportLink).max(10)
|
|
595
|
-
})
|
|
596
|
-
]);
|
|
597
|
-
const PlatformFiles = z.array(z.string().min(1).max(300)).max(10).nullable();
|
|
598
|
-
/** What sync did on a platform, about a board message: it landed, its files did, it gave up, or its thread syncs with a target. */
|
|
599
|
-
const SyncReceiptBody = z.discriminatedUnion("kind", [
|
|
600
|
-
z.object({
|
|
601
|
-
kind: z.literal("message"),
|
|
602
|
-
message: Ref,
|
|
603
|
-
target: ExternalTarget,
|
|
604
|
-
external: z.object({
|
|
605
|
-
thread: ExternalTarget,
|
|
606
|
-
message: z.string().min(1).max(300)
|
|
607
|
-
}),
|
|
608
|
-
/** Its files, when they went with it: the platform's IDs, or null when it refused them. */
|
|
609
|
-
files: PlatformFiles.optional()
|
|
610
|
-
}),
|
|
611
|
-
z.object({
|
|
612
|
-
kind: z.literal("files"),
|
|
613
|
-
message: Ref,
|
|
614
|
-
target: ExternalTarget,
|
|
615
|
-
files: PlatformFiles
|
|
616
|
-
}),
|
|
617
|
-
z.object({
|
|
618
|
-
kind: z.literal("failed"),
|
|
619
|
-
message: Ref,
|
|
620
|
-
target: ExternalTarget,
|
|
621
|
-
error: z.string().min(1).max(500)
|
|
622
|
-
}),
|
|
623
|
-
z.object({
|
|
624
|
-
kind: z.literal("thread"),
|
|
625
|
-
/** Any message in the thread. */
|
|
626
|
-
message: Ref,
|
|
627
|
-
target: ExternalTarget,
|
|
628
|
-
/** A channel to start a thread in, or a thread to join. */
|
|
629
|
-
targetKind: z.enum(["channel", "thread"]),
|
|
630
|
-
cause: z.enum(["config", "request"])
|
|
631
|
-
})
|
|
632
|
-
]);
|
|
633
|
-
/** What sync looks up by platform ID: a thread or a message. */
|
|
634
|
-
const SyncFindQuery = z.object({
|
|
635
|
-
/** The post the caller's sync imported with this client ID. */
|
|
636
|
-
post: z.string().min(1).max(200).optional(),
|
|
637
|
-
thread: ExternalTarget.optional(),
|
|
638
|
-
/** With `thread`: the platform message in it. */
|
|
639
|
-
message: z.string().min(1).max(300).optional()
|
|
640
|
-
});
|
|
641
|
-
const SyncCopiesQuery = z.object({ message: repeated.pipe(z.array(Ref).min(1).max(100)) });
|
|
642
|
-
const InboxPushBody = z.object({ events: z.array(z.object({
|
|
643
|
-
id: z.string().min(1).max(300),
|
|
644
|
-
event: ExternalEvent,
|
|
645
|
-
raw: z.unknown()
|
|
646
|
-
})).min(1).max(50) });
|
|
647
|
-
const InboxNextQuery = z.object({ limit: z.coerce.number().int().min(1).max(50).optional() });
|
|
648
|
-
const InboxAckBody = z.object({
|
|
649
|
-
lease: z.string().min(1).max(64),
|
|
650
|
-
error: z.string().min(1).max(500).optional()
|
|
651
|
-
});
|
|
652
|
-
/**
|
|
653
|
-
* A direct upload, before its bytes: what the file will be called, its type, its exact size, and
|
|
654
|
-
* the SHA-256 of its bytes, in base64, for a store that signs its URL for them (Vercel's).
|
|
655
|
-
*/
|
|
656
|
-
const UploadStartBody = z.object({
|
|
657
|
-
name: z.string().max(1024).nullable().optional(),
|
|
658
|
-
type: z.string().max(1024).nullable().optional(),
|
|
659
|
-
size: z.number().int().positive().max(DIRECT_UPLOAD_BYTES_MAX, `direct uploads are at most ${DIRECT_UPLOAD_BYTES_MAX / 1024 / 1024} MB`),
|
|
660
|
-
sha256: z.string().regex(/^[A-Za-z0-9+/]{43}=$/, "sha256 is the base64 SHA-256 of the bytes").optional()
|
|
661
|
-
});
|
|
662
|
-
const EditBody = z.object({
|
|
663
|
-
text: SentText,
|
|
664
|
-
revision: Revision.optional()
|
|
665
|
-
});
|
|
666
|
-
const DeleteBody = z.object({ revision: Revision.optional() }).optional();
|
|
667
|
-
/** `status`: what Slack shows in place of "Typing…" (other platforms ignore it). */
|
|
668
|
-
const TypingBody = z.object({ status: z.string().trim().min(1).max(50).optional() }).optional();
|
|
669
|
-
const ReactBody = z.object({
|
|
670
|
-
emoji: Emoji,
|
|
671
|
-
remove: z.boolean().optional()
|
|
672
|
-
});
|
|
673
|
-
/**
|
|
674
|
-
* A channel to make before anything posts to it, and nothing else: a key it doesn't know is a 400,
|
|
675
|
-
* so a client that asks for more than a channel (one that expects `private: true` to close it, say)
|
|
676
|
-
* is told, never handed an open one.
|
|
677
|
-
*/
|
|
678
|
-
const CreateChannelBody = z.strictObject({ path: ChannelPath });
|
|
679
|
-
const LabelBody = z.object({
|
|
680
|
-
set: NewLabels.optional(),
|
|
681
|
-
unset: z.array(LabelKey).optional(),
|
|
682
|
-
/**
|
|
683
|
-
* What the message's labels must be now: a key's value, or null for one that mustn't be set.
|
|
684
|
-
* If one isn't, nothing changes, and the board answers 409 `label_conflict`.
|
|
685
|
-
*/
|
|
686
|
-
if: z.record(LabelKey, LabelValue.nullable()).refine((expected) => Object.keys(expected).length <= 16, `at most 16 labels`).optional()
|
|
687
|
-
}).refine((body) => body.set !== void 0 || body.unset !== void 0, { message: "nothing to change: pass `set` or `unset`" });
|
|
688
|
-
/** The route table: method, path, and the schemas that validate input. */
|
|
689
|
-
const routes = {
|
|
690
|
-
/** Where the board is, its project, and its sync entries. No token. */
|
|
691
|
-
discovery: {
|
|
692
|
-
method: "GET",
|
|
693
|
-
path: "/"
|
|
694
|
-
},
|
|
695
|
-
me: {
|
|
696
|
-
method: "GET",
|
|
697
|
-
path: "/me"
|
|
698
|
-
},
|
|
699
|
-
channels: {
|
|
700
|
-
method: "GET",
|
|
701
|
-
path: "/channels",
|
|
702
|
-
query: ChannelsQuery
|
|
703
|
-
},
|
|
704
|
-
/** Makes a channel before anything posts to it: needs `read` and `post` there. One that's there already is left as it is. */
|
|
705
|
-
createChannel: {
|
|
706
|
-
method: "POST",
|
|
707
|
-
path: "/channels",
|
|
708
|
-
body: CreateChannelBody
|
|
709
|
-
},
|
|
710
|
-
actors: {
|
|
711
|
-
method: "GET",
|
|
712
|
-
path: "/actors"
|
|
713
|
-
},
|
|
714
|
-
/** One channel's messages across its threads: the newest, or those after one of its cursors. */
|
|
715
|
-
channelMessages: {
|
|
716
|
-
method: "GET",
|
|
717
|
-
path: "/messages",
|
|
718
|
-
query: ChannelMessagesQuery
|
|
719
|
-
},
|
|
720
|
-
message: {
|
|
721
|
-
method: "GET",
|
|
722
|
-
path: "/messages/:id",
|
|
723
|
-
query: ThreadQuery
|
|
724
|
-
},
|
|
725
|
-
/** Threads with a matching message, one summary each, by latest activity. `before` takes a page's `older`. */
|
|
726
|
-
threads: {
|
|
727
|
-
method: "GET",
|
|
728
|
-
path: "/threads",
|
|
729
|
-
query: ThreadsQuery
|
|
730
|
-
},
|
|
731
|
-
post: {
|
|
732
|
-
method: "POST",
|
|
733
|
-
path: "/messages",
|
|
734
|
-
body: PostBody
|
|
735
|
-
},
|
|
736
|
-
edit: {
|
|
737
|
-
method: "POST",
|
|
738
|
-
path: "/messages/:id/edit",
|
|
739
|
-
body: EditBody
|
|
740
|
-
},
|
|
741
|
-
delete: {
|
|
742
|
-
method: "POST",
|
|
743
|
-
path: "/messages/:id/delete",
|
|
744
|
-
body: DeleteBody
|
|
745
|
-
},
|
|
746
|
-
react: {
|
|
747
|
-
method: "POST",
|
|
748
|
-
path: "/messages/:id/reactions",
|
|
749
|
-
body: ReactBody
|
|
750
|
-
},
|
|
751
|
-
label: {
|
|
752
|
-
method: "POST",
|
|
753
|
-
path: "/messages/:id/labels",
|
|
754
|
-
body: LabelBody
|
|
755
|
-
},
|
|
756
|
-
/** Attaches the thread to a sync target, recording a `thread` receipt: needs `sync` where the thread is. */
|
|
757
|
-
sync: {
|
|
758
|
-
method: "POST",
|
|
759
|
-
path: "/messages/:id/sync",
|
|
760
|
-
body: SyncBody
|
|
761
|
-
},
|
|
762
|
-
/** Where the message's thread is synced, and its copy on each target: needs `read` where it is. */
|
|
763
|
-
synced: {
|
|
764
|
-
method: "GET",
|
|
765
|
-
path: "/messages/:id/sync"
|
|
766
|
-
},
|
|
767
|
-
/** The board message a platform link names, from what the board synced: 404 `message_not_found` for one it didn't, or that the caller can't read. */
|
|
768
|
-
linked: {
|
|
769
|
-
method: "GET",
|
|
770
|
-
path: "/links",
|
|
771
|
-
query: LinkedQuery
|
|
772
|
-
},
|
|
773
|
-
/** Ephemeral: shows typing in the thread's synced platform threads, and writes nothing to the log. Needs `post` where the thread is. */
|
|
774
|
-
typing: {
|
|
775
|
-
method: "POST",
|
|
776
|
-
path: "/messages/:id/typing",
|
|
777
|
-
body: TypingBody
|
|
778
|
-
},
|
|
779
|
-
/** Posts a message later, as the caller: needs a scheduler. */
|
|
780
|
-
schedule: {
|
|
781
|
-
method: "POST",
|
|
782
|
-
path: "/schedules",
|
|
783
|
-
body: ScheduleBody
|
|
784
|
-
},
|
|
785
|
-
schedules: {
|
|
786
|
-
method: "GET",
|
|
787
|
-
path: "/schedules",
|
|
788
|
-
query: SchedulesQuery
|
|
789
|
-
},
|
|
790
|
-
/** Its creator, or manage in its channel, may cancel a schedule. Canceling one that's done is a no-op. */
|
|
791
|
-
cancelSchedule: {
|
|
792
|
-
method: "POST",
|
|
793
|
-
path: "/schedules/:id/cancel"
|
|
794
|
-
},
|
|
795
|
-
/** Tasks, oldest first: open ones unless `state` says otherwise. */
|
|
796
|
-
tasks: {
|
|
797
|
-
method: "GET",
|
|
798
|
-
path: "/tasks",
|
|
799
|
-
query: TasksQuery
|
|
800
|
-
},
|
|
801
|
-
/** Starts a thread as a task (`post` there, and `label` for its labels), or makes the thread `re` roots one (`label` there). */
|
|
802
|
-
createTask: {
|
|
803
|
-
method: "POST",
|
|
804
|
-
path: "/tasks",
|
|
805
|
-
body: CreateTaskBody
|
|
806
|
-
},
|
|
807
|
-
/** Starts several threads in one channel as tasks, in one write: all of them or none, and nothing shows before all have landed. */
|
|
808
|
-
createTasks: {
|
|
809
|
-
method: "POST",
|
|
810
|
-
path: "/tasks/batch",
|
|
811
|
-
body: CreateTasksBody
|
|
812
|
-
},
|
|
813
|
-
/** The caller's own batch made under the `id` it gave, its tasks as they are now: for telling a retry before making anything. */
|
|
814
|
-
createdTasks: {
|
|
815
|
-
method: "GET",
|
|
816
|
-
path: "/tasks/batch/:id",
|
|
817
|
-
query: CreatedTasksQuery
|
|
818
|
-
},
|
|
819
|
-
/** Claims the oldest ready task in a channel or subtree: `label` where it is. Answers `{ task: null }` when none is. */
|
|
820
|
-
claimReadyTask: {
|
|
821
|
-
method: "POST",
|
|
822
|
-
path: "/tasks/claim",
|
|
823
|
-
body: ClaimReadyTaskBody
|
|
824
|
-
},
|
|
825
|
-
/** Claims a task: `label` in its channel. Its answer's `claim` goes on what the claim does next. */
|
|
826
|
-
claimTask: {
|
|
827
|
-
method: "POST",
|
|
828
|
-
path: "/tasks/:id/claim",
|
|
829
|
-
body: ClaimTaskBody
|
|
830
|
-
},
|
|
831
|
-
/** What a claim does, with its `epoch` and `token`: 409 `claim_lost` once it's over. */
|
|
832
|
-
renewTask: {
|
|
833
|
-
method: "POST",
|
|
834
|
-
path: "/tasks/:id/renew",
|
|
835
|
-
body: RenewTaskBody
|
|
836
|
-
},
|
|
837
|
-
releaseTask: {
|
|
838
|
-
method: "POST",
|
|
839
|
-
path: "/tasks/:id/release",
|
|
840
|
-
body: ReleaseTaskBody
|
|
841
|
-
},
|
|
842
|
-
completeTask: {
|
|
843
|
-
method: "POST",
|
|
844
|
-
path: "/tasks/:id/complete",
|
|
845
|
-
body: CompleteTaskBody
|
|
846
|
-
},
|
|
847
|
-
failTask: {
|
|
848
|
-
method: "POST",
|
|
849
|
-
path: "/tasks/:id/fail",
|
|
850
|
-
body: FailTaskBody
|
|
851
|
-
},
|
|
852
|
-
/** Holds a task for a person: its claim while it's claimed, its owner or `manage` in its channel otherwise. */
|
|
853
|
-
blockTask: {
|
|
854
|
-
method: "POST",
|
|
855
|
-
path: "/tasks/:id/block",
|
|
856
|
-
body: BlockTaskBody
|
|
857
|
-
},
|
|
858
|
-
/** What a task's owner does, or `manage` in its channel. */
|
|
859
|
-
unblockTask: {
|
|
860
|
-
method: "POST",
|
|
861
|
-
path: "/tasks/:id/unblock"
|
|
862
|
-
},
|
|
863
|
-
reopenTask: {
|
|
864
|
-
method: "POST",
|
|
865
|
-
path: "/tasks/:id/reopen"
|
|
866
|
-
},
|
|
867
|
-
assignTask: {
|
|
868
|
-
method: "POST",
|
|
869
|
-
path: "/tasks/:id/assign",
|
|
870
|
-
body: AssignTaskBody
|
|
871
|
-
},
|
|
872
|
-
/** Replaces what a task waits for, while no one holds it and it isn't finished. */
|
|
873
|
-
setTaskNeeds: {
|
|
874
|
-
method: "POST",
|
|
875
|
-
path: "/tasks/:id/needs",
|
|
876
|
-
body: TaskNeedsBody
|
|
877
|
-
},
|
|
878
|
-
cancelTask: {
|
|
879
|
-
method: "POST",
|
|
880
|
-
path: "/tasks/:id/cancel",
|
|
881
|
-
body: CancelTaskBody
|
|
882
|
-
},
|
|
883
|
-
/** Listing grants needs manage at `*`; changing one, manage at each pattern its `can` names. Team owners always may. */
|
|
884
|
-
grants: {
|
|
885
|
-
method: "GET",
|
|
886
|
-
path: "/grants"
|
|
887
|
-
},
|
|
888
|
-
createGrant: {
|
|
889
|
-
method: "POST",
|
|
890
|
-
path: "/grants",
|
|
891
|
-
body: GrantBody
|
|
892
|
-
},
|
|
893
|
-
/** Several grants in one write, all or none, judged together. */
|
|
894
|
-
createGrants: {
|
|
895
|
-
method: "POST",
|
|
896
|
-
path: "/grants/batch",
|
|
897
|
-
body: CreateGrantsBody
|
|
898
|
-
},
|
|
899
|
-
updateGrant: {
|
|
900
|
-
method: "PATCH",
|
|
901
|
-
path: "/grants/:id",
|
|
902
|
-
body: UpdateGrantBody
|
|
903
|
-
},
|
|
904
|
-
/** Which grant decides a channel, for the caller or, with `manage` at `*`, a principal it names. */
|
|
905
|
-
explain: {
|
|
906
|
-
method: "GET",
|
|
907
|
-
path: "/grants/explain",
|
|
908
|
-
query: ExplainQuery
|
|
909
|
-
},
|
|
910
|
-
revokeGrant: {
|
|
911
|
-
method: "POST",
|
|
912
|
-
path: "/grants/:id/revoke",
|
|
913
|
-
body: RevokeGrantBody
|
|
914
|
-
},
|
|
915
|
-
/** Every schema: the built-ins, then the board's own. Anyone the board lets in reads them. */
|
|
916
|
-
schemas: {
|
|
917
|
-
method: "GET",
|
|
918
|
-
path: "/schemas"
|
|
919
|
-
},
|
|
920
|
-
/** One schema version, by `name@version`. */
|
|
921
|
-
schema: {
|
|
922
|
-
method: "GET",
|
|
923
|
-
path: "/schemas/:id"
|
|
924
|
-
},
|
|
925
|
-
/** Registers a version, which never changes after: needs manage at `*`. The same definition again is a no-op. */
|
|
926
|
-
createSchema: {
|
|
927
|
-
method: "POST",
|
|
928
|
-
path: "/schemas",
|
|
929
|
-
body: SchemaBody
|
|
930
|
-
},
|
|
931
|
-
/** The caller's own post with the client ID it gave: what `POST /messages` answered, for telling a retry before posting. */
|
|
932
|
-
posted: {
|
|
933
|
-
method: "GET",
|
|
934
|
-
path: "/posts/:id"
|
|
935
|
-
},
|
|
936
|
-
/** Raw platform events in a sync key's inbox, newest first: the caller's own, and the board's with `sync` everywhere. */
|
|
937
|
-
inbox: {
|
|
938
|
-
method: "GET",
|
|
939
|
-
path: "/inbox/:key",
|
|
940
|
-
query: InboxQuery
|
|
941
|
-
},
|
|
942
|
-
/** Pushes platform events into the caller's inbox for a sync key, deduplicated by their platform IDs. */
|
|
943
|
-
inboxPush: {
|
|
944
|
-
method: "POST",
|
|
945
|
-
path: "/inbox/:key",
|
|
946
|
-
body: InboxPushBody
|
|
947
|
-
},
|
|
948
|
-
/** The caller's next inbox events, leased to it, one platform thread at a time and in order. */
|
|
949
|
-
inboxNext: {
|
|
950
|
-
method: "GET",
|
|
951
|
-
path: "/inbox/:key/next",
|
|
952
|
-
query: InboxNextQuery
|
|
953
|
-
},
|
|
954
|
-
/** How one went: done, or an error to try it again. */
|
|
955
|
-
inboxAck: {
|
|
956
|
-
method: "POST",
|
|
957
|
-
path: "/inbox/:key/:id/ack",
|
|
958
|
-
body: InboxAckBody
|
|
959
|
-
},
|
|
960
|
-
/** A platform's write, as its platform author: `sync` where it lands. */
|
|
961
|
-
syncImport: {
|
|
962
|
-
method: "POST",
|
|
963
|
-
path: "/sync/imports",
|
|
964
|
-
body: SyncImportBody
|
|
965
|
-
},
|
|
966
|
-
/** What sync did on a platform: a delivery, its files, a failure, or a thread's new target. */
|
|
967
|
-
syncReceipt: {
|
|
968
|
-
method: "POST",
|
|
969
|
-
path: "/sync/receipts",
|
|
970
|
-
body: SyncReceiptBody
|
|
971
|
-
},
|
|
972
|
-
/** A board thread's sync, by its key. */
|
|
973
|
-
syncThread: {
|
|
974
|
-
method: "GET",
|
|
975
|
-
path: "/sync/threads/:thread"
|
|
976
|
-
},
|
|
977
|
-
/** What platform IDs are on the board. */
|
|
978
|
-
syncFind: {
|
|
979
|
-
method: "GET",
|
|
980
|
-
path: "/sync/find",
|
|
981
|
-
query: SyncFindQuery
|
|
982
|
-
},
|
|
983
|
-
/** Messages' copies on platforms. */
|
|
984
|
-
syncCopies: {
|
|
985
|
-
method: "GET",
|
|
986
|
-
path: "/sync/copies",
|
|
987
|
-
query: SyncCopiesQuery
|
|
988
|
-
},
|
|
989
|
-
/** Reads a platform channel or thread on demand, where that sync runs, without syncing or storing it. Full access only. */
|
|
990
|
-
readSource: {
|
|
991
|
-
method: "GET",
|
|
992
|
-
path: "/sources/:key/read",
|
|
993
|
-
query: SourceReadQuery
|
|
994
|
-
},
|
|
995
|
-
/** Adds the app to a public channel so it can be read, where that sync runs and opted in with `join`. Full access only. */
|
|
996
|
-
joinSource: {
|
|
997
|
-
method: "POST",
|
|
998
|
-
path: "/sources/:key/join",
|
|
999
|
-
body: SourceJoinBody
|
|
1000
|
-
},
|
|
1001
|
-
webhook: {
|
|
1002
|
-
method: "POST",
|
|
1003
|
-
path: "/webhooks/:key"
|
|
1004
|
-
},
|
|
1005
|
-
events: {
|
|
1006
|
-
method: "GET",
|
|
1007
|
-
path: "/events",
|
|
1008
|
-
query: EventsQuery
|
|
1009
|
-
},
|
|
1010
|
-
avatar: {
|
|
1011
|
-
method: "GET",
|
|
1012
|
-
path: "/avatars/:name"
|
|
1013
|
-
},
|
|
1014
|
-
/** The file is the body; `content-type` is its type and `x-board-filename` its name, URI-encoded. */
|
|
1015
|
-
upload: {
|
|
1016
|
-
method: "POST",
|
|
1017
|
-
path: "/attachments"
|
|
1018
|
-
},
|
|
1019
|
-
attachment: {
|
|
1020
|
-
method: "GET",
|
|
1021
|
-
path: "/attachments/:id"
|
|
1022
|
-
},
|
|
1023
|
-
/** A file too big for one request: the board answers where to `PUT` it in its blob store. Needs a store with `uploadUrl`. */
|
|
1024
|
-
uploadStart: {
|
|
1025
|
-
method: "POST",
|
|
1026
|
-
path: "/attachments/uploads",
|
|
1027
|
-
body: UploadStartBody
|
|
1028
|
-
},
|
|
1029
|
-
/** After the `PUT`: the board checks what landed in the store and records the attachment. */
|
|
1030
|
-
uploadFinish: {
|
|
1031
|
-
method: "POST",
|
|
1032
|
-
path: "/attachments/uploads/:id"
|
|
1033
|
-
},
|
|
1034
|
-
openapi: {
|
|
1035
|
-
method: "GET",
|
|
1036
|
-
path: "/openapi.json"
|
|
1037
|
-
},
|
|
1038
|
-
/** Watchers registered by boards on `http()`: every one to `manage` everywhere, the caller's own to anyone else. */
|
|
1039
|
-
watchers: {
|
|
1040
|
-
method: "GET",
|
|
1041
|
-
path: "/watchers"
|
|
1042
|
-
},
|
|
1043
|
-
/** Registers the caller's watchers, replacing its last registration. On a board on `http()`, registers its own, with no body or token. */
|
|
1044
|
-
register: {
|
|
1045
|
-
method: "POST",
|
|
1046
|
-
path: "/watchers",
|
|
1047
|
-
body: RegisterBody
|
|
1048
|
-
},
|
|
1049
|
-
/** The caller's matches it can run now, each leased to it until it acks. */
|
|
1050
|
-
matches: {
|
|
1051
|
-
method: "GET",
|
|
1052
|
-
path: "/watchers/matches",
|
|
1053
|
-
query: MatchesQuery
|
|
1054
|
-
},
|
|
1055
|
-
ack: {
|
|
1056
|
-
method: "POST",
|
|
1057
|
-
path: "/watchers/matches/:id/ack",
|
|
1058
|
-
body: AckBody
|
|
1059
|
-
},
|
|
1060
|
-
/** On a board on `http()`: something matched. No body, no token: the board pulls what. */
|
|
1061
|
-
wake: {
|
|
1062
|
-
method: "POST",
|
|
1063
|
-
path: "/wake"
|
|
1064
|
-
}
|
|
1065
|
-
};
|
|
1066
|
-
//#endregion
|
|
1067
|
-
export { routes as $, ReactBody as A, SourceReadQuery as B, InboxNextQuery as C, LinkedQuery as D, LabelBody as E, RevokeGrantBody as F, SyncReceiptBody as G, SyncCopiesQuery as H, ScheduleBody as I, ThreadQuery as J, TaskNeedsBody as K, SchedulesQuery as L, RegisterBody as M, ReleaseTaskBody as N, MatchesQuery as O, RenewTaskBody as P, UploadStartBody as Q, SchemaBody as R, InboxAckBody as S, InboxQuery as T, SyncFindQuery as U, SyncBody as V, SyncImportBody as W, TypingBody as X, ThreadsQuery as Y, UpdateGrantBody as Z, EventsQuery as _, ChannelMessagesQuery as a, Filters as b, ClaimTaskBody as c, CreateGrantsBody as d, CreateTaskBody as f, EditBody as g, DeleteBody as h, CancelTaskBody as i, Ref as j, PostBody as k, CompleteTaskBody as l, CreatedTasksQuery as m, AssignTaskBody as n, ChannelsQuery as o, CreateTasksBody as p, TasksQuery as q, BlockTaskBody as r, ClaimReadyTaskBody as s, AckBody as t, CreateChannelBody as u, ExplainQuery as v, InboxPushBody as w, GrantBody as x, FailTaskBody as y, SourceJoinBody as z };
|