Allow budgets to be set on the resources

This commit is contained in:
Owen
2026-08-14 11:42:33 -04:00
parent 4989d1e31a
commit c8f170d197
4 changed files with 160 additions and 2 deletions
+17
View File
@@ -57,6 +57,7 @@ import next from "next";
import { LimitId } from "../billing";
import { usageService } from "../billing/usageService";
import { syncInferenceAiConfig } from "./aiProviders";
import { syncAiBudgets } from "./aiBudgets";
export type PublicResourcesResults = {
proxyResource: Resource;
@@ -696,6 +697,14 @@ export async function updatePublicResources(
})
)
});
await syncAiBudgets({
orgId,
trx,
scope: "public",
resourceId: existingResource.resourceId,
budgets: resourceData["ai-budget"] || []
});
}
const existingResourceTargets = await trx
@@ -1258,6 +1267,14 @@ export async function updatePublicResources(
}))
});
await syncAiBudgets({
orgId,
trx,
scope: "public",
resourceId: newResource.resourceId,
budgets: resourceData["ai-budget"] || []
});
await trx.insert(roleResources).values({
roleId: adminRole.roleId,
resourceId: newResource.resourceId