@vercel/board 0.32.0 → 0.34.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-CdBcYPQH.mjs} +170 -13
- package/dist/access.d.mts +4 -5
- package/dist/access.mjs +5 -5
- package/dist/{actors-Bm-ojWWT.mjs → actors-MrIEr9LI.mjs} +3 -3
- package/dist/auth-DjoJygbG.mjs +599 -0
- package/dist/{auth-K8dY1nBY.d.mts → auth-aaoKt5DK.d.mts} +133 -100
- package/dist/backend-local.d.mts +28 -0
- package/dist/backend-local.mjs +2 -0
- package/dist/{backend-DxE9wGKm.d.mts → backend-u1sVvybh.d.mts} +108 -55
- package/dist/{chat-provider-DkFp2hrh.mjs → chat-provider-9hCT654s.mjs} +2 -2
- package/dist/{chat-provider-BChYrrA7.d.mts → chat-provider-De0iDnUB.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-DsnQKTdB.mjs → commands-B8oZEByR.mjs} +37 -52
- package/dist/{commands-CpyPV_tk.d.mts → commands-BkVMdXP1.d.mts} +9 -6
- package/dist/{conformance-3RBKxwbp.mjs → conformance-gqYBkXFS.mjs} +79 -86
- package/dist/conformance.d.mts +1 -1
- package/dist/conformance.mjs +1 -1
- package/dist/{engine-DurYIRt8.mjs → engine-rtOVWsiF.mjs} +6 -8
- package/dist/{errors-CJXhhzvT.mjs → errors-D8ifv16L.mjs} +75 -6
- package/dist/{events-lujPA3gQ.mjs → events-IQg0k281.mjs} +2 -2
- package/dist/exports-Bx2dGpzr.mjs +3252 -0
- package/dist/exports-uwRl5qIj.d.mts +4 -0
- package/dist/{external-D3p5T57R.mjs → external-CYe424fO.mjs} +1 -1
- package/dist/index-D6mK0Ial.d.mts +11 -0
- package/dist/index.d.mts +10 -9
- package/dist/index.mjs +21 -8
- package/dist/index.node.d.mts +6 -7
- 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-CPz22MQ8.mjs +9225 -0
- package/dist/{main-CcYDo9Hb.mjs → main-DScDKwQN.mjs} +129 -54
- package/dist/{backend-a2/store-memory.mjs → memory-7RRnLa4X.mjs} +3 -3
- package/dist/middleware-BjYpk4yq.mjs +103 -0
- package/dist/{provider-gynDUoyW.d.mts → provider-hB8QNrwm.d.mts} +369 -3
- package/dist/{client-COfYrgfV.d.mts → routes-De4W6lEs.d.mts} +997 -367
- package/dist/{schemas-DBmUO6pr.mjs → schemas-BG205xds.mjs} +2 -5
- package/dist/{serve-Bplieh0C.mjs → serve-B1noQRkn.mjs} +33 -24
- package/dist/{node-BgeGcwX0.mjs → server-Ov6GBJ8j.mjs} +419 -6
- package/dist/{serving-Y7s7VDjB.mjs → serving-2s7lqSBS.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 +3 -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-aMdbp84G.mjs} +134 -16
- package/dist/{tokens-C7kYyrAG.mjs → tokens-LHLrnV_P.mjs} +15 -43
- package/docs/01-board/01-mounting.md +245 -288
- package/docs/01-board/03-identity.md +42 -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 +187 -343
- 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 +29 -36
- package/docs/04-reference/01-cli.md +113 -38
- package/docs/04-reference/02-board.md +79 -82
- package/docs/04-reference/03-http.md +138 -69
- package/docs/04-reference/05-conformance.md +32 -46
- 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/auth-8pRZnF1M.mjs +0 -393
- 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-DLUzfibJ.d.mts +0 -558
- 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/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
package/dist/folds-DsWfIftc.mjs
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { b as actorKind } from "./schemas-DBmUO6pr.mjs";
|
|
2
|
-
import { c as externalMessageKey, l as isThreadTarget } from "./external-D3p5T57R.mjs";
|
|
3
|
-
import { t as canonicalEmoji } from "./emoji-CTLpvH-A.mjs";
|
|
4
|
-
import { n as setOwn, t as own } from "./own-OwgPWdmh.mjs";
|
|
5
|
-
//#region src/contract/folds.ts
|
|
6
|
-
const iso = (date) => typeof date === "string" ? date : date.toISOString();
|
|
7
|
-
function foldMessages(state, event) {
|
|
8
|
-
const changed = foldMessage(state, event);
|
|
9
|
-
if (changed) changed.version = event.index;
|
|
10
|
-
if (changed && (event.type === "message.posted" || event.type === "message.edited" || event.type === "message.deleted")) changed.revision = event.index;
|
|
11
|
-
return state;
|
|
12
|
-
}
|
|
13
|
-
/** Applies `event`, and returns the message it changed: none for an event that changes nothing. */
|
|
14
|
-
function foldMessage(state, event) {
|
|
15
|
-
switch (event.type) {
|
|
16
|
-
case "message.posted": {
|
|
17
|
-
const { payload } = event;
|
|
18
|
-
const message = {
|
|
19
|
-
id: event.index,
|
|
20
|
-
channel: payload.channel,
|
|
21
|
-
text: payload.text,
|
|
22
|
-
re: payload.re,
|
|
23
|
-
replyTo: payload.replyTo,
|
|
24
|
-
thread: payload.thread,
|
|
25
|
-
labels: { ...payload.labels },
|
|
26
|
-
reactions: {},
|
|
27
|
-
mentions: payload.mentions,
|
|
28
|
-
by: payload.by,
|
|
29
|
-
noSync: payload.noSync,
|
|
30
|
-
origin: payload.origin,
|
|
31
|
-
from: payload.from,
|
|
32
|
-
createdAt: iso(event.createdAt),
|
|
33
|
-
editedAt: null,
|
|
34
|
-
deleted: false,
|
|
35
|
-
undelivered: {},
|
|
36
|
-
attachments: payload.attachments ?? [],
|
|
37
|
-
links: payload.links ?? [],
|
|
38
|
-
...payload.schedule ? { schedule: { ...payload.schedule } } : {},
|
|
39
|
-
...payload.blind ? { blind: true } : {}
|
|
40
|
-
};
|
|
41
|
-
state.byId[event.index] = message;
|
|
42
|
-
if (payload.re !== null) (state.replies[payload.re] ??= []).push(event.index);
|
|
43
|
-
return message;
|
|
44
|
-
}
|
|
45
|
-
case "message.edited": {
|
|
46
|
-
const message = state.byId[event.payload.id];
|
|
47
|
-
if (!message || message.deleted) return void 0;
|
|
48
|
-
message.text = event.payload.text;
|
|
49
|
-
message.mentions = event.payload.mentions;
|
|
50
|
-
message.editedAt = iso(event.createdAt);
|
|
51
|
-
return message;
|
|
52
|
-
}
|
|
53
|
-
case "message.deleted": {
|
|
54
|
-
const message = state.byId[event.payload.id];
|
|
55
|
-
if (!message || message.deleted) return void 0;
|
|
56
|
-
message.deleted = true;
|
|
57
|
-
message.text = "";
|
|
58
|
-
message.reactions = {};
|
|
59
|
-
message.labels = {};
|
|
60
|
-
message.mentions = [];
|
|
61
|
-
message.attachments = [];
|
|
62
|
-
message.links = [];
|
|
63
|
-
return message;
|
|
64
|
-
}
|
|
65
|
-
case "reaction.added": {
|
|
66
|
-
const message = state.byId[event.payload.id];
|
|
67
|
-
if (!message || message.deleted) return void 0;
|
|
68
|
-
const emoji = canonicalEmoji(event.payload.emoji);
|
|
69
|
-
const actors = own(message.reactions, emoji);
|
|
70
|
-
if (actors?.includes(event.payload.by.actor)) return void 0;
|
|
71
|
-
if (actors) actors.push(event.payload.by.actor);
|
|
72
|
-
else setOwn(message.reactions, emoji, [event.payload.by.actor]);
|
|
73
|
-
return message;
|
|
74
|
-
}
|
|
75
|
-
case "reaction.removed": {
|
|
76
|
-
const message = state.byId[event.payload.id];
|
|
77
|
-
if (!message || message.deleted) return void 0;
|
|
78
|
-
const { by } = event.payload;
|
|
79
|
-
const emoji = canonicalEmoji(event.payload.emoji);
|
|
80
|
-
const had = own(message.reactions, emoji);
|
|
81
|
-
if (!had?.includes(by.actor)) return void 0;
|
|
82
|
-
const actors = had.filter((a) => a !== by.actor);
|
|
83
|
-
if (actors.length > 0) setOwn(message.reactions, emoji, actors);
|
|
84
|
-
else delete message.reactions[emoji];
|
|
85
|
-
return message;
|
|
86
|
-
}
|
|
87
|
-
case "labels.changed": {
|
|
88
|
-
const message = state.byId[event.payload.id];
|
|
89
|
-
if (!message || message.deleted) return void 0;
|
|
90
|
-
for (const [key, value] of Object.entries(event.payload.set)) setOwn(message.labels, key, value);
|
|
91
|
-
for (const key of event.payload.unset) delete message.labels[key];
|
|
92
|
-
return message;
|
|
93
|
-
}
|
|
94
|
-
case "message.linked": {
|
|
95
|
-
const message = state.byId[event.payload.id];
|
|
96
|
-
if (!message || message.deleted) return void 0;
|
|
97
|
-
message.links = event.payload.links;
|
|
98
|
-
return message;
|
|
99
|
-
}
|
|
100
|
-
case "message.sync_failed": {
|
|
101
|
-
const message = state.byId[event.payload.id];
|
|
102
|
-
if (!message) return void 0;
|
|
103
|
-
setOwn(message.undelivered, event.payload.target, event.payload.error);
|
|
104
|
-
return message;
|
|
105
|
-
}
|
|
106
|
-
case "message.synced": {
|
|
107
|
-
const message = state.byId[event.payload.id];
|
|
108
|
-
if (!message || !Object.hasOwn(message.undelivered, event.payload.target)) return void 0;
|
|
109
|
-
delete message.undelivered[event.payload.target];
|
|
110
|
-
return message;
|
|
111
|
-
}
|
|
112
|
-
default: return;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
/** Who's who: `actor.seen`. */
|
|
116
|
-
function foldActors(state, event) {
|
|
117
|
-
if (event.type !== "actor.seen") return state;
|
|
118
|
-
const { actor, kind, handle, name, avatar, host } = event.payload;
|
|
119
|
-
const previous = own(state.byId, actor);
|
|
120
|
-
if (previous) {
|
|
121
|
-
const key = previous.handle.toLowerCase();
|
|
122
|
-
const remaining = (own(state.byHandle, key) ?? []).filter((id) => id !== actor);
|
|
123
|
-
if (remaining.length > 0) setOwn(state.byHandle, key, remaining);
|
|
124
|
-
else delete state.byHandle[key];
|
|
125
|
-
}
|
|
126
|
-
setOwn(state.byId, actor, {
|
|
127
|
-
id: actor,
|
|
128
|
-
kind: actorKind(kind),
|
|
129
|
-
handle,
|
|
130
|
-
name,
|
|
131
|
-
avatar,
|
|
132
|
-
...host || previous?.host ? { host: true } : {}
|
|
133
|
-
});
|
|
134
|
-
const key = handle.toLowerCase();
|
|
135
|
-
const ids = own(state.byHandle, key) ?? setOwn(state.byHandle, key, []);
|
|
136
|
-
if (!ids.includes(actor)) ids.push(actor);
|
|
137
|
-
return state;
|
|
138
|
-
}
|
|
139
|
-
const addTarget = (thread, target) => {
|
|
140
|
-
if (!thread.targets.includes(target)) thread.targets.push(target);
|
|
141
|
-
};
|
|
142
|
-
function foldSync(state, event) {
|
|
143
|
-
switch (event.type) {
|
|
144
|
-
case "message.posted": {
|
|
145
|
-
const { payload } = event;
|
|
146
|
-
if (payload.re === null) setOwn(state.threads, payload.thread, {
|
|
147
|
-
root: event.index,
|
|
148
|
-
channel: payload.channel,
|
|
149
|
-
targets: [],
|
|
150
|
-
external: {}
|
|
151
|
-
});
|
|
152
|
-
const origin = payload.origin;
|
|
153
|
-
if (!origin) return state;
|
|
154
|
-
const thread = own(state.threads, payload.thread);
|
|
155
|
-
if (thread && payload.re === null) {
|
|
156
|
-
addTarget(thread, origin.thread);
|
|
157
|
-
setOwn(thread.kinds ??= {}, origin.thread, "thread");
|
|
158
|
-
setOwn(thread.external, origin.thread, origin.thread);
|
|
159
|
-
setOwn(state.byExternalThread, origin.thread, payload.thread);
|
|
160
|
-
}
|
|
161
|
-
const precise = origin.subthread ?? origin.thread;
|
|
162
|
-
setOwn(state.copies[event.index] ??= {}, origin.thread, {
|
|
163
|
-
thread: precise,
|
|
164
|
-
message: origin.message,
|
|
165
|
-
...payload.importedBy ? { by: payload.importedBy } : {}
|
|
166
|
-
});
|
|
167
|
-
state.byExternalMessage[externalMessageKey(precise, origin.message)] = event.index;
|
|
168
|
-
if (precise !== origin.thread) state.byExternalMessage[externalMessageKey(origin.thread, origin.message)] = event.index;
|
|
169
|
-
return state;
|
|
170
|
-
}
|
|
171
|
-
case "thread.synced": {
|
|
172
|
-
const thread = own(state.threads, event.payload.thread);
|
|
173
|
-
if (!thread) return state;
|
|
174
|
-
addTarget(thread, event.payload.target);
|
|
175
|
-
if (event.payload.kind) setOwn(thread.kinds ??= {}, event.payload.target, event.payload.kind);
|
|
176
|
-
if ((event.payload.kind ?? (isThreadTarget(event.payload.target) ? "thread" : "channel")) === "thread") {
|
|
177
|
-
setOwn(thread.external, event.payload.target, event.payload.target);
|
|
178
|
-
setOwn(state.byExternalThread, event.payload.target, event.payload.thread);
|
|
179
|
-
}
|
|
180
|
-
return state;
|
|
181
|
-
}
|
|
182
|
-
case "message.files_synced": {
|
|
183
|
-
const copies = state.copies[event.payload.id];
|
|
184
|
-
const copy = copies && own(copies, event.payload.target);
|
|
185
|
-
if (copy && copy.by === event.payload.syncedBy) copy.files = event.payload.files;
|
|
186
|
-
return state;
|
|
187
|
-
}
|
|
188
|
-
case "message.synced": {
|
|
189
|
-
const { id, target, external, syncedBy } = event.payload;
|
|
190
|
-
setOwn(state.copies[id] ??= {}, target, {
|
|
191
|
-
...external,
|
|
192
|
-
...syncedBy ? { by: syncedBy } : {}
|
|
193
|
-
});
|
|
194
|
-
state.byExternalMessage[externalMessageKey(external.thread, external.message)] = id;
|
|
195
|
-
const thread = own(state.threads, event.payload.thread);
|
|
196
|
-
const main = thread ? own(thread.external, target) : void 0;
|
|
197
|
-
if (main && main !== external.thread) state.byExternalMessage[externalMessageKey(main, external.message)] = id;
|
|
198
|
-
if (thread && thread.root === id && ((thread.kinds && own(thread.kinds, target)) ?? (isThreadTarget(target) ? "thread" : "channel")) === "channel") {
|
|
199
|
-
setOwn(thread.external, target, external.thread);
|
|
200
|
-
setOwn(state.byExternalThread, external.thread, event.payload.thread);
|
|
201
|
-
}
|
|
202
|
-
return state;
|
|
203
|
-
}
|
|
204
|
-
default: return state;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
//#endregion
|
|
208
|
-
export { iso as i, foldMessages as n, foldSync as r, foldActors as t };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { f as Board, p as BoardOptions } from "./backend-DxE9wGKm.mjs";
|
|
2
|
-
import "./exports-u5mApVvn.mjs";
|
|
3
|
-
//#region src/server/index.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* The handle on a board. With a `backend`, the board lives there: `a2()` keeps it in this
|
|
6
|
-
* deployment, `http(url)` uses another. Without one, it's `http()` to the board the environment
|
|
7
|
-
* points at: `BOARD_URL`.
|
|
8
|
-
*/
|
|
9
|
-
declare function board(options?: BoardOptions): Board;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { board as t };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { r as createHttp } from "./backend-http-l5A8UmL-.mjs";
|
|
2
|
-
//#region src/backend-http/index.default.ts
|
|
3
|
-
/**
|
|
4
|
-
* The board at `url`, which keeps the log. Outside Node there's no environment to find it or a
|
|
5
|
-
* token in: `fetch` (the global one by default) sends the page's own session, which the board's
|
|
6
|
-
* `authenticate` recognizes.
|
|
7
|
-
*/
|
|
8
|
-
function http(url, options = {}) {
|
|
9
|
-
return createHttp(url, options, null);
|
|
10
|
-
}
|
|
11
|
-
//#endregion
|
|
12
|
-
export { http as t };
|
package/dist/local-C76Fy5ad.mjs
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { i as deliverSchedulerClear, r as deliverSchedulerAppend } from "./server-DX7mM6nm-D7N_7bug.mjs";
|
|
2
|
-
//#region src/scheduler/local.ts
|
|
3
|
-
/** The longest delay a timer takes: past it, `setTimeout` fires at once. */
|
|
4
|
-
const MAX_DELAY = 2 ** 31 - 1;
|
|
5
|
-
/**
|
|
6
|
-
* A scheduler in this process (`@vercel/board/backend-a2/scheduler-local`): each task runs at its time on
|
|
7
|
-
* a timer, so retries, leases, wake-ups, and scheduled messages work with nothing else running.
|
|
8
|
-
* Its timers live in the process, and a restart drops the pending ones, so it's for development,
|
|
9
|
-
* `vb serve`, tests, and long-running servers, never serverless functions, which stop between
|
|
10
|
-
* requests: there, use `vercelQueues()` or `qstash()`.
|
|
11
|
-
*/
|
|
12
|
-
function localScheduler() {
|
|
13
|
-
let servers = [];
|
|
14
|
-
const pending = /* @__PURE__ */ new Set();
|
|
15
|
-
async function run(task) {
|
|
16
|
-
const server = servers.find((candidate) => candidate.contract.name === task.contract);
|
|
17
|
-
if (!server) throw new Error(`no server for contract ${task.contract}: mount it with scheduler.handler(...)`);
|
|
18
|
-
if (task.kind === "drain") await server.drain(task.sessionId);
|
|
19
|
-
else if (task.kind === "append") await deliverSchedulerAppend(server, task);
|
|
20
|
-
else await deliverSchedulerClear(server, task);
|
|
21
|
-
}
|
|
22
|
-
return {
|
|
23
|
-
async schedule(task) {
|
|
24
|
-
const key = task.kind === "drain" ? `drain\u001f${task.contract}\u001f${task.sessionId}\u001f${task.dueAt}` : task.id;
|
|
25
|
-
if (pending.has(key)) return;
|
|
26
|
-
pending.add(key);
|
|
27
|
-
const arm = () => {
|
|
28
|
-
const wait = task.dueAt - Date.now();
|
|
29
|
-
setTimeout(() => {
|
|
30
|
-
if (wait > MAX_DELAY) return arm();
|
|
31
|
-
pending.delete(key);
|
|
32
|
-
run(task).catch((error) => console.error("[board] a scheduled task failed:", error));
|
|
33
|
-
}, Math.min(Math.max(0, wait), MAX_DELAY)).unref?.();
|
|
34
|
-
};
|
|
35
|
-
arm();
|
|
36
|
-
},
|
|
37
|
-
handler(...mounted) {
|
|
38
|
-
servers = mounted;
|
|
39
|
-
return async () => new Response(null, { status: 204 });
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
export { localScheduler as t };
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { m as MESSAGE_TEXT_MAX, p as Labels } from "./schemas-DBmUO6pr.mjs";
|
|
2
|
-
import { t as HttpError } from "./errors-CJXhhzvT.mjs";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
//#region src/server/middleware.ts
|
|
5
|
-
/** A write the middleware didn't let through: the API answers 422 with what it responded. */
|
|
6
|
-
var DroppedError = class extends HttpError {
|
|
7
|
-
/** What the middleware responded, in order: none when it dropped the write without a word. */
|
|
8
|
-
responses;
|
|
9
|
-
constructor(responses) {
|
|
10
|
-
super(422, "dropped", responses.join("\n") || "the board dropped this message");
|
|
11
|
-
this.responses = responses;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
const Patch = z.object({
|
|
15
|
-
text: z.string().max(MESSAGE_TEXT_MAX).optional(),
|
|
16
|
-
labels: Labels.optional()
|
|
17
|
-
}).strict();
|
|
18
|
-
const MIDDLEWARE_ACTOR = "board:middleware";
|
|
19
|
-
/**
|
|
20
|
-
* Runs `write` through `middleware` in order, then `commit`s what the last one
|
|
21
|
-
* passed on. Throws `DroppedError` when one doesn't call `next`.
|
|
22
|
-
*/
|
|
23
|
-
async function runMiddleware(middleware, input, commit) {
|
|
24
|
-
const responses = [];
|
|
25
|
-
let committed = null;
|
|
26
|
-
const step = async (i, write) => {
|
|
27
|
-
if (i === middleware.length) {
|
|
28
|
-
if (write.text.trim() === "" && (write.kind === "edit" || write.attachments.length === 0)) return;
|
|
29
|
-
committed = { value: await commit(write) };
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
let next = null;
|
|
33
|
-
await middleware[i]({
|
|
34
|
-
write: Object.freeze({ ...write }),
|
|
35
|
-
author: Object.freeze({ ...input.author }),
|
|
36
|
-
source: Object.freeze({ ...input.source }),
|
|
37
|
-
board: input.board(),
|
|
38
|
-
respond: async (text) => {
|
|
39
|
-
responses.push(text);
|
|
40
|
-
},
|
|
41
|
-
next: (patch = {}) => {
|
|
42
|
-
if (next) throw new Error("next() was already called");
|
|
43
|
-
const { text, labels } = Patch.parse(patch);
|
|
44
|
-
next = step(i + 1, {
|
|
45
|
-
...write,
|
|
46
|
-
...text !== void 0 ? { text } : {},
|
|
47
|
-
...write.kind === "post" && labels ? { labels: {
|
|
48
|
-
...write.labels,
|
|
49
|
-
...labels
|
|
50
|
-
} } : {}
|
|
51
|
-
});
|
|
52
|
-
return next;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
if (next) await next;
|
|
56
|
-
};
|
|
57
|
-
await step(0, input.write);
|
|
58
|
-
if (!committed) throw new DroppedError(responses);
|
|
59
|
-
return committed.value;
|
|
60
|
-
}
|
|
61
|
-
//#endregion
|
|
62
|
-
export { MIDDLEWARE_ACTOR as n, runMiddleware as r, DroppedError as t };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/experimental-a2@0.24.0_@upstash+qstash@2.12.0_@vercel+queue@0.7.0_ai@7.0.130_zod@4.6.5__b1e2c243a963f2620a5d202817417c26/node_modules/experimental-a2/dist/platform-B4TnJtWu.js
|
|
2
|
-
const SYMBOL_FOR_REQ_CONTEXT = Symbol.for("@vercel/request-context");
|
|
3
|
-
function requestContext() {
|
|
4
|
-
try {
|
|
5
|
-
return Reflect.get(globalThis, SYMBOL_FOR_REQ_CONTEXT)?.get?.() ?? {};
|
|
6
|
-
} catch {
|
|
7
|
-
return {};
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
/** The current invocation's Vercel deployment identity, when available. */
|
|
11
|
-
function platformVercelOidcToken() {
|
|
12
|
-
try {
|
|
13
|
-
const token = requestContext().headers?.["x-vercel-oidc-token"];
|
|
14
|
-
return typeof token === "string" && token.length > 0 ? token : null;
|
|
15
|
-
} catch {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function platformWaitUntil(promise) {
|
|
20
|
-
try {
|
|
21
|
-
requestContext().waitUntil?.(promise);
|
|
22
|
-
} catch {}
|
|
23
|
-
}
|
|
24
|
-
/** The invocation's termination time in epoch ms, or null if unknowable. */
|
|
25
|
-
function invocationDeadlineMs() {
|
|
26
|
-
const deadline = requestContext().deadline;
|
|
27
|
-
if (deadline === void 0 || deadline === null) return null;
|
|
28
|
-
const ms = new Date(deadline).getTime();
|
|
29
|
-
return Number.isNaN(ms) ? null : ms;
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
|
-
export { platformVercelOidcToken as n, platformWaitUntil as r, invocationDeadlineMs as t };
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { n as setOwn, t as own } from "./own-OwgPWdmh.mjs";
|
|
2
|
-
import { n as foldMessages, r as foldSync } from "./folds-DsWfIftc.mjs";
|
|
3
|
-
//#region src/store/project.ts
|
|
4
|
-
/** The message an event concerns, if any. */
|
|
5
|
-
function concernedMessageId(event) {
|
|
6
|
-
if (event.type === "message.posted") return event.index;
|
|
7
|
-
if ("id" in event.payload) return event.payload.id;
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
const termsOf = (message) => JSON.stringify([
|
|
11
|
-
message.labels,
|
|
12
|
-
message.mentions,
|
|
13
|
-
message.attachments.map((file) => file.id)
|
|
14
|
-
]);
|
|
15
|
-
/**
|
|
16
|
-
* Applies one event to what the tables hold, with the same fold the board has
|
|
17
|
-
* always used, on a state of just that message. Pure: the caller reads `before`
|
|
18
|
-
* and writes the change.
|
|
19
|
-
*/
|
|
20
|
-
function project(before, event) {
|
|
21
|
-
const id = concernedMessageId(event);
|
|
22
|
-
if (id === null) return {};
|
|
23
|
-
const current = before.message;
|
|
24
|
-
if (event.type !== "message.posted" && !current) return {};
|
|
25
|
-
const state = {
|
|
26
|
-
byId: current ? { [id]: structuredClone(current) } : {},
|
|
27
|
-
replies: {}
|
|
28
|
-
};
|
|
29
|
-
foldMessages(state, event);
|
|
30
|
-
const after = state.byId[id];
|
|
31
|
-
if (!after) return {};
|
|
32
|
-
const change = {};
|
|
33
|
-
const created = current === void 0;
|
|
34
|
-
if (created || JSON.stringify(after) !== JSON.stringify(current)) change.message = {
|
|
35
|
-
after,
|
|
36
|
-
created,
|
|
37
|
-
terms: created || termsOf(after) !== termsOf(current)
|
|
38
|
-
};
|
|
39
|
-
if (event.type === "message.posted") {
|
|
40
|
-
if (after.re === null) change.summary = {
|
|
41
|
-
root: id,
|
|
42
|
-
replies: 0,
|
|
43
|
-
at: id
|
|
44
|
-
};
|
|
45
|
-
else if (before.root) change.summary = {
|
|
46
|
-
root: after.re,
|
|
47
|
-
replies: before.root.replies + 1,
|
|
48
|
-
at: id
|
|
49
|
-
};
|
|
50
|
-
} else if (event.type === "message.deleted" && current && !current.deleted && current.re !== null && before.root) {
|
|
51
|
-
const at = before.root.at === id ? before.previousLast ?? current.re : before.root.at;
|
|
52
|
-
change.summary = {
|
|
53
|
-
root: current.re,
|
|
54
|
-
replies: before.root.replies - 1,
|
|
55
|
-
at
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
return change;
|
|
59
|
-
}
|
|
60
|
-
/** The sync rows `event` reads before it applies: none for events that don't touch the sync state. */
|
|
61
|
-
function syncReads(event) {
|
|
62
|
-
switch (event.type) {
|
|
63
|
-
case "message.posted": return {
|
|
64
|
-
thread: null,
|
|
65
|
-
copy: null
|
|
66
|
-
};
|
|
67
|
-
case "thread.synced":
|
|
68
|
-
case "message.synced": return {
|
|
69
|
-
thread: event.payload.thread,
|
|
70
|
-
copy: null
|
|
71
|
-
};
|
|
72
|
-
case "message.files_synced": return {
|
|
73
|
-
thread: null,
|
|
74
|
-
copy: [event.payload.id, event.payload.target]
|
|
75
|
-
};
|
|
76
|
-
default: return {
|
|
77
|
-
thread: null,
|
|
78
|
-
copy: null
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Applies one event to the sync state, with the fold the board has always used,
|
|
84
|
-
* on a state of just what the event touches. Pure, like `project`.
|
|
85
|
-
*/
|
|
86
|
-
function projectSync(before, event) {
|
|
87
|
-
const change = {
|
|
88
|
-
externalThreads: [],
|
|
89
|
-
copies: [],
|
|
90
|
-
externalMessages: []
|
|
91
|
-
};
|
|
92
|
-
if (![
|
|
93
|
-
"message.posted",
|
|
94
|
-
"thread.synced",
|
|
95
|
-
"message.synced",
|
|
96
|
-
"message.files_synced"
|
|
97
|
-
].includes(event.type)) return change;
|
|
98
|
-
const key = event.payload.thread;
|
|
99
|
-
const state = {
|
|
100
|
-
threads: {},
|
|
101
|
-
byExternalThread: {},
|
|
102
|
-
copies: {},
|
|
103
|
-
byExternalMessage: {}
|
|
104
|
-
};
|
|
105
|
-
if (before.thread) setOwn(state.threads, key, structuredClone(before.thread));
|
|
106
|
-
const reads = syncReads(event);
|
|
107
|
-
if (reads.copy && before.copy) state.copies[reads.copy[0]] = { [reads.copy[1]]: structuredClone(before.copy) };
|
|
108
|
-
foldSync(state, event);
|
|
109
|
-
const thread = own(state.threads, key);
|
|
110
|
-
if (thread && JSON.stringify(thread) !== JSON.stringify(before.thread)) change.thread = {
|
|
111
|
-
key,
|
|
112
|
-
data: thread
|
|
113
|
-
};
|
|
114
|
-
for (const [external, owner] of Object.entries(state.byExternalThread)) change.externalThreads.push([external, owner]);
|
|
115
|
-
for (const [message, targets] of Object.entries(state.copies)) for (const [target, copy] of Object.entries(targets)) if (!(reads.copy?.[0] === Number(message) && reads.copy[1] === target && JSON.stringify(copy) === JSON.stringify(before.copy))) change.copies.push([
|
|
116
|
-
Number(message),
|
|
117
|
-
target,
|
|
118
|
-
copy
|
|
119
|
-
]);
|
|
120
|
-
for (const [externalKey, message] of Object.entries(state.byExternalMessage)) change.externalMessages.push([externalKey, message]);
|
|
121
|
-
return change;
|
|
122
|
-
}
|
|
123
|
-
//#endregion
|
|
124
|
-
export { syncReads as i, project as n, projectSync as r, concernedMessageId as t };
|