Versions 116 to 318
new file, 200 lines
1+// How the open server's Worker reaches a project's issues, and what the IssueProject object does with a
4+// issuesFetch the Worker's entry for /issues/p/:project/...: the router has checked the token or key;
7+// IssuesObject one project's issues: migrations, the store, and its routes (routes.ts). An ask's `of` is
10+// The project object (env.PROJECT, named by the project) is asked two things, both optional: agents(project)
11+// for the ask check, and news(project, items) to deliver a write's news as announcements. Without them the
13+
18+
19+/** A write's news for the project to deliver: the issue's claimers and those in `to` hear it, never `from`. */
24+
25+/** What issues asks of the project's own object. Each method is optional: an older project object may lack it. */
32+
33+/** A Durable Object namespace as far as issues uses one; Cloudflare's DurableObjectNamespace fits it. */
38+
46+
47+/** How the router let the request in: the shared token acts as any agent; a key only as its own agent. */
49+
54+
57+
62+
67+
69+ * Whether an RPC call failed because the receiver has no such method. On an RPC stub every property reads as a
76+
78+ * /issues/p/:project<rest> after the router's sign-in check. `rest` is the path after the project, like
97+ if (!AGENT_NAME.test(agent)) return json(400, { error: "an agent's name is 1-64 of A-Z a-z 0-9 . _ -" });
103+ if (auth.role === "reader" && !reading) return json(403, { error: "a reader's key only reads issues" });
118+ const forwarded = new Request(`https://issues.invalid/p/${encodeURIComponent(project)}${rest}${search}`, {
125+ if (!reading && agent !== undefined && answer.ok) ctx.waitUntil(tell(env, project, agent, answer.clone()));
128+
129+/** A write's news to the project object, sent after the answer. A failed send is only logged; the write stands. */
130+async function tell(env: IssuesEnv, project: string, from: string, answer: Response): Promise<void> {
141+ if (missingMethod(err)) console.log(`issues: news for ${project} dropped: the project object has no news method`);
145+
151+
152+/** One project's issues: the store over the object's SQLite, migrated, and the routes over it. */
157+
164+
168+ sql.exec("CREATE TABLE IF NOT EXISTS migrations (n INTEGER PRIMARY KEY, at INTEGER NOT NULL)");
169+ const done = (sql.exec("SELECT COALESCE(MAX(n), 0) AS n FROM migrations").toArray()[0] as { n: number }).n;
176+
179+ return (this.storage.sql.exec("SELECT COUNT(*) AS n FROM migrations").toArray()[0] as { n: number }).n;
181+
- MCP
- compare on this site's /mcp
- CLI
- abso diff 116 318 server/src/issues/serve.ts --json
- JSON
- /christopher/abso-core/compare/116..318?file=server%2Fsrc%2Fissues%2Fserve.ts&format=json