bopodev-db 0.1.27 → 0.1.29

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.27 build /Users/danielkrusenstrahle/Documents/Projects/Monorepo/bopohq/packages/db
3
+ > bopodev-db@0.1.29 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.15 lint /Users/danielkrusenstrahle/Documents/Projects/Monorepo/bopohq/packages/db
2
+ > bopodev-db@0.1.28 lint /Users/danielkrusenstrahle/Documents/Projects/Monorepo/bopodev/packages/db
3
3
  > tsc -p tsconfig.json --noEmit
4
4
 
@@ -1,4 +1,4 @@
1
1
 
2
- > bopodev-db@0.1.26 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
 
@@ -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,5 +1,7 @@
1
+ export { and, asc, desc, eq, gt, inArray, like, max, notInArray, sql } from "drizzle-orm";
1
2
  export * from "./bootstrap";
2
3
  export * from "./client";
3
4
  export { resolveDefaultDbPath, resolveBopoInstanceRoot } from "./default-paths";
5
+ export * from "./ping";
4
6
  export * from "./repositories";
5
7
  export * from "./schema";
@@ -0,0 +1 @@
1
+ export {};
package/dist/ping.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { BopoDb } from "./client";
2
+ /** Cheap connection liveness check (no table scan). Kept as SQL because Drizzle has no relational API for a table-free SELECT. */
3
+ export declare function pingDatabase(db: BopoDb): Promise<void>;
@@ -0,0 +1,32 @@
1
+ import type { BopoDb } from "../client";
2
+ export declare function createCompany(db: BopoDb, input: {
3
+ name: string;
4
+ mission?: string | null;
5
+ }): Promise<{
6
+ name: string;
7
+ mission?: string | null;
8
+ id: string;
9
+ }>;
10
+ export declare function listCompanies(db: BopoDb): Promise<{
11
+ id: string;
12
+ name: string;
13
+ mission: string | null;
14
+ createdAt: Date;
15
+ }[]>;
16
+ export declare function getCompany(db: BopoDb, id: string): Promise<{
17
+ id: string;
18
+ name: string;
19
+ mission: string | null;
20
+ createdAt: Date;
21
+ } | null>;
22
+ export declare function updateCompany(db: BopoDb, input: {
23
+ id: string;
24
+ name?: string;
25
+ mission?: string | null;
26
+ }): Promise<{
27
+ id: string;
28
+ name: string;
29
+ mission: string | null;
30
+ createdAt: Date;
31
+ } | null>;
32
+ export declare function deleteCompany(db: BopoDb, id: string): Promise<boolean>;
@@ -0,0 +1,16 @@
1
+ import type { BopoDb } from "../client";
2
+ export declare class RepositoryValidationError extends Error {
3
+ constructor(message: string);
4
+ }
5
+ export declare function assertProjectBelongsToCompany(db: BopoDb, companyId: string, projectId: string): Promise<void>;
6
+ export declare function assertIssueBelongsToCompany(db: BopoDb, companyId: string, issueId: string): Promise<void>;
7
+ export declare function assertGoalBelongsToCompany(db: BopoDb, companyId: string, goalId: string): Promise<void>;
8
+ /** Ensures a goal can be linked to an issue: same company; project-scoped goals must match the issue's project. */
9
+ export declare function assertIssueGoalAssignable(db: BopoDb, companyId: string, issueProjectId: string, goalId: string | null | undefined): Promise<void>;
10
+ /** Validates each goal can be linked to an issue (same company; project goals must match issue project). */
11
+ export declare function assertIssueGoalsAssignable(db: BopoDb, companyId: string, issueProjectId: string, goalIds: string[]): Promise<void>;
12
+ export declare function assertAgentBelongsToCompany(db: BopoDb, companyId: string, agentId: string): Promise<void>;
13
+ export declare function assertTemplateBelongsToCompany(db: BopoDb, companyId: string, templateId: string): Promise<void>;
14
+ export declare function compactUpdate<T extends Record<string, unknown>>(input: T): {
15
+ [k: string]: unknown;
16
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./helpers";
2
+ export * from "./companies";
3
+ export * from "./legacy";