@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 CHANGED
@@ -1018,8 +1018,11 @@ var DrizzleAgentStore = class {
1018
1018
  });
1019
1019
  }
1020
1020
  async quotaToday(actorRef, day) {
1021
- const start = /* @__PURE__ */ new Date(`${day}T00:00:00.000Z`);
1022
- const end = /* @__PURE__ */ new Date(`${day}T23:59:59.999Z`);
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);