{"draft":null,"from":84,"to":318,"files":[{"path":"server/src/issues/index.ts","added":64,"removed":0,"diff":"--- /dev/null\n+++ b/server/src/issues/index.ts\n@@ -0,0 +1,64 @@\n+// Issues, asks and news for the open server: one IssueProject Durable Object per project (bound as ISSUES_DO,\n+// named by the project's name), reached through issuesFetch from the Worker's /issues/p/:project/... routes.\n+// The logic is in serve.ts, store.ts and routes.ts, which run under node --test without Cloudflare's runtime.\n+//\n+//   GET  /issues/p/:project/issues[?status=&agent=&parent=&label=&open=1]   issues, most recently updated first\n+//   GET  /issues/p/:project/issue/:n                                        one issue with its comments, edits and asks\n+//   GET  /issues/p/:project/search?q=[&limit=]                               full-text search\n+//   GET  /issues/p/:project/labels | changes | waiting[?of=] | ask/:n | asked?by= | answered?of=\n+//   GET  /issues/p/:project/a/:agent/waiting | asked | drafts | news[?before=]\n+//   POST /issues/p/:project/a/:agent/issue | ask | answer/:n | ack/:n | reply/:n | withdraw/:n\n+//   POST /issues/p/:project/a/:agent/issue/:n/comment | edit | drop | reopen | done\n+//   POST /issues/p/:project/a/:agent/draft | draft/:n/open | draft/:n/delete | news/read\n+\n+import { DurableObject } from \"cloudflare:workers\";\n+import { type IssuesEnv, IssuesObject } from \"./serve.ts\";\n+import type { News } from \"./store.ts\";\n+\n+export {\n+\ttype IssueNews,\n+\ttype IssuesAuth,\n+\ttype IssuesEnv,\n+\tissuesFetch,\n+\ttype NamespaceLike,\n+\ttype ProjectHooks,\n+\ttype WaitUntil,\n+} from \"./serve.ts\";\n+\n+/** One project's issues, in its own SQLite. */\n+export class IssueProject extends DurableObject<IssuesEnv> {\n+\tprivate readonly issues: IssuesObject;\n+\n+\tconstructor(ctx: DurableObjectState, env: IssuesEnv) {\n+\t\tsuper(ctx, env);\n+\t\t// The migrations are synchronous SQL, so they finish here, before the object takes any request.\n+\t\tthis.issues = new IssuesObject(\n+\t\t\t{ sql: ctx.storage.sql, transactionSync: (action) => ctx.storage.transactionSync(action) },\n+\t\t\tenv,\n+\t\t);\n+\t}\n+\n+\tasync fetch(request: Request): Promise<Response> {\n+\t\treturn this.issues.fetch(request);\n+\t}\n+\n+\t/** A start note names the issue; `change` is the note's log position. A missing or closed issue is ignored. */\n+\tasync claim(agent: string, issue: number, change: number): Promise<void> {\n+\t\tthis.issues.store.claim(agent, issue, change);\n+\t}\n+\n+\t/** The start note ended without finishing the issue. */\n+\tasync unclaim(agent: string, issue: number): Promise<void> {\n+\t\tthis.issues.store.unclaim(agent, issue);\n+\t}\n+\n+\t/** publish --done finished the issue in `version`: done, and its news for the project to deliver. */\n+\tasync done(agent: string, issue: number, version: number): Promise<{ news?: News }> {\n+\t\treturn this.issues.store.done(agent, issue, version);\n+\t}\n+\n+\t/** How many schema migrations this object has run. */\n+\tasync schema(): Promise<{ migrations: number }> {\n+\t\treturn { migrations: this.issues.migrations() };\n+\t}\n+}"}],"unmatched":[]}