@layer-ai/core 2.0.23 → 2.0.24
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gate-spending-tracker.d.ts","sourceRoot":"","sources":["../../src/lib/gate-spending-tracker.ts"],"names":[],"mappings":"AAEA,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,mBAAmB;0BACF,MAAM,QAAQ,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"gate-spending-tracker.d.ts","sourceRoot":"","sources":["../../src/lib/gate-spending-tracker.ts"],"names":[],"mappings":"AAEA,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,mBAAmB;0BACF,MAAM,QAAQ,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;iCAsCpE,MAAM,mBACG,MAAM,SAChB,MAAM,GAAG,IAAI,GACnB,OAAO,CAAC,IAAI,CAAC;+BAiBiB,MAAM,GAAG,OAAO,CAAC;QAChD,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CAYH,CAAC"}
|
|
@@ -2,9 +2,7 @@ import { db } from './db/postgres.js';
|
|
|
2
2
|
export const gateSpendingTracker = {
|
|
3
3
|
async trackSpending(gateId, cost) {
|
|
4
4
|
try {
|
|
5
|
-
// Check if gate spending limit check is needed before request
|
|
6
5
|
const limitCheck = await db.checkGateSpendingLimit(gateId);
|
|
7
|
-
// If blocked, don't track spending
|
|
8
6
|
if (!limitCheck.allowed) {
|
|
9
7
|
return {
|
|
10
8
|
gateId,
|
|
@@ -13,16 +11,13 @@ export const gateSpendingTracker = {
|
|
|
13
11
|
newSpending: limitCheck.currentSpending,
|
|
14
12
|
};
|
|
15
13
|
}
|
|
16
|
-
// Track the spending
|
|
17
14
|
await db.trackGateSpending(gateId, cost);
|
|
18
|
-
// Get updated spending info
|
|
19
15
|
const spendingInfo = await db.getGateSpending(gateId);
|
|
20
16
|
if (!spendingInfo) {
|
|
21
17
|
return { gateId, cost };
|
|
22
18
|
}
|
|
23
19
|
const { spendingLimit, spendingCurrent, spendingEnforcement } = spendingInfo;
|
|
24
20
|
const exceeded = spendingLimit !== null && spendingCurrent > spendingLimit;
|
|
25
|
-
// Check alert thresholds
|
|
26
21
|
await this.checkAlertThresholds(gateId, spendingCurrent, spendingLimit);
|
|
27
22
|
return {
|
|
28
23
|
gateId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layer-ai/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.24",
|
|
4
4
|
"description": "Core API routes and services for Layer AI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"nanoid": "^5.0.4",
|
|
37
37
|
"openai": "^4.24.0",
|
|
38
38
|
"pg": "^8.11.3",
|
|
39
|
-
"@layer-ai/sdk": "^2.5.
|
|
39
|
+
"@layer-ai/sdk": "^2.5.9"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/bcryptjs": "^2.4.6",
|