@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.
Files changed (166) hide show
  1. package/README.md +25 -20
  2. package/dist/{access-CY5xVMIK.mjs → access-N3XmkKXg.mjs} +3 -3
  3. package/dist/access.d.mts +4 -5
  4. package/dist/access.mjs +5 -5
  5. package/dist/{actors-Bm-ojWWT.mjs → actors-ihyN47OV.mjs} +3 -3
  6. package/dist/{auth-K8dY1nBY.d.mts → auth-D6z3rMNj.d.mts} +7 -93
  7. package/dist/{auth-8pRZnF1M.mjs → auth-r-_PeZyw.mjs} +32 -148
  8. package/dist/{backend-DxE9wGKm.d.mts → backend-CWpyR1A7.d.mts} +81 -51
  9. package/dist/backend-local.d.mts +28 -0
  10. package/dist/backend-local.mjs +2 -0
  11. package/dist/{chat-provider-DkFp2hrh.mjs → chat-provider-9hCT654s.mjs} +2 -2
  12. package/dist/{chat-provider-BChYrrA7.d.mts → chat-provider-DJpFUaFv.d.mts} +2 -3
  13. package/dist/cli-commands.d.mts +1 -1
  14. package/dist/cli-commands.mjs +1 -1
  15. package/dist/cli-embedded.d.mts +2 -2
  16. package/dist/cli-embedded.mjs +1 -1
  17. package/dist/cli.mjs +6 -6
  18. package/dist/{commands-CpyPV_tk.d.mts → commands-BOBQHVqM.d.mts} +9 -0
  19. package/dist/{commands-DsnQKTdB.mjs → commands-CHoMl06v.mjs} +12 -1
  20. package/dist/{conformance-3RBKxwbp.mjs → conformance-qKmGLTAT.mjs} +5 -5
  21. package/dist/conformance.d.mts +1 -1
  22. package/dist/conformance.mjs +1 -1
  23. package/dist/{engine-DurYIRt8.mjs → engine-JxgZiikU.mjs} +6 -8
  24. package/dist/{errors-CJXhhzvT.mjs → errors-Pk0XV1hK.mjs} +56 -2
  25. package/dist/{events-lujPA3gQ.mjs → events-IQg0k281.mjs} +2 -2
  26. package/dist/exports-BuKjVq2t.d.mts +4 -0
  27. package/dist/exports-gHDHlg0i.mjs +3207 -0
  28. package/dist/{external-D3p5T57R.mjs → external-CYe424fO.mjs} +1 -1
  29. package/dist/{folds-DLUzfibJ.d.mts → folds-DjFTiqIM.d.mts} +38 -44
  30. package/dist/index-CXvvYNYj.d.mts +11 -0
  31. package/dist/index.d.mts +9 -8
  32. package/dist/index.mjs +21 -8
  33. package/dist/index.node.d.mts +5 -6
  34. package/dist/index.node.mjs +3 -3
  35. package/dist/inspect/app.js +95 -95
  36. package/dist/{internal-CvsrprnU-zZMpDiRY.mjs → internal-CvsrprnU-CEPOUpAv.mjs} +63 -43
  37. package/dist/local-BbLjA5vI.mjs +8818 -0
  38. package/dist/{main-CcYDo9Hb.mjs → main-CQpCZJFw.mjs} +91 -23
  39. package/dist/{backend-a2/store-memory.mjs → memory-7RRnLa4X.mjs} +3 -3
  40. package/dist/middleware-BU7rVi9F.mjs +103 -0
  41. package/dist/{client-COfYrgfV.d.mts → provider-BlzUvcM9.d.mts} +665 -5
  42. package/dist/{schemas-DBmUO6pr.mjs → schemas-BG205xds.mjs} +2 -5
  43. package/dist/{serve-Bplieh0C.mjs → serve-D8_W4UN6.mjs} +33 -24
  44. package/dist/{node-BgeGcwX0.mjs → server-BiIUXWbU.mjs} +419 -6
  45. package/dist/{serving-Y7s7VDjB.mjs → serving-D7rcUtSC.mjs} +1 -1
  46. package/dist/{sql-E1K5g_ih.mjs → sql-BQzKUqQt.mjs} +349 -114
  47. package/dist/sqlite-DCtZFEVm.mjs +30 -0
  48. package/dist/{sqlite-db-CzcD_FW8.mjs → sqlite-db-qLTs52Ny.mjs} +2 -3
  49. package/dist/{store-codec-pAG2oPgQ-SqDXlPBR.mjs → store-N8PXxDAS-BdL4Sq-f.mjs} +6 -2
  50. package/dist/{store-memory-B0PkVSuQ.mjs → store-memory-CKQVEzXN.mjs} +2 -4
  51. package/dist/store-memory-OdGsc-t_.mjs +2 -0
  52. package/dist/{store-polling-BZt2Rf3D-Div-bJ_D.mjs → store-polling-BZt2Rf3D-oh3aU_An.mjs} +1 -1
  53. package/dist/store-sqlite-CTxAVCcz.mjs +2 -0
  54. package/dist/{store-sqlite-D85t3tE7.mjs → store-sqlite-D6fIszST.mjs} +3 -4
  55. package/dist/sync-chat-sdk.d.mts +2 -2
  56. package/dist/sync-chat-sdk.mjs +2 -2
  57. package/dist/sync-github.d.mts +2 -2
  58. package/dist/sync-github.mjs +2 -2
  59. package/dist/sync-linear.d.mts +2 -3
  60. package/dist/sync-linear.mjs +2 -2
  61. package/dist/sync-slack.d.mts +3 -3
  62. package/dist/sync-slack.mjs +4 -4
  63. package/dist/sync.d.mts +2 -2
  64. package/dist/sync.mjs +2 -2
  65. package/dist/{watchers-hash-CurCzwhe.mjs → targets-CknPGGVi.mjs} +40 -10
  66. package/dist/{tokens-C7kYyrAG.mjs → tokens-DPKjl3jf.mjs} +15 -43
  67. package/docs/01-board/01-mounting.md +243 -288
  68. package/docs/01-board/03-identity.md +41 -50
  69. package/docs/01-board/04-messages.md +15 -14
  70. package/docs/01-board/05-reading.md +3 -3
  71. package/docs/01-board/06-watchers.md +58 -105
  72. package/docs/01-board/07-schedules.md +21 -41
  73. package/docs/01-board/08-middleware.md +11 -17
  74. package/docs/01-board/09-access.md +76 -313
  75. package/docs/01-board/10-local.md +81 -0
  76. package/docs/01-quickstart.md +49 -126
  77. package/docs/02-sync/01-overview.md +25 -80
  78. package/docs/02-sync/02-functions.md +10 -16
  79. package/docs/02-sync/03-slack.md +13 -26
  80. package/docs/02-sync/04-github.md +8 -20
  81. package/docs/02-sync/07-linear.md +6 -10
  82. package/docs/03-guides/02-inspector.md +3 -3
  83. package/docs/03-guides/03-ci.md +88 -128
  84. package/docs/03-guides/04-triage.md +7 -15
  85. package/docs/03-guides/05-agent-factory.md +30 -36
  86. package/docs/04-reference/01-cli.md +104 -22
  87. package/docs/04-reference/02-board.md +60 -74
  88. package/docs/04-reference/03-http.md +119 -57
  89. package/docs/04-reference/05-conformance.md +31 -45
  90. package/docs/index.md +41 -65
  91. package/package.json +12 -83
  92. package/dist/a2-DiDc77Uf.mjs +0 -4238
  93. package/dist/access-DPcrKIH_.d.mts +0 -37
  94. package/dist/backend-a2/blob-vercel.d.mts +0 -8
  95. package/dist/backend-a2/blob-vercel.mjs +0 -81
  96. package/dist/backend-a2/contract.d.mts +0 -828
  97. package/dist/backend-a2/contract.mjs +0 -5
  98. package/dist/backend-a2/scheduler-local.d.mts +0 -11
  99. package/dist/backend-a2/scheduler-local.mjs +0 -2
  100. package/dist/backend-a2/scheduler-qstash.d.mts +0 -79
  101. package/dist/backend-a2/scheduler-qstash.mjs +0 -522
  102. package/dist/backend-a2/scheduler-vercel.d.mts +0 -38
  103. package/dist/backend-a2/scheduler-vercel.mjs +0 -204
  104. package/dist/backend-a2/store-memory.d.mts +0 -11
  105. package/dist/backend-a2/store-postgres.d.mts +0 -38
  106. package/dist/backend-a2/store-postgres.mjs +0 -2977
  107. package/dist/backend-a2/store-redis-http.d.mts +0 -17
  108. package/dist/backend-a2/store-redis-http.mjs +0 -520
  109. package/dist/backend-a2/store-redis.d.mts +0 -31
  110. package/dist/backend-a2/store-redis.mjs +0 -88
  111. package/dist/backend-a2/store-sqlite.d.mts +0 -12
  112. package/dist/backend-a2/store-sqlite.mjs +0 -31
  113. package/dist/backend-a2.d.mts +0 -2633
  114. package/dist/backend-a2.mjs +0 -3
  115. package/dist/backend-http-CaN06CaD.d.mts +0 -672
  116. package/dist/backend-http-CoaCghuJ.mjs +0 -18
  117. package/dist/backend-http-l5A8UmL-.mjs +0 -585
  118. package/dist/backend-http.d.mts +0 -10
  119. package/dist/backend-http.mjs +0 -2
  120. package/dist/backend-http.node.d.mts +0 -10
  121. package/dist/backend-http.node.mjs +0 -2
  122. package/dist/backend-vercel-BE65okBC.mjs +0 -86
  123. package/dist/backend-vercel-CVxoTNF2.mjs +0 -1744
  124. package/dist/backend-vercel-jg-6PAgD.d.mts +0 -674
  125. package/dist/backend-vercel.d.mts +0 -9
  126. package/dist/backend-vercel.mjs +0 -11
  127. package/dist/backend-vercel.node.d.mts +0 -17
  128. package/dist/backend-vercel.node.mjs +0 -2
  129. package/dist/blob-Bx8QPWEd.d.mts +0 -40
  130. package/dist/blob-WbB2DJKn.mjs +0 -201
  131. package/dist/errors-2vGs49Db.d.mts +0 -16
  132. package/dist/exports-BnUZuRm9.mjs +0 -1389
  133. package/dist/exports-u5mApVvn.d.mts +0 -5
  134. package/dist/files-SniSmeEr.mjs +0 -47
  135. package/dist/folds-DsWfIftc.mjs +0 -208
  136. package/dist/index-UXpTPWNc.d.mts +0 -11
  137. package/dist/index.default-Dp8gexln.mjs +0 -12
  138. package/dist/local-C76Fy5ad.mjs +0 -44
  139. package/dist/middleware-BavYSDUa.mjs +0 -62
  140. package/dist/platform-B4TnJtWu-Do3agKr5.mjs +0 -32
  141. package/dist/project-4Vl7_uy5.mjs +0 -124
  142. package/dist/provider-gynDUoyW.d.mts +0 -665
  143. package/dist/redis-tables-BFRj_SEJ.mjs +0 -3895
  144. package/dist/reducer-Bswr11ar-P324o9vn.mjs +0 -74
  145. package/dist/reducer-CYPHsSmd-BXjGiptm.d.mts +0 -170
  146. package/dist/reducers-DQVSP3kk.mjs +0 -538
  147. package/dist/retryable-lazy-DZWmHpii-DpTc5PIP.mjs +0 -19
  148. package/dist/scheduler-task-X1SToDjP-D2Il2rln.mjs +0 -69
  149. package/dist/server-B9gu0qi1-DI1WvcVK.d.mts +0 -391
  150. package/dist/server-DX7mM6nm-D7N_7bug.mjs +0 -3611
  151. package/dist/server-wIpAEjpX.mjs +0 -17
  152. package/dist/session-clear-XJYpmUpg-2q8l_FJR.mjs +0 -63
  153. package/dist/store-DEzcHZOA-B-5vhxef.d.mts +0 -540
  154. package/dist/store-N8PXxDAS-DWWgv-Vz.mjs +0 -5
  155. package/dist/store-memory-4IBl0Ztu.mjs +0 -2
  156. package/dist/store-presence-polling-JuAy2Ck2-Dh-g_KYM.mjs +0 -109
  157. package/dist/store-sqlite-iBTYYKBj.mjs +0 -2
  158. package/dist/stream-buffer-DrTyiIuo-Be10yOBR.mjs +0 -53
  159. package/dist/targets-Cgjs29T0.mjs +0 -33
  160. package/dist/types-CmrFjpml.d.mts +0 -102
  161. package/dist/wait-until-Dw4XrIDQ.mjs +0 -42
  162. package/docs/01-board/02-database.md +0 -258
  163. package/docs/04-reference/04-log.md +0 -247
  164. package/sql/postgres/board.sql +0 -145
  165. package/sql/postgres/notifications.sql +0 -24
  166. package/sql/postgres/schema.sql +0 -451
@@ -1,5 +0,0 @@
1
- import "./auth-K8dY1nBY.mjs";
2
- import "./folds-DLUzfibJ.mjs";
3
- import "./client-COfYrgfV.mjs";
4
- import "./backend-DxE9wGKm.mjs";
5
- import "./errors-2vGs49Db.mjs";
@@ -1,47 +0,0 @@
1
- //#region src/contract/files.ts
2
- /** Under Vercel Functions' 4.5 MB request body limit, so an upload fits in one request. */
3
- const ATTACHMENT_BYTES_MAX = 4194304;
4
- /**
5
- * The most a file sync brings over from a platform can be. Sync fetches it on the server and
6
- * stores it in-process, so no request carries it and the request limit doesn't apply: this bounds
7
- * what one import holds in memory.
8
- */
9
- const IMPORT_BYTES_MAX = 26214400;
10
- /**
11
- * The most a direct upload can be: the client sends the bytes straight to the blob store, on a URL
12
- * the board signs, so no request to the board carries them. Needs a store with `uploadUrl`.
13
- */
14
- const DIRECT_UPLOAD_BYTES_MAX = 104857600;
15
- /** `120 KB`, `3.4 MB`: a file's size the way people read it. */
16
- function fileSize(bytes) {
17
- if (bytes < 1024) return `${bytes} B`;
18
- if (bytes < 1048576) return `${Math.round(bytes / 1024)} KB`;
19
- return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
20
- }
21
- const TYPES = {
22
- ".png": "image/png",
23
- ".jpg": "image/jpeg",
24
- ".jpeg": "image/jpeg",
25
- ".gif": "image/gif",
26
- ".webp": "image/webp",
27
- ".avif": "image/avif",
28
- ".svg": "image/svg+xml",
29
- ".mp4": "video/mp4",
30
- ".webm": "video/webm",
31
- ".mov": "video/quicktime",
32
- ".pdf": "application/pdf",
33
- ".txt": "text/plain",
34
- ".log": "text/plain",
35
- ".md": "text/markdown",
36
- ".json": "application/json",
37
- ".csv": "text/csv",
38
- ".html": "text/html",
39
- ".zip": "application/zip"
40
- };
41
- /** A file's type from its name, for when nothing better says: browsers leave `.log` untyped. */
42
- function typeOf(name) {
43
- const dot = name.lastIndexOf(".");
44
- return dot > 0 && TYPES[name.slice(dot).toLowerCase()] || "application/octet-stream";
45
- }
46
- //#endregion
47
- export { typeOf as a, fileSize as i, DIRECT_UPLOAD_BYTES_MAX as n, IMPORT_BYTES_MAX as r, ATTACHMENT_BYTES_MAX as t };
@@ -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 };
@@ -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 };