@vercel/board 0.30.0 → 0.32.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 +8 -17
- package/dist/{a2-D_28Pdip.mjs → a2-DiDc77Uf.mjs} +573 -361
- package/dist/{access-CQ39gqEV.mjs → access-CY5xVMIK.mjs} +19 -3
- package/dist/{access-CV96SYgr.d.mts → access-DPcrKIH_.d.mts} +6 -1
- package/dist/access.d.mts +4 -4
- package/dist/access.mjs +5 -4
- package/dist/{actors-xPiamLWk.mjs → actors-Bm-ojWWT.mjs} +2 -2
- package/dist/{auth-BPinwfN0.mjs → auth-8pRZnF1M.mjs} +131 -14
- package/dist/{auth-CU56Q2Xh.d.mts → auth-K8dY1nBY.d.mts} +36 -4
- package/dist/{backend-n3hajfrD.d.mts → backend-DxE9wGKm.d.mts} +86 -41
- package/dist/backend-a2/blob-vercel.d.mts +1 -1
- package/dist/backend-a2/contract.d.mts +37 -97
- package/dist/backend-a2/contract.mjs +1 -1
- package/dist/backend-a2/store-memory.d.mts +1 -1
- package/dist/backend-a2/store-memory.mjs +2 -2
- package/dist/backend-a2/store-postgres.d.mts +1 -1
- package/dist/backend-a2/store-postgres.mjs +1 -1
- package/dist/backend-a2/store-redis-http.d.mts +1 -1
- package/dist/backend-a2/store-redis-http.mjs +1 -1
- package/dist/backend-a2/store-redis.d.mts +1 -1
- package/dist/backend-a2/store-redis.mjs +1 -1
- package/dist/backend-a2/store-sqlite.d.mts +1 -1
- package/dist/backend-a2/store-sqlite.mjs +2 -2
- package/dist/backend-a2.d.mts +131 -240
- package/dist/backend-a2.mjs +2 -2
- package/dist/{backend-http-3PoBYQoo.d.mts → backend-http-CaN06CaD.d.mts} +49 -45
- package/dist/{backend-http-16SbvnAK.mjs → backend-http-CoaCghuJ.mjs} +2 -2
- package/dist/{backend-http-BPaNYLWj.mjs → backend-http-l5A8UmL-.mjs} +11 -9
- package/dist/backend-http.d.mts +1 -1
- package/dist/backend-http.mjs +1 -1
- package/dist/backend-http.node.d.mts +1 -1
- package/dist/backend-http.node.mjs +1 -1
- package/dist/{backend-vercel-Kd8nvW5A.mjs → backend-vercel-BE65okBC.mjs} +3 -3
- package/dist/{backend-vercel-C4Kee2-K.mjs → backend-vercel-CVxoTNF2.mjs} +186 -33
- package/dist/{backend-vercel-qznuDxnN.d.mts → backend-vercel-jg-6PAgD.d.mts} +49 -45
- package/dist/backend-vercel.d.mts +1 -1
- package/dist/backend-vercel.mjs +1 -1
- package/dist/backend-vercel.node.d.mts +1 -1
- package/dist/backend-vercel.node.mjs +1 -1
- package/dist/{blob-CqILvdmr.d.mts → blob-Bx8QPWEd.d.mts} +2 -2
- package/dist/{blob-DQK5prXT.mjs → blob-WbB2DJKn.mjs} +30 -11
- package/dist/{chat-provider-D6jVT4wS.d.mts → chat-provider-BChYrrA7.d.mts} +32 -28
- package/dist/{chat-provider-COtsU5jB.mjs → chat-provider-DkFp2hrh.mjs} +105 -60
- 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 +2 -2
- package/dist/cli.mjs +4 -4
- package/dist/{client-CjAatpV4.d.mts → client-COfYrgfV.d.mts} +184 -221
- package/dist/{commands-BtH69yqt.d.mts → commands-CpyPV_tk.d.mts} +35 -10
- package/dist/{commands-B5DHjZKK.mjs → commands-DsnQKTdB.mjs} +189 -56
- package/dist/{conformance-C7fwIvmN.mjs → conformance-3RBKxwbp.mjs} +259 -20
- package/dist/conformance.d.mts +8 -2
- package/dist/conformance.mjs +1 -1
- package/dist/{engine-DkdkXQEy.mjs → engine-DurYIRt8.mjs} +29 -210
- package/dist/{errors-87TVtXeb.d.mts → errors-2vGs49Db.d.mts} +1 -1
- package/dist/{errors-C_5rB8Iz.mjs → errors-CJXhhzvT.mjs} +28 -23
- package/dist/{provider-BaVmi4Hi.mjs → events-lujPA3gQ.mjs} +80 -17
- package/dist/{exports-CG0P8Qi4.mjs → exports-BnUZuRm9.mjs} +146 -80
- package/dist/exports-u5mApVvn.d.mts +5 -0
- package/dist/{folds-8wRRXjAt.d.mts → folds-DLUzfibJ.d.mts} +13 -40
- package/dist/{folds-DGYkMW19.mjs → folds-DsWfIftc.mjs} +3 -22
- package/dist/{index-BygAXP7t.d.mts → index-UXpTPWNc.d.mts} +2 -2
- package/dist/index.d.mts +7 -7
- package/dist/{index.default-DhkgpfR2.mjs → index.default-Dp8gexln.mjs} +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.node.d.mts +7 -7
- package/dist/index.node.mjs +3 -3
- package/dist/inspect/app.js +62 -61
- package/dist/inspect/engine.js +3 -3
- package/dist/{main-D2s-QBOK.mjs → main-CcYDo9Hb.mjs} +240 -127
- package/dist/{middleware-DlJQYiwV.mjs → middleware-BavYSDUa.mjs} +1 -1
- package/dist/{node-D8Rtg1su.mjs → node-BgeGcwX0.mjs} +7 -3
- package/dist/{project-C_2xs57L.mjs → project-4Vl7_uy5.mjs} +1 -1
- package/dist/{provider-Bm46LAdp.d.mts → provider-gynDUoyW.d.mts} +13 -43
- package/dist/{redis-tables-BWJZHUGg.mjs → redis-tables-BFRj_SEJ.mjs} +1 -19
- package/dist/{reducers-8jqLewgw.mjs → reducers-DQVSP3kk.mjs} +72 -75
- package/dist/{serve-lPoBDEds.mjs → serve-Bplieh0C.mjs} +6 -6
- package/dist/{server-D82a4uMe.mjs → server-wIpAEjpX.mjs} +4 -4
- package/dist/{serving-DKny38LK.mjs → serving-Y7s7VDjB.mjs} +1 -1
- package/dist/{sql-Bj0fk6dn.mjs → sql-E1K5g_ih.mjs} +2 -8
- package/dist/{sqlite-db-Dc8G78XV.mjs → sqlite-db-CzcD_FW8.mjs} +1 -1
- package/dist/{sync-kapso.d.mts → sync-chat-sdk.d.mts} +33 -37
- package/dist/sync-chat-sdk.mjs +44 -0
- package/dist/sync-github.d.mts +5 -18
- package/dist/sync-github.mjs +4 -70
- package/dist/sync-linear.d.mts +3 -3
- package/dist/sync-linear.mjs +2 -3
- package/dist/sync-slack.d.mts +7 -7
- package/dist/sync-slack.mjs +33 -54
- package/dist/sync.d.mts +3 -3
- package/dist/sync.mjs +2 -4
- package/dist/{tokens-C5_yGRlL.mjs → tokens-C7kYyrAG.mjs} +15 -6
- package/dist/{types-shZmGZ-q.d.mts → types-CmrFjpml.d.mts} +1 -3
- package/dist/{watchers-hash-B_5b0-ZG.mjs → watchers-hash-CurCzwhe.mjs} +85 -105
- package/docs/01-board/01-mounting.md +2 -2
- package/docs/01-board/03-identity.md +5 -6
- package/docs/01-board/04-messages.md +7 -4
- package/docs/01-board/05-reading.md +2 -1
- package/docs/01-board/06-watchers.md +8 -6
- package/docs/01-board/08-middleware.md +1 -1
- package/docs/01-board/09-access.md +145 -14
- package/docs/02-sync/01-overview.md +19 -26
- package/docs/02-sync/02-functions.md +8 -9
- package/docs/02-sync/03-slack.md +5 -5
- package/docs/02-sync/04-github.md +2 -2
- package/docs/02-sync/06-providers.md +91 -62
- package/docs/03-guides/01-coding-agents.md +1 -1
- package/docs/03-guides/03-ci.md +7 -4
- package/docs/04-reference/01-cli.md +100 -51
- package/docs/04-reference/02-board.md +56 -23
- package/docs/04-reference/03-http.md +59 -32
- package/docs/04-reference/04-log.md +8 -11
- package/docs/04-reference/05-conformance.md +35 -6
- package/docs/index.md +2 -2
- package/package.json +6 -9
- package/sql/postgres/board.sql +1 -1
- package/sql/postgres/schema.sql +1 -1
- package/dist/events-qf5XG5VQ.mjs +0 -75
- package/dist/exports-CrGA5_yN.d.mts +0 -5
- package/dist/sync-kapso.mjs +0 -89
- package/dist/sync.chat.d.mts +0 -2
- package/dist/sync.chat.mjs +0 -2
- package/dist/users-yryHKFMo.mjs +0 -42
- package/docs/02-sync/05-whatsapp.md +0 -152
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as Actor, x as Attachment } from "./folds-
|
|
2
|
-
import {
|
|
3
|
-
import { i as Caller, n as BackendRoute, r as BoardBinding } from "./backend-
|
|
1
|
+
import { t as Actor, x as Attachment } from "./folds-DLUzfibJ.mjs";
|
|
2
|
+
import { At as ThreadsPage, B as MatchView, C as EventsPage, Dt as SyncedView, Et as SyncThreadView, Ft as TokenView, H as Me, M as InboxItem, U as MessageView, W as MessagesPage, dt as SourceJoin, j as InboxEntry, k as GrantView, kt as ThreadView, mt as SourceRead, o as ProfileOption, st as ScheduleView, tt as RegistrationView, v as ChannelView, vt as SyncCopiesView, x as Discovery, xt as SyncFindView, zt as UploadTicket } from "./client-COfYrgfV.mjs";
|
|
3
|
+
import { i as Caller, n as BackendRoute, r as BoardBinding } from "./backend-DxE9wGKm.mjs";
|
|
4
4
|
//#region src/server/backend-http.d.ts
|
|
5
5
|
type HttpOptions = {
|
|
6
6
|
/**
|
|
@@ -46,17 +46,18 @@ declare function createHttp(url: string | undefined, options: HttpOptions, envir
|
|
|
46
46
|
channels: ChannelView[];
|
|
47
47
|
cursor: string;
|
|
48
48
|
}>;
|
|
49
|
+
createChannel: (caller: Caller, input: {
|
|
50
|
+
path: string;
|
|
51
|
+
}, signal: AbortSignal) => Promise<{
|
|
52
|
+
channel: ChannelView;
|
|
53
|
+
created: boolean;
|
|
54
|
+
}>;
|
|
49
55
|
actors: (caller: Caller, input: {
|
|
50
56
|
[x: string]: never;
|
|
51
57
|
}, signal: AbortSignal) => Promise<{
|
|
52
|
-
actors:
|
|
53
|
-
person?: PersonView;
|
|
54
|
-
})[];
|
|
58
|
+
actors: Actor[];
|
|
55
59
|
cursor: string;
|
|
56
60
|
}>;
|
|
57
|
-
identity: (caller: Caller, input: {
|
|
58
|
-
[x: string]: never;
|
|
59
|
-
}, signal: AbortSignal) => Promise<IdentityView>;
|
|
60
61
|
messages: (caller: Caller, input: {
|
|
61
62
|
channel?: string | undefined;
|
|
62
63
|
re?: string | undefined;
|
|
@@ -169,6 +170,45 @@ declare function createHttp(url: string | undefined, options: HttpOptions, envir
|
|
|
169
170
|
schedule: ScheduleView;
|
|
170
171
|
canceled: boolean;
|
|
171
172
|
}>;
|
|
173
|
+
grants: (caller: Caller, input: {
|
|
174
|
+
[x: string]: never;
|
|
175
|
+
}, signal: AbortSignal) => Promise<{
|
|
176
|
+
grants: GrantView[];
|
|
177
|
+
}>;
|
|
178
|
+
createGrant: (caller: Caller, input: {
|
|
179
|
+
issuer: string;
|
|
180
|
+
claims: Record<string, string | string[]>;
|
|
181
|
+
can?: "all" | string[] | Record<string, "all" | string[]> | undefined;
|
|
182
|
+
}, signal: AbortSignal) => Promise<{
|
|
183
|
+
grant: GrantView;
|
|
184
|
+
created: boolean;
|
|
185
|
+
}>;
|
|
186
|
+
revokeGrant: (caller: Caller, input: {
|
|
187
|
+
id: string;
|
|
188
|
+
}, signal: AbortSignal) => Promise<{
|
|
189
|
+
revoked: boolean;
|
|
190
|
+
}>;
|
|
191
|
+
tokens: (caller: Caller, input: {
|
|
192
|
+
[x: string]: never;
|
|
193
|
+
}, signal: AbortSignal) => Promise<{
|
|
194
|
+
tokens: TokenView[];
|
|
195
|
+
}>;
|
|
196
|
+
createToken: (caller: Caller, input: {
|
|
197
|
+
name: string;
|
|
198
|
+
can?: "all" | string[] | Record<string, "all" | string[]> | undefined;
|
|
199
|
+
profile?: string | undefined;
|
|
200
|
+
avatar?: string | undefined;
|
|
201
|
+
session?: string | undefined;
|
|
202
|
+
expires?: string | undefined;
|
|
203
|
+
}, signal: AbortSignal) => Promise<{
|
|
204
|
+
token: TokenView;
|
|
205
|
+
secret: string;
|
|
206
|
+
}>;
|
|
207
|
+
revokeToken: (caller: Caller, input: {
|
|
208
|
+
id: string;
|
|
209
|
+
}, signal: AbortSignal) => Promise<{
|
|
210
|
+
revoked: boolean;
|
|
211
|
+
}>;
|
|
172
212
|
upload: (caller: Caller, input: {
|
|
173
213
|
data: Uint8Array;
|
|
174
214
|
name: string | null;
|
|
@@ -206,7 +246,6 @@ declare function createHttp(url: string | undefined, options: HttpOptions, envir
|
|
|
206
246
|
sync?: {
|
|
207
247
|
key: string;
|
|
208
248
|
platform: string;
|
|
209
|
-
signIn: boolean;
|
|
210
249
|
}[] | undefined;
|
|
211
250
|
url?: string | null | undefined;
|
|
212
251
|
path?: null | undefined;
|
|
@@ -219,7 +258,6 @@ declare function createHttp(url: string | undefined, options: HttpOptions, envir
|
|
|
219
258
|
sync?: {
|
|
220
259
|
key: string;
|
|
221
260
|
platform: string;
|
|
222
|
-
signIn: boolean;
|
|
223
261
|
}[] | undefined;
|
|
224
262
|
url?: null | undefined;
|
|
225
263
|
path: string;
|
|
@@ -443,7 +481,6 @@ declare function createHttp(url: string | undefined, options: HttpOptions, envir
|
|
|
443
481
|
external: {
|
|
444
482
|
thread: string;
|
|
445
483
|
message: string;
|
|
446
|
-
asUser?: true | undefined;
|
|
447
484
|
};
|
|
448
485
|
files?: string[] | null | undefined;
|
|
449
486
|
} | {
|
|
@@ -470,22 +507,13 @@ declare function createHttp(url: string | undefined, options: HttpOptions, envir
|
|
|
470
507
|
thread: string;
|
|
471
508
|
}, signal: AbortSignal) => Promise<SyncThreadView>;
|
|
472
509
|
syncFind: (caller: Caller, input: {
|
|
473
|
-
code?: string | undefined;
|
|
474
510
|
post?: string | undefined;
|
|
475
511
|
thread?: string | undefined;
|
|
476
512
|
message?: string | undefined;
|
|
477
|
-
account?: string | undefined;
|
|
478
|
-
person?: string | undefined;
|
|
479
513
|
}, signal: AbortSignal) => Promise<SyncFindView>;
|
|
480
514
|
syncCopies: (caller: Caller, input: {
|
|
481
515
|
message: string[];
|
|
482
516
|
}, signal: AbortSignal) => Promise<SyncCopiesView>;
|
|
483
|
-
syncRoots: (caller: Caller, input: {
|
|
484
|
-
by: string;
|
|
485
|
-
since: number;
|
|
486
|
-
}, signal: AbortSignal) => Promise<{
|
|
487
|
-
roots: MessageView[];
|
|
488
|
-
}>;
|
|
489
517
|
inboxPush: (caller: Caller, input: {
|
|
490
518
|
key: string;
|
|
491
519
|
} & {
|
|
@@ -631,30 +659,6 @@ declare function createHttp(url: string | undefined, options: HttpOptions, envir
|
|
|
631
659
|
}, signal: AbortSignal) => Promise<{
|
|
632
660
|
events: InboxEntry[];
|
|
633
661
|
}>;
|
|
634
|
-
syncCode: (caller: Caller, input: {
|
|
635
|
-
sync: string;
|
|
636
|
-
}, signal: AbortSignal) => Promise<SyncCodeView>;
|
|
637
|
-
syncAccount: (caller: Caller, input: {
|
|
638
|
-
sync: string;
|
|
639
|
-
account: {
|
|
640
|
-
id: string;
|
|
641
|
-
handle: string;
|
|
642
|
-
name: string;
|
|
643
|
-
isBot: boolean;
|
|
644
|
-
avatar: string | null;
|
|
645
|
-
};
|
|
646
|
-
code: string;
|
|
647
|
-
message?: string | undefined;
|
|
648
|
-
method?: "code" | "consent" | undefined;
|
|
649
|
-
}, signal: AbortSignal) => Promise<{
|
|
650
|
-
person: string;
|
|
651
|
-
link: LinkedAccount;
|
|
652
|
-
}>;
|
|
653
|
-
syncUnlink: (caller: Caller, input: {
|
|
654
|
-
account: string;
|
|
655
|
-
}, signal: AbortSignal) => Promise<{
|
|
656
|
-
ok: true;
|
|
657
|
-
}>;
|
|
658
662
|
routes: BackendRoute[];
|
|
659
663
|
keeps: boolean;
|
|
660
664
|
bind(next: BoardBinding): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as createHttp } from "./backend-http-
|
|
2
|
-
import { i as environmentProfile, n as boardUrl, r as connect } from "./node-
|
|
1
|
+
import { r as createHttp } from "./backend-http-l5A8UmL-.mjs";
|
|
2
|
+
import { i as environmentProfile, n as boardUrl, r as connect } from "./node-BgeGcwX0.mjs";
|
|
3
3
|
//#region src/backend-http/index.ts
|
|
4
4
|
const environment = {
|
|
5
5
|
url: boardUrl,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./files-SniSmeEr.mjs";
|
|
2
2
|
import "./schemas-DBmUO6pr.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { a as forbidden, d as createBoardClient, o as json, t as HttpError, u as BoardError } from "./errors-
|
|
3
|
+
import { A as RegisterBody, W as routes, a as METHODS, n as compileWatcher, t as canonicalWatchers } from "./watchers-hash-CurCzwhe.mjs";
|
|
4
|
+
import { a as forbidden, d as createBoardClient, o as json, t as HttpError, u as BoardError } from "./errors-CJXhhzvT.mjs";
|
|
5
5
|
import { a as keyId, n as DERIVED_ID, o as sha256, r as derivedId, t as waitUntil } from "./wait-until-Dw4XrIDQ.mjs";
|
|
6
6
|
//#region src/server/registrant.ts
|
|
7
7
|
/** Registering again this soon after the same registration only repeats it. */
|
|
@@ -186,12 +186,12 @@ const PROFILE = /^[A-Za-z][A-Za-z0-9-]{0,31}$/;
|
|
|
186
186
|
const PROFILE_RULE = "ids start with a letter and use up to 32 letters, numbers, and hyphens";
|
|
187
187
|
/**
|
|
188
188
|
* What a board's own callers can't do on the board it uses, where they act as its project: what's
|
|
189
|
-
* the project's own there (its registration, its sync, its links
|
|
189
|
+
* the project's own there (its registration, its sync, its links, who it trusts and the tokens it
|
|
190
|
+
* mints, which would act as the project), and what's anyone's own there by
|
|
190
191
|
* principal (editing, deleting, scheduling, and uploading, since a file is its uploader's to read
|
|
191
192
|
* and attach until a message carries it), which the board it uses can't tell them apart for.
|
|
192
193
|
*/
|
|
193
194
|
const PROJECTS_OWN = /* @__PURE__ */ new Set([
|
|
194
|
-
"identity",
|
|
195
195
|
"edit",
|
|
196
196
|
"delete",
|
|
197
197
|
"schedule",
|
|
@@ -203,19 +203,21 @@ const PROJECTS_OWN = /* @__PURE__ */ new Set([
|
|
|
203
203
|
"register",
|
|
204
204
|
"matches",
|
|
205
205
|
"ack",
|
|
206
|
+
"grants",
|
|
207
|
+
"createGrant",
|
|
208
|
+
"revokeGrant",
|
|
209
|
+
"tokens",
|
|
210
|
+
"createToken",
|
|
211
|
+
"revokeToken",
|
|
206
212
|
"syncImport",
|
|
207
213
|
"syncReceipt",
|
|
208
214
|
"syncThread",
|
|
209
215
|
"syncFind",
|
|
210
216
|
"syncCopies",
|
|
211
|
-
"syncRoots",
|
|
212
217
|
"inboxPush",
|
|
213
218
|
"inboxNext",
|
|
214
219
|
"inboxAck",
|
|
215
|
-
"inbox"
|
|
216
|
-
"syncCode",
|
|
217
|
-
"syncAccount",
|
|
218
|
-
"syncUnlink"
|
|
220
|
+
"inbox"
|
|
219
221
|
]);
|
|
220
222
|
/**
|
|
221
223
|
* A caller's handle as a profile on the board this one uses: `ada`, `ada-lovelace` for
|
package/dist/backend-http.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as HttpOptions, t as HttpBackend } from "./backend-http-
|
|
1
|
+
import { n as HttpOptions, t as HttpBackend } from "./backend-http-CaN06CaD.mjs";
|
|
2
2
|
//#region src/backend-http/index.default.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* The board at `url`, which keeps the log. Outside Node there's no environment to find it or a
|
package/dist/backend-http.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as http } from "./index.default-
|
|
1
|
+
import { t as http } from "./index.default-Dp8gexln.mjs";
|
|
2
2
|
export { http };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as HttpOptions, t as HttpBackend } from "./backend-http-
|
|
1
|
+
import { n as HttpOptions, t as HttpBackend } from "./backend-http-CaN06CaD.mjs";
|
|
2
2
|
//#region src/backend-http/index.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* The board at `url`, which keeps the log: this board uses it as this deployment. Without a
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as http } from "./backend-http-
|
|
1
|
+
import { t as http } from "./backend-http-CoaCghuJ.mjs";
|
|
2
2
|
export { http };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as HttpError } from "./errors-
|
|
2
|
-
import { c as loginHanded, d as vercelProjectFile, i as environmentProfile, t as asYou, u as vercelLogin } from "./node-
|
|
3
|
-
import { t as createVercel } from "./backend-vercel-
|
|
1
|
+
import { t as HttpError } from "./errors-CJXhhzvT.mjs";
|
|
2
|
+
import { c as loginHanded, d as vercelProjectFile, i as environmentProfile, t as asYou, u as vercelLogin } from "./node-BgeGcwX0.mjs";
|
|
3
|
+
import { t as createVercel } from "./backend-vercel-CVxoTNF2.mjs";
|
|
4
4
|
import { readFile } from "node:fs/promises";
|
|
5
5
|
import { decodeJwt } from "jose";
|
|
6
6
|
import { getVercelOidcToken } from "@vercel/oidc";
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { r as IMPORT_BYTES_MAX } from "./files-SniSmeEr.mjs";
|
|
2
2
|
import { _ as RemoteWatcherId } from "./schemas-DBmUO6pr.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { a as forbidden, f as duration, o as json, r as badRequest, s as notFound, t as HttpError } from "./errors-
|
|
3
|
+
import { A as RegisterBody, a as METHODS, d as VERSION, n as compileWatcher, t as canonicalWatchers } from "./watchers-hash-CurCzwhe.mjs";
|
|
4
|
+
import { a as forbidden, f as duration, o as json, r as badRequest, s as notFound, t as HttpError } from "./errors-CJXhhzvT.mjs";
|
|
5
5
|
import { o as sha256, r as derivedId } from "./wait-until-Dw4XrIDQ.mjs";
|
|
6
|
-
import { a as wakePath, i as registrant, n as callerProfile, t as PROJECTS_OWN } from "./backend-http-
|
|
7
|
-
import { o as mediaType, r as fileName } from "./blob-
|
|
6
|
+
import { a as wakePath, i as registrant, n as callerProfile, t as PROJECTS_OWN } from "./backend-http-l5A8UmL-.mjs";
|
|
7
|
+
import { o as mediaType, r as fileName } from "./blob-WbB2DJKn.mjs";
|
|
8
8
|
//#region src/server/backend-vercel.ts
|
|
9
9
|
const PROFILE = /^[A-Za-z][A-Za-z0-9-]{0,31}$/;
|
|
10
10
|
const SESSION = /^[A-Za-z0-9_.:-]{1,128}$/;
|
|
11
11
|
const CLIENT_ID = /^[A-Za-z0-9_.:-]{1,128}$/;
|
|
12
12
|
const MESSAGE_ID = /^msg_([0-9a-f-]{36})_([1-9]\d*)$/;
|
|
13
|
+
/** Whether `value` is a message ID Vercel's API hands out (`msg_<thread>_<n>`): the CLI takes one as a message, even where a channel has its name. */
|
|
14
|
+
const isApiMessageId = (value) => MESSAGE_ID.test(value);
|
|
13
15
|
/** A cursor this backend made: a time, then the position it names, in base 36. */
|
|
14
16
|
const CURSOR = /^([0-9a-z]+)(?:\.([0-9a-z]+))?$/;
|
|
15
17
|
/** The API's own cursor for one channel, which its message list and feed share, and any process resumes. */
|
|
@@ -191,10 +193,13 @@ function createVercel(options, environment) {
|
|
|
191
193
|
if (!found) throw new HttpError(502, "remote_error", `Vercel's API names a channel it doesn't list: ${id}`);
|
|
192
194
|
return found;
|
|
193
195
|
}
|
|
194
|
-
/**
|
|
195
|
-
async function
|
|
196
|
+
/** The channel by `name`, made if it isn't there: `created` says whether this made it. */
|
|
197
|
+
async function ensureChannel(who, name) {
|
|
196
198
|
const found = await channelNamed(who, name);
|
|
197
|
-
if (found) return
|
|
199
|
+
if (found) return {
|
|
200
|
+
channel: found,
|
|
201
|
+
created: false
|
|
202
|
+
};
|
|
198
203
|
try {
|
|
199
204
|
const { channel } = await api(who, "POST", await onBoard(who, "/channels"), { body: {
|
|
200
205
|
operationId: operationId(),
|
|
@@ -202,15 +207,23 @@ function createVercel(options, environment) {
|
|
|
202
207
|
} });
|
|
203
208
|
channels = null;
|
|
204
209
|
named.set(name, channel);
|
|
205
|
-
return
|
|
210
|
+
return {
|
|
211
|
+
channel,
|
|
212
|
+
created: true
|
|
213
|
+
};
|
|
206
214
|
} catch (error) {
|
|
207
215
|
if (error instanceof HttpError && error.code === "channel_name_taken") {
|
|
208
216
|
const made = await channelNamed(who, name);
|
|
209
|
-
if (made) return
|
|
217
|
+
if (made) return {
|
|
218
|
+
channel: made,
|
|
219
|
+
created: false
|
|
220
|
+
};
|
|
210
221
|
}
|
|
211
222
|
throw error;
|
|
212
223
|
}
|
|
213
224
|
}
|
|
225
|
+
/** A channel to post in, made the first time something posts to it, as on any board. */
|
|
226
|
+
const channelToPost = async (who, name) => (await ensureChannel(who, name)).channel;
|
|
214
227
|
/** The channels a filter names that `access` reads: one, a channel and those under it (`dev/`), or every one. */
|
|
215
228
|
async function channelsFor(who, filter, access) {
|
|
216
229
|
const readable = (channel) => access === null || access.readable(channel.name);
|
|
@@ -242,15 +255,27 @@ function createVercel(options, environment) {
|
|
|
242
255
|
channel
|
|
243
256
|
};
|
|
244
257
|
}
|
|
245
|
-
/**
|
|
258
|
+
/**
|
|
259
|
+
* Each thread a read needs, read once, with the labels its messages match on: a label matches on
|
|
260
|
+
* its root's, which the API keeps on the thread. It reads the root, which names its thread, so it
|
|
261
|
+
* knows when the root is deleted.
|
|
262
|
+
*/
|
|
246
263
|
function threadReader(who, signal) {
|
|
247
264
|
const read = /* @__PURE__ */ new Map();
|
|
248
265
|
return (id) => {
|
|
249
266
|
let thread = read.get(id);
|
|
250
|
-
if (!thread) read.set(id, thread =
|
|
267
|
+
if (!thread) read.set(id, thread = messageById(who, idAt(id, 1), signal).then(({ thread, message }) => labeledBy(thread, message)));
|
|
251
268
|
return thread;
|
|
252
269
|
};
|
|
253
270
|
}
|
|
271
|
+
/** A thread as its root's labels find it: the API keeps a deleted root's labels on its thread, and a deleted message has none. */
|
|
272
|
+
const labeledBy = (thread, root) => {
|
|
273
|
+
if (root?.deletedAt === void 0) return thread;
|
|
274
|
+
const { labels: _kept, ...rest } = thread;
|
|
275
|
+
return rest;
|
|
276
|
+
};
|
|
277
|
+
/** A message's labels: a deleted message keeps none, though the API still holds them. */
|
|
278
|
+
const labelsOf = (message) => message.deletedAt === void 0 ? { ...message.labels } : {};
|
|
254
279
|
const threadMessages = async (who, threadId, signal) => all(who, await onBoard(who, `/threads/${encodeURIComponent(threadId)}/messages`), "messages", {}, signal);
|
|
255
280
|
/** Who reacted with each emoji. The API counts them on the message and lists them apart. */
|
|
256
281
|
async function reactors(who, message) {
|
|
@@ -316,7 +341,7 @@ function createVercel(options, environment) {
|
|
|
316
341
|
re: root ? null : idAt(message.threadId, 1),
|
|
317
342
|
replyTo: message.replyTo !== void 0 && message.replyTo !== 1 ? idAt(message.threadId, message.replyTo) : null,
|
|
318
343
|
thread: message.threadId,
|
|
319
|
-
labels:
|
|
344
|
+
labels: labelsOf(message),
|
|
320
345
|
reactions: message.deletedAt === void 0 ? await reactors(who, message) : {},
|
|
321
346
|
mentions: [],
|
|
322
347
|
by: authorOf(message.createdBy),
|
|
@@ -398,7 +423,10 @@ function createVercel(options, environment) {
|
|
|
398
423
|
skip: 0
|
|
399
424
|
}]));
|
|
400
425
|
}
|
|
401
|
-
/**
|
|
426
|
+
/**
|
|
427
|
+
* Whether a message matches a read's filters. A label matches on the message or its thread's root:
|
|
428
|
+
* `thread`'s labels, as `labeledBy` gives them when the read filters on labels.
|
|
429
|
+
*/
|
|
402
430
|
function matches(filters, message, thread, me) {
|
|
403
431
|
if (filters.re !== void 0 && filters.re !== message.id && filters.re !== idAt(thread.id, 1)) return false;
|
|
404
432
|
if (filters.by !== void 0) {
|
|
@@ -415,7 +443,7 @@ function createVercel(options, environment) {
|
|
|
415
443
|
if (filters.text !== void 0 && !message.text.toLowerCase().includes(filters.text.toLowerCase())) return false;
|
|
416
444
|
for (const [key, values] of filters.label ?? []) {
|
|
417
445
|
const on = (labels) => labels !== void 0 && Object.hasOwn(labels, key) && (values === null || values.includes(labels[key]));
|
|
418
|
-
if (!on(message
|
|
446
|
+
if (!on(labelsOf(message)) && !on(thread.labels)) return false;
|
|
419
447
|
}
|
|
420
448
|
return true;
|
|
421
449
|
}
|
|
@@ -555,13 +583,17 @@ function createVercel(options, environment) {
|
|
|
555
583
|
const mine = await actorOf(who);
|
|
556
584
|
let newest = 0;
|
|
557
585
|
const messages = [];
|
|
558
|
-
for (const { thread, channel } of threads)
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
586
|
+
for (const { thread, channel } of threads) {
|
|
587
|
+
const all = await threadMessages(who, thread.id, signal);
|
|
588
|
+
const labeled = labeledBy(thread, all.find((message) => message.sequence === 1));
|
|
589
|
+
for (const message of all) {
|
|
590
|
+
newest = Math.max(newest, message.createdAt);
|
|
591
|
+
if (matches(filters, message, labeled, mine)) messages.push({
|
|
592
|
+
message,
|
|
593
|
+
thread,
|
|
594
|
+
channel
|
|
595
|
+
});
|
|
596
|
+
}
|
|
565
597
|
}
|
|
566
598
|
messages.sort((a, b) => a.message.createdAt - b.message.createdAt || a.thread.id.localeCompare(b.thread.id) || a.message.sequence - b.message.sequence);
|
|
567
599
|
return {
|
|
@@ -571,12 +603,16 @@ function createVercel(options, environment) {
|
|
|
571
603
|
};
|
|
572
604
|
}
|
|
573
605
|
/** A change in the API's feed as a board event, with the message as it is now. Null for what isn't a message's. */
|
|
574
|
-
async function eventOf(who, change, channel, cursor, filters, me, given) {
|
|
606
|
+
async function eventOf(who, change, channel, cursor, filters, me, given, threads = threadReader(who)) {
|
|
575
607
|
if (!change.messageId || !change.type.startsWith("message.")) return null;
|
|
576
|
-
|
|
608
|
+
let found = given ?? await messageById(who, change.messageId).catch((error) => {
|
|
577
609
|
if (error instanceof HttpError && error.status === 404) return null;
|
|
578
610
|
throw error;
|
|
579
611
|
});
|
|
612
|
+
if (found && !given && filters.label?.length) found = {
|
|
613
|
+
...found,
|
|
614
|
+
thread: found.message.sequence === 1 ? labeledBy(found.thread, found.message) : await threads(found.thread.id)
|
|
615
|
+
};
|
|
580
616
|
if (!found || !matches(filters, found.message, found.thread, me)) return null;
|
|
581
617
|
const message = await view(who, found.message, channel);
|
|
582
618
|
const by = authorOf(change.actor);
|
|
@@ -683,6 +719,7 @@ function createVercel(options, environment) {
|
|
|
683
719
|
};
|
|
684
720
|
}));
|
|
685
721
|
const mine = await actorOf(who);
|
|
722
|
+
const threads = threadReader(who, signal);
|
|
686
723
|
const running = { ...position.feeds };
|
|
687
724
|
const merged = pages.flatMap((page) => page.events.map((event) => ({
|
|
688
725
|
...event,
|
|
@@ -697,7 +734,7 @@ function createVercel(options, environment) {
|
|
|
697
734
|
const event = await eventOf(who, change, page.channel.name, cursorOf({
|
|
698
735
|
t: change.createdAt,
|
|
699
736
|
feeds: { ...running }
|
|
700
|
-
}), filters, mine);
|
|
737
|
+
}), filters, mine, void 0, threads);
|
|
701
738
|
if (event) events.push(event);
|
|
702
739
|
}
|
|
703
740
|
const after = { ...position.feeds };
|
|
@@ -713,6 +750,49 @@ function createVercel(options, environment) {
|
|
|
713
750
|
}
|
|
714
751
|
};
|
|
715
752
|
}
|
|
753
|
+
/** `ms` passing, or `signal` stopping it first. */
|
|
754
|
+
const pause = (ms, signal) => ms <= 0 || signal.aborted ? Promise.resolve() : new Promise((resolve) => {
|
|
755
|
+
const timer = setTimeout(resolve, ms);
|
|
756
|
+
signal.addEventListener("abort", () => (clearTimeout(timer), resolve()), { once: true });
|
|
757
|
+
});
|
|
758
|
+
/**
|
|
759
|
+
* Until one of `listed`'s feeds has something after `position` (true), or it's `until` (false). The API's feed is
|
|
760
|
+
* one channel's, and only it can wait for what comes next, so this waits on each at once and lets
|
|
761
|
+
* the rest go when the first answers with something: a read across channels costs a request a
|
|
762
|
+
* channel each time it waits, not each second it does.
|
|
763
|
+
*/
|
|
764
|
+
async function changed(who, listed, position, until, signal) {
|
|
765
|
+
const wait = Math.min(WAIT_MAX_S, Math.ceil((until - Date.now()) / 1e3));
|
|
766
|
+
if (wait <= 0) return false;
|
|
767
|
+
if (listed.length === 0) {
|
|
768
|
+
await pause(until - Date.now(), signal);
|
|
769
|
+
return false;
|
|
770
|
+
}
|
|
771
|
+
const stop = new AbortController();
|
|
772
|
+
const either = AbortSignal.any([signal, stop.signal]);
|
|
773
|
+
const path = await onBoard(who, "/changes");
|
|
774
|
+
try {
|
|
775
|
+
return await new Promise((resolve, reject) => {
|
|
776
|
+
let pending = listed.length;
|
|
777
|
+
for (const channel of listed) {
|
|
778
|
+
const at = position.feeds[channel.id]?.at;
|
|
779
|
+
api(who, "GET", path, {
|
|
780
|
+
query: {
|
|
781
|
+
channelId: channel.id,
|
|
782
|
+
...at ? { cursor: at } : { from: "latest" },
|
|
783
|
+
wait: String(wait)
|
|
784
|
+
},
|
|
785
|
+
signal: either
|
|
786
|
+
}).then((page) => {
|
|
787
|
+
if (page.events.length > 0) resolve(true);
|
|
788
|
+
else if (--pending === 0) resolve(false);
|
|
789
|
+
}).catch((error) => stop.signal.aborted && !signal.aborted ? void 0 : reject(error));
|
|
790
|
+
}
|
|
791
|
+
});
|
|
792
|
+
} finally {
|
|
793
|
+
stop.abort();
|
|
794
|
+
}
|
|
795
|
+
}
|
|
716
796
|
/** Whether a read filters on what messages say, who wrote them, or their labels: what the API can't narrow by. */
|
|
717
797
|
const filtered = (filters) => filters.by !== void 0 || filters.mentions !== void 0 || filters.text !== void 0 || filters.from !== void 0 || (filters.label?.length ?? 0) > 0;
|
|
718
798
|
/**
|
|
@@ -1072,18 +1152,24 @@ function createVercel(options, environment) {
|
|
|
1072
1152
|
},
|
|
1073
1153
|
async channels(caller) {
|
|
1074
1154
|
return {
|
|
1075
|
-
channels: (await channelsFor(whoOf(caller), void 0, accessOf(caller))).map((channel) => ({
|
|
1076
|
-
path: channel.name,
|
|
1077
|
-
lastIndex: 0,
|
|
1078
|
-
messages: 0,
|
|
1079
|
-
threads: 0
|
|
1080
|
-
})),
|
|
1155
|
+
channels: (await channelsFor(whoOf(caller), void 0, accessOf(caller))).map((channel) => ({ path: channel.name })).sort((a, b) => a.path.localeCompare(b.path)),
|
|
1081
1156
|
cursor: cursorOf({
|
|
1082
1157
|
t: Date.now(),
|
|
1083
1158
|
feeds: {}
|
|
1084
1159
|
})
|
|
1085
1160
|
};
|
|
1086
1161
|
},
|
|
1162
|
+
async createChannel(caller, { path }) {
|
|
1163
|
+
checkCaller("createChannel", caller);
|
|
1164
|
+
const access = accessOf(caller);
|
|
1165
|
+
need(access, "read", path);
|
|
1166
|
+
need(access, "post", path);
|
|
1167
|
+
const { created } = await ensureChannel(whoOf(caller), path);
|
|
1168
|
+
return {
|
|
1169
|
+
channel: { path },
|
|
1170
|
+
created
|
|
1171
|
+
};
|
|
1172
|
+
},
|
|
1087
1173
|
async actors(caller, _input, signal) {
|
|
1088
1174
|
const who = whoOf(caller);
|
|
1089
1175
|
const listed = (await all(who, await onBoard(who, "/actors"), "actors", {}, signal)).map((actor) => ({
|
|
@@ -1177,13 +1263,29 @@ function createVercel(options, environment) {
|
|
|
1177
1263
|
}))))).flat();
|
|
1178
1264
|
const rooted = found.filter(({ thread }) => (query.label ?? []).every(([key, values]) => thread.labels !== void 0 && Object.hasOwn(thread.labels, key) && (values === null || values.includes(thread.labels[key]))));
|
|
1179
1265
|
const newest = found.reduce((max, { at }) => Math.max(max, at), 0);
|
|
1180
|
-
return {
|
|
1266
|
+
if (!query.label?.length) return {
|
|
1181
1267
|
threads: await Promise.all(pick(rooted).map(({ thread, channel }) => summary(who, thread, channel, signal))),
|
|
1182
1268
|
cursor: cursorOf({
|
|
1183
1269
|
t: newest,
|
|
1184
1270
|
feeds
|
|
1185
1271
|
})
|
|
1186
1272
|
};
|
|
1273
|
+
const candidates = rooted.filter(({ at }) => after === void 0 || at > after).sort((a, b) => a.at - b.at);
|
|
1274
|
+
if (after === void 0) candidates.reverse();
|
|
1275
|
+
const threads = [];
|
|
1276
|
+
for (let next = 0; next < candidates.length && threads.length < limit;) {
|
|
1277
|
+
const page = candidates.slice(next, next + limit - threads.length);
|
|
1278
|
+
next += page.length;
|
|
1279
|
+
for (const shown of await Promise.all(page.map(({ thread, channel }) => summary(who, thread, channel, signal)))) if (!shown.message.deleted) threads.push(shown);
|
|
1280
|
+
}
|
|
1281
|
+
if (after === void 0) threads.reverse();
|
|
1282
|
+
return {
|
|
1283
|
+
threads,
|
|
1284
|
+
cursor: cursorOf({
|
|
1285
|
+
t: newest,
|
|
1286
|
+
feeds
|
|
1287
|
+
})
|
|
1288
|
+
};
|
|
1187
1289
|
},
|
|
1188
1290
|
async message(caller, { id }, signal) {
|
|
1189
1291
|
const who = whoOf(caller);
|
|
@@ -1416,6 +1518,54 @@ function createVercel(options, environment) {
|
|
|
1416
1518
|
});
|
|
1417
1519
|
return { ok: true };
|
|
1418
1520
|
},
|
|
1521
|
+
async grants(caller, _input, signal) {
|
|
1522
|
+
checkCaller("grants", caller);
|
|
1523
|
+
const who = whoOf(caller);
|
|
1524
|
+
return api(who, "GET", await onBoard(who, "/grants"), signal ? { signal } : {});
|
|
1525
|
+
},
|
|
1526
|
+
async createGrant(caller, input, signal) {
|
|
1527
|
+
checkCaller("createGrant", caller);
|
|
1528
|
+
const who = whoOf(caller);
|
|
1529
|
+
return api(who, "POST", await onBoard(who, "/grants"), {
|
|
1530
|
+
body: {
|
|
1531
|
+
operationId: operationId(),
|
|
1532
|
+
...input
|
|
1533
|
+
},
|
|
1534
|
+
...signal ? { signal } : {}
|
|
1535
|
+
});
|
|
1536
|
+
},
|
|
1537
|
+
async revokeGrant(caller, { id }, signal) {
|
|
1538
|
+
checkCaller("revokeGrant", caller);
|
|
1539
|
+
const who = whoOf(caller);
|
|
1540
|
+
return api(who, "POST", await onBoard(who, `/grants/${encodeURIComponent(id)}/revoke`), {
|
|
1541
|
+
body: { operationId: operationId() },
|
|
1542
|
+
...signal ? { signal } : {}
|
|
1543
|
+
});
|
|
1544
|
+
},
|
|
1545
|
+
async tokens(caller, _input, signal) {
|
|
1546
|
+
checkCaller("tokens", caller);
|
|
1547
|
+
const who = whoOf(caller);
|
|
1548
|
+
return api(who, "GET", await onBoard(who, "/tokens"), signal ? { signal } : {});
|
|
1549
|
+
},
|
|
1550
|
+
async createToken(caller, input, signal) {
|
|
1551
|
+
checkCaller("createToken", caller);
|
|
1552
|
+
const who = whoOf(caller);
|
|
1553
|
+
return api(who, "POST", await onBoard(who, "/tokens"), {
|
|
1554
|
+
body: {
|
|
1555
|
+
operationId: operationId(),
|
|
1556
|
+
...input
|
|
1557
|
+
},
|
|
1558
|
+
...signal ? { signal } : {}
|
|
1559
|
+
});
|
|
1560
|
+
},
|
|
1561
|
+
async revokeToken(caller, { id }, signal) {
|
|
1562
|
+
checkCaller("revokeToken", caller);
|
|
1563
|
+
const who = whoOf(caller);
|
|
1564
|
+
return api(who, "POST", await onBoard(who, `/tokens/${encodeURIComponent(id)}/revoke`), {
|
|
1565
|
+
body: { operationId: operationId() },
|
|
1566
|
+
...signal ? { signal } : {}
|
|
1567
|
+
});
|
|
1568
|
+
},
|
|
1419
1569
|
async schedule(caller, input, signal) {
|
|
1420
1570
|
if (input.attachments?.length) throw notSupported("files on scheduled messages");
|
|
1421
1571
|
const who = whoOf(caller);
|
|
@@ -1514,14 +1664,17 @@ function createVercel(options, environment) {
|
|
|
1514
1664
|
feeds: {}
|
|
1515
1665
|
} : positionOf(query.after);
|
|
1516
1666
|
const until = Date.now() + (query.wait ?? 0) * 1e3;
|
|
1667
|
+
let busy = false;
|
|
1517
1668
|
for (;;) {
|
|
1669
|
+
const started = Date.now();
|
|
1518
1670
|
const page = await read(who, listed, position, query, signal);
|
|
1519
1671
|
position = page.position;
|
|
1520
1672
|
if (page.events.length > 0 || Date.now() >= until || signal.aborted) return {
|
|
1521
1673
|
events: page.events,
|
|
1522
1674
|
cursor: cursorOf(position)
|
|
1523
1675
|
};
|
|
1524
|
-
|
|
1676
|
+
if (!busy) busy = await changed(who, listed, position, until, signal) && Date.now() - started < 1e3;
|
|
1677
|
+
await pause(Math.min(started + 1e3, until) - Date.now(), signal);
|
|
1525
1678
|
}
|
|
1526
1679
|
},
|
|
1527
1680
|
async typing() {
|
|
@@ -1588,4 +1741,4 @@ function createVercel(options, environment) {
|
|
|
1588
1741
|
};
|
|
1589
1742
|
}
|
|
1590
1743
|
//#endregion
|
|
1591
|
-
export { createVercel as t };
|
|
1744
|
+
export { isApiMessageId as n, createVercel as t };
|