@vercel/board 0.48.1 → 0.49.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-C06pIr0M.mjs → access-B8DnrnHa.mjs} +29 -17
- package/dist/access.d.mts +2 -2
- package/dist/access.mjs +5 -5
- package/dist/{actors-Dkyg-oo0.mjs → actors-DewJKyqy.mjs} +4 -3
- package/dist/{auth-B9-wXQ-x.mjs → auth-CEU06Nyp.mjs} +2 -2
- package/dist/{auth-li3lKwJG.d.mts → auth-Z9-Khvvw.d.mts} +1 -1
- package/dist/{backend-UBP6HimX.d.mts → backend-BzCXxVZ-.d.mts} +19 -5
- package/dist/backend-local.d.mts +1 -1
- package/dist/backend-local.mjs +1 -1
- package/dist/{chat-provider-kNWd6MQC.mjs → chat-provider-BS_fr61g.mjs} +2 -2
- package/dist/{chat-provider-iN0DFsSE.d.mts → chat-provider-DQ1GHm4o.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 +2 -2
- package/dist/cli-embedded.mjs +3 -3
- package/dist/cli.mjs +6 -6
- package/dist/client-C2T4eaXd.d.mts +544 -0
- package/dist/{commands-CJsOA-hf.d.mts → commands-Cm4sODIu.d.mts} +12 -8
- package/dist/{commands-Dk6_cHLS.mjs → commands-nN8WpvCe.mjs} +75 -58
- package/dist/{conformance-CDP8y2Zm.mjs → conformance-0xONNKcB.mjs} +102 -20
- package/dist/conformance.d.mts +1 -1
- package/dist/conformance.mjs +1 -1
- package/dist/{engine-BQ0hJw2w.mjs → engine-BH_nfJ3N.mjs} +6 -5
- package/dist/{errors-QhkdzI-o.mjs → errors-DwV7I0g4.mjs} +53 -174
- package/dist/{events-B-qyxNsJ.mjs → events-B76-4bNp.mjs} +2 -2
- package/dist/{exports-inhbjAWi.d.mts → exports-CKEK1fxf.d.mts} +4 -4
- package/dist/{exports-BzSG0_wL.mjs → exports-DLzyKwEp.mjs} +336 -82
- package/dist/{external-BuVTXT1R.mjs → external-BLI4W_-V.mjs} +1 -1
- package/dist/{index-B0Fnhvk7.d.mts → index-DxqSw8yd.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 +39 -39
- package/dist/inspect-B2ImmOvw.mjs +272 -0
- package/dist/inspect-DnRQUmP8.mjs +2 -0
- package/dist/inspect.d.mts +17 -0
- package/dist/inspect.mjs +196 -0
- package/dist/{local-BdKxz-Dn.mjs → local-DPpSEq2_.mjs} +132 -50
- package/dist/{main-BgiViRZ8.mjs → main-CqX7JqzE.mjs} +214 -46
- package/dist/{memory-CMm-Fk_A.mjs → memory-DzqkXIB-.mjs} +2 -2
- package/dist/{middleware-CT6vMNUc.mjs → middleware-ysFm2S4v.mjs} +2 -2
- package/dist/{page-D-OzDOAX.mjs → page-7KWSGxyC.mjs} +12 -2
- package/dist/page-CN77B014.mjs +2 -0
- package/dist/profile-header-Cj0Cb1cf.mjs +163 -0
- package/dist/{provider-DC3WHUXo.d.mts → provider-Dwb_9mnu.d.mts} +3 -529
- package/dist/{routes-CjA6Mp4D.d.mts → routes-B6SEA9yw.d.mts} +130 -4
- package/dist/{routes-ABXf3CKq.mjs → routes-qS92xz8U.mjs} +33 -7
- package/dist/{schemas-7VFdomFB.mjs → schemas-TeVe4Udh.mjs} +4 -2
- package/dist/{serve-C2Jbr7pR.mjs → serve-CYr4RwRM.mjs} +5 -5
- package/dist/{server-EOQC5Gtq.mjs → server-V7qyVUiJ.mjs} +11 -9
- package/dist/{serving-BNdiReQT.mjs → serving-BzNxlnDV.mjs} +1 -1
- package/dist/{inspect-n9brh-TT.mjs → shell-BLHZoP-x.mjs} +25 -274
- package/dist/{sql-IEbO5vXs.mjs → sql-DIKQd5Me.mjs} +2 -2
- package/dist/{sqlite-CVG8XKHm.mjs → sqlite-BF9kBDh1.mjs} +2 -2
- package/dist/{sqlite-db-BJjPQYx4.mjs → sqlite-db-CSYwiZ4E.mjs} +1 -1
- package/dist/sync-chat-sdk.d.mts +2 -2
- package/dist/sync-chat-sdk.mjs +2 -2
- package/dist/sync-github.d.mts +2 -2
- package/dist/sync-github.mjs +2 -2
- package/dist/sync-linear.d.mts +3 -3
- package/dist/sync-linear.mjs +2 -2
- package/dist/sync-slack.d.mts +3 -3
- package/dist/sync-slack.mjs +11 -7
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/{task-batch-D4p9N8lN.mjs → task-batch-CujTLmTB.mjs} +10 -11
- package/dist/{tokens-BCp4EWTQ.mjs → tokens-BmCDAT4N.mjs} +2 -2
- package/dist/version-BCoWGLEW.mjs +5 -0
- package/docs/01-board/01-mounting.md +8 -0
- package/docs/01-board/04-messages.md +6 -2
- package/docs/01-board/05-reading.md +17 -2
- package/docs/01-board/09-access.md +40 -6
- package/docs/01-board/11-tasks.md +3 -3
- package/docs/03-guides/02-inspector.md +31 -0
- package/docs/04-reference/01-cli.md +81 -32
- package/docs/04-reference/02-board.md +14 -3
- package/docs/04-reference/03-http.md +5 -3
- package/docs/04-reference/05-conformance.md +7 -0
- package/package.json +5 -1
- package/dist/inspect-BB-XUPuz.mjs +0 -2
- package/dist/page-Dr9Aqlej.mjs +0 -2
|
@@ -1,61 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as DIRECT_UPLOAD_BYTES_MAX, i as ATTACHMENT_BYTES_MAX, n as formatProfileHeader, u as typeOf } from "./profile-header-Cj0Cb1cf.mjs";
|
|
2
|
+
import { m as MESSAGE_TEXT_MAX } from "./schemas-TeVe4Udh.mjs";
|
|
2
3
|
import { r as normalizeEmoji } from "./emoji-CTLpvH-A.mjs";
|
|
3
4
|
import { ZodError } from "zod";
|
|
4
|
-
//#region src/contract/files.ts
|
|
5
|
-
/** Under Vercel Functions' 4.5 MB request body limit, so an upload fits in one request. */
|
|
6
|
-
const ATTACHMENT_BYTES_MAX = 4194304;
|
|
7
|
-
/**
|
|
8
|
-
* The most a file sync brings over from a platform can be. Sync fetches it on the server and
|
|
9
|
-
* stores it in-process, so no request carries it and the request limit doesn't apply: this bounds
|
|
10
|
-
* what one import holds in memory.
|
|
11
|
-
*/
|
|
12
|
-
const IMPORT_BYTES_MAX = 26214400;
|
|
13
|
-
/**
|
|
14
|
-
* The most a direct upload can be: the client sends the bytes straight to the blob store, on a URL
|
|
15
|
-
* the board signs, so no request to the board carries them. Needs a store with `uploadUrl`.
|
|
16
|
-
*/
|
|
17
|
-
const DIRECT_UPLOAD_BYTES_MAX = 104857600;
|
|
18
|
-
/** `120 KB`, `3.4 MB`: a file's size the way people read it. */
|
|
19
|
-
function fileSize(bytes) {
|
|
20
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
21
|
-
if (bytes < 1048576) return `${Math.round(bytes / 1024)} KB`;
|
|
22
|
-
return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
|
23
|
-
}
|
|
24
|
-
const TYPES = {
|
|
25
|
-
".png": "image/png",
|
|
26
|
-
".jpg": "image/jpeg",
|
|
27
|
-
".jpeg": "image/jpeg",
|
|
28
|
-
".gif": "image/gif",
|
|
29
|
-
".webp": "image/webp",
|
|
30
|
-
".avif": "image/avif",
|
|
31
|
-
".svg": "image/svg+xml",
|
|
32
|
-
".mp4": "video/mp4",
|
|
33
|
-
".webm": "video/webm",
|
|
34
|
-
".mov": "video/quicktime",
|
|
35
|
-
".pdf": "application/pdf",
|
|
36
|
-
".txt": "text/plain",
|
|
37
|
-
".log": "text/plain",
|
|
38
|
-
".md": "text/markdown",
|
|
39
|
-
".json": "application/json",
|
|
40
|
-
".csv": "text/csv",
|
|
41
|
-
".html": "text/html",
|
|
42
|
-
".zip": "application/zip"
|
|
43
|
-
};
|
|
44
|
-
/** A file's type from its name, for when nothing better says: browsers leave `.log` untyped. */
|
|
45
|
-
function typeOf(name) {
|
|
46
|
-
const dot = name.lastIndexOf(".");
|
|
47
|
-
return dot > 0 && TYPES[name.slice(dot).toLowerCase()] || "application/octet-stream";
|
|
48
|
-
}
|
|
49
|
-
/** `shot.png`, as the board stores a name: no paths, no control characters. */
|
|
50
|
-
function fileName(name) {
|
|
51
|
-
return (name ?? "").split(/[\\/]/).pop().replace(/[\u0000-\u001f\u007f]/g, "").trim().slice(0, 255) || "file";
|
|
52
|
-
}
|
|
53
|
-
/** `image/png`, or `application/octet-stream` when the type isn't one. */
|
|
54
|
-
function mediaType(type) {
|
|
55
|
-
const value = (type ?? "").split(";")[0].trim().toLowerCase();
|
|
56
|
-
return /^[a-z0-9][a-z0-9!#$&^_.+-]*\/[a-z0-9][a-z0-9!#$&^_.+-]*$/.test(value) && value.length <= 255 ? value : "application/octet-stream";
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
5
|
//#region src/client/sse.ts
|
|
60
6
|
/** Parses a text/event-stream body into messages. */
|
|
61
7
|
async function* parseSse(body, signal) {
|
|
@@ -94,113 +40,6 @@ async function* parseSse(body, signal) {
|
|
|
94
40
|
}
|
|
95
41
|
}
|
|
96
42
|
//#endregion
|
|
97
|
-
//#region src/contract/profile-header.ts
|
|
98
|
-
/** Why a header isn't one: the board's 400 says it. */
|
|
99
|
-
var InvalidProfileHeader = class extends Error {};
|
|
100
|
-
const TOKEN_START = /[A-Za-z*]/;
|
|
101
|
-
const TCHAR = /[!#$%&'*+\-.^_`|~0-9A-Za-z:/]/;
|
|
102
|
-
const KEY_START = /[a-z*]/;
|
|
103
|
-
const KEY_CHAR = /[a-z0-9_\-.*]/;
|
|
104
|
-
/** RFC 8941's other bare items: an integer, a decimal, a boolean, or a byte sequence. */
|
|
105
|
-
const OTHER_ITEM = /^(?:-?\d{1,15}|-?\d{1,12}\.\d{1,3}|\?[01]|:[A-Za-z0-9+/=]*:)$/;
|
|
106
|
-
/** An sf-string: printable ASCII in quotes, with `"` and `\` escaped. */
|
|
107
|
-
function sfString(value) {
|
|
108
|
-
if (!/^[\x20-\x7e]*$/.test(value)) throw new InvalidProfileHeader("an avatar URL is printable ASCII: percent-encode the rest");
|
|
109
|
-
return `"${value.replace(/[\\"]/g, (char) => `\\${char}`)}"`;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* The header's value for a profile: `fixer`, or `fixer;avatar="https://example.com/fixer.png"`,
|
|
113
|
-
* serialized as RFC 8941 says. An avatar outside printable ASCII goes as its URL percent-encodes it.
|
|
114
|
-
*/
|
|
115
|
-
function formatProfileHeader(profile) {
|
|
116
|
-
if (!profile.avatar) return profile.name;
|
|
117
|
-
const avatar = /^[\x20-\x7e]*$/.test(profile.avatar) ? profile.avatar : URL.parse(profile.avatar)?.href ?? profile.avatar;
|
|
118
|
-
return `${profile.name};avatar=${sfString(avatar)}`;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Reads the header as RFC 8941 parses an Item. Its bare item is the profile's name, a token or a
|
|
122
|
-
* string; `avatar` is a string. A parameter it doesn't know is ignored, as structured fields' are,
|
|
123
|
-
* and the last of a repeated one wins. Anything else throws `InvalidProfileHeader`.
|
|
124
|
-
*/
|
|
125
|
-
function parseProfileHeader(value) {
|
|
126
|
-
let at = 0;
|
|
127
|
-
const fail = (why) => {
|
|
128
|
-
throw new InvalidProfileHeader(`x-board-profile is a structured header, like fixer;avatar="https://example.com/fixer.png": ${why}`);
|
|
129
|
-
};
|
|
130
|
-
const spaces = () => {
|
|
131
|
-
while (value[at] === " ") at++;
|
|
132
|
-
};
|
|
133
|
-
const string = () => {
|
|
134
|
-
at++;
|
|
135
|
-
let out = "";
|
|
136
|
-
while (at < value.length) {
|
|
137
|
-
const char = value[at++];
|
|
138
|
-
if (char === "\\") {
|
|
139
|
-
const next = value[at++];
|
|
140
|
-
if (next !== "\"" && next !== "\\") fail("a string escapes only \" and \\");
|
|
141
|
-
out += next;
|
|
142
|
-
} else if (char === "\"") return out;
|
|
143
|
-
else if (char < " " || char > "~") fail("a string is printable ASCII");
|
|
144
|
-
else out += char;
|
|
145
|
-
}
|
|
146
|
-
return fail("a string is missing its closing \"");
|
|
147
|
-
};
|
|
148
|
-
const token = () => {
|
|
149
|
-
const start = at;
|
|
150
|
-
while (at < value.length && TCHAR.test(value[at])) at++;
|
|
151
|
-
return value.slice(start, at);
|
|
152
|
-
};
|
|
153
|
-
/** A bare item: a string, a token, or another of RFC 8941's (a number, a boolean, bytes), which the header names nothing with. */
|
|
154
|
-
const bare = () => {
|
|
155
|
-
const char = value[at];
|
|
156
|
-
if (char === "\"") return {
|
|
157
|
-
kind: "string",
|
|
158
|
-
value: string()
|
|
159
|
-
};
|
|
160
|
-
if (char !== void 0 && TOKEN_START.test(char)) return {
|
|
161
|
-
kind: "token",
|
|
162
|
-
value: token()
|
|
163
|
-
};
|
|
164
|
-
const start = at;
|
|
165
|
-
while (at < value.length && value[at] !== ";" && value[at] !== " ") at++;
|
|
166
|
-
const item = value.slice(start, at);
|
|
167
|
-
if (!OTHER_ITEM.test(item)) fail(item === "" ? "a parameter has no value after its =" : `${item} isn't a value`);
|
|
168
|
-
return {
|
|
169
|
-
kind: "other",
|
|
170
|
-
value: item
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
spaces();
|
|
174
|
-
const name = bare();
|
|
175
|
-
if (name.kind === "other") fail(name.value === "" ? "it names no profile" : `${name.value} isn't a profile's name`);
|
|
176
|
-
let avatar = null;
|
|
177
|
-
while (value[at] === ";") {
|
|
178
|
-
at++;
|
|
179
|
-
spaces();
|
|
180
|
-
if (!KEY_START.test(value[at] ?? "")) fail("a parameter starts with a lowercase letter");
|
|
181
|
-
const start = at;
|
|
182
|
-
while (at < value.length && KEY_CHAR.test(value[at])) at++;
|
|
183
|
-
const key = value.slice(start, at);
|
|
184
|
-
let param = {
|
|
185
|
-
kind: "boolean",
|
|
186
|
-
value: "?1"
|
|
187
|
-
};
|
|
188
|
-
if (value[at] === "=") {
|
|
189
|
-
at++;
|
|
190
|
-
param = bare();
|
|
191
|
-
}
|
|
192
|
-
if (key !== "avatar") continue;
|
|
193
|
-
if (param.kind !== "string") fail("avatar is a string, in quotes");
|
|
194
|
-
avatar = param.value;
|
|
195
|
-
}
|
|
196
|
-
spaces();
|
|
197
|
-
if (at < value.length) fail(`${JSON.stringify(value.slice(at, at + 20))} follows the profile`);
|
|
198
|
-
return {
|
|
199
|
-
name: name.value,
|
|
200
|
-
avatar
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
//#endregion
|
|
204
43
|
//#region src/client/client.ts
|
|
205
44
|
/**
|
|
206
45
|
* What went wrong: `message` says what and why, `code` is what to branch on, `hint`, when there's
|
|
@@ -212,6 +51,8 @@ var BoardError = class extends Error {
|
|
|
212
51
|
status;
|
|
213
52
|
hint;
|
|
214
53
|
origin;
|
|
54
|
+
/** For a 429, how many seconds the board asked to wait before sending again (its `Retry-After`), when it said. */
|
|
55
|
+
retryAfter;
|
|
215
56
|
constructor(code, message, status, options = {}) {
|
|
216
57
|
super(message);
|
|
217
58
|
this.name = "BoardError";
|
|
@@ -219,6 +60,7 @@ var BoardError = class extends Error {
|
|
|
219
60
|
this.status = status;
|
|
220
61
|
this.hint = options.hint;
|
|
221
62
|
this.origin = options.origin ?? "handle";
|
|
63
|
+
this.retryAfter = options.retryAfter;
|
|
222
64
|
}
|
|
223
65
|
};
|
|
224
66
|
/**
|
|
@@ -298,6 +140,13 @@ const withEnvironments = (principal) => (principal.kind === "project" || princip
|
|
|
298
140
|
...principal,
|
|
299
141
|
environments: ["production"]
|
|
300
142
|
} : principal;
|
|
143
|
+
/** A grant as the wire takes it. */
|
|
144
|
+
const wireGrant = (input) => ({
|
|
145
|
+
principals: input.principals.map(withEnvironments),
|
|
146
|
+
can: wireCan(input.can)
|
|
147
|
+
});
|
|
148
|
+
/** What a grant write's body says to go ahead with a lockout: nothing, unless it was asked to. */
|
|
149
|
+
const goAhead = ({ lockMeOut }) => lockMeOut ? { lockMeOut: true } : {};
|
|
301
150
|
/**
|
|
302
151
|
* The principal a private channel lets its creator in as, from what `/me` says it is: a person's
|
|
303
152
|
* user, or a deployment's project in the environment it runs in. Anyone else is refused before
|
|
@@ -511,13 +360,20 @@ function createBoardClient(options) {
|
|
|
511
360
|
principals: [creator],
|
|
512
361
|
can: { [pattern]: "all" }
|
|
513
362
|
} });
|
|
363
|
+
const takeBack = (id) => {
|
|
364
|
+
const revoke = (body) => call("POST", `/grants/${encodeURIComponent(id)}/revoke`, { body });
|
|
365
|
+
return revoke({}).catch((error) => {
|
|
366
|
+
if (error instanceof BoardError && error.code === "grant_lockout") return revoke({ lockMeOut: true });
|
|
367
|
+
throw error;
|
|
368
|
+
});
|
|
369
|
+
};
|
|
514
370
|
const others = (grants, mine) => grants.filter((grant) => {
|
|
515
371
|
const made = mine.find((ours) => ours.id === grant.id);
|
|
516
372
|
return made === void 0 || JSON.stringify([grant.principals, grant.can]) !== JSON.stringify([made.principals, made.can]);
|
|
517
373
|
});
|
|
518
374
|
const raced = others(await reaching(), [own.grant]);
|
|
519
375
|
if (raced.length > 0) {
|
|
520
|
-
await
|
|
376
|
+
await takeBack(own.grant.id);
|
|
521
377
|
throw granted(raced, [own.grant]);
|
|
522
378
|
}
|
|
523
379
|
const closed = await call("POST", "/grants", { body: {
|
|
@@ -526,7 +382,7 @@ function createBoardClient(options) {
|
|
|
526
382
|
} });
|
|
527
383
|
const late = others(await reaching(), [own.grant, closed.grant]);
|
|
528
384
|
if (late.length > 0) {
|
|
529
|
-
for (const id of [closed.grant.id, own.grant.id]) await
|
|
385
|
+
for (const id of [closed.grant.id, own.grant.id]) await takeBack(id);
|
|
530
386
|
throw granted(late, [own.grant, closed.grant]);
|
|
531
387
|
}
|
|
532
388
|
return {
|
|
@@ -628,16 +484,30 @@ function createBoardClient(options) {
|
|
|
628
484
|
* (`[]` for none). The same principals again are another grant. At each channel, the most
|
|
629
485
|
* specific pattern among the grants that name a caller decides, then the closest principal,
|
|
630
486
|
* and grants tied there add up. Needs manage at each pattern `can` names.
|
|
487
|
+
*
|
|
488
|
+
* One you couldn't take back, since it takes your own manage at a pattern it names (closing
|
|
489
|
+
* `security/` to `everyone` closes it to you), is 409 `grant_lockout`: keep yourself in with
|
|
490
|
+
* `createGrants`, or pass `lockMeOut` to make it anyway. Every grant write takes it.
|
|
631
491
|
*/
|
|
632
|
-
createGrant: (input) => call("POST", "/grants", { body: {
|
|
633
|
-
|
|
634
|
-
|
|
492
|
+
createGrant: (input, options = {}) => call("POST", "/grants", { body: {
|
|
493
|
+
...wireGrant(input),
|
|
494
|
+
...goAhead(options)
|
|
495
|
+
} }),
|
|
496
|
+
/**
|
|
497
|
+
* Several grants in one write, all of them or none, judged together: each needs what
|
|
498
|
+
* `createGrant` does on the grants as they are, and what they leave you with is judged with
|
|
499
|
+
* all of them made. So a lock and the grant that keeps you in go together, in any order.
|
|
500
|
+
*/
|
|
501
|
+
createGrants: (inputs, options = {}) => call("POST", "/grants/batch", { body: {
|
|
502
|
+
grants: inputs.map(wireGrant),
|
|
503
|
+
...goAhead(options)
|
|
635
504
|
} }),
|
|
636
505
|
/** 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. */
|
|
637
|
-
updateGrant: (id, { add, remove, can }) => call("PATCH", `/grants/${path(id)}`, { body: {
|
|
506
|
+
updateGrant: (id, { add, remove, can }, options = {}) => call("PATCH", `/grants/${path(id)}`, { body: {
|
|
638
507
|
...add ? { add: add.map(withEnvironments) } : {},
|
|
639
508
|
...remove ? { remove } : {},
|
|
640
|
-
...can ? { can: wireCan(can) } : {}
|
|
509
|
+
...can ? { can: wireCan(can) } : {},
|
|
510
|
+
...goAhead(options)
|
|
641
511
|
} }),
|
|
642
512
|
/**
|
|
643
513
|
* Which grants decide `channel`, and what they give: for you, or with manage at `*`, for the
|
|
@@ -654,7 +524,7 @@ function createBoardClient(options) {
|
|
|
654
524
|
/** The board's grants. Needs manage at `*`, or a team owner. */
|
|
655
525
|
grants: async () => (await call("GET", "/grants")).grants,
|
|
656
526
|
/** `revoked` is false when it was already gone. Its principals' next requests are refused. */
|
|
657
|
-
revokeGrant: (id) => call("POST", `/grants/${path(id)}/revoke`, { body:
|
|
527
|
+
revokeGrant: (id, options = {}) => call("POST", `/grants/${path(id)}/revoke`, { body: goAhead(options) }),
|
|
658
528
|
/** Every schema: the built-ins, then the board's own, by name and version. */
|
|
659
529
|
schemas: async () => (await call("GET", "/schemas")).schemas,
|
|
660
530
|
/** One schema version, by its ID: `sandbox@1`. */
|
|
@@ -844,9 +714,11 @@ function createBoardClient(options) {
|
|
|
844
714
|
async function toError(response) {
|
|
845
715
|
try {
|
|
846
716
|
const body = await response.json();
|
|
717
|
+
const retryAfter = response.status === 429 ? /^\d{1,6}$/.exec(response.headers.get("retry-after") ?? "")?.[0] : void 0;
|
|
847
718
|
if (body.error?.message) return new BoardError(body.error.code ?? "error", body.error.message, response.status, {
|
|
848
719
|
...typeof body.error.hint === "string" ? { hint: body.error.hint } : {},
|
|
849
|
-
origin: handleErrors.has(response) ? "handle" : "board"
|
|
720
|
+
origin: handleErrors.has(response) ? "handle" : "board",
|
|
721
|
+
...retryAfter !== void 0 ? { retryAfter: Number(retryAfter) } : {}
|
|
850
722
|
});
|
|
851
723
|
} catch {}
|
|
852
724
|
return new BoardError("http_error", `The board answered ${`${response.status} ${response.statusText}`.trim()}.`, response.status);
|
|
@@ -860,12 +732,15 @@ var HttpError = class extends Error {
|
|
|
860
732
|
hint;
|
|
861
733
|
/** `handle` for a handle's own error on its way through: everything else is the board's. */
|
|
862
734
|
origin;
|
|
735
|
+
/** For a 429, how many seconds until it's worth sending again, when that's known: the response's `Retry-After`. */
|
|
736
|
+
retryAfter;
|
|
863
737
|
constructor(status, code, message, options = {}) {
|
|
864
738
|
super(message);
|
|
865
739
|
this.status = status;
|
|
866
740
|
this.code = code;
|
|
867
741
|
this.hint = options.hint;
|
|
868
742
|
this.origin = options.origin ?? "board";
|
|
743
|
+
this.retryAfter = options.retryAfter;
|
|
869
744
|
}
|
|
870
745
|
};
|
|
871
746
|
/** A request a host's own verifier rejected with `response`, which the board answers with as it is. */
|
|
@@ -896,6 +771,10 @@ const json = (body, status = 200, headers) => new Response(JSON.stringify(body),
|
|
|
896
771
|
* it's the first issue of the option that came closest, the one with the fewest, at its own path.
|
|
897
772
|
*/
|
|
898
773
|
function reported(issue) {
|
|
774
|
+
if (issue.code === "invalid_key" && issue.issues[0]) return reported({
|
|
775
|
+
...issue.issues[0],
|
|
776
|
+
path: issue.path.slice(0, -1)
|
|
777
|
+
});
|
|
899
778
|
if (issue.code !== "invalid_union" || issue.errors.length === 0) return issue;
|
|
900
779
|
const first = issue.errors.reduce((best, option) => option.length < best.length ? option : best)[0];
|
|
901
780
|
return first ? reported({
|
|
@@ -911,7 +790,7 @@ function toErrorResponse(error) {
|
|
|
911
790
|
code: error.code,
|
|
912
791
|
message: error.message,
|
|
913
792
|
...error.hint !== void 0 ? { hint: error.hint } : {}
|
|
914
|
-
} }, error.status);
|
|
793
|
+
} }, error.status, error.retryAfter !== void 0 ? { "retry-after": String(error.retryAfter) } : void 0);
|
|
915
794
|
if (error.origin === "handle") handleErrors.add(response);
|
|
916
795
|
return response;
|
|
917
796
|
}
|
|
@@ -941,4 +820,4 @@ function toErrorResponse(error) {
|
|
|
941
820
|
} }, 500);
|
|
942
821
|
}
|
|
943
822
|
//#endregion
|
|
944
|
-
export {
|
|
823
|
+
export { duplicateId as a, notFound as c, unauthorized as d, BoardError as f, eventsState as h, batchTooLarge as i, textTooLong as l, duration as m, RejectedError as n, forbidden as o, createBoardClient as p, badRequest as r, json as s, HttpError as t, toErrorResponse as u };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as LabelKey, p as Labels } from "./schemas-
|
|
2
|
-
import { n as ExternalEvent, r as ExternalLocation } from "./external-
|
|
1
|
+
import { d as LabelKey, p as Labels } from "./schemas-TeVe4Udh.mjs";
|
|
2
|
+
import { n as ExternalEvent, r as ExternalLocation } from "./external-BLI4W_-V.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/sync/fn.ts
|
|
5
5
|
const ROUTES = Symbol.for("board.syncRoutes");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./auth-
|
|
3
|
-
import "./backend-
|
|
4
|
-
import {
|
|
1
|
+
import { $ as MessageView } from "./routes-B6SEA9yw.mjs";
|
|
2
|
+
import "./auth-Z9-Khvvw.mjs";
|
|
3
|
+
import "./backend-BzCXxVZ-.mjs";
|
|
4
|
+
import { g as TaskInBatch, n as BoardError } from "./client-C2T4eaXd.mjs";
|
|
5
5
|
//#region src/client/chunks.d.ts
|
|
6
6
|
/** What `createTasksInChunks` makes tasks with: a handle, or anything with its `tasks.createMany`. */
|
|
7
7
|
type TaskBatches = {
|