bopodev-db 0.1.27 → 0.1.28

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.
@@ -0,0 +1,389 @@
1
+ CREATE TABLE "companies" (
2
+ "id" text PRIMARY KEY NOT NULL,
3
+ "name" text NOT NULL,
4
+ "mission" text,
5
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
6
+ );
7
+ --> statement-breakpoint
8
+ CREATE TABLE "projects" (
9
+ "id" text PRIMARY KEY NOT NULL,
10
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
11
+ "name" text NOT NULL,
12
+ "description" text,
13
+ "status" text DEFAULT 'planned' NOT NULL,
14
+ "planned_start_at" timestamp,
15
+ "monthly_budget_usd" numeric(12, 4) DEFAULT 100 NOT NULL,
16
+ "used_budget_usd" numeric(12, 4) DEFAULT 0 NOT NULL,
17
+ "budget_window_start_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
18
+ "execution_workspace_policy" text,
19
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
20
+ "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
21
+ );
22
+ --> statement-breakpoint
23
+ CREATE TABLE "project_workspaces" (
24
+ "id" text PRIMARY KEY NOT NULL,
25
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
26
+ "project_id" text NOT NULL REFERENCES "projects"("id") ON DELETE CASCADE,
27
+ "name" text NOT NULL,
28
+ "cwd" text,
29
+ "repo_url" text,
30
+ "repo_ref" text,
31
+ "is_primary" boolean DEFAULT false NOT NULL,
32
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
33
+ "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
34
+ );
35
+ --> statement-breakpoint
36
+ CREATE TABLE "goals" (
37
+ "id" text PRIMARY KEY NOT NULL,
38
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
39
+ "project_id" text REFERENCES "projects"("id") ON DELETE SET NULL,
40
+ "parent_goal_id" text,
41
+ "level" text NOT NULL,
42
+ "title" text NOT NULL,
43
+ "description" text,
44
+ "status" text DEFAULT 'draft' NOT NULL,
45
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
46
+ "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
47
+ );
48
+ --> statement-breakpoint
49
+ CREATE TABLE "agents" (
50
+ "id" text PRIMARY KEY NOT NULL,
51
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
52
+ "manager_agent_id" text,
53
+ "role" text NOT NULL,
54
+ "role_key" text,
55
+ "title" text,
56
+ "name" text NOT NULL,
57
+ "provider_type" text NOT NULL,
58
+ "status" text DEFAULT 'idle' NOT NULL,
59
+ "heartbeat_cron" text NOT NULL,
60
+ "monthly_budget_usd" numeric(12, 4) DEFAULT 0 NOT NULL,
61
+ "used_budget_usd" numeric(12, 4) DEFAULT 0 NOT NULL,
62
+ "token_usage" integer DEFAULT 0 NOT NULL,
63
+ "can_hire_agents" boolean DEFAULT false NOT NULL,
64
+ "avatar_seed" text DEFAULT '' NOT NULL,
65
+ "runtime_command" text,
66
+ "runtime_args_json" text DEFAULT '[]' NOT NULL,
67
+ "runtime_cwd" text,
68
+ "runtime_env_json" text DEFAULT '{}' NOT NULL,
69
+ "runtime_model" text,
70
+ "runtime_thinking_effort" text DEFAULT 'auto' NOT NULL,
71
+ "bootstrap_prompt" text,
72
+ "runtime_timeout_sec" integer DEFAULT 0 NOT NULL,
73
+ "interrupt_grace_sec" integer DEFAULT 15 NOT NULL,
74
+ "run_policy_json" text DEFAULT '{}' NOT NULL,
75
+ "state_blob" text DEFAULT '{}' NOT NULL,
76
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
77
+ "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
78
+ );
79
+ --> statement-breakpoint
80
+ CREATE TABLE "issues" (
81
+ "id" text PRIMARY KEY NOT NULL,
82
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
83
+ "project_id" text NOT NULL REFERENCES "projects"("id") ON DELETE CASCADE,
84
+ "parent_issue_id" text,
85
+ "title" text NOT NULL,
86
+ "body" text,
87
+ "status" text DEFAULT 'todo' NOT NULL,
88
+ "priority" text DEFAULT 'none' NOT NULL,
89
+ "assignee_agent_id" text,
90
+ "labels_json" text DEFAULT '[]' NOT NULL,
91
+ "tags_json" text DEFAULT '[]' NOT NULL,
92
+ "is_claimed" boolean DEFAULT false NOT NULL,
93
+ "claimed_by_heartbeat_run_id" text,
94
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
95
+ "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
96
+ );
97
+ --> statement-breakpoint
98
+ CREATE TABLE "issue_comments" (
99
+ "id" text PRIMARY KEY NOT NULL,
100
+ "issue_id" text NOT NULL REFERENCES "issues"("id") ON DELETE CASCADE,
101
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
102
+ "author_type" text NOT NULL,
103
+ "author_id" text,
104
+ "recipients_json" text DEFAULT '[]' NOT NULL,
105
+ "run_id" text,
106
+ "body" text NOT NULL,
107
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
108
+ );
109
+ --> statement-breakpoint
110
+ CREATE TABLE "issue_attachments" (
111
+ "id" text PRIMARY KEY NOT NULL,
112
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
113
+ "issue_id" text NOT NULL REFERENCES "issues"("id") ON DELETE CASCADE,
114
+ "project_id" text NOT NULL REFERENCES "projects"("id") ON DELETE CASCADE,
115
+ "file_name" text NOT NULL,
116
+ "mime_type" text,
117
+ "file_size_bytes" integer NOT NULL,
118
+ "relative_path" text NOT NULL,
119
+ "uploaded_by_actor_type" text DEFAULT 'human' NOT NULL,
120
+ "uploaded_by_actor_id" text,
121
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
122
+ );
123
+ --> statement-breakpoint
124
+ CREATE TABLE "activity_logs" (
125
+ "id" text PRIMARY KEY NOT NULL,
126
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
127
+ "issue_id" text REFERENCES "issues"("id") ON DELETE SET NULL,
128
+ "actor_type" text NOT NULL,
129
+ "actor_id" text,
130
+ "event_type" text NOT NULL,
131
+ "payload_json" text DEFAULT '{}' NOT NULL,
132
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
133
+ );
134
+ --> statement-breakpoint
135
+ CREATE TABLE "heartbeat_runs" (
136
+ "id" text PRIMARY KEY NOT NULL,
137
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
138
+ "agent_id" text NOT NULL REFERENCES "agents"("id") ON DELETE CASCADE,
139
+ "status" text DEFAULT 'started' NOT NULL,
140
+ "started_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
141
+ "finished_at" timestamp,
142
+ "message" text
143
+ );
144
+ --> statement-breakpoint
145
+ CREATE TABLE "heartbeat_run_queue" (
146
+ "id" text PRIMARY KEY NOT NULL,
147
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
148
+ "agent_id" text NOT NULL REFERENCES "agents"("id") ON DELETE CASCADE,
149
+ "job_type" text NOT NULL,
150
+ "payload_json" text DEFAULT '{}' NOT NULL,
151
+ "status" text DEFAULT 'pending' NOT NULL,
152
+ "priority" integer DEFAULT 100 NOT NULL,
153
+ "idempotency_key" text,
154
+ "available_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
155
+ "attempt_count" integer DEFAULT 0 NOT NULL,
156
+ "max_attempts" integer DEFAULT 10 NOT NULL,
157
+ "last_error" text,
158
+ "started_at" timestamp,
159
+ "finished_at" timestamp,
160
+ "heartbeat_run_id" text REFERENCES "heartbeat_runs"("id") ON DELETE SET NULL,
161
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
162
+ "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
163
+ );
164
+ --> statement-breakpoint
165
+ CREATE TABLE "heartbeat_run_messages" (
166
+ "id" text PRIMARY KEY NOT NULL,
167
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
168
+ "run_id" text NOT NULL REFERENCES "heartbeat_runs"("id") ON DELETE CASCADE,
169
+ "sequence" integer NOT NULL,
170
+ "kind" text NOT NULL,
171
+ "label" text,
172
+ "text" text,
173
+ "payload_json" text,
174
+ "signal_level" text,
175
+ "group_key" text,
176
+ "source" text,
177
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
178
+ );
179
+ --> statement-breakpoint
180
+ CREATE TABLE "approval_requests" (
181
+ "id" text PRIMARY KEY NOT NULL,
182
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
183
+ "requested_by_agent_id" text,
184
+ "action" text NOT NULL,
185
+ "payload_json" text DEFAULT '{}' NOT NULL,
186
+ "status" text DEFAULT 'pending' NOT NULL,
187
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
188
+ "resolved_at" timestamp
189
+ );
190
+ --> statement-breakpoint
191
+ CREATE TABLE "approval_inbox_states" (
192
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
193
+ "actor_id" text NOT NULL,
194
+ "approval_id" text NOT NULL REFERENCES "approval_requests"("id") ON DELETE CASCADE,
195
+ "seen_at" timestamp,
196
+ "dismissed_at" timestamp,
197
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
198
+ "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
199
+ PRIMARY KEY ("company_id", "actor_id", "approval_id")
200
+ );
201
+ --> statement-breakpoint
202
+ CREATE TABLE "attention_inbox_states" (
203
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
204
+ "actor_id" text NOT NULL,
205
+ "item_key" text NOT NULL,
206
+ "seen_at" timestamp,
207
+ "acknowledged_at" timestamp,
208
+ "dismissed_at" timestamp,
209
+ "resolved_at" timestamp,
210
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
211
+ "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
212
+ PRIMARY KEY ("company_id", "actor_id", "item_key")
213
+ );
214
+ --> statement-breakpoint
215
+ CREATE TABLE "cost_ledger" (
216
+ "id" text PRIMARY KEY NOT NULL,
217
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
218
+ "run_id" text REFERENCES "heartbeat_runs"("id") ON DELETE SET NULL,
219
+ "project_id" text REFERENCES "projects"("id") ON DELETE SET NULL,
220
+ "issue_id" text REFERENCES "issues"("id") ON DELETE SET NULL,
221
+ "agent_id" text REFERENCES "agents"("id") ON DELETE SET NULL,
222
+ "provider_type" text NOT NULL,
223
+ "runtime_model_id" text,
224
+ "pricing_provider_type" text,
225
+ "pricing_model_id" text,
226
+ "pricing_source" text,
227
+ "token_input" integer DEFAULT 0 NOT NULL,
228
+ "token_output" integer DEFAULT 0 NOT NULL,
229
+ "usd_cost" numeric(12, 6) DEFAULT 0 NOT NULL,
230
+ "usd_cost_status" text,
231
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
232
+ );
233
+ --> statement-breakpoint
234
+ DROP TABLE IF EXISTS "model_pricing";
235
+ --> statement-breakpoint
236
+ CREATE TABLE "audit_events" (
237
+ "id" text PRIMARY KEY NOT NULL,
238
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
239
+ "actor_type" text NOT NULL,
240
+ "actor_id" text,
241
+ "event_type" text NOT NULL,
242
+ "entity_type" text NOT NULL,
243
+ "entity_id" text NOT NULL,
244
+ "correlation_id" text,
245
+ "payload_json" text DEFAULT '{}' NOT NULL,
246
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
247
+ );
248
+ --> statement-breakpoint
249
+ CREATE TABLE "plugins" (
250
+ "id" text PRIMARY KEY NOT NULL,
251
+ "name" text NOT NULL,
252
+ "version" text NOT NULL,
253
+ "kind" text NOT NULL,
254
+ "runtime_type" text NOT NULL,
255
+ "runtime_entrypoint" text NOT NULL,
256
+ "hooks_json" text DEFAULT '[]' NOT NULL,
257
+ "capabilities_json" text DEFAULT '[]' NOT NULL,
258
+ "manifest_json" text DEFAULT '{}' NOT NULL,
259
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
260
+ "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
261
+ );
262
+ --> statement-breakpoint
263
+ CREATE TABLE "templates" (
264
+ "id" text PRIMARY KEY NOT NULL,
265
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
266
+ "slug" text NOT NULL,
267
+ "name" text NOT NULL,
268
+ "description" text,
269
+ "current_version" text DEFAULT '1.0.0' NOT NULL,
270
+ "status" text DEFAULT 'draft' NOT NULL,
271
+ "visibility" text DEFAULT 'company' NOT NULL,
272
+ "variables_json" text DEFAULT '[]' NOT NULL,
273
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
274
+ "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
275
+ );
276
+ --> statement-breakpoint
277
+ CREATE TABLE "template_versions" (
278
+ "id" text PRIMARY KEY NOT NULL,
279
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
280
+ "template_id" text NOT NULL REFERENCES "templates"("id") ON DELETE CASCADE,
281
+ "version" text NOT NULL,
282
+ "manifest_json" text DEFAULT '{}' NOT NULL,
283
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
284
+ );
285
+ --> statement-breakpoint
286
+ CREATE TABLE "template_installs" (
287
+ "id" text PRIMARY KEY NOT NULL,
288
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
289
+ "template_id" text REFERENCES "templates"("id") ON DELETE SET NULL,
290
+ "template_version_id" text REFERENCES "template_versions"("id") ON DELETE SET NULL,
291
+ "status" text DEFAULT 'applied' NOT NULL,
292
+ "summary_json" text DEFAULT '{}' NOT NULL,
293
+ "variables_json" text DEFAULT '{}' NOT NULL,
294
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
295
+ );
296
+ --> statement-breakpoint
297
+ CREATE TABLE "plugin_configs" (
298
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
299
+ "plugin_id" text NOT NULL REFERENCES "plugins"("id") ON DELETE CASCADE,
300
+ "enabled" boolean DEFAULT false NOT NULL,
301
+ "priority" integer DEFAULT 100 NOT NULL,
302
+ "config_json" text DEFAULT '{}' NOT NULL,
303
+ "granted_capabilities_json" text DEFAULT '[]' NOT NULL,
304
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
305
+ "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
306
+ PRIMARY KEY ("company_id", "plugin_id")
307
+ );
308
+ --> statement-breakpoint
309
+ CREATE TABLE "plugin_runs" (
310
+ "id" text PRIMARY KEY NOT NULL,
311
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
312
+ "run_id" text REFERENCES "heartbeat_runs"("id") ON DELETE CASCADE,
313
+ "plugin_id" text NOT NULL REFERENCES "plugins"("id") ON DELETE CASCADE,
314
+ "hook" text NOT NULL,
315
+ "status" text NOT NULL,
316
+ "duration_ms" integer DEFAULT 0 NOT NULL,
317
+ "error" text,
318
+ "diagnostics_json" text DEFAULT '{}' NOT NULL,
319
+ "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
320
+ );
321
+ --> statement-breakpoint
322
+ CREATE TABLE "agent_issue_labels" (
323
+ "company_id" text NOT NULL REFERENCES "companies"("id") ON DELETE CASCADE,
324
+ "issue_id" text NOT NULL REFERENCES "issues"("id") ON DELETE CASCADE,
325
+ "label" text NOT NULL,
326
+ PRIMARY KEY ("company_id", "issue_id", "label")
327
+ );
328
+ --> statement-breakpoint
329
+ CREATE INDEX "idx_project_workspaces_company_project"
330
+ ON "project_workspaces" ("company_id", "project_id", "is_primary", "created_at");
331
+ --> statement-breakpoint
332
+ CREATE INDEX "idx_issues_company_status"
333
+ ON "issues" ("company_id", "status", "updated_at");
334
+ --> statement-breakpoint
335
+ CREATE INDEX "idx_issues_assignee_claim_priority"
336
+ ON "issues" ("company_id", "assignee_agent_id", "is_claimed", "status", "priority", "updated_at");
337
+ --> statement-breakpoint
338
+ CREATE INDEX "idx_issue_attachments_company_issue"
339
+ ON "issue_attachments" ("company_id", "issue_id", "created_at");
340
+ --> statement-breakpoint
341
+ CREATE INDEX "idx_issue_attachments_company_project"
342
+ ON "issue_attachments" ("company_id", "project_id", "created_at");
343
+ --> statement-breakpoint
344
+ CREATE INDEX "idx_audit_events_company_created"
345
+ ON "audit_events" ("company_id", "created_at");
346
+ --> statement-breakpoint
347
+ CREATE INDEX "idx_cost_ledger_company_created"
348
+ ON "cost_ledger" ("company_id", "created_at");
349
+ --> statement-breakpoint
350
+ CREATE UNIQUE INDEX "idx_heartbeat_runs_single_started"
351
+ ON "heartbeat_runs" ("company_id", "agent_id")
352
+ WHERE "status" = 'started';
353
+ --> statement-breakpoint
354
+ CREATE INDEX "idx_heartbeat_run_queue_status_available_priority"
355
+ ON "heartbeat_run_queue" ("company_id", "status", "available_at", "priority", "created_at");
356
+ --> statement-breakpoint
357
+ CREATE INDEX "idx_heartbeat_run_queue_agent_status"
358
+ ON "heartbeat_run_queue" ("company_id", "agent_id", "status", "available_at", "created_at");
359
+ --> statement-breakpoint
360
+ CREATE UNIQUE INDEX "idx_heartbeat_run_queue_idempotency"
361
+ ON "heartbeat_run_queue" ("company_id", "agent_id", "idempotency_key")
362
+ WHERE "idempotency_key" IS NOT NULL AND btrim("idempotency_key") <> '';
363
+ --> statement-breakpoint
364
+ CREATE INDEX "idx_heartbeat_run_messages_company_run_sequence"
365
+ ON "heartbeat_run_messages" ("company_id", "run_id", "sequence");
366
+ --> statement-breakpoint
367
+ CREATE INDEX "idx_heartbeat_run_messages_company_created"
368
+ ON "heartbeat_run_messages" ("company_id", "created_at");
369
+ --> statement-breakpoint
370
+ CREATE INDEX "idx_approval_inbox_states_company_actor_updated"
371
+ ON "approval_inbox_states" ("company_id", "actor_id", "updated_at");
372
+ --> statement-breakpoint
373
+ CREATE INDEX "idx_attention_inbox_states_company_actor_updated"
374
+ ON "attention_inbox_states" ("company_id", "actor_id", "updated_at");
375
+ --> statement-breakpoint
376
+ CREATE INDEX "idx_plugin_configs_company_enabled_priority"
377
+ ON "plugin_configs" ("company_id", "enabled", "priority", "plugin_id");
378
+ --> statement-breakpoint
379
+ CREATE INDEX "idx_plugin_runs_company_created"
380
+ ON "plugin_runs" ("company_id", "created_at");
381
+ --> statement-breakpoint
382
+ CREATE UNIQUE INDEX "idx_templates_company_slug"
383
+ ON "templates" ("company_id", "slug");
384
+ --> statement-breakpoint
385
+ CREATE INDEX "idx_template_versions_company_template_created"
386
+ ON "template_versions" ("company_id", "template_id", "created_at");
387
+ --> statement-breakpoint
388
+ CREATE INDEX "idx_template_installs_company_created"
389
+ ON "template_installs" ("company_id", "created_at");
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "postgresql",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "7",
8
+ "when": 1742500000000,
9
+ "tag": "0000_initial",
10
+ "breakpoints": true
11
+ }
12
+ ]
13
+ }
@@ -215,7 +215,7 @@ export async function updateProject(
215
215
  }
216
216
  if (input.workspaceLocalPath !== undefined || input.workspaceGithubRepo !== undefined) {
217
217
  const existingWorkspaces = await listProjectWorkspaces(db, input.companyId, input.id);
218
- const primaryWorkspace = existingWorkspaces.find((workspace) => workspace.isPrimary) ?? existingWorkspaces[0] ?? null;
218
+ const primaryWorkspace = existingWorkspaces.find((workspace: any) => workspace.isPrimary) ?? existingWorkspaces[0] ?? null;
219
219
  const hasAnyWorkspaceField =
220
220
  (input.workspaceLocalPath?.trim() ?? "").length > 0 || (input.workspaceGithubRepo?.trim() ?? "").length > 0;
221
221
  if (!hasAnyWorkspaceField) {
@@ -272,7 +272,7 @@ export async function createProjectWorkspace(
272
272
  }
273
273
  ) {
274
274
  const id = nanoid(12);
275
- return db.transaction(async (tx) => {
275
+ return db.transaction(async (tx: any) => {
276
276
  const existingWorkspaces = await tx
277
277
  .select({ id: projectWorkspaces.id })
278
278
  .from(projectWorkspaces)
@@ -315,7 +315,7 @@ export async function updateProjectWorkspace(
315
315
  isPrimary?: boolean;
316
316
  }
317
317
  ) {
318
- return db.transaction(async (tx) => {
318
+ return db.transaction(async (tx: any) => {
319
319
  if (input.isPrimary === true) {
320
320
  await tx
321
321
  .update(projectWorkspaces)
@@ -385,7 +385,7 @@ export async function deleteProjectWorkspace(
385
385
  db: BopoDb,
386
386
  input: { companyId: string; projectId: string; id: string }
387
387
  ) {
388
- return db.transaction(async (tx) => {
388
+ return db.transaction(async (tx: any) => {
389
389
  const [workspace] = await tx
390
390
  .delete(projectWorkspaces)
391
391
  .where(
@@ -763,7 +763,7 @@ export async function listIssueComments(db: BopoDb, companyId: string, issueId:
763
763
  .from(issueComments)
764
764
  .where(and(eq(issueComments.companyId, companyId), eq(issueComments.issueId, issueId)))
765
765
  .orderBy(asc(issueComments.createdAt));
766
- return comments.map((comment) => normalizeIssueComment(comment));
766
+ return comments.map((comment: any) => normalizeIssueComment(comment));
767
767
  }
768
768
 
769
769
  export async function listIssueActivity(db: BopoDb, companyId: string, issueId: string, limit = 100) {
@@ -1674,7 +1674,7 @@ export async function claimNextHeartbeatJob(db: BopoDb, companyId: string) {
1674
1674
  WHERE q.id = c.id
1675
1675
  RETURNING q.*;
1676
1676
  `);
1677
- const row = (result.rows ?? [])[0] as Record<string, unknown> | undefined;
1677
+ const row = result[0] as Record<string, unknown> | undefined;
1678
1678
  return row ? normalizeHeartbeatQueueJob(row) : null;
1679
1679
  }
1680
1680
 
@@ -1804,7 +1804,7 @@ export async function listHeartbeatQueueJobs(
1804
1804
  .where(and(...conditions))
1805
1805
  .orderBy(asc(heartbeatRunQueue.priority), asc(heartbeatRunQueue.availableAt), asc(heartbeatRunQueue.createdAt))
1806
1806
  .limit(limit);
1807
- return rows.map((row) => normalizeHeartbeatQueueJob(row));
1807
+ return rows.map((row: any) => normalizeHeartbeatQueueJob(row));
1808
1808
  }
1809
1809
 
1810
1810
  export async function getHeartbeatRun(db: BopoDb, companyId: string, runId: string) {
@@ -1935,7 +1935,7 @@ export async function listHeartbeatRunMessagesForRuns(
1935
1935
  WHERE rn <= ${perRunLimit}
1936
1936
  ORDER BY run_id ASC, sequence ASC
1937
1937
  `);
1938
- const rows = (rankedRows.rows ?? []) as Array<{
1938
+ const rows = rankedRows as unknown as Array<{
1939
1939
  id: string;
1940
1940
  company_id: string;
1941
1941
  run_id: string;
@@ -1,4 +0,0 @@
1
-
2
- > bopodev-db@0.1.15 lint /Users/danielkrusenstrahle/Documents/Projects/Monorepo/bopohq/packages/db
3
- > tsc -p tsconfig.json --noEmit
4
-