@vercel/board 0.32.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -20
- package/dist/{access-CY5xVMIK.mjs → access-N3XmkKXg.mjs} +3 -3
- package/dist/access.d.mts +4 -5
- package/dist/access.mjs +5 -5
- package/dist/{actors-Bm-ojWWT.mjs → actors-ihyN47OV.mjs} +3 -3
- package/dist/{auth-K8dY1nBY.d.mts → auth-D6z3rMNj.d.mts} +7 -93
- package/dist/{auth-8pRZnF1M.mjs → auth-r-_PeZyw.mjs} +32 -148
- package/dist/{backend-DxE9wGKm.d.mts → backend-CWpyR1A7.d.mts} +81 -51
- package/dist/backend-local.d.mts +28 -0
- package/dist/backend-local.mjs +2 -0
- package/dist/{chat-provider-DkFp2hrh.mjs → chat-provider-9hCT654s.mjs} +2 -2
- package/dist/{chat-provider-BChYrrA7.d.mts → chat-provider-DJpFUaFv.d.mts} +2 -3
- 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 +1 -1
- package/dist/cli.mjs +6 -6
- package/dist/{commands-CpyPV_tk.d.mts → commands-BOBQHVqM.d.mts} +9 -0
- package/dist/{commands-DsnQKTdB.mjs → commands-CHoMl06v.mjs} +12 -1
- package/dist/{conformance-3RBKxwbp.mjs → conformance-qKmGLTAT.mjs} +5 -5
- package/dist/conformance.d.mts +1 -1
- package/dist/conformance.mjs +1 -1
- package/dist/{engine-DurYIRt8.mjs → engine-JxgZiikU.mjs} +6 -8
- package/dist/{errors-CJXhhzvT.mjs → errors-Pk0XV1hK.mjs} +56 -2
- package/dist/{events-lujPA3gQ.mjs → events-IQg0k281.mjs} +2 -2
- package/dist/exports-BuKjVq2t.d.mts +4 -0
- package/dist/exports-gHDHlg0i.mjs +3207 -0
- package/dist/{external-D3p5T57R.mjs → external-CYe424fO.mjs} +1 -1
- package/dist/{folds-DLUzfibJ.d.mts → folds-DjFTiqIM.d.mts} +38 -44
- package/dist/index-CXvvYNYj.d.mts +11 -0
- package/dist/index.d.mts +9 -8
- package/dist/index.mjs +21 -8
- package/dist/index.node.d.mts +5 -6
- package/dist/index.node.mjs +3 -3
- package/dist/inspect/app.js +95 -95
- package/dist/{internal-CvsrprnU-zZMpDiRY.mjs → internal-CvsrprnU-CEPOUpAv.mjs} +63 -43
- package/dist/local-BbLjA5vI.mjs +8818 -0
- package/dist/{main-CcYDo9Hb.mjs → main-CQpCZJFw.mjs} +91 -23
- package/dist/{backend-a2/store-memory.mjs → memory-7RRnLa4X.mjs} +3 -3
- package/dist/middleware-BU7rVi9F.mjs +103 -0
- package/dist/{client-COfYrgfV.d.mts → provider-BlzUvcM9.d.mts} +665 -5
- package/dist/{schemas-DBmUO6pr.mjs → schemas-BG205xds.mjs} +2 -5
- package/dist/{serve-Bplieh0C.mjs → serve-D8_W4UN6.mjs} +33 -24
- package/dist/{node-BgeGcwX0.mjs → server-BiIUXWbU.mjs} +419 -6
- package/dist/{serving-Y7s7VDjB.mjs → serving-D7rcUtSC.mjs} +1 -1
- package/dist/{sql-E1K5g_ih.mjs → sql-BQzKUqQt.mjs} +349 -114
- package/dist/sqlite-DCtZFEVm.mjs +30 -0
- package/dist/{sqlite-db-CzcD_FW8.mjs → sqlite-db-qLTs52Ny.mjs} +2 -3
- package/dist/{store-codec-pAG2oPgQ-SqDXlPBR.mjs → store-N8PXxDAS-BdL4Sq-f.mjs} +6 -2
- package/dist/{store-memory-B0PkVSuQ.mjs → store-memory-CKQVEzXN.mjs} +2 -4
- package/dist/store-memory-OdGsc-t_.mjs +2 -0
- package/dist/{store-polling-BZt2Rf3D-Div-bJ_D.mjs → store-polling-BZt2Rf3D-oh3aU_An.mjs} +1 -1
- package/dist/store-sqlite-CTxAVCcz.mjs +2 -0
- package/dist/{store-sqlite-D85t3tE7.mjs → store-sqlite-D6fIszST.mjs} +3 -4
- 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 +2 -3
- package/dist/sync-linear.mjs +2 -2
- package/dist/sync-slack.d.mts +3 -3
- package/dist/sync-slack.mjs +4 -4
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/{watchers-hash-CurCzwhe.mjs → targets-CknPGGVi.mjs} +40 -10
- package/dist/{tokens-C7kYyrAG.mjs → tokens-DPKjl3jf.mjs} +15 -43
- package/docs/01-board/01-mounting.md +243 -288
- package/docs/01-board/03-identity.md +41 -50
- package/docs/01-board/04-messages.md +15 -14
- package/docs/01-board/05-reading.md +3 -3
- package/docs/01-board/06-watchers.md +58 -105
- package/docs/01-board/07-schedules.md +21 -41
- package/docs/01-board/08-middleware.md +11 -17
- package/docs/01-board/09-access.md +76 -313
- package/docs/01-board/10-local.md +81 -0
- package/docs/01-quickstart.md +49 -126
- package/docs/02-sync/01-overview.md +25 -80
- package/docs/02-sync/02-functions.md +10 -16
- package/docs/02-sync/03-slack.md +13 -26
- package/docs/02-sync/04-github.md +8 -20
- package/docs/02-sync/07-linear.md +6 -10
- package/docs/03-guides/02-inspector.md +3 -3
- package/docs/03-guides/03-ci.md +88 -128
- package/docs/03-guides/04-triage.md +7 -15
- package/docs/03-guides/05-agent-factory.md +30 -36
- package/docs/04-reference/01-cli.md +104 -22
- package/docs/04-reference/02-board.md +60 -74
- package/docs/04-reference/03-http.md +119 -57
- package/docs/04-reference/05-conformance.md +31 -45
- package/docs/index.md +41 -65
- package/package.json +12 -83
- package/dist/a2-DiDc77Uf.mjs +0 -4238
- package/dist/access-DPcrKIH_.d.mts +0 -37
- package/dist/backend-a2/blob-vercel.d.mts +0 -8
- package/dist/backend-a2/blob-vercel.mjs +0 -81
- package/dist/backend-a2/contract.d.mts +0 -828
- package/dist/backend-a2/contract.mjs +0 -5
- package/dist/backend-a2/scheduler-local.d.mts +0 -11
- package/dist/backend-a2/scheduler-local.mjs +0 -2
- package/dist/backend-a2/scheduler-qstash.d.mts +0 -79
- package/dist/backend-a2/scheduler-qstash.mjs +0 -522
- package/dist/backend-a2/scheduler-vercel.d.mts +0 -38
- package/dist/backend-a2/scheduler-vercel.mjs +0 -204
- package/dist/backend-a2/store-memory.d.mts +0 -11
- package/dist/backend-a2/store-postgres.d.mts +0 -38
- package/dist/backend-a2/store-postgres.mjs +0 -2977
- package/dist/backend-a2/store-redis-http.d.mts +0 -17
- package/dist/backend-a2/store-redis-http.mjs +0 -520
- package/dist/backend-a2/store-redis.d.mts +0 -31
- package/dist/backend-a2/store-redis.mjs +0 -88
- package/dist/backend-a2/store-sqlite.d.mts +0 -12
- package/dist/backend-a2/store-sqlite.mjs +0 -31
- package/dist/backend-a2.d.mts +0 -2633
- package/dist/backend-a2.mjs +0 -3
- package/dist/backend-http-CaN06CaD.d.mts +0 -672
- package/dist/backend-http-CoaCghuJ.mjs +0 -18
- package/dist/backend-http-l5A8UmL-.mjs +0 -585
- package/dist/backend-http.d.mts +0 -10
- package/dist/backend-http.mjs +0 -2
- package/dist/backend-http.node.d.mts +0 -10
- package/dist/backend-http.node.mjs +0 -2
- package/dist/backend-vercel-BE65okBC.mjs +0 -86
- package/dist/backend-vercel-CVxoTNF2.mjs +0 -1744
- package/dist/backend-vercel-jg-6PAgD.d.mts +0 -674
- package/dist/backend-vercel.d.mts +0 -9
- package/dist/backend-vercel.mjs +0 -11
- package/dist/backend-vercel.node.d.mts +0 -17
- package/dist/backend-vercel.node.mjs +0 -2
- package/dist/blob-Bx8QPWEd.d.mts +0 -40
- package/dist/blob-WbB2DJKn.mjs +0 -201
- package/dist/errors-2vGs49Db.d.mts +0 -16
- package/dist/exports-BnUZuRm9.mjs +0 -1389
- package/dist/exports-u5mApVvn.d.mts +0 -5
- package/dist/files-SniSmeEr.mjs +0 -47
- package/dist/folds-DsWfIftc.mjs +0 -208
- package/dist/index-UXpTPWNc.d.mts +0 -11
- package/dist/index.default-Dp8gexln.mjs +0 -12
- package/dist/local-C76Fy5ad.mjs +0 -44
- package/dist/middleware-BavYSDUa.mjs +0 -62
- package/dist/platform-B4TnJtWu-Do3agKr5.mjs +0 -32
- package/dist/project-4Vl7_uy5.mjs +0 -124
- package/dist/provider-gynDUoyW.d.mts +0 -665
- package/dist/redis-tables-BFRj_SEJ.mjs +0 -3895
- package/dist/reducer-Bswr11ar-P324o9vn.mjs +0 -74
- package/dist/reducer-CYPHsSmd-BXjGiptm.d.mts +0 -170
- package/dist/reducers-DQVSP3kk.mjs +0 -538
- package/dist/retryable-lazy-DZWmHpii-DpTc5PIP.mjs +0 -19
- package/dist/scheduler-task-X1SToDjP-D2Il2rln.mjs +0 -69
- package/dist/server-B9gu0qi1-DI1WvcVK.d.mts +0 -391
- package/dist/server-DX7mM6nm-D7N_7bug.mjs +0 -3611
- package/dist/server-wIpAEjpX.mjs +0 -17
- package/dist/session-clear-XJYpmUpg-2q8l_FJR.mjs +0 -63
- package/dist/store-DEzcHZOA-B-5vhxef.d.mts +0 -540
- package/dist/store-N8PXxDAS-DWWgv-Vz.mjs +0 -5
- package/dist/store-memory-4IBl0Ztu.mjs +0 -2
- package/dist/store-presence-polling-JuAy2Ck2-Dh-g_KYM.mjs +0 -109
- package/dist/store-sqlite-iBTYYKBj.mjs +0 -2
- package/dist/stream-buffer-DrTyiIuo-Be10yOBR.mjs +0 -53
- package/dist/targets-Cgjs29T0.mjs +0 -33
- package/dist/types-CmrFjpml.d.mts +0 -102
- package/dist/wait-until-Dw4XrIDQ.mjs +0 -42
- package/docs/01-board/02-database.md +0 -258
- package/docs/04-reference/04-log.md +0 -247
- package/sql/postgres/board.sql +0 -145
- package/sql/postgres/notifications.sql +0 -24
- package/sql/postgres/schema.sql +0 -451
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
//#region src/contract/schemas.ts
|
|
3
|
-
const CHANNEL_PATH_MAX = 80;
|
|
4
2
|
const MESSAGE_TEXT_MAX = 1e4;
|
|
5
3
|
/** The longest `x-board-scope` header the board reads; a schedule keeps its creator's. */
|
|
6
4
|
const SCOPE_MAX = 4e3;
|
|
7
|
-
const ATTACHMENTS_PER_MESSAGE_MAX = 10;
|
|
8
5
|
const segment = "[a-z0-9][a-z0-9_-]*";
|
|
9
6
|
/** `errors-www`, `www/production`: lowercase segments joined by `/`. */
|
|
10
7
|
const ChannelPath = z.string().max(80).regex(new RegExp(`^${segment}(?:/${segment})*$`), "invalid channel path");
|
|
@@ -60,7 +57,7 @@ const Author = z.object({
|
|
|
60
57
|
session: z.string().nullable()
|
|
61
58
|
});
|
|
62
59
|
/** 128 random bits, base64url: an attachment is named by an ID nobody can guess. */
|
|
63
|
-
/** 128 random bits, base64url, as
|
|
60
|
+
/** 128 random bits, base64url, as a board on this machine makes them; or `att_` and a UUID, as Vercel's board does. */
|
|
64
61
|
const AttachmentId = z.string().regex(/^(?:[A-Za-z0-9_-]{22}|att_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/, "invalid attachment id");
|
|
65
62
|
/** A file on a message. The board records `type` and `size` from what it stored, never from the request. */
|
|
66
63
|
const Attachment = z.object({
|
|
@@ -72,4 +69,4 @@ const Attachment = z.object({
|
|
|
72
69
|
/** A registered watcher's ID: a profile name, since its writes are by that profile. */
|
|
73
70
|
const RemoteWatcherId = z.string().regex(/^[A-Za-z][A-Za-z0-9-]{0,31}$/, "ids start with a letter and use up to 32 letters, numbers, and hyphens");
|
|
74
71
|
//#endregion
|
|
75
|
-
export {
|
|
72
|
+
export { actorKind as _, ChannelPath as a, toStorable as b, LabelKey as c, MESSAGE_TEXT_MAX as d, MessageId as f, SeenActorKind as g, SCOPE_MAX as h, Author as i, LabelValue as l, RemoteWatcherId as m, Attachment as n, Emoji as o, MessageText as p, AttachmentId as r, Handle as s, ActorId as t, Labels as u, platformAvatar as v, storable as y };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { u as BoardError } from "./errors-
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import { t as
|
|
5
|
-
import {
|
|
6
|
-
import { a as fsBlob } from "./blob-WbB2DJKn.mjs";
|
|
7
|
-
import { t as localScheduler } from "./local-C76Fy5ad.mjs";
|
|
8
|
-
import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
1
|
+
import { u as BoardError } from "./errors-Pk0XV1hK.mjs";
|
|
2
|
+
import { t as board, u as localTokenFile } from "./server-BiIUXWbU.mjs";
|
|
3
|
+
import { t as oidcTokens } from "./tokens-DPKjl3jf.mjs";
|
|
4
|
+
import { t as local } from "./local-BbLjA5vI.mjs";
|
|
5
|
+
import { mkdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
9
6
|
import { userInfo } from "node:os";
|
|
10
7
|
import { dirname, join, resolve } from "node:path";
|
|
11
8
|
import { SignJWT, createLocalJWKSet, exportJWK, generateKeyPair } from "jose";
|
|
@@ -23,12 +20,22 @@ function safeUsername() {
|
|
|
23
20
|
return process.env.USER || process.env.USERNAME || "me";
|
|
24
21
|
}
|
|
25
22
|
}
|
|
23
|
+
/** What an earlier `vb serve` left under `dir` (`board.db`, `attachments/`), moved to where `local()` keeps the board. */
|
|
24
|
+
async function carryOver(dir) {
|
|
25
|
+
const there = (path) => stat(join(dir, path)).then(() => true, () => false);
|
|
26
|
+
if (!await there("board.db") || await there("local.db")) return;
|
|
27
|
+
for (const suffix of [
|
|
28
|
+
"",
|
|
29
|
+
"-wal",
|
|
30
|
+
"-shm"
|
|
31
|
+
]) if (await there(`board.db${suffix}`)) await rename(join(dir, `board.db${suffix}`), join(dir, `local.db${suffix}`));
|
|
32
|
+
if (await there("attachments") && !await there("local")) await rename(join(dir, "attachments"), join(dir, "local"));
|
|
33
|
+
}
|
|
26
34
|
/**
|
|
27
|
-
* A board on this machine, for agents and people sharing one computer:
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* only you can read (`localTokenFile`), which `vb` on this machine picks up.
|
|
35
|
+
* A board on this machine, for agents and people sharing one computer: `local()` under `dir`, its
|
|
36
|
+
* log in SQLite, attachments next to it, a scheduler in this process, no sync, on 127.0.0.1 only.
|
|
37
|
+
* Its keys live in memory for this run; it signs one token, for you, into a file only you can read
|
|
38
|
+
* (`localTokenFile`), which `vb` on this machine picks up.
|
|
32
39
|
*/
|
|
33
40
|
async function serveLocal(options) {
|
|
34
41
|
const dir = resolve(options.dir);
|
|
@@ -37,8 +44,8 @@ async function serveLocal(options) {
|
|
|
37
44
|
mode: 448
|
|
38
45
|
});
|
|
39
46
|
quietSqliteWarning();
|
|
40
|
-
|
|
41
|
-
const
|
|
47
|
+
await carryOver(dir);
|
|
48
|
+
const backend = local({ dir });
|
|
42
49
|
const { publicKey, privateKey } = await generateKeyPair("ES256");
|
|
43
50
|
const jwks = createLocalJWKSet({ keys: [{
|
|
44
51
|
...await exportJWK(publicKey),
|
|
@@ -54,24 +61,26 @@ async function serveLocal(options) {
|
|
|
54
61
|
try {
|
|
55
62
|
port = await listen(server, options.port ?? 4100);
|
|
56
63
|
} catch (error) {
|
|
57
|
-
await store.close();
|
|
58
64
|
if (error.code === "EADDRINUSE") throw new BoardError("port_taken", `Port ${options.port ?? 4100} is taken. Is a board already running there?`, 0);
|
|
59
65
|
throw error;
|
|
60
66
|
}
|
|
61
67
|
const url = `http://127.0.0.1:${port}/api/board`;
|
|
62
|
-
|
|
63
|
-
backend
|
|
64
|
-
store,
|
|
65
|
-
scheduler: localScheduler(),
|
|
66
|
-
blob: fsBlob(join(dir, "attachments"))
|
|
67
|
-
}),
|
|
68
|
+
const mounted = board({
|
|
69
|
+
backend,
|
|
68
70
|
authenticate: oidcTokens({ local: {
|
|
69
71
|
issuer: ISSUER,
|
|
70
72
|
jwks
|
|
71
73
|
} }),
|
|
72
74
|
url,
|
|
73
75
|
basePath: "/api/board"
|
|
74
|
-
})
|
|
76
|
+
});
|
|
77
|
+
try {
|
|
78
|
+
await mounted.channels();
|
|
79
|
+
} catch (error) {
|
|
80
|
+
server.close();
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
handler = mounted.fetch;
|
|
75
84
|
const handle = options.handle ?? localHandle();
|
|
76
85
|
const token = await new SignJWT({}).setProtectedHeader({
|
|
77
86
|
alg: "ES256",
|
|
@@ -97,7 +106,7 @@ async function serveLocal(options) {
|
|
|
97
106
|
await rm(file, { force: true });
|
|
98
107
|
server.closeAllConnections();
|
|
99
108
|
await new Promise((done) => server.close(() => done()));
|
|
100
|
-
await
|
|
109
|
+
await backend.close();
|
|
101
110
|
}
|
|
102
111
|
};
|
|
103
112
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { u as BoardError } from "./errors-
|
|
1
|
+
import { d as createBoardClient, o as json, t as HttpError, u as BoardError } from "./errors-Pk0XV1hK.mjs";
|
|
2
|
+
import "./schemas-BG205xds.mjs";
|
|
3
|
+
import { N as RegisterBody, a as compileWatcher, c as METHODS, i as canonicalWatchers, q as routes } from "./targets-CknPGGVi.mjs";
|
|
4
|
+
import { a as DERIVED_ID, c as keyId, l as sha256 } from "./middleware-BU7rVi9F.mjs";
|
|
5
|
+
import { a as registrant, o as wakePath, r as createVercel, t as createBoard } from "./exports-gHDHlg0i.mjs";
|
|
2
6
|
import { execFile } from "node:child_process";
|
|
3
7
|
import { createHash } from "node:crypto";
|
|
4
8
|
import { mkdir, readFile, readdir, stat, unlink, writeFile } from "node:fs/promises";
|
|
@@ -148,14 +152,14 @@ async function writeCache(audience, login, cached) {
|
|
|
148
152
|
}
|
|
149
153
|
}
|
|
150
154
|
/** The login a CLI that runs board's hands it to ask for (`vercel board`'s), while one does. */
|
|
151
|
-
let handed = null;
|
|
155
|
+
let handed$1 = null;
|
|
152
156
|
/**
|
|
153
157
|
* Hands board a login to ask for when a request needs one, as `vercel board` does with its own:
|
|
154
158
|
* nothing asks for it before then, so help, a typo, or misuse never refreshes or prompts. Null
|
|
155
159
|
* takes it back.
|
|
156
160
|
*/
|
|
157
161
|
function handLogin(login) {
|
|
158
|
-
handed = login;
|
|
162
|
+
handed$1 = login;
|
|
159
163
|
}
|
|
160
164
|
/** The fetch a CLI that runs board's hands it for Vercel's API (`vercel board`'s), while one does. */
|
|
161
165
|
let handedFetch = null;
|
|
@@ -182,12 +186,12 @@ function asYou(input, init, login, send = fetch) {
|
|
|
182
186
|
});
|
|
183
187
|
}
|
|
184
188
|
/** Whether the login is one a CLI handed over (`createApp`'s `login`, or `VERCEL_AUTH_TOKEN`). */
|
|
185
|
-
const loginHanded = () => handed !== null || !!process.env.VERCEL_AUTH_TOKEN;
|
|
189
|
+
const loginHanded = () => handed$1 !== null || !!process.env.VERCEL_AUTH_TOKEN;
|
|
186
190
|
/**
|
|
187
191
|
* Your Vercel login: what the CLI that runs board's hands it, as `vercel board` does (its `login`,
|
|
188
192
|
* or `VERCEL_AUTH_TOKEN` from its `--token`), or else what `vercel login` saved.
|
|
189
193
|
*/
|
|
190
|
-
const vercelLogin = () => handed ? handed() : process.env.VERCEL_AUTH_TOKEN ? Promise.resolve(process.env.VERCEL_AUTH_TOKEN) : getVercelToken();
|
|
194
|
+
const vercelLogin = () => handed$1 ? handed$1() : process.env.VERCEL_AUTH_TOKEN ? Promise.resolve(process.env.VERCEL_AUTH_TOKEN) : getVercelToken();
|
|
191
195
|
/**
|
|
192
196
|
* A handed login's token, which its board tokens are cached by: null for `vercel login`'s own. One
|
|
193
197
|
* that fails fails the request: `vercel login`'s, cached or in the `vercel` on PATH, can be someone
|
|
@@ -679,4 +683,413 @@ const vercelCliApi = async (method, path) => {
|
|
|
679
683
|
}
|
|
680
684
|
};
|
|
681
685
|
//#endregion
|
|
682
|
-
|
|
686
|
+
//#region src/server/backend-http.ts
|
|
687
|
+
/** A watcher's or client's name is the profile its writes are by. */
|
|
688
|
+
const PROFILE = /^[A-Za-z][A-Za-z0-9-]{0,31}$/;
|
|
689
|
+
const PROFILE_RULE = "ids start with a letter and use up to 32 letters, numbers, and hyphens";
|
|
690
|
+
const describe = (error) => ((error instanceof Error ? error.message : String(error)) || "unknown error").slice(0, 500);
|
|
691
|
+
/** The SDK's error, as the board answers it: the remote's own status and code, or 502 when it never answered. */
|
|
692
|
+
const rethrow = (error) => {
|
|
693
|
+
if (error instanceof BoardError) throw new HttpError(error.status >= 400 ? error.status : 502, error.code, error.message, {
|
|
694
|
+
...error.hint !== void 0 ? { hint: error.hint } : {},
|
|
695
|
+
origin: error.origin
|
|
696
|
+
});
|
|
697
|
+
if (error instanceof HttpError || error instanceof Error && error.name === "AbortError") throw error;
|
|
698
|
+
throw new HttpError(502, "unreachable", `the board didn't answer: ${describe(error)}`);
|
|
699
|
+
};
|
|
700
|
+
/** A parsed input, back on the wire as a query string. */
|
|
701
|
+
function queryString(input) {
|
|
702
|
+
const params = new URLSearchParams();
|
|
703
|
+
for (const [key, value] of Object.entries(input)) {
|
|
704
|
+
if (value === void 0 || value === null || value === false) continue;
|
|
705
|
+
if (key === "label" && Array.isArray(value)) for (const [name, values] of value) params.append("label", values === null ? name : `${name}=${values.join("|")}`);
|
|
706
|
+
else if (Array.isArray(value)) for (const item of value) params.append(key, String(item));
|
|
707
|
+
else params.set(key, String(value));
|
|
708
|
+
}
|
|
709
|
+
const text = params.toString();
|
|
710
|
+
return text ? `?${text}` : "";
|
|
711
|
+
}
|
|
712
|
+
/** A file the remote served, as the board stored it: its headers say what it is. */
|
|
713
|
+
function attachmentOf(id, response) {
|
|
714
|
+
const encoded = (response.headers.get("content-disposition") ?? "").match(/filename\*=UTF-8''([^;]+)/)?.[1];
|
|
715
|
+
let name = "file";
|
|
716
|
+
try {
|
|
717
|
+
if (encoded) name = decodeURIComponent(encoded);
|
|
718
|
+
} catch {}
|
|
719
|
+
return {
|
|
720
|
+
attachment: {
|
|
721
|
+
id,
|
|
722
|
+
name,
|
|
723
|
+
type: response.headers.get("content-type") ?? "application/octet-stream",
|
|
724
|
+
size: Number(response.headers.get("content-length") ?? 0)
|
|
725
|
+
},
|
|
726
|
+
data: response.body ?? /* @__PURE__ */ new Uint8Array()
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Another board that speaks the protocol, at `url` (in Node, the one the environment points at
|
|
731
|
+
* by default): this board keeps nothing, and this deployment reads and writes that one as itself.
|
|
732
|
+
* Its watchers' tails are registered there. The remote wakes it when one matches, with nothing in
|
|
733
|
+
* the wake-up but a hash, and it pulls what matched with its own credentials, runs it, and acks
|
|
734
|
+
* it. When it can't be woken (no https URL of its own: a dev server, say), it pulls on its own.
|
|
735
|
+
*/
|
|
736
|
+
function createHttp(url, options, environment) {
|
|
737
|
+
if (url !== void 0 && !/^https?:\/\/[^/]/.test(url)) throw new Error(`http: ${url} isn't a URL: pass the board's, like https://board.example.com/api/board`);
|
|
738
|
+
if (url === void 0 && !environment) throw new Error("http: pass the board's URL: outside Node there's no environment to find it in");
|
|
739
|
+
const remote = (url ?? environment.url()).replace(/\/+$/, "");
|
|
740
|
+
const doFetch = options.fetch ?? environment?.fetch(remote) ?? ((input, init) => globalThis.fetch(input, init));
|
|
741
|
+
let binding = null;
|
|
742
|
+
const specs = {};
|
|
743
|
+
/** This board's sync entries, registered there when it syncs. */
|
|
744
|
+
let sync = [];
|
|
745
|
+
let hash = null;
|
|
746
|
+
/** What every wake-up carries, so the board it uses can tell it's stale. */
|
|
747
|
+
const watchersHash = () => hash ??= sha256(canonicalWatchers(specs, sync)).then((hex) => hex.slice(0, 32));
|
|
748
|
+
const bound = () => {
|
|
749
|
+
if (!binding) throw new Error("http: this backend isn't serving a board yet: pass it to board({ backend })");
|
|
750
|
+
return binding;
|
|
751
|
+
};
|
|
752
|
+
/**
|
|
753
|
+
* The SDK against the remote, as this deployment with `profile`. `quiet` names no session: this
|
|
754
|
+
* deployment's own code. Otherwise a profile chosen in code keeps the environment's session, and
|
|
755
|
+
* yourself (`null`) has none. Who the token's holder is, `fetch` says.
|
|
756
|
+
*/
|
|
757
|
+
const sdk = (profile, quiet) => createBoardClient({
|
|
758
|
+
url: remote,
|
|
759
|
+
fetch: doFetch,
|
|
760
|
+
profile: profile !== void 0 ? profile : () => environment?.profile().profile ?? null,
|
|
761
|
+
session: quiet || profile === null ? null : () => environment?.profile().session ?? null
|
|
762
|
+
});
|
|
763
|
+
const own = sdk(null, true);
|
|
764
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
765
|
+
/** This deployment as `profile`: a watcher's ID, or the middleware. */
|
|
766
|
+
function asProfile(profile) {
|
|
767
|
+
if (!PROFILE.test(profile)) throw new HttpError(400, "invalid_request", `as: ${profile}: profiles start with a letter and use up to 32 letters, numbers, and hyphens`);
|
|
768
|
+
let client = profiles.get(profile);
|
|
769
|
+
if (!client) profiles.set(profile, client = sdk(profile, true));
|
|
770
|
+
return client;
|
|
771
|
+
}
|
|
772
|
+
const holders = /* @__PURE__ */ new Map();
|
|
773
|
+
/** The token's holder, with `profile` (`undefined`: the environment's). */
|
|
774
|
+
function holder(profile) {
|
|
775
|
+
const key = JSON.stringify(profile ?? (profile === null ? null : "\0"));
|
|
776
|
+
let client = holders.get(key);
|
|
777
|
+
if (!client) holders.set(key, client = sdk(profile, false));
|
|
778
|
+
return client;
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* The client a call of this deployment's own code goes through: a handle's, as the token's holder
|
|
782
|
+
* with its profile; a watcher's or the middleware's, as this deployment with theirs; and sync's,
|
|
783
|
+
* as the deployment itself.
|
|
784
|
+
*/
|
|
785
|
+
function clientOf(caller) {
|
|
786
|
+
if (caller.origin.via?.kind === "engine") return own;
|
|
787
|
+
if (caller.origin.via?.kind === "client") {
|
|
788
|
+
if (caller.self !== null) asProfile(caller.self);
|
|
789
|
+
return holder("profile" in caller ? caller.profile : caller.self ?? void 0);
|
|
790
|
+
}
|
|
791
|
+
return asProfile(caller.self ?? "client");
|
|
792
|
+
}
|
|
793
|
+
let discovered = null;
|
|
794
|
+
/** The board it uses' discovery, for a handle here: who it is, and the sync entries it lists. */
|
|
795
|
+
const discovery = () => (discovered ??= doFetch(remote).then(async (response) => {
|
|
796
|
+
if (!response.ok) throw new HttpError(response.status >= 400 ? response.status : 502, "no_board", `There's no board at ${remote}: it answered ${response.status}.`, { origin: "handle" });
|
|
797
|
+
return await response.json();
|
|
798
|
+
}, rethrow)).catch((error) => {
|
|
799
|
+
discovered = null;
|
|
800
|
+
throw error;
|
|
801
|
+
});
|
|
802
|
+
let principal = null;
|
|
803
|
+
/** This deployment's principal on the remote, asked once. */
|
|
804
|
+
const self = () => principal ??= own.me().then((me) => me.principal).catch((error) => {
|
|
805
|
+
principal = null;
|
|
806
|
+
throw error;
|
|
807
|
+
});
|
|
808
|
+
/**
|
|
809
|
+
* A post's ID, from the one board() derived for it, under this deployment's own principal: the
|
|
810
|
+
* remote takes a `key:<principal>:` ID only from that principal, so no one can post with it first.
|
|
811
|
+
*/
|
|
812
|
+
const ownKey = async (derived) => keyId(await self(), derived);
|
|
813
|
+
/** One protocol call on the remote, as `client`: the same route, with the input back on the wire. */
|
|
814
|
+
async function call(client, method, input, signal) {
|
|
815
|
+
const route = routes[method];
|
|
816
|
+
const fields = { ...input };
|
|
817
|
+
const path = route.path.replace(/:(\w+)/g, (_, name) => {
|
|
818
|
+
const value = fields[name];
|
|
819
|
+
delete fields[name];
|
|
820
|
+
return encodeURIComponent(String(value));
|
|
821
|
+
});
|
|
822
|
+
let response;
|
|
823
|
+
if (method === "upload") {
|
|
824
|
+
const { data, name, type } = input;
|
|
825
|
+
if (data.byteLength > 4194304) {
|
|
826
|
+
const attachment = await client.upload({
|
|
827
|
+
data,
|
|
828
|
+
name: name ?? "file",
|
|
829
|
+
...type ? { type } : {}
|
|
830
|
+
}).catch(rethrow);
|
|
831
|
+
return Response.json({ attachment });
|
|
832
|
+
}
|
|
833
|
+
response = await client.request(path, {
|
|
834
|
+
method: "POST",
|
|
835
|
+
body: data,
|
|
836
|
+
headers: {
|
|
837
|
+
...type ? { "content-type": type } : {},
|
|
838
|
+
...name !== null ? { "x-board-filename": encodeURIComponent(name) } : {}
|
|
839
|
+
},
|
|
840
|
+
signal
|
|
841
|
+
}).catch(rethrow);
|
|
842
|
+
} else if (route.method === "GET") response = await client.request(`${path}${queryString(fields)}`, { signal }).catch(rethrow);
|
|
843
|
+
else response = await client.request(path, {
|
|
844
|
+
method: "POST",
|
|
845
|
+
body: new TextEncoder().encode(JSON.stringify(fields)),
|
|
846
|
+
headers: { "content-type": "application/json" },
|
|
847
|
+
signal
|
|
848
|
+
}).catch(rethrow);
|
|
849
|
+
if (response.ok) return response;
|
|
850
|
+
try {
|
|
851
|
+
const body = await response.json();
|
|
852
|
+
if (body.error?.message) throw new HttpError(response.status, body.error.code ?? "error", body.error.message, typeof body.error.hint === "string" ? { hint: body.error.hint } : {});
|
|
853
|
+
} catch (error) {
|
|
854
|
+
if (error instanceof HttpError) throw error;
|
|
855
|
+
}
|
|
856
|
+
throw new HttpError(502, "remote_error", `${remote} answered ${response.status}`);
|
|
857
|
+
}
|
|
858
|
+
/** A protocol method, called on the board it uses, as `caller`. */
|
|
859
|
+
async function remoteCall(method, caller, input, signal) {
|
|
860
|
+
const registering = start();
|
|
861
|
+
if ("identity" in caller) throw new HttpError(404, "not_found", `this board uses ${remote}, and answers only wake-ups and webhooks`);
|
|
862
|
+
const client = clientOf(caller);
|
|
863
|
+
if ("self" in caller && caller.origin.via?.kind === "engine") await registering;
|
|
864
|
+
if ((method === "post" || method === "posted") && "self" in caller && typeof input.id === "string" && DERIVED_ID.test(input.id)) input = {
|
|
865
|
+
...input,
|
|
866
|
+
id: await ownKey(input.id).catch(rethrow)
|
|
867
|
+
};
|
|
868
|
+
const response = await call(client, method, input, signal);
|
|
869
|
+
return method === "attachment" ? attachmentOf(String(input.id), response) : response.json();
|
|
870
|
+
}
|
|
871
|
+
const methods = {
|
|
872
|
+
...Object.fromEntries(METHODS.map((method) => [method, (caller, input, signal) => remoteCall(method, caller, input, signal)])),
|
|
873
|
+
async discovery() {
|
|
874
|
+
return discovery();
|
|
875
|
+
},
|
|
876
|
+
async readSource(caller, input, signal) {
|
|
877
|
+
if ("self" in caller && bound().sync.some((entry) => entry.key === input.key)) return bound().readSource(input.key, input.target, input.limit ?? 50, input.after ?? null);
|
|
878
|
+
return remoteCall("readSource", caller, input, signal);
|
|
879
|
+
},
|
|
880
|
+
async joinSource(caller, input, signal) {
|
|
881
|
+
if ("self" in caller && bound().sync.some((entry) => entry.key === input.key)) return bound().joinSource(input.key, input.target);
|
|
882
|
+
return remoteCall("joinSource", caller, input, signal);
|
|
883
|
+
},
|
|
884
|
+
async synced(caller, input, signal) {
|
|
885
|
+
const { targets } = await remoteCall("synced", caller, input, signal);
|
|
886
|
+
return { targets: await Promise.all(targets.map(async (row) => ({
|
|
887
|
+
...row,
|
|
888
|
+
url: row.url ?? (row.thread !== null && row.message !== null ? await bound().linkOf(row.key, row.thread, row.message) : null)
|
|
889
|
+
}))) };
|
|
890
|
+
},
|
|
891
|
+
async linked(caller, input, signal) {
|
|
892
|
+
const missing = () => new HttpError(404, "message_not_found", "no message on this board for that link");
|
|
893
|
+
const first = async () => {
|
|
894
|
+
for (const { platform, thread, message } of bound().locate(input.url)) for (const entry of bound().sync.filter((candidate) => candidate.platform === platform)) {
|
|
895
|
+
const at = await own.syncFind({
|
|
896
|
+
thread: `${entry.key}:${thread}`,
|
|
897
|
+
...message !== null ? { message } : {}
|
|
898
|
+
}, { signal }).catch(rethrow);
|
|
899
|
+
const found = message !== null ? at.message : at.thread === null ? null : (await own.syncThread(at.thread).catch(rethrow)).root;
|
|
900
|
+
if (found !== null) return found;
|
|
901
|
+
}
|
|
902
|
+
return null;
|
|
903
|
+
};
|
|
904
|
+
const id = await first();
|
|
905
|
+
if (id === null) return remoteCall("linked", caller, input, signal);
|
|
906
|
+
try {
|
|
907
|
+
return await methods.message(caller, { id }, signal);
|
|
908
|
+
} catch (error) {
|
|
909
|
+
if (error instanceof HttpError && error.status === 404) throw missing();
|
|
910
|
+
throw error;
|
|
911
|
+
}
|
|
912
|
+
},
|
|
913
|
+
async typing(caller, input, signal) {
|
|
914
|
+
const { targets } = await remoteCall("typing", caller, input, signal);
|
|
915
|
+
if (!("self" in caller) || bound().sync.length === 0) return { targets };
|
|
916
|
+
const { message, replies } = await methods.message(caller, { id: input.id }, signal);
|
|
917
|
+
const here = await bound().typing([message, ...replies], input.status).catch((error) => {
|
|
918
|
+
console.warn("[board] skipped typing where this board syncs:", describe(error));
|
|
919
|
+
return [];
|
|
920
|
+
});
|
|
921
|
+
return { targets: [...targets, ...here] };
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
/**
|
|
925
|
+
* Where the remote wakes this board: on a board that wakes by path, the path on this project,
|
|
926
|
+
* which gets through its Deployment Protection (`wakePath`); anywhere else, its URL.
|
|
927
|
+
*/
|
|
928
|
+
async function wakeAt(here) {
|
|
929
|
+
const path = wakePath(here);
|
|
930
|
+
return path && (await discovery()).wake_by_path ? path : { url: here };
|
|
931
|
+
}
|
|
932
|
+
const runner = registrant({
|
|
933
|
+
remote,
|
|
934
|
+
registry: {
|
|
935
|
+
register: (where) => own.register({
|
|
936
|
+
...where,
|
|
937
|
+
watch: specs,
|
|
938
|
+
...sync.length > 0 ? { sync } : {}
|
|
939
|
+
}),
|
|
940
|
+
matches: (query) => own.matches(query),
|
|
941
|
+
ack: (id, body) => own.ack(id, body)
|
|
942
|
+
},
|
|
943
|
+
wakeAt,
|
|
944
|
+
binding: bound,
|
|
945
|
+
hash: watchersHash,
|
|
946
|
+
hasWork: () => Object.keys(specs).length > 0 || sync.length > 0,
|
|
947
|
+
rethrow,
|
|
948
|
+
registerFor: async (caller, request) => json(await methods.register(caller, RegisterBody.parse(await request.json()), request.signal))
|
|
949
|
+
});
|
|
950
|
+
const start = runner.start;
|
|
951
|
+
return {
|
|
952
|
+
...methods,
|
|
953
|
+
routes: runner.routes,
|
|
954
|
+
keeps: false,
|
|
955
|
+
bind(next) {
|
|
956
|
+
if (binding) throw new Error("http: this backend already serves a board: create one http() per board()");
|
|
957
|
+
for (const [id, spec] of Object.entries(next.subscriptions)) {
|
|
958
|
+
if (spec.kind === "sync") {
|
|
959
|
+
if (id === "@sync") sync = next.sync.map((entry) => ({ ...entry }));
|
|
960
|
+
continue;
|
|
961
|
+
}
|
|
962
|
+
if (!PROFILE.test(id)) throw new Error(`watch ${id}: ${PROFILE_RULE}`);
|
|
963
|
+
compileWatcher(id, spec);
|
|
964
|
+
specs[id] = {
|
|
965
|
+
tail: spec.tail,
|
|
966
|
+
when: spec.when
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
hash = null;
|
|
970
|
+
binding = next;
|
|
971
|
+
},
|
|
972
|
+
/** Registers this board's watchers with the board it uses now, as `POST /watchers` does. */
|
|
973
|
+
registerWatchers: runner.registerNow,
|
|
974
|
+
/** Stops pulling, for a board that pulls on its own. */
|
|
975
|
+
close: runner.close
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
//#endregion
|
|
979
|
+
//#region src/backend-http/index.ts
|
|
980
|
+
const environment$1 = {
|
|
981
|
+
url: boardUrl,
|
|
982
|
+
fetch: (url) => connect(url).fetch,
|
|
983
|
+
profile: environmentProfile
|
|
984
|
+
};
|
|
985
|
+
/**
|
|
986
|
+
* The board at `url`, which keeps the log: this board uses it as this deployment. Without a
|
|
987
|
+
* `url`, the one the environment points at: `BOARD_URL`.
|
|
988
|
+
* Without a `fetch`, it sends the credentials `vb` would.
|
|
989
|
+
*/
|
|
990
|
+
function http(url, options = {}) {
|
|
991
|
+
return createHttp(url, options, environment$1);
|
|
992
|
+
}
|
|
993
|
+
//#endregion
|
|
994
|
+
//#region src/backend-vercel/index.ts
|
|
995
|
+
/** On Vercel, or with its OIDC token pulled (`vercel env pull`): a deployment acts as its project. */
|
|
996
|
+
const deployed = () => process.env.VERCEL === "1" || !!process.env.VERCEL_OIDC_TOKEN;
|
|
997
|
+
/**
|
|
998
|
+
* A token you set for the board: it goes as `Authorization: Bearer <token>`, as it is, whatever its
|
|
999
|
+
* format (that's Vercel's API's), ahead of every other, as it does to a board at a URL.
|
|
1000
|
+
*/
|
|
1001
|
+
const boardToken = () => process.env.BOARD_TOKEN || null;
|
|
1002
|
+
/**
|
|
1003
|
+
* A token Vercel's API takes: `BOARD_TOKEN`, `VERCEL_TOKEN`, this deployment's OIDC token, or your
|
|
1004
|
+
* Vercel login, the one the CLI that runs board's hands it (`vercel board`'s) or your `vercel login`.
|
|
1005
|
+
*/
|
|
1006
|
+
async function token() {
|
|
1007
|
+
const given = boardToken();
|
|
1008
|
+
if (given) return given;
|
|
1009
|
+
if (process.env.VERCEL_TOKEN) return process.env.VERCEL_TOKEN;
|
|
1010
|
+
if (deployed()) return getVercelOidcToken();
|
|
1011
|
+
return vercelLogin().catch(() => {
|
|
1012
|
+
throw new HttpError(401, "not_logged_in", "You're not logged in to Vercel.", {
|
|
1013
|
+
hint: "Run vercel login.",
|
|
1014
|
+
origin: "handle"
|
|
1015
|
+
});
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
/** Where `token` comes from, in words: what `vb whoami` says. */
|
|
1019
|
+
function credentialSource() {
|
|
1020
|
+
if (boardToken()) return "BOARD_TOKEN";
|
|
1021
|
+
if (process.env.VERCEL_TOKEN) return "VERCEL_TOKEN";
|
|
1022
|
+
if (deployed()) return "Vercel OIDC";
|
|
1023
|
+
return loginHanded() ? "the Vercel CLI" : "vercel login";
|
|
1024
|
+
}
|
|
1025
|
+
/** The team a CLI that runs board's resolves itself (`vercel board`'s), while one does. */
|
|
1026
|
+
let handed = null;
|
|
1027
|
+
/**
|
|
1028
|
+
* Hands board the team to use when nothing names one (`--scope` still wins), resolved as the app
|
|
1029
|
+
* resolves its own and asked for only when a request needs it. Null takes it back.
|
|
1030
|
+
*/
|
|
1031
|
+
function handTeam(resolve) {
|
|
1032
|
+
handed = resolve;
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
* The team: the one a CLI that runs board's hands it, `VERCEL_ORG_ID`, the one the deployment's OIDC
|
|
1036
|
+
* token names, or the linked project's (the nearest `.vercel/project.json`). A handed one that
|
|
1037
|
+
* throws fails the request with what it threw: the app's own words, not an internal error.
|
|
1038
|
+
*/
|
|
1039
|
+
async function team() {
|
|
1040
|
+
if (handed) try {
|
|
1041
|
+
return await handed();
|
|
1042
|
+
} catch (error) {
|
|
1043
|
+
throw new HttpError(502, "no_team", error instanceof Error ? error.message : String(error), { origin: "handle" });
|
|
1044
|
+
}
|
|
1045
|
+
if (process.env.VERCEL_ORG_ID) return process.env.VERCEL_ORG_ID;
|
|
1046
|
+
if (!process.env.VERCEL_TOKEN && deployed()) try {
|
|
1047
|
+
const owner = decodeJwt(await getVercelOidcToken()).owner_id;
|
|
1048
|
+
if (typeof owner === "string") return owner;
|
|
1049
|
+
} catch {}
|
|
1050
|
+
const file = vercelProjectFile();
|
|
1051
|
+
if (!file) return null;
|
|
1052
|
+
try {
|
|
1053
|
+
const linked = JSON.parse(await readFile(file, "utf8"));
|
|
1054
|
+
if (typeof linked.orgId === "string") return linked.orgId;
|
|
1055
|
+
} catch {}
|
|
1056
|
+
return null;
|
|
1057
|
+
}
|
|
1058
|
+
const environment = {
|
|
1059
|
+
fetch: () => async (input, init = {}) => {
|
|
1060
|
+
const credential = await token();
|
|
1061
|
+
if (!boardToken() && !process.env.VERCEL_TOKEN && !deployed()) return asYou(input, init, credential);
|
|
1062
|
+
const headers = new Headers(init.headers);
|
|
1063
|
+
headers.set("authorization", `Bearer ${credential}`);
|
|
1064
|
+
return globalThis.fetch(input, {
|
|
1065
|
+
...init,
|
|
1066
|
+
headers
|
|
1067
|
+
});
|
|
1068
|
+
},
|
|
1069
|
+
team,
|
|
1070
|
+
profile: environmentProfile
|
|
1071
|
+
};
|
|
1072
|
+
/**
|
|
1073
|
+
* Your team's board, in Vercel's API: this board keeps nothing, and reads and writes that one as
|
|
1074
|
+
* this deployment's project, or as you. Without `board`, the team's board; without `fetch`, it
|
|
1075
|
+
* sends the credentials the Vercel CLI or the deployment has.
|
|
1076
|
+
*/
|
|
1077
|
+
function vercel(options = {}) {
|
|
1078
|
+
return createVercel(options, environment);
|
|
1079
|
+
}
|
|
1080
|
+
//#endregion
|
|
1081
|
+
//#region src/server/index.ts
|
|
1082
|
+
/**
|
|
1083
|
+
* The handle on a board. Without a `backend`, it's Vercel's board for your team, the one `name`
|
|
1084
|
+
* names, reached with the credentials the Vercel CLI or the deployment has (or `fetch`'s). With
|
|
1085
|
+
* `BOARD_URL` set, it's the board at that URL instead: `vb serve`'s, say.
|
|
1086
|
+
*/
|
|
1087
|
+
function board(options = {}) {
|
|
1088
|
+
return createBoard(options, {
|
|
1089
|
+
backend: (fetch) => process.env.BOARD_URL?.trim() ? http() : vercel(fetch ? { fetch } : {}),
|
|
1090
|
+
sync: () => import("./engine-JxgZiikU.mjs"),
|
|
1091
|
+
serving: () => import("./serving-D7rcUtSC.mjs")
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
//#endregion
|
|
1095
|
+
export { http as a, handFetch as c, projectDir as d, vercelProjectFile as f, vercel as i, handLogin as l, credentialSource as n, boardUrl as o, handTeam as r, connect as s, board as t, localTokenFile as u };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as ownTeamId, n as discoveryIdentity, r as ownProjectId, t as oidcTokens } from "./tokens-
|
|
1
|
+
import { i as ownTeamId, n as discoveryIdentity, r as ownProjectId, t as oidcTokens } from "./tokens-DPKjl3jf.mjs";
|
|
2
2
|
export { discoveryIdentity, oidcTokens, ownProjectId, ownTeamId };
|