@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.
Files changed (167) hide show
  1. package/README.md +25 -20
  2. package/dist/{access-CY5xVMIK.mjs → access-CdBcYPQH.mjs} +170 -13
  3. package/dist/access.d.mts +4 -5
  4. package/dist/access.mjs +5 -5
  5. package/dist/{actors-Bm-ojWWT.mjs → actors-MrIEr9LI.mjs} +3 -3
  6. package/dist/auth-DjoJygbG.mjs +599 -0
  7. package/dist/{auth-K8dY1nBY.d.mts → auth-aaoKt5DK.d.mts} +133 -100
  8. package/dist/backend-local.d.mts +28 -0
  9. package/dist/backend-local.mjs +2 -0
  10. package/dist/{backend-DxE9wGKm.d.mts → backend-u1sVvybh.d.mts} +108 -55
  11. package/dist/{chat-provider-DkFp2hrh.mjs → chat-provider-9hCT654s.mjs} +2 -2
  12. package/dist/{chat-provider-BChYrrA7.d.mts → chat-provider-De0iDnUB.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-DsnQKTdB.mjs → commands-B8oZEByR.mjs} +37 -52
  19. package/dist/{commands-CpyPV_tk.d.mts → commands-BkVMdXP1.d.mts} +9 -6
  20. package/dist/{conformance-3RBKxwbp.mjs → conformance-gqYBkXFS.mjs} +79 -86
  21. package/dist/conformance.d.mts +1 -1
  22. package/dist/conformance.mjs +1 -1
  23. package/dist/{engine-DurYIRt8.mjs → engine-rtOVWsiF.mjs} +6 -8
  24. package/dist/{errors-CJXhhzvT.mjs → errors-D8ifv16L.mjs} +75 -6
  25. package/dist/{events-lujPA3gQ.mjs → events-IQg0k281.mjs} +2 -2
  26. package/dist/exports-Bx2dGpzr.mjs +3252 -0
  27. package/dist/exports-uwRl5qIj.d.mts +4 -0
  28. package/dist/{external-D3p5T57R.mjs → external-CYe424fO.mjs} +1 -1
  29. package/dist/index-D6mK0Ial.d.mts +11 -0
  30. package/dist/index.d.mts +10 -9
  31. package/dist/index.mjs +21 -8
  32. package/dist/index.node.d.mts +6 -7
  33. package/dist/index.node.mjs +3 -3
  34. package/dist/inspect/app.js +95 -95
  35. package/dist/{internal-CvsrprnU-zZMpDiRY.mjs → internal-CvsrprnU-CEPOUpAv.mjs} +63 -43
  36. package/dist/local-CPz22MQ8.mjs +9225 -0
  37. package/dist/{main-CcYDo9Hb.mjs → main-DScDKwQN.mjs} +129 -54
  38. package/dist/{backend-a2/store-memory.mjs → memory-7RRnLa4X.mjs} +3 -3
  39. package/dist/middleware-BjYpk4yq.mjs +103 -0
  40. package/dist/{provider-gynDUoyW.d.mts → provider-hB8QNrwm.d.mts} +369 -3
  41. package/dist/{client-COfYrgfV.d.mts → routes-De4W6lEs.d.mts} +997 -367
  42. package/dist/{schemas-DBmUO6pr.mjs → schemas-BG205xds.mjs} +2 -5
  43. package/dist/{serve-Bplieh0C.mjs → serve-B1noQRkn.mjs} +33 -24
  44. package/dist/{node-BgeGcwX0.mjs → server-Ov6GBJ8j.mjs} +419 -6
  45. package/dist/{serving-Y7s7VDjB.mjs → serving-2s7lqSBS.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 +3 -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-aMdbp84G.mjs} +134 -16
  66. package/dist/{tokens-C7kYyrAG.mjs → tokens-LHLrnV_P.mjs} +15 -43
  67. package/docs/01-board/01-mounting.md +245 -288
  68. package/docs/01-board/03-identity.md +42 -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 +187 -343
  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 +29 -36
  86. package/docs/04-reference/01-cli.md +113 -38
  87. package/docs/04-reference/02-board.md +79 -82
  88. package/docs/04-reference/03-http.md +138 -69
  89. package/docs/04-reference/05-conformance.md +32 -46
  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/auth-8pRZnF1M.mjs +0 -393
  95. package/dist/backend-a2/blob-vercel.d.mts +0 -8
  96. package/dist/backend-a2/blob-vercel.mjs +0 -81
  97. package/dist/backend-a2/contract.d.mts +0 -828
  98. package/dist/backend-a2/contract.mjs +0 -5
  99. package/dist/backend-a2/scheduler-local.d.mts +0 -11
  100. package/dist/backend-a2/scheduler-local.mjs +0 -2
  101. package/dist/backend-a2/scheduler-qstash.d.mts +0 -79
  102. package/dist/backend-a2/scheduler-qstash.mjs +0 -522
  103. package/dist/backend-a2/scheduler-vercel.d.mts +0 -38
  104. package/dist/backend-a2/scheduler-vercel.mjs +0 -204
  105. package/dist/backend-a2/store-memory.d.mts +0 -11
  106. package/dist/backend-a2/store-postgres.d.mts +0 -38
  107. package/dist/backend-a2/store-postgres.mjs +0 -2977
  108. package/dist/backend-a2/store-redis-http.d.mts +0 -17
  109. package/dist/backend-a2/store-redis-http.mjs +0 -520
  110. package/dist/backend-a2/store-redis.d.mts +0 -31
  111. package/dist/backend-a2/store-redis.mjs +0 -88
  112. package/dist/backend-a2/store-sqlite.d.mts +0 -12
  113. package/dist/backend-a2/store-sqlite.mjs +0 -31
  114. package/dist/backend-a2.d.mts +0 -2633
  115. package/dist/backend-a2.mjs +0 -3
  116. package/dist/backend-http-CaN06CaD.d.mts +0 -672
  117. package/dist/backend-http-CoaCghuJ.mjs +0 -18
  118. package/dist/backend-http-l5A8UmL-.mjs +0 -585
  119. package/dist/backend-http.d.mts +0 -10
  120. package/dist/backend-http.mjs +0 -2
  121. package/dist/backend-http.node.d.mts +0 -10
  122. package/dist/backend-http.node.mjs +0 -2
  123. package/dist/backend-vercel-BE65okBC.mjs +0 -86
  124. package/dist/backend-vercel-CVxoTNF2.mjs +0 -1744
  125. package/dist/backend-vercel-jg-6PAgD.d.mts +0 -674
  126. package/dist/backend-vercel.d.mts +0 -9
  127. package/dist/backend-vercel.mjs +0 -11
  128. package/dist/backend-vercel.node.d.mts +0 -17
  129. package/dist/backend-vercel.node.mjs +0 -2
  130. package/dist/blob-Bx8QPWEd.d.mts +0 -40
  131. package/dist/blob-WbB2DJKn.mjs +0 -201
  132. package/dist/errors-2vGs49Db.d.mts +0 -16
  133. package/dist/exports-BnUZuRm9.mjs +0 -1389
  134. package/dist/exports-u5mApVvn.d.mts +0 -5
  135. package/dist/files-SniSmeEr.mjs +0 -47
  136. package/dist/folds-DLUzfibJ.d.mts +0 -558
  137. package/dist/folds-DsWfIftc.mjs +0 -208
  138. package/dist/index-UXpTPWNc.d.mts +0 -11
  139. package/dist/index.default-Dp8gexln.mjs +0 -12
  140. package/dist/local-C76Fy5ad.mjs +0 -44
  141. package/dist/middleware-BavYSDUa.mjs +0 -62
  142. package/dist/platform-B4TnJtWu-Do3agKr5.mjs +0 -32
  143. package/dist/project-4Vl7_uy5.mjs +0 -124
  144. package/dist/redis-tables-BFRj_SEJ.mjs +0 -3895
  145. package/dist/reducer-Bswr11ar-P324o9vn.mjs +0 -74
  146. package/dist/reducer-CYPHsSmd-BXjGiptm.d.mts +0 -170
  147. package/dist/reducers-DQVSP3kk.mjs +0 -538
  148. package/dist/retryable-lazy-DZWmHpii-DpTc5PIP.mjs +0 -19
  149. package/dist/scheduler-task-X1SToDjP-D2Il2rln.mjs +0 -69
  150. package/dist/server-B9gu0qi1-DI1WvcVK.d.mts +0 -391
  151. package/dist/server-DX7mM6nm-D7N_7bug.mjs +0 -3611
  152. package/dist/server-wIpAEjpX.mjs +0 -17
  153. package/dist/session-clear-XJYpmUpg-2q8l_FJR.mjs +0 -63
  154. package/dist/store-DEzcHZOA-B-5vhxef.d.mts +0 -540
  155. package/dist/store-N8PXxDAS-DWWgv-Vz.mjs +0 -5
  156. package/dist/store-memory-4IBl0Ztu.mjs +0 -2
  157. package/dist/store-presence-polling-JuAy2Ck2-Dh-g_KYM.mjs +0 -109
  158. package/dist/store-sqlite-iBTYYKBj.mjs +0 -2
  159. package/dist/stream-buffer-DrTyiIuo-Be10yOBR.mjs +0 -53
  160. package/dist/targets-Cgjs29T0.mjs +0 -33
  161. package/dist/types-CmrFjpml.d.mts +0 -102
  162. package/dist/wait-until-Dw4XrIDQ.mjs +0 -42
  163. package/docs/01-board/02-database.md +0 -258
  164. package/docs/04-reference/04-log.md +0 -247
  165. package/sql/postgres/board.sql +0 -145
  166. package/sql/postgres/notifications.sql +0 -24
  167. package/sql/postgres/schema.sql +0 -451
@@ -1,17 +0,0 @@
1
- import { t as BoardStore } from "../types-CmrFjpml.mjs";
2
- //#region src/store/redis-http.d.ts
3
- export type RedisHttpOptions = {
4
- /** The REST endpoint, e.g. `process.env.UPSTASH_REDIS_REST_URL`. */
5
- url: string;
6
- /** Its bearer token, e.g. `process.env.UPSTASH_REDIS_REST_TOKEN`. */
7
- token: string;
8
- /**
9
- * Isolates boards on one Redis: A2's log and board's tables both live under it. Default `'a2'`.
10
- * It can't contain braces. board 0.14 (A2 0.22) names every key differently, so a board moves
11
- * to a new prefix and starts with an empty log: on one board 0.13 wrote, every request answers 503.
12
- */
13
- keyPrefix?: string;
14
- };
15
- /** A board on Redis over Upstash's REST API: no connection to keep, so it suits functions. */
16
- export declare function redisHttp(options: RedisHttpOptions): BoardStore;
17
- //#endregion
@@ -1,520 +0,0 @@
1
- import { t as A2Error } from "../session-clear-XJYpmUpg-2q8l_FJR.mjs";
2
- import { n as NOTIFY_TIMINGS } from "../internal-CvsrprnU-zZMpDiRY.mjs";
3
- import { n as defaultSleep } from "../store-polling-BZt2Rf3D-Div-bJ_D.mjs";
4
- import { n as SYSTEM_CLOCK, t as RANDOM_IDS } from "../store-N8PXxDAS-DWWgv-Vz.mjs";
5
- import { n as createRedisNotifyStore, t as redisTables } from "../redis-tables-BFRj_SEJ.mjs";
6
- //#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/store-redis-http.js
7
- function redisHttpSubscriptions({ url, token, onReconnect, fallback }) {
8
- const subscriptions = /* @__PURE__ */ new Map();
9
- const listeners = /* @__PURE__ */ new Set();
10
- let closed = false;
11
- let supported = false;
12
- const subscribe = (channel) => {
13
- if (fallback.enabled()) return Promise.resolve();
14
- const existing = subscriptions.get(channel);
15
- if (existing) return existing.ready;
16
- let resolve;
17
- let reject;
18
- const ready = new Promise((yes, no) => {
19
- resolve = yes;
20
- reject = no;
21
- });
22
- let stopped = false;
23
- let connected = false;
24
- let request;
25
- let retry;
26
- const subscription = {
27
- ready,
28
- stop() {
29
- stopped = true;
30
- request?.abort();
31
- retry?.cancel();
32
- resolve();
33
- }
34
- };
35
- subscriptions.set(channel, subscription);
36
- const run = async () => {
37
- let delay = 100;
38
- for (;;) {
39
- if (stopped) return;
40
- request = new AbortController();
41
- const timeout = setTimeout(() => request?.abort(), NOTIFY_TIMINGS.safetyReadMs);
42
- let reader;
43
- let connectedAt;
44
- try {
45
- const response = await fetch(`${url.replace(/\/$/, "")}/subscribe/${encodeURIComponent(channel)}`, {
46
- method: "POST",
47
- headers: {
48
- authorization: `Bearer ${token}`,
49
- accept: "text/event-stream"
50
- },
51
- signal: request.signal
52
- });
53
- if (!supported && [
54
- 404,
55
- 405,
56
- 501
57
- ].includes(response.status)) {
58
- await response.body?.cancel();
59
- await fallback.checkCommands();
60
- if (stopped) return;
61
- if (!supported) {
62
- fallback.enable();
63
- for (const active of subscriptions.values()) active.stop();
64
- subscriptions.clear();
65
- return;
66
- }
67
- }
68
- if (!response.ok || !response.headers.get("content-type")?.startsWith("text/event-stream") || !response.body) {
69
- await response.body?.cancel();
70
- throw new A2Error("STORE_UNAVAILABLE", `redis rest subscription failed: status ${response.status}`);
71
- }
72
- reader = response.body.getReader();
73
- const decoder = new TextDecoder();
74
- let buffer = "";
75
- let data = [];
76
- let acknowledged = false;
77
- for (;;) {
78
- if (stopped) break;
79
- const chunk = await reader.read();
80
- if (chunk.done) break;
81
- buffer += decoder.decode(chunk.value, { stream: true });
82
- let newline;
83
- while ((newline = buffer.indexOf("\n")) !== -1) {
84
- const line = buffer.slice(0, newline).replace(/\r$/, "");
85
- buffer = buffer.slice(newline + 1);
86
- if (line.startsWith("data:")) data.push(line.slice(5).replace(/^ /, ""));
87
- else if (line === "" && data.length > 0) {
88
- const message = data.join("\n");
89
- data = [];
90
- if (message.startsWith(`subscribe,${channel},`)) {
91
- if (acknowledged) continue;
92
- acknowledged = true;
93
- supported = true;
94
- clearTimeout(timeout);
95
- connectedAt = Date.now();
96
- resolve();
97
- if (connected) onReconnect(channel);
98
- connected = true;
99
- } else if (message.startsWith(`message,${channel},`)) {
100
- const payload = message.slice(`message,${channel},`.length);
101
- for (const listener of listeners) listener(channel, payload);
102
- }
103
- }
104
- }
105
- }
106
- if (!connected && !stopped) throw new A2Error("STORE_UNAVAILABLE", "redis rest subscription ended before acknowledgement");
107
- } catch (error) {
108
- if (!connected && !stopped) {
109
- reject(error);
110
- if (subscriptions.get(channel) === subscription) subscriptions.delete(channel);
111
- return;
112
- }
113
- } finally {
114
- clearTimeout(timeout);
115
- request.abort();
116
- await reader?.cancel().catch(() => {});
117
- reader?.releaseLock();
118
- }
119
- if (stopped) return;
120
- if (connectedAt !== void 0 && Date.now() - connectedAt >= NOTIFY_TIMINGS.safetyReadMs) delay = 100;
121
- retry = defaultSleep(delay);
122
- await retry.promise;
123
- delay = Math.min(delay * 2, NOTIFY_TIMINGS.safetyReadMs);
124
- }
125
- };
126
- run();
127
- return ready;
128
- };
129
- const connection = {
130
- call(command, ...args) {
131
- if (closed) return Promise.reject(new A2Error("STORE_UNAVAILABLE", "the store was closed"));
132
- const channel = String(args[0]);
133
- if (command === "echo") return Promise.resolve(args[0]);
134
- if (command === "subscribe") return subscribe(channel);
135
- if (command === "unsubscribe") {
136
- subscriptions.get(channel)?.stop();
137
- subscriptions.delete(channel);
138
- return Promise.resolve(null);
139
- }
140
- return Promise.reject(/* @__PURE__ */ new Error(`unsupported subscription command: ${command}`));
141
- },
142
- duplicate: () => connection,
143
- on(_event, listener) {
144
- listeners.add(listener);
145
- },
146
- disconnect() {
147
- closed = true;
148
- for (const subscription of subscriptions.values()) subscription.stop();
149
- subscriptions.clear();
150
- listeners.clear();
151
- }
152
- };
153
- return connection;
154
- }
155
- /**
156
- * Index just past the array or string `scan` is inside, or -1 when `text`
157
- * ends first; `scan` then carries the state into the next chunk. Strings
158
- * are skipped with `indexOf`, so the per-character loop only walks
159
- * structure. A quote is escaped when an odd run of backslashes precedes
160
- * it; a run is counted back only to where the string scan resumed, and
161
- * `escaped` carries an odd trailing run across the chunk boundary.
162
- */
163
- function scanValue(text, from, scan) {
164
- let at = from;
165
- while (at < text.length) {
166
- if (scan.quoted) {
167
- if (scan.escaped) {
168
- scan.escaped = false;
169
- at++;
170
- continue;
171
- }
172
- const quote = text.indexOf("\"", at);
173
- const end = quote < 0 ? text.length : quote;
174
- let run = 0;
175
- while (end - run - 1 >= at && text.charCodeAt(end - run - 1) === 92) run++;
176
- if (quote < 0) {
177
- scan.escaped = run % 2 === 1;
178
- return -1;
179
- }
180
- at = quote + 1;
181
- if (run % 2 === 1) continue;
182
- scan.quoted = false;
183
- if (scan.depth === 0) return at;
184
- continue;
185
- }
186
- const code = text.charCodeAt(at++);
187
- if (code === 34) scan.quoted = true;
188
- else if (code === 91 || code === 123) scan.depth++;
189
- else if ((code === 93 || code === 125) && --scan.depth === 0) return at;
190
- }
191
- return -1;
192
- }
193
- var JsonReply = class {
194
- reader;
195
- decoder = new TextDecoder("utf-8", { fatal: true });
196
- signal;
197
- text = "";
198
- position = 0;
199
- done = false;
200
- abort;
201
- array = "first";
202
- scan = {
203
- depth: 0,
204
- quoted: false,
205
- escaped: false
206
- };
207
- fragments = [];
208
- failure;
209
- constructor(options) {
210
- const { body, signal } = options;
211
- this.reader = body.getReader();
212
- this.signal = signal;
213
- this.abort = () => {
214
- this.reader.cancel(signal.reason).catch(() => {});
215
- };
216
- signal.addEventListener("abort", this.abort, { once: true });
217
- if (signal.aborted) this.abort();
218
- }
219
- async available() {
220
- while (this.position === this.text.length && !this.done) {
221
- this.signal.throwIfAborted();
222
- const chunk = await this.reader.read();
223
- this.signal.throwIfAborted();
224
- this.done = Boolean(chunk.done);
225
- this.text = chunk.done ? this.decoder.decode() : this.decoder.decode(chunk.value, { stream: true });
226
- this.position = 0;
227
- }
228
- return this.position < this.text.length;
229
- }
230
- async peek() {
231
- while (await this.available()) while (this.position < this.text.length) {
232
- const value = this.text[this.position];
233
- if (value !== " " && value !== "\n" && value !== "\r" && value !== " ") return value;
234
- this.position++;
235
- }
236
- }
237
- async expect(value) {
238
- if (await this.peek() !== value) throw new Error("Invalid or truncated Redis HTTP reply");
239
- this.position++;
240
- }
241
- async value() {
242
- const first = await this.peek();
243
- if (first !== "[" && first !== "\"") throw new Error("Invalid Redis HTTP reply value");
244
- const scan = {
245
- depth: 0,
246
- quoted: false,
247
- escaped: false
248
- };
249
- const fragments = [];
250
- while (await this.available()) {
251
- const start = this.position;
252
- const end = scanValue(this.text, start, scan);
253
- this.position = end < 0 ? this.text.length : end;
254
- fragments.push(this.text.slice(start, this.position));
255
- if (end >= 0) return JSON.parse(fragments.join(""));
256
- }
257
- throw new Error("Truncated Redis HTTP reply value");
258
- }
259
- /**
260
- * The next entries of an open array, parsed together: every entry that
261
- * completes in the current transport chunk, reading further chunks only
262
- * until one has completed. Entries before a malformed one are returned
263
- * first; the malformed one fails the next call. `undefined` once the
264
- * array has closed.
265
- */
266
- async entries() {
267
- if (this.failure !== void 0) throw this.failure;
268
- const texts = [];
269
- const fail = (message) => {
270
- const error = new Error(message);
271
- if (texts.length === 0) throw error;
272
- this.failure = error;
273
- };
274
- while (this.array !== "closed") {
275
- if (this.position === this.text.length) {
276
- if (texts.length > 0) break;
277
- if (!await this.available()) throw new Error(this.array === "entry" ? "Truncated Redis HTTP reply value" : this.array === "separator" ? "Invalid or truncated Redis HTTP reply" : "Invalid Redis HTTP reply value");
278
- continue;
279
- }
280
- if (this.array === "entry") {
281
- const start = this.position;
282
- const end = scanValue(this.text, start, this.scan);
283
- this.position = end < 0 ? this.text.length : end;
284
- this.fragments.push(this.text.slice(start, this.position));
285
- if (end < 0) continue;
286
- texts.push(this.fragments.length === 1 ? this.fragments[0] : this.fragments.join(""));
287
- this.fragments = [];
288
- this.array = "separator";
289
- continue;
290
- }
291
- const value = this.text[this.position];
292
- if (value === " " || value === "\n" || value === "\r" || value === " ") {
293
- this.position++;
294
- continue;
295
- }
296
- if (this.array === "separator" || this.array === "first" && value === "]") {
297
- if (value === "]") this.array = "closed";
298
- else if (value === ",") this.array = "value";
299
- else {
300
- fail("Invalid or truncated Redis HTTP reply");
301
- break;
302
- }
303
- this.position++;
304
- continue;
305
- }
306
- if (value !== "[" && value !== "\"") {
307
- fail("Invalid Redis HTTP reply value");
308
- break;
309
- }
310
- this.scan = {
311
- depth: 0,
312
- quoted: false,
313
- escaped: false
314
- };
315
- this.array = "entry";
316
- }
317
- return texts.length > 0 ? this.parse(texts) : void 0;
318
- }
319
- parse(texts) {
320
- try {
321
- return JSON.parse(`[${texts.join(",")}]`);
322
- } catch {
323
- const parsed = [];
324
- for (const text of texts) try {
325
- parsed.push(JSON.parse(text));
326
- } catch (error) {
327
- this.failure = error;
328
- break;
329
- }
330
- if (parsed.length === 0) throw this.failure;
331
- return parsed;
332
- }
333
- }
334
- async end() {
335
- await this.expect("}");
336
- if (await this.peek() !== void 0) throw new Error("Trailing data in Redis HTTP reply");
337
- }
338
- async close() {
339
- this.signal.removeEventListener("abort", this.abort);
340
- try {
341
- await this.reader.cancel();
342
- } finally {
343
- this.reader.releaseLock();
344
- this.text = "";
345
- }
346
- }
347
- };
348
- /**
349
- * The `result` array of an Upstash REST reply, in batches of the entries
350
- * that complete in each transport chunk.
351
- */
352
- async function* redisHttpReply(options) {
353
- const reply = new JsonReply(options);
354
- try {
355
- await reply.expect("{");
356
- const key = await reply.value();
357
- await reply.expect(":");
358
- if (key === "error") {
359
- const error = await reply.value();
360
- if (typeof error !== "string") throw new Error("Invalid Redis HTTP error");
361
- await reply.end();
362
- throw new Error(`Redis HTTP command failed: ${String(error)}`);
363
- }
364
- if (key !== "result") throw new Error("Invalid Redis HTTP reply envelope");
365
- await reply.expect("[");
366
- for (;;) {
367
- const entries = await reply.entries();
368
- if (entries === void 0) break;
369
- yield entries;
370
- }
371
- await reply.end();
372
- } finally {
373
- await reply.close();
374
- }
375
- }
376
- const REDIS_HTTP_STREAM_READ_COUNT = 1e3;
377
- async function* readRedisStreamPage({ key, from, signal, url, token, count }) {
378
- signal.throwIfAborted();
379
- const response = await fetch(url, {
380
- method: "POST",
381
- headers: {
382
- authorization: `Bearer ${token}`,
383
- "content-type": "application/json"
384
- },
385
- body: JSON.stringify([
386
- "XRANGE",
387
- key,
388
- from,
389
- "+",
390
- "COUNT",
391
- String(count)
392
- ]),
393
- signal
394
- });
395
- if (!response.ok || !response.body) {
396
- const body = await response.json().catch(() => null);
397
- throw new A2Error("STORE_UNAVAILABLE", `redis rest command failed: ${typeof body?.error === "string" ? body.error : `status ${response.status}`}`);
398
- }
399
- let last = Number(from.slice(0, -2)) - 1;
400
- for await (const batch of redisHttpReply({
401
- body: response.body,
402
- signal
403
- })) {
404
- const entries = [];
405
- try {
406
- for (const entry of batch) {
407
- if (!Array.isArray(entry) || entry.length !== 2 || typeof entry[0] !== "string" || !Array.isArray(entry[1]) || entry[1].length % 2 !== 0 || !entry[1].every((field) => typeof field === "string")) throw new Error("Invalid Redis stream entry");
408
- const index = /^\d+-0$/.test(entry[0]) ? Number(entry[0].slice(0, -2)) : NaN;
409
- if (!Number.isSafeInteger(index) || index <= last) throw new Error("Redis stream entry did not advance");
410
- last = index;
411
- entries.push(entry);
412
- }
413
- } catch (error) {
414
- if (entries.length > 0) yield entries;
415
- throw error;
416
- }
417
- yield entries;
418
- }
419
- }
420
- function redisHttp$1(options) {
421
- if (!options.url || !options.token) throw new TypeError("redisHttp() needs a url and a token");
422
- const { url, token } = options;
423
- let polling = false;
424
- let fallbackCheck;
425
- const call = async (command, ...args) => {
426
- let response;
427
- try {
428
- response = await fetch(url, {
429
- method: "POST",
430
- headers: {
431
- authorization: `Bearer ${token}`,
432
- "content-type": "application/json"
433
- },
434
- body: JSON.stringify([command, ...args.map(String)]),
435
- ...command === "PING" ? { signal: AbortSignal.timeout(NOTIFY_TIMINGS.safetyReadMs) } : {}
436
- });
437
- } catch (err) {
438
- throw new A2Error("STORE_UNAVAILABLE", "redis rest request failed", { cause: err });
439
- }
440
- const body = await response.json().catch(() => null);
441
- if (body === null || !response.ok || body.error !== void 0) throw new A2Error("STORE_UNAVAILABLE", `redis rest command failed: ${body?.error ?? `status ${response.status}`}`);
442
- return body.result;
443
- };
444
- const readStream = (read) => readRedisStreamPage({
445
- ...read,
446
- url,
447
- token,
448
- count: REDIS_HTTP_STREAM_READ_COUNT
449
- });
450
- let subscriber;
451
- let onReconnect;
452
- const client = {
453
- call,
454
- duplicate: () => subscriber ??= redisHttpSubscriptions({
455
- url,
456
- token,
457
- onReconnect: (channel) => onReconnect?.(channel),
458
- fallback: {
459
- enabled: () => polling,
460
- checkCommands() {
461
- fallbackCheck ??= call("PING").then((result) => {
462
- if (result !== "PONG") throw new A2Error("STORE_UNAVAILABLE", "redis rest capability check failed");
463
- }).catch((error) => {
464
- fallbackCheck = void 0;
465
- throw error;
466
- });
467
- return fallbackCheck;
468
- },
469
- enable() {
470
- polling = true;
471
- }
472
- }
473
- }),
474
- on() {},
475
- disconnect: () => subscriber?.disconnect()
476
- };
477
- return createRedisNotifyStore({
478
- client: () => Promise.resolve(client),
479
- closeClient: async () => client.disconnect(),
480
- polling: () => polling,
481
- onReconnect: (listener) => {
482
- onReconnect = listener;
483
- },
484
- clock: options.clock ?? SYSTEM_CLOCK,
485
- ids: options.ids ?? RANDOM_IDS,
486
- keyPrefix: options.keyPrefix ?? "a2",
487
- readStream
488
- });
489
- }
490
- //#endregion
491
- //#region src/store/redis-http.ts
492
- /** A board on Redis over Upstash's REST API: no connection to keep, so it suits functions. */
493
- function redisHttp(options) {
494
- const keyPrefix = options.keyPrefix ?? "a2";
495
- const log = redisHttp$1({
496
- url: options.url,
497
- token: options.token,
498
- keyPrefix
499
- });
500
- const call = async (command, ...args) => {
501
- const response = await fetch(options.url, {
502
- method: "POST",
503
- headers: {
504
- authorization: `Bearer ${options.token}`,
505
- "content-type": "application/json"
506
- },
507
- body: JSON.stringify([command, ...args.map(String)])
508
- });
509
- const body = await response.json().catch(() => null);
510
- if (body === null || !response.ok || body.error !== void 0) throw new Error(`redis rest command failed: ${body?.error ?? `status ${response.status}`}`);
511
- return body.result;
512
- };
513
- return {
514
- log,
515
- tables: redisTables(call, keyPrefix),
516
- close: () => log.close()
517
- };
518
- }
519
- //#endregion
520
- export { redisHttp };
@@ -1,31 +0,0 @@
1
- import { t as BoardStore } from "../types-CmrFjpml.mjs";
2
- //#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/store-redis.d.ts
3
- //#region src/store-redis-notify.d.ts
4
- type RedisConnection = {
5
- call(command: string, ...args: Array<string | number>): Promise<unknown>;
6
- duplicate(): RedisConnection;
7
- on(event: "message", listener: (channel: string, message: string) => void): unknown;
8
- disconnect(): void;
9
- };
10
- //#endregion
11
- //#region src/store/redis.d.ts
12
- export type RedisOptions = {
13
- /**
14
- * Isolates boards on one Redis: A2's log and board's tables both live under it. Default `'a2'`.
15
- * It can't contain braces. board 0.14 (A2 0.22) names every key differently, so a board moves
16
- * to a new prefix and starts with an empty log: on one board 0.13 wrote, every request answers 503.
17
- */
18
- keyPrefix?: string;
19
- } & ({
20
- /** The Redis server, as `ioredis` takes it: `redis://…` or `rediss://…`. */
21
- url: string;
22
- } | {
23
- /** A client you made, shared by A2's log and board's tables. Closing the store ends it. */
24
- client: RedisConnection;
25
- });
26
- /**
27
- * A board on Redis over TCP (`npm i ioredis`): a single server or a provider
28
- * without cluster mode, since each write is one script across many keys.
29
- */
30
- export declare function redis(options: RedisOptions): BoardStore;
31
- //#endregion
@@ -1,88 +0,0 @@
1
- import { t as A2Error } from "../session-clear-XJYpmUpg-2q8l_FJR.mjs";
2
- import { t as retryableLazy } from "../retryable-lazy-DZWmHpii-DpTc5PIP.mjs";
3
- import { n as SYSTEM_CLOCK, t as RANDOM_IDS } from "../store-N8PXxDAS-DWWgv-Vz.mjs";
4
- import { n as createRedisNotifyStore, t as redisTables } from "../redis-tables-BFRj_SEJ.mjs";
5
- //#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/store-redis.js
6
- /**
7
- * experimental-a2/store-redis — the Redis-protocol store backend, on Redis
8
- * Streams. The storage semantics live in store-redis-core.ts (shared
9
- * with experimental-a2/store-redis-http); this module owns the connection and
10
- * the live feed.
11
- *
12
- * `stream()` is notify-driven: every write publishes a wake-up that
13
- * carries the appended events, one shared subscriber connection per backend
14
- * serves every local feed, and a caught-up feed applies carried events that
15
- * continue its sequence without reading. A gap, an oversized batch, a
16
- * reconnect, or the safety re-read (NOTIFY_TIMINGS) triggers an `XRANGE`
17
- * catch-up, so a lost wake-up costs latency, never delivery. Connections
18
- * scale with processes (one command client plus one subscriber), not with
19
- * concurrent viewers.
20
- *
21
- * Works with any Redis-protocol server on a single instance or a
22
- * non-cluster provider (Upstash — durable by default — Redis, Valkey).
23
- * `ioredis` is an optional peer dependency; pass `url`, or inject any client
24
- * exposing `call`/`duplicate`/`on`/`disconnect`.
25
- */
26
- function redis$1(options = {}) {
27
- const clock = options.clock ?? SYSTEM_CLOCK;
28
- const ids = options.ids ?? RANDOM_IDS;
29
- const prefix = options.keyPrefix ?? "a2";
30
- if (!options.client && !options.url) throw new TypeError("redis() needs a url or an injected client");
31
- const connection = retryableLazy(async () => {
32
- if (options.client) return options.client;
33
- return new (await (import("ioredis").catch(() => {
34
- throw new A2Error("STORE_NOT_CONFIGURED", "experimental-a2/store-redis with a url needs the 'ioredis' package (optional peer dependency) — install it, or inject a client");
35
- }))).default(options.url);
36
- });
37
- const client = connection.get;
38
- return createRedisNotifyStore({
39
- client,
40
- ...options.client ? {} : { callBytes: async (command, ...args) => (await client()).callBuffer(command, ...args) },
41
- clock,
42
- ids,
43
- keyPrefix: prefix,
44
- async closeClient() {
45
- const current = connection.peek();
46
- if (!current) return;
47
- (await current.catch(() => null))?.disconnect();
48
- }
49
- });
50
- }
51
- //#endregion
52
- //#region src/store/redis.ts
53
- /** `ioredis` is an optional peer, installed by the apps that use Redis over TCP. */
54
- const IOREDIS = "ioredis";
55
- /**
56
- * A board on Redis over TCP (`npm i ioredis`): a single server or a provider
57
- * without cluster mode, since each write is one script across many keys.
58
- */
59
- function redis(options) {
60
- const keyPrefix = options.keyPrefix ?? "a2";
61
- if ("client" in options) {
62
- const log = redis$1({
63
- client: options.client,
64
- keyPrefix
65
- });
66
- return {
67
- log,
68
- tables: redisTables((command, ...args) => options.client.call(command, ...args), keyPrefix),
69
- close: () => log.close()
70
- };
71
- }
72
- const log = redis$1({
73
- url: options.url,
74
- keyPrefix
75
- });
76
- let client = null;
77
- const open = () => client ??= import(IOREDIS).then(({ default: Redis }) => new Redis(options.url));
78
- return {
79
- log,
80
- tables: redisTables(async (command, ...args) => (await open()).call(command, ...args), keyPrefix),
81
- async close() {
82
- if (client) (await client).disconnect();
83
- await log.close();
84
- }
85
- };
86
- }
87
- //#endregion
88
- export { redis };
@@ -1,12 +0,0 @@
1
- import { t as BoardStore } from "../types-CmrFjpml.mjs";
2
- //#region src/store/sqlite.d.ts
3
- /**
4
- * A board in one SQLite file, A2's log and board's tables side by side: `a2()`'s
5
- * store when it's given none, for development, `vb serve`, and a single
6
- * long-running server. It creates its tables when it opens, and a serverless
7
- * function, whose files are read-only, can't open it.
8
- */
9
- export declare function sqlite(options?: {
10
- path?: string;
11
- }): BoardStore;
12
- //#endregion
@@ -1,31 +0,0 @@
1
- import { r as sqlTables } from "../sql-E1K5g_ih.mjs";
2
- import { t as sqlite$1 } from "../store-sqlite-D85t3tE7.mjs";
3
- import { t as sqliteDb } from "../sqlite-db-CzcD_FW8.mjs";
4
- //#region src/store/sqlite.ts
5
- /**
6
- * A board in one SQLite file, A2's log and board's tables side by side: `a2()`'s
7
- * store when it's given none, for development, `vb serve`, and a single
8
- * long-running server. It creates its tables when it opens, and a serverless
9
- * function, whose files are read-only, can't open it.
10
- */
11
- function sqlite(options = {}) {
12
- const path = options.path ?? ".a2/dev.db";
13
- const log = sqlite$1({ path });
14
- let tables;
15
- try {
16
- tables = sqlTables(sqliteDb(path));
17
- } catch (error) {
18
- log.close();
19
- throw error;
20
- }
21
- return {
22
- log,
23
- tables,
24
- async close() {
25
- await tables.close();
26
- log.close();
27
- }
28
- };
29
- }
30
- //#endregion
31
- export { sqlite };