Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

feat(acuc): bump to v45 (#2865)

firecrawl-spring[bot]6f45065ee0c5
diff --git a/apps/api/src/controllers/auth.ts b/apps/api/src/controllers/auth.ts
index aefad2b6d..c421dcd5d 100644
--- a/apps/api/src/controllers/auth.ts
+++ b/apps/api/src/controllers/auth.ts
@@ -186,7 +186,7 @@ export async function getACUC(
? supabase_rr_service
: supabase_service;
({ data, error } = await client.rpc(
- "auth_credit_usage_chunk_44",
+ "auth_credit_usage_chunk_45",
{
input_key: api_key,
i_is_extract: isExtract,
@@ -316,7 +316,7 @@ export async function getACUCTeam(
? supabase_rr_service
: supabase_service;
({ data, error } = await client.rpc(
- "auth_credit_usage_chunk_44_from_team",
+ "auth_credit_usage_chunk_45_from_team",
{
input_team: team_id,
i_is_extract: isExtract,
diff --git a/apps/api/src/controllers/v0/admin/create-user.ts b/apps/api/src/controllers/v0/admin/create-user.ts
index 3ca708f71..b8a664105 100644
--- a/apps/api/src/controllers/v0/admin/create-user.ts
+++ b/apps/api/src/controllers/v0/admin/create-user.ts
@@ -29,13 +29,12 @@ async function addCoupon(teamId: string, integration: any) {
throw error;
}
- if (integration.coupon_rate_limits || integration.coupon_concurrency) {
+ if (integration.coupon_rate_limits) {
const { error: overrideError } = await (supabase_service as any)
.from("team_overrides")
.insert({
team_id: teamId,
- rate_limits: integration.coupon_rate_limits || null,
- concurrency: integration.coupon_concurrency || null,
+ rate_limits: integration.coupon_rate_limits,
expires_at: expiresAt,
internal_comment: `Integration coupon (${integration.display_name || integration.slug || "unknown"})`,
});
@@ -44,6 +43,32 @@ async function addCoupon(teamId: string, integration: any) {
throw overrideError;
}
}
+
+ if (integration.coupon_concurrency) {
+ // Look up the org for this team (created by handle_new_user trigger)
+ const { data: orgLink } = await supabase_service
+ .from("organization_teams")
+ .select("org_id")
+ .eq("team_id", teamId)
+ .eq("is_active", true)
+ .limit(1)
+ .single();
+
+ if (orgLink) {
+ const { error: orgOverrideError } = await (supabase_service as any)
+ .from("organization_overrides")
+ .insert({
+ org_id: orgLink.org_id,
+ concurrent_browsers: integration.coupon_concurrency,
+ expires_at: expiresAt,
+ internal_comment: `Integration coupon (${integration.display_name || integration.slug || "unknown"})`,
+ });
+
+ if (orgOverrideError) {
+ throw orgOverrideError;
+ }
+ }
+ }
}
/**
@@ -213,6 +238,29 @@ export async function integCreateUserController(req: Request, res: Response) {
}
teamId = newTeam.id;
+ // Create an org and link the team (mirrors handle_new_user trigger)
+ const { data: newOrg, error: newOrgError } = await supabase_service
+ .from("organizations")
+ .insert({ name: teamId })
+ .select()
+ .single();
+ if (newOrgError) {
+ logger.error("Failed to create organization", { error: newOrgError });
+ return res.status(500).json({ error: "Failed to create organization" });
+ }
+
+ const { error: orgLinkError } = await supabase_service
+ .from("organization_teams")
+ .insert({
+ org_id: newOrg.id,
+ team_id: teamId,
+ is_active: true,
+ });
+ if (orgLinkError) {
+ logger.error("Failed to link team to organization", { error: orgLinkError });
+ return res.status(500).json({ error: "Failed to link team to organization" });
+ }
+
const { error: newUserTeamError } = await supabase_service
.from("user_teams")
.insert({