@dudousxd/nestjs-agent-store-drizzle 0.16.0 → 0.17.0
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/dist/index.cjs +5 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1018,8 +1018,11 @@ var DrizzleAgentStore = class {
|
|
|
1018
1018
|
});
|
|
1019
1019
|
}
|
|
1020
1020
|
async quotaToday(actorRef, day) {
|
|
1021
|
-
|
|
1022
|
-
|
|
1021
|
+
return this.usageBetween(actorRef, day, day);
|
|
1022
|
+
}
|
|
1023
|
+
async usageBetween(actorRef, fromDay, toDay) {
|
|
1024
|
+
const start = /* @__PURE__ */ new Date(`${fromDay}T00:00:00.000Z`);
|
|
1025
|
+
const end = /* @__PURE__ */ new Date(`${toDay}T23:59:59.999Z`);
|
|
1023
1026
|
const rows = await this.db.select().from(agentTokenUsage).where((0, import_drizzle_orm2.and)((0, import_drizzle_orm2.eq)(agentTokenUsage.actorRef, actorRef), (0, import_drizzle_orm2.gte)(agentTokenUsage.createdAt, start), (0, import_drizzle_orm2.lte)(agentTokenUsage.createdAt, end)));
|
|
1024
1027
|
const usedTokens = rows.reduce((sum2, row) => sum2 + row.inputTokens + row.outputTokens, 0);
|
|
1025
1028
|
const costUsd = rows.reduce((sum2, row) => sum2 + (row.costUsd ?? 0), 0);
|