bopodev-db 0.1.25 → 0.1.26
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.
- package/.turbo/turbo-build.log +1 -1
- package/dist/repositories.d.ts +4 -0
- package/dist/schema.d.ts +68 -0
- package/package.json +1 -1
- package/src/bootstrap.ts +10 -0
- package/src/repositories.ts +4 -0
- package/src/schema.ts +2 -0
package/.turbo/turbo-build.log
CHANGED
package/dist/repositories.d.ts
CHANGED
|
@@ -872,11 +872,13 @@ export declare function markAttentionInboxResolved(db: BopoDb, input: {
|
|
|
872
872
|
}): Promise<void>;
|
|
873
873
|
export declare function appendCost(db: BopoDb, input: {
|
|
874
874
|
companyId: string;
|
|
875
|
+
runId?: string | null;
|
|
875
876
|
providerType: string;
|
|
876
877
|
runtimeModelId?: string | null;
|
|
877
878
|
pricingProviderType?: string | null;
|
|
878
879
|
pricingModelId?: string | null;
|
|
879
880
|
pricingSource?: "exact" | "missing" | null;
|
|
881
|
+
usdCostStatus?: "exact" | "estimated" | "unknown" | null;
|
|
880
882
|
tokenInput: number;
|
|
881
883
|
tokenOutput: number;
|
|
882
884
|
usdCost: string;
|
|
@@ -887,6 +889,7 @@ export declare function appendCost(db: BopoDb, input: {
|
|
|
887
889
|
export declare function listCostEntries(db: BopoDb, companyId: string, limit?: number): Promise<{
|
|
888
890
|
id: string;
|
|
889
891
|
companyId: string;
|
|
892
|
+
runId: string | null;
|
|
890
893
|
projectId: string | null;
|
|
891
894
|
issueId: string | null;
|
|
892
895
|
agentId: string | null;
|
|
@@ -898,6 +901,7 @@ export declare function listCostEntries(db: BopoDb, companyId: string, limit?: n
|
|
|
898
901
|
tokenInput: number;
|
|
899
902
|
tokenOutput: number;
|
|
900
903
|
usdCost: string;
|
|
904
|
+
usdCostStatus: string | null;
|
|
901
905
|
createdAt: Date;
|
|
902
906
|
}[]>;
|
|
903
907
|
export declare function listHeartbeatRuns(db: BopoDb, companyId: string, limit?: number): Promise<{
|
package/dist/schema.d.ts
CHANGED
|
@@ -2980,6 +2980,23 @@ export declare const costLedger: import("drizzle-orm/pg-core").PgTableWithColumn
|
|
|
2980
2980
|
identity: undefined;
|
|
2981
2981
|
generated: undefined;
|
|
2982
2982
|
}, {}, {}>;
|
|
2983
|
+
runId: import("drizzle-orm/pg-core").PgColumn<{
|
|
2984
|
+
name: "run_id";
|
|
2985
|
+
tableName: "cost_ledger";
|
|
2986
|
+
dataType: "string";
|
|
2987
|
+
columnType: "PgText";
|
|
2988
|
+
data: string;
|
|
2989
|
+
driverParam: string;
|
|
2990
|
+
notNull: false;
|
|
2991
|
+
hasDefault: false;
|
|
2992
|
+
isPrimaryKey: false;
|
|
2993
|
+
isAutoincrement: false;
|
|
2994
|
+
hasRuntimeDefault: false;
|
|
2995
|
+
enumValues: [string, ...string[]];
|
|
2996
|
+
baseColumn: never;
|
|
2997
|
+
identity: undefined;
|
|
2998
|
+
generated: undefined;
|
|
2999
|
+
}, {}, {}>;
|
|
2983
3000
|
projectId: import("drizzle-orm/pg-core").PgColumn<{
|
|
2984
3001
|
name: "project_id";
|
|
2985
3002
|
tableName: "cost_ledger";
|
|
@@ -3167,6 +3184,23 @@ export declare const costLedger: import("drizzle-orm/pg-core").PgTableWithColumn
|
|
|
3167
3184
|
identity: undefined;
|
|
3168
3185
|
generated: undefined;
|
|
3169
3186
|
}, {}, {}>;
|
|
3187
|
+
usdCostStatus: import("drizzle-orm/pg-core").PgColumn<{
|
|
3188
|
+
name: "usd_cost_status";
|
|
3189
|
+
tableName: "cost_ledger";
|
|
3190
|
+
dataType: "string";
|
|
3191
|
+
columnType: "PgText";
|
|
3192
|
+
data: string;
|
|
3193
|
+
driverParam: string;
|
|
3194
|
+
notNull: false;
|
|
3195
|
+
hasDefault: false;
|
|
3196
|
+
isPrimaryKey: false;
|
|
3197
|
+
isAutoincrement: false;
|
|
3198
|
+
hasRuntimeDefault: false;
|
|
3199
|
+
enumValues: [string, ...string[]];
|
|
3200
|
+
baseColumn: never;
|
|
3201
|
+
identity: undefined;
|
|
3202
|
+
generated: undefined;
|
|
3203
|
+
}, {}, {}>;
|
|
3170
3204
|
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
3171
3205
|
name: "created_at";
|
|
3172
3206
|
tableName: "cost_ledger";
|
|
@@ -7348,6 +7382,23 @@ export declare const schema: {
|
|
|
7348
7382
|
identity: undefined;
|
|
7349
7383
|
generated: undefined;
|
|
7350
7384
|
}, {}, {}>;
|
|
7385
|
+
runId: import("drizzle-orm/pg-core").PgColumn<{
|
|
7386
|
+
name: "run_id";
|
|
7387
|
+
tableName: "cost_ledger";
|
|
7388
|
+
dataType: "string";
|
|
7389
|
+
columnType: "PgText";
|
|
7390
|
+
data: string;
|
|
7391
|
+
driverParam: string;
|
|
7392
|
+
notNull: false;
|
|
7393
|
+
hasDefault: false;
|
|
7394
|
+
isPrimaryKey: false;
|
|
7395
|
+
isAutoincrement: false;
|
|
7396
|
+
hasRuntimeDefault: false;
|
|
7397
|
+
enumValues: [string, ...string[]];
|
|
7398
|
+
baseColumn: never;
|
|
7399
|
+
identity: undefined;
|
|
7400
|
+
generated: undefined;
|
|
7401
|
+
}, {}, {}>;
|
|
7351
7402
|
projectId: import("drizzle-orm/pg-core").PgColumn<{
|
|
7352
7403
|
name: "project_id";
|
|
7353
7404
|
tableName: "cost_ledger";
|
|
@@ -7535,6 +7586,23 @@ export declare const schema: {
|
|
|
7535
7586
|
identity: undefined;
|
|
7536
7587
|
generated: undefined;
|
|
7537
7588
|
}, {}, {}>;
|
|
7589
|
+
usdCostStatus: import("drizzle-orm/pg-core").PgColumn<{
|
|
7590
|
+
name: "usd_cost_status";
|
|
7591
|
+
tableName: "cost_ledger";
|
|
7592
|
+
dataType: "string";
|
|
7593
|
+
columnType: "PgText";
|
|
7594
|
+
data: string;
|
|
7595
|
+
driverParam: string;
|
|
7596
|
+
notNull: false;
|
|
7597
|
+
hasDefault: false;
|
|
7598
|
+
isPrimaryKey: false;
|
|
7599
|
+
isAutoincrement: false;
|
|
7600
|
+
hasRuntimeDefault: false;
|
|
7601
|
+
enumValues: [string, ...string[]];
|
|
7602
|
+
baseColumn: never;
|
|
7603
|
+
identity: undefined;
|
|
7604
|
+
generated: undefined;
|
|
7605
|
+
}, {}, {}>;
|
|
7538
7606
|
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
7539
7607
|
name: "created_at";
|
|
7540
7608
|
tableName: "cost_ledger";
|
package/package.json
CHANGED
package/src/bootstrap.ts
CHANGED
|
@@ -371,6 +371,7 @@ export async function bootstrapDatabase(dbPath?: string) {
|
|
|
371
371
|
CREATE TABLE IF NOT EXISTS cost_ledger (
|
|
372
372
|
id TEXT PRIMARY KEY,
|
|
373
373
|
company_id TEXT NOT NULL REFERENCES companies(id) ON DELETE CASCADE,
|
|
374
|
+
run_id TEXT REFERENCES heartbeat_runs(id) ON DELETE SET NULL,
|
|
374
375
|
project_id TEXT REFERENCES projects(id) ON DELETE SET NULL,
|
|
375
376
|
issue_id TEXT REFERENCES issues(id) ON DELETE SET NULL,
|
|
376
377
|
agent_id TEXT REFERENCES agents(id) ON DELETE SET NULL,
|
|
@@ -382,9 +383,14 @@ export async function bootstrapDatabase(dbPath?: string) {
|
|
|
382
383
|
token_input INTEGER NOT NULL DEFAULT 0,
|
|
383
384
|
token_output INTEGER NOT NULL DEFAULT 0,
|
|
384
385
|
usd_cost NUMERIC(12, 6) NOT NULL DEFAULT 0,
|
|
386
|
+
usd_cost_status TEXT,
|
|
385
387
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
386
388
|
);
|
|
387
389
|
`);
|
|
390
|
+
await db.execute(sql`
|
|
391
|
+
ALTER TABLE cost_ledger
|
|
392
|
+
ADD COLUMN IF NOT EXISTS run_id TEXT REFERENCES heartbeat_runs(id) ON DELETE SET NULL;
|
|
393
|
+
`);
|
|
388
394
|
await db.execute(sql`
|
|
389
395
|
ALTER TABLE cost_ledger
|
|
390
396
|
ADD COLUMN IF NOT EXISTS runtime_model_id TEXT;
|
|
@@ -401,6 +407,10 @@ export async function bootstrapDatabase(dbPath?: string) {
|
|
|
401
407
|
ALTER TABLE cost_ledger
|
|
402
408
|
ADD COLUMN IF NOT EXISTS pricing_source TEXT;
|
|
403
409
|
`);
|
|
410
|
+
await db.execute(sql`
|
|
411
|
+
ALTER TABLE cost_ledger
|
|
412
|
+
ADD COLUMN IF NOT EXISTS usd_cost_status TEXT;
|
|
413
|
+
`);
|
|
404
414
|
await db.execute(sql`
|
|
405
415
|
CREATE TABLE IF NOT EXISTS model_pricing (
|
|
406
416
|
company_id TEXT NOT NULL REFERENCES companies(id) ON DELETE CASCADE,
|
package/src/repositories.ts
CHANGED
|
@@ -1458,11 +1458,13 @@ export async function appendCost(
|
|
|
1458
1458
|
db: BopoDb,
|
|
1459
1459
|
input: {
|
|
1460
1460
|
companyId: string;
|
|
1461
|
+
runId?: string | null;
|
|
1461
1462
|
providerType: string;
|
|
1462
1463
|
runtimeModelId?: string | null;
|
|
1463
1464
|
pricingProviderType?: string | null;
|
|
1464
1465
|
pricingModelId?: string | null;
|
|
1465
1466
|
pricingSource?: "exact" | "missing" | null;
|
|
1467
|
+
usdCostStatus?: "exact" | "estimated" | "unknown" | null;
|
|
1466
1468
|
tokenInput: number;
|
|
1467
1469
|
tokenOutput: number;
|
|
1468
1470
|
usdCost: string;
|
|
@@ -1475,11 +1477,13 @@ export async function appendCost(
|
|
|
1475
1477
|
await db.insert(costLedger).values({
|
|
1476
1478
|
id,
|
|
1477
1479
|
companyId: input.companyId,
|
|
1480
|
+
runId: input.runId ?? null,
|
|
1478
1481
|
providerType: input.providerType,
|
|
1479
1482
|
runtimeModelId: input.runtimeModelId ?? null,
|
|
1480
1483
|
pricingProviderType: input.pricingProviderType ?? null,
|
|
1481
1484
|
pricingModelId: input.pricingModelId ?? null,
|
|
1482
1485
|
pricingSource: input.pricingSource ?? null,
|
|
1486
|
+
usdCostStatus: input.usdCostStatus ?? null,
|
|
1483
1487
|
tokenInput: input.tokenInput,
|
|
1484
1488
|
tokenOutput: input.tokenOutput,
|
|
1485
1489
|
usdCost: input.usdCost,
|
package/src/schema.ts
CHANGED
|
@@ -280,6 +280,7 @@ export const costLedger = pgTable("cost_ledger", {
|
|
|
280
280
|
companyId: text("company_id")
|
|
281
281
|
.notNull()
|
|
282
282
|
.references(() => companies.id, { onDelete: "cascade" }),
|
|
283
|
+
runId: text("run_id").references(() => heartbeatRuns.id, { onDelete: "set null" }),
|
|
283
284
|
projectId: text("project_id").references(() => projects.id, { onDelete: "set null" }),
|
|
284
285
|
issueId: text("issue_id").references(() => issues.id, { onDelete: "set null" }),
|
|
285
286
|
agentId: text("agent_id").references(() => agents.id, { onDelete: "set null" }),
|
|
@@ -291,6 +292,7 @@ export const costLedger = pgTable("cost_ledger", {
|
|
|
291
292
|
tokenInput: integer("token_input").notNull().default(0),
|
|
292
293
|
tokenOutput: integer("token_output").notNull().default(0),
|
|
293
294
|
usdCost: numeric("usd_cost", { precision: 12, scale: 6 }).notNull().default("0"),
|
|
295
|
+
usdCostStatus: text("usd_cost_status"),
|
|
294
296
|
createdAt: timestamp("created_at", { mode: "date" }).defaultNow().notNull()
|
|
295
297
|
});
|
|
296
298
|
|