bopodev-db 0.1.26 → 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.
@@ -1,5 +1,5 @@
1
1
 
2
2
  
3
- > bopodev-db@0.1.26 build /Users/danielkrusenstrahle/Documents/Projects/Monorepo/bopohq/packages/db
3
+ > bopodev-db@0.1.28 build /Users/danielkrusenstrahle/Documents/Projects/Monorepo/bopodev/packages/db
4
4
  > tsc -p tsconfig.json --emitDeclarationOnly
5
5
 
@@ -1,4 +1,4 @@
1
1
 
2
- > bopodev-db@0.1.24 typecheck /Users/danielkrusenstrahle/Documents/Projects/Monorepo/bopohq/packages/db
2
+ > bopodev-db@0.1.20 typecheck /Users/danielkrusenstrahle/Documents/Projects/Monorepo/bopodev/packages/db
3
3
  > tsc -p tsconfig.json --noEmit
4
4
 
package/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # `packages/db`
2
+
3
+ Database schema and repository layer for Bopo, backed by Drizzle + PGlite.
4
+
5
+ ## Responsibilities
6
+
7
+ - Define schema models and migrations/bootstrap behavior.
8
+ - Expose repository functions used by API services/routes.
9
+ - Provide typed DB access primitives for shared business logic.
10
+
11
+ ## Usage
12
+
13
+ Primary consumer is `apps/api`.
14
+
15
+ ## Commands
16
+
17
+ - `pnpm --filter bopodev-db build`
18
+ - `pnpm --filter bopodev-db typecheck`
19
+
20
+ ## Notes
21
+
22
+ - Default DB path is managed by app/runtime config; see configuration docs before overriding.
23
+ - API startup bootstraps DB and registers built-in plugins/templates.
24
+
25
+ ## Related Docs
26
+
27
+ - `docs/developer/architecture.md`
28
+ - `docs/developer/configuration-reference.md`
29
+ - `docs/operations/deployment.md`
@@ -1,6 +1,6 @@
1
1
  export declare function bootstrapDatabase(dbPath?: string): Promise<{
2
- db: import("drizzle-orm/pglite").PgliteDatabase<typeof import("./schema")> & {
3
- $client: import("@electric-sql/pglite").PGlite;
2
+ db: import("drizzle-orm/postgres-js").PostgresJsDatabase<typeof import("./schema")> & {
3
+ $client: import("postgres").Sql<{}>;
4
4
  };
5
- client: import("@electric-sql/pglite").PGlite;
5
+ client: import("./client").BopoDatabaseClient;
6
6
  }>;
package/dist/client.d.ts CHANGED
@@ -1,10 +1,38 @@
1
- import { PGlite } from "@electric-sql/pglite";
2
- import { drizzle } from "drizzle-orm/pglite";
1
+ import { type PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import postgres from "postgres";
3
3
  import * as dbSchema from "./schema";
4
- export type BopoDb = ReturnType<typeof drizzle<typeof dbSchema>>;
4
+ export type BopoDb = PostgresJsDatabase<typeof dbSchema>;
5
+ export type BopoDatabaseClient = {
6
+ close: () => Promise<void>;
7
+ };
8
+ type DatabaseTarget = {
9
+ connectionString: string;
10
+ dataPath: string | null;
11
+ stop: () => Promise<void>;
12
+ source: "external-postgres" | "embedded-postgres";
13
+ };
14
+ type MigrationVersion = {
15
+ count: number;
16
+ latestTag: string | null;
17
+ };
5
18
  export declare function createDb(dbPath?: string): Promise<{
6
- db: import("drizzle-orm/pglite").PgliteDatabase<typeof dbSchema> & {
7
- $client: PGlite;
19
+ db: PostgresJsDatabase<typeof dbSchema> & {
20
+ $client: postgres.Sql<{}>;
8
21
  };
9
- client: PGlite;
22
+ client: BopoDatabaseClient;
23
+ connectionString: string;
24
+ dataPath: string | null;
25
+ source: "external-postgres" | "embedded-postgres";
10
26
  }>;
27
+ export declare function applyDatabaseMigrations(connectionString: string, options?: {
28
+ dataPath?: string | null;
29
+ }): Promise<void>;
30
+ export declare function getExpectedDatabaseSchemaVersion(): MigrationVersion;
31
+ export declare function verifyDatabaseSchema(connectionString: string): Promise<{
32
+ appliedCount: number;
33
+ expectedCount: number;
34
+ latestTag: string | null;
35
+ }>;
36
+ export declare function readAppliedMigrationCount(connectionString: string): Promise<number>;
37
+ export declare function ensureDatabaseTarget(dbPath?: string): Promise<DatabaseTarget>;
38
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
+ export { and, asc, desc, eq, gt, inArray, like, notInArray, sql } from "drizzle-orm";
1
2
  export * from "./bootstrap";
2
3
  export * from "./client";
4
+ export { resolveDefaultDbPath, resolveBopoInstanceRoot } from "./default-paths";
3
5
  export * from "./repositories";
4
6
  export * from "./schema";
@@ -0,0 +1 @@
1
+ export {};
@@ -254,18 +254,7 @@ export declare function createProjectWorkspace(db: BopoDb, input: {
254
254
  repoUrl?: string | null;
255
255
  repoRef?: string | null;
256
256
  isPrimary?: boolean;
257
- }): Promise<{
258
- id: string;
259
- name: string;
260
- createdAt: Date;
261
- companyId: string;
262
- updatedAt: Date;
263
- projectId: string;
264
- cwd: string | null;
265
- repoUrl: string | null;
266
- repoRef: string | null;
267
- isPrimary: boolean;
268
- } | undefined>;
257
+ }): Promise<any>;
269
258
  export declare function updateProjectWorkspace(db: BopoDb, input: {
270
259
  companyId: string;
271
260
  projectId: string;
@@ -275,34 +264,12 @@ export declare function updateProjectWorkspace(db: BopoDb, input: {
275
264
  repoUrl?: string | null;
276
265
  repoRef?: string | null;
277
266
  isPrimary?: boolean;
278
- }): Promise<{
279
- id: string;
280
- companyId: string;
281
- projectId: string;
282
- name: string;
283
- cwd: string | null;
284
- repoUrl: string | null;
285
- repoRef: string | null;
286
- isPrimary: boolean;
287
- createdAt: Date;
288
- updatedAt: Date;
289
- } | null>;
267
+ }): Promise<any>;
290
268
  export declare function deleteProjectWorkspace(db: BopoDb, input: {
291
269
  companyId: string;
292
270
  projectId: string;
293
271
  id: string;
294
- }): Promise<{
295
- id: string;
296
- name: string;
297
- createdAt: Date;
298
- companyId: string;
299
- updatedAt: Date;
300
- projectId: string;
301
- cwd: string | null;
302
- repoUrl: string | null;
303
- repoRef: string | null;
304
- isPrimary: boolean;
305
- } | null>;
272
+ }): Promise<any>;
306
273
  export declare function syncProjectGoals(db: BopoDb, input: {
307
274
  companyId: string;
308
275
  projectId: string;
@@ -326,6 +293,23 @@ export declare function listIssues(db: BopoDb, companyId: string, projectId?: st
326
293
  createdAt: Date;
327
294
  updatedAt: Date;
328
295
  }[]>;
296
+ export declare function getIssue(db: BopoDb, companyId: string, issueId: string): Promise<{
297
+ id: string;
298
+ companyId: string;
299
+ projectId: string;
300
+ parentIssueId: string | null;
301
+ title: string;
302
+ body: string | null;
303
+ status: string;
304
+ priority: string;
305
+ assigneeAgentId: string | null;
306
+ labelsJson: string;
307
+ tagsJson: string;
308
+ isClaimed: boolean;
309
+ claimedByHeartbeatRunId: string | null;
310
+ createdAt: Date;
311
+ updatedAt: Date;
312
+ } | null>;
329
313
  export declare function createIssue(db: BopoDb, input: {
330
314
  companyId: string;
331
315
  projectId: string;
@@ -1433,39 +1417,3 @@ export declare function createTemplateInstall(db: BopoDb, input: {
1433
1417
  templateVersionId: string | null;
1434
1418
  summaryJson: string;
1435
1419
  } | null>;
1436
- export declare function listModelPricing(db: BopoDb, companyId: string): Promise<{
1437
- companyId: string;
1438
- providerType: string;
1439
- modelId: string;
1440
- displayName: string | null;
1441
- inputUsdPer1M: string;
1442
- outputUsdPer1M: string;
1443
- currency: string;
1444
- updatedAt: Date;
1445
- updatedBy: string | null;
1446
- }[]>;
1447
- export declare function getModelPricing(db: BopoDb, input: {
1448
- companyId: string;
1449
- providerType: string;
1450
- modelId: string;
1451
- }): Promise<{
1452
- companyId: string;
1453
- providerType: string;
1454
- modelId: string;
1455
- displayName: string | null;
1456
- inputUsdPer1M: string;
1457
- outputUsdPer1M: string;
1458
- currency: string;
1459
- updatedAt: Date;
1460
- updatedBy: string | null;
1461
- } | null>;
1462
- export declare function upsertModelPricing(db: BopoDb, input: {
1463
- companyId: string;
1464
- providerType: string;
1465
- modelId: string;
1466
- displayName?: string | null;
1467
- inputUsdPer1M?: string | null;
1468
- outputUsdPer1M?: string | null;
1469
- currency?: string | null;
1470
- updatedBy?: string | null;
1471
- }): Promise<void>;
package/dist/schema.d.ts CHANGED
@@ -4038,166 +4038,6 @@ export declare const templateInstalls: import("drizzle-orm/pg-core").PgTableWith
4038
4038
  };
4039
4039
  dialect: "pg";
4040
4040
  }>;
4041
- export declare const modelPricing: import("drizzle-orm/pg-core").PgTableWithColumns<{
4042
- name: "model_pricing";
4043
- schema: undefined;
4044
- columns: {
4045
- companyId: import("drizzle-orm/pg-core").PgColumn<{
4046
- name: "company_id";
4047
- tableName: "model_pricing";
4048
- dataType: "string";
4049
- columnType: "PgText";
4050
- data: string;
4051
- driverParam: string;
4052
- notNull: true;
4053
- hasDefault: false;
4054
- isPrimaryKey: false;
4055
- isAutoincrement: false;
4056
- hasRuntimeDefault: false;
4057
- enumValues: [string, ...string[]];
4058
- baseColumn: never;
4059
- identity: undefined;
4060
- generated: undefined;
4061
- }, {}, {}>;
4062
- providerType: import("drizzle-orm/pg-core").PgColumn<{
4063
- name: "provider_type";
4064
- tableName: "model_pricing";
4065
- dataType: "string";
4066
- columnType: "PgText";
4067
- data: string;
4068
- driverParam: string;
4069
- notNull: true;
4070
- hasDefault: false;
4071
- isPrimaryKey: false;
4072
- isAutoincrement: false;
4073
- hasRuntimeDefault: false;
4074
- enumValues: [string, ...string[]];
4075
- baseColumn: never;
4076
- identity: undefined;
4077
- generated: undefined;
4078
- }, {}, {}>;
4079
- modelId: import("drizzle-orm/pg-core").PgColumn<{
4080
- name: "model_id";
4081
- tableName: "model_pricing";
4082
- dataType: "string";
4083
- columnType: "PgText";
4084
- data: string;
4085
- driverParam: string;
4086
- notNull: true;
4087
- hasDefault: false;
4088
- isPrimaryKey: false;
4089
- isAutoincrement: false;
4090
- hasRuntimeDefault: false;
4091
- enumValues: [string, ...string[]];
4092
- baseColumn: never;
4093
- identity: undefined;
4094
- generated: undefined;
4095
- }, {}, {}>;
4096
- displayName: import("drizzle-orm/pg-core").PgColumn<{
4097
- name: "display_name";
4098
- tableName: "model_pricing";
4099
- dataType: "string";
4100
- columnType: "PgText";
4101
- data: string;
4102
- driverParam: string;
4103
- notNull: false;
4104
- hasDefault: false;
4105
- isPrimaryKey: false;
4106
- isAutoincrement: false;
4107
- hasRuntimeDefault: false;
4108
- enumValues: [string, ...string[]];
4109
- baseColumn: never;
4110
- identity: undefined;
4111
- generated: undefined;
4112
- }, {}, {}>;
4113
- inputUsdPer1M: import("drizzle-orm/pg-core").PgColumn<{
4114
- name: "input_usd_per_1m";
4115
- tableName: "model_pricing";
4116
- dataType: "string";
4117
- columnType: "PgNumeric";
4118
- data: string;
4119
- driverParam: string;
4120
- notNull: true;
4121
- hasDefault: true;
4122
- isPrimaryKey: false;
4123
- isAutoincrement: false;
4124
- hasRuntimeDefault: false;
4125
- enumValues: undefined;
4126
- baseColumn: never;
4127
- identity: undefined;
4128
- generated: undefined;
4129
- }, {}, {}>;
4130
- outputUsdPer1M: import("drizzle-orm/pg-core").PgColumn<{
4131
- name: "output_usd_per_1m";
4132
- tableName: "model_pricing";
4133
- dataType: "string";
4134
- columnType: "PgNumeric";
4135
- data: string;
4136
- driverParam: string;
4137
- notNull: true;
4138
- hasDefault: true;
4139
- isPrimaryKey: false;
4140
- isAutoincrement: false;
4141
- hasRuntimeDefault: false;
4142
- enumValues: undefined;
4143
- baseColumn: never;
4144
- identity: undefined;
4145
- generated: undefined;
4146
- }, {}, {}>;
4147
- currency: import("drizzle-orm/pg-core").PgColumn<{
4148
- name: "currency";
4149
- tableName: "model_pricing";
4150
- dataType: "string";
4151
- columnType: "PgText";
4152
- data: string;
4153
- driverParam: string;
4154
- notNull: true;
4155
- hasDefault: true;
4156
- isPrimaryKey: false;
4157
- isAutoincrement: false;
4158
- hasRuntimeDefault: false;
4159
- enumValues: [string, ...string[]];
4160
- baseColumn: never;
4161
- identity: undefined;
4162
- generated: undefined;
4163
- }, {}, {}>;
4164
- updatedAt: import("drizzle-orm/pg-core").PgColumn<{
4165
- name: "updated_at";
4166
- tableName: "model_pricing";
4167
- dataType: "date";
4168
- columnType: "PgTimestamp";
4169
- data: Date;
4170
- driverParam: string;
4171
- notNull: true;
4172
- hasDefault: true;
4173
- isPrimaryKey: false;
4174
- isAutoincrement: false;
4175
- hasRuntimeDefault: false;
4176
- enumValues: undefined;
4177
- baseColumn: never;
4178
- identity: undefined;
4179
- generated: undefined;
4180
- }, {}, {}>;
4181
- updatedBy: import("drizzle-orm/pg-core").PgColumn<{
4182
- name: "updated_by";
4183
- tableName: "model_pricing";
4184
- dataType: "string";
4185
- columnType: "PgText";
4186
- data: string;
4187
- driverParam: string;
4188
- notNull: false;
4189
- hasDefault: false;
4190
- isPrimaryKey: false;
4191
- isAutoincrement: false;
4192
- hasRuntimeDefault: false;
4193
- enumValues: [string, ...string[]];
4194
- baseColumn: never;
4195
- identity: undefined;
4196
- generated: undefined;
4197
- }, {}, {}>;
4198
- };
4199
- dialect: "pg";
4200
- }>;
4201
4041
  export declare const pluginConfigs: import("drizzle-orm/pg-core").PgTableWithColumns<{
4202
4042
  name: "plugin_configs";
4203
4043
  schema: undefined;
@@ -8760,166 +8600,6 @@ export declare const schema: {
8760
8600
  };
8761
8601
  dialect: "pg";
8762
8602
  }>;
8763
- modelPricing: import("drizzle-orm/pg-core").PgTableWithColumns<{
8764
- name: "model_pricing";
8765
- schema: undefined;
8766
- columns: {
8767
- companyId: import("drizzle-orm/pg-core").PgColumn<{
8768
- name: "company_id";
8769
- tableName: "model_pricing";
8770
- dataType: "string";
8771
- columnType: "PgText";
8772
- data: string;
8773
- driverParam: string;
8774
- notNull: true;
8775
- hasDefault: false;
8776
- isPrimaryKey: false;
8777
- isAutoincrement: false;
8778
- hasRuntimeDefault: false;
8779
- enumValues: [string, ...string[]];
8780
- baseColumn: never;
8781
- identity: undefined;
8782
- generated: undefined;
8783
- }, {}, {}>;
8784
- providerType: import("drizzle-orm/pg-core").PgColumn<{
8785
- name: "provider_type";
8786
- tableName: "model_pricing";
8787
- dataType: "string";
8788
- columnType: "PgText";
8789
- data: string;
8790
- driverParam: string;
8791
- notNull: true;
8792
- hasDefault: false;
8793
- isPrimaryKey: false;
8794
- isAutoincrement: false;
8795
- hasRuntimeDefault: false;
8796
- enumValues: [string, ...string[]];
8797
- baseColumn: never;
8798
- identity: undefined;
8799
- generated: undefined;
8800
- }, {}, {}>;
8801
- modelId: import("drizzle-orm/pg-core").PgColumn<{
8802
- name: "model_id";
8803
- tableName: "model_pricing";
8804
- dataType: "string";
8805
- columnType: "PgText";
8806
- data: string;
8807
- driverParam: string;
8808
- notNull: true;
8809
- hasDefault: false;
8810
- isPrimaryKey: false;
8811
- isAutoincrement: false;
8812
- hasRuntimeDefault: false;
8813
- enumValues: [string, ...string[]];
8814
- baseColumn: never;
8815
- identity: undefined;
8816
- generated: undefined;
8817
- }, {}, {}>;
8818
- displayName: import("drizzle-orm/pg-core").PgColumn<{
8819
- name: "display_name";
8820
- tableName: "model_pricing";
8821
- dataType: "string";
8822
- columnType: "PgText";
8823
- data: string;
8824
- driverParam: string;
8825
- notNull: false;
8826
- hasDefault: false;
8827
- isPrimaryKey: false;
8828
- isAutoincrement: false;
8829
- hasRuntimeDefault: false;
8830
- enumValues: [string, ...string[]];
8831
- baseColumn: never;
8832
- identity: undefined;
8833
- generated: undefined;
8834
- }, {}, {}>;
8835
- inputUsdPer1M: import("drizzle-orm/pg-core").PgColumn<{
8836
- name: "input_usd_per_1m";
8837
- tableName: "model_pricing";
8838
- dataType: "string";
8839
- columnType: "PgNumeric";
8840
- data: string;
8841
- driverParam: string;
8842
- notNull: true;
8843
- hasDefault: true;
8844
- isPrimaryKey: false;
8845
- isAutoincrement: false;
8846
- hasRuntimeDefault: false;
8847
- enumValues: undefined;
8848
- baseColumn: never;
8849
- identity: undefined;
8850
- generated: undefined;
8851
- }, {}, {}>;
8852
- outputUsdPer1M: import("drizzle-orm/pg-core").PgColumn<{
8853
- name: "output_usd_per_1m";
8854
- tableName: "model_pricing";
8855
- dataType: "string";
8856
- columnType: "PgNumeric";
8857
- data: string;
8858
- driverParam: string;
8859
- notNull: true;
8860
- hasDefault: true;
8861
- isPrimaryKey: false;
8862
- isAutoincrement: false;
8863
- hasRuntimeDefault: false;
8864
- enumValues: undefined;
8865
- baseColumn: never;
8866
- identity: undefined;
8867
- generated: undefined;
8868
- }, {}, {}>;
8869
- currency: import("drizzle-orm/pg-core").PgColumn<{
8870
- name: "currency";
8871
- tableName: "model_pricing";
8872
- dataType: "string";
8873
- columnType: "PgText";
8874
- data: string;
8875
- driverParam: string;
8876
- notNull: true;
8877
- hasDefault: true;
8878
- isPrimaryKey: false;
8879
- isAutoincrement: false;
8880
- hasRuntimeDefault: false;
8881
- enumValues: [string, ...string[]];
8882
- baseColumn: never;
8883
- identity: undefined;
8884
- generated: undefined;
8885
- }, {}, {}>;
8886
- updatedAt: import("drizzle-orm/pg-core").PgColumn<{
8887
- name: "updated_at";
8888
- tableName: "model_pricing";
8889
- dataType: "date";
8890
- columnType: "PgTimestamp";
8891
- data: Date;
8892
- driverParam: string;
8893
- notNull: true;
8894
- hasDefault: true;
8895
- isPrimaryKey: false;
8896
- isAutoincrement: false;
8897
- hasRuntimeDefault: false;
8898
- enumValues: undefined;
8899
- baseColumn: never;
8900
- identity: undefined;
8901
- generated: undefined;
8902
- }, {}, {}>;
8903
- updatedBy: import("drizzle-orm/pg-core").PgColumn<{
8904
- name: "updated_by";
8905
- tableName: "model_pricing";
8906
- dataType: "string";
8907
- columnType: "PgText";
8908
- data: string;
8909
- driverParam: string;
8910
- notNull: false;
8911
- hasDefault: false;
8912
- isPrimaryKey: false;
8913
- isAutoincrement: false;
8914
- hasRuntimeDefault: false;
8915
- enumValues: [string, ...string[]];
8916
- baseColumn: never;
8917
- identity: undefined;
8918
- generated: undefined;
8919
- }, {}, {}>;
8920
- };
8921
- dialect: "pg";
8922
- }>;
8923
8603
  agentIssueLabels: import("drizzle-orm/pg-core").PgTableWithColumns<{
8924
8604
  name: "agent_issue_labels";
8925
8605
  schema: undefined;
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from "drizzle-kit";
2
+
3
+ export default defineConfig({
4
+ schema: "./src/schema.ts",
5
+ out: "./src/migrations",
6
+ dialect: "postgresql",
7
+ dbCredentials: {
8
+ url: process.env.DATABASE_URL ?? "postgres://bopodev:bopodev@127.0.0.1:55432/bopodev"
9
+ }
10
+ });
package/package.json CHANGED
@@ -1,19 +1,26 @@
1
1
  {
2
2
  "name": "bopodev-db",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
7
7
  "types": "src/index.ts",
8
8
  "dependencies": {
9
- "@electric-sql/pglite": "^0.3.7",
9
+ "drizzle-kit": "^0.31.10",
10
10
  "drizzle-orm": "^0.44.5",
11
11
  "drizzle-zod": "^0.8.2",
12
- "nanoid": "^5.1.5"
12
+ "embedded-postgres": "18.3.0-beta.16",
13
+ "nanoid": "^5.1.5",
14
+ "postgres": "^3.4.8"
15
+ },
16
+ "devDependencies": {
17
+ "tsx": "^4.20.5"
13
18
  },
14
19
  "scripts": {
15
20
  "build": "tsc -p tsconfig.json --emitDeclarationOnly",
21
+ "generate": "drizzle-kit generate",
16
22
  "lint": "tsc -p tsconfig.json --noEmit",
23
+ "migrate": "node --import tsx src/migrate.ts",
17
24
  "typecheck": "tsc -p tsconfig.json --noEmit"
18
25
  }
19
26
  }