diff --git a/app/api/auth/steward-session/route.ts b/app/api/auth/steward-session/route.ts index d96b3abee..782aa45e5 100644 --- a/app/api/auth/steward-session/route.ts +++ b/app/api/auth/steward-session/route.ts @@ -35,6 +35,15 @@ export async function POST(request: NextRequest) { maxAge: 60 * 60 * 24 * 7, // 7 days }); + // Non-httpOnly flag so client JS can detect steward auth + cookieStore.set("steward-authed", "1", { + httpOnly: false, + secure: process.env.NODE_ENV === "production", + sameSite: "lax", + path: "/", + maxAge: 60 * 60 * 24 * 7, + }); + return NextResponse.json({ ok: true, userId: claims.userId }); } catch { return NextResponse.json({ error: "Internal error" }, { status: 500 }); @@ -48,5 +57,6 @@ export async function POST(request: NextRequest) { export async function DELETE() { const cookieStore = await cookies(); cookieStore.delete("steward-token"); + cookieStore.delete("steward-authed"); return NextResponse.json({ ok: true }); } diff --git a/app/api/v1/generate-image/route.ts b/app/api/v1/generate-image/route.ts index 703f766e7..9d415d85b 100644 --- a/app/api/v1/generate-image/route.ts +++ b/app/api/v1/generate-image/route.ts @@ -3,7 +3,6 @@ import { streamText } from "ai"; import type { NextRequest } from "next/server"; import { NextResponse } from "next/server"; import { requireAuthOrApiKey } from "@/lib/auth"; -import { getAnonymousUser, getOrCreateAnonymousUser } from "@/lib/auth-anonymous"; import { uploadBase64Image } from "@/lib/blob"; import { RateLimitPresets, withRateLimit } from "@/lib/middleware/rate-limit"; import { getProviderFromModel } from "@/lib/pricing"; @@ -94,46 +93,19 @@ interface AuthContext { user: UserWithOrganization; apiKey?: { id: string } | null; session_token?: string; - isAnonymous: boolean; } /** - * Authenticate user - supports both authenticated and anonymous users + * Authenticate user - requires valid auth or API key. + * Anonymous users are not allowed to generate images. */ async function authenticateUser(req: NextRequest): Promise { - // Try authenticated user first - try { - const authResult = await requireAuthOrApiKey(req); - return { - user: authResult.user, - apiKey: authResult.apiKey, - session_token: authResult.session_token, - isAnonymous: false, - }; - } catch { - // Fall back to anonymous user - let anonData = await getAnonymousUser(); - - if (!anonData) { - const newAnonData = await getOrCreateAnonymousUser(); - anonData = { - user: newAnonData.user, - session: newAnonData.session, - }; - } - - // Create a minimal UserWithOrganization for anonymous users - const anonymousUser: UserWithOrganization = { - ...anonData.user, - organization_id: null, - organization: null, - }; - - return { - user: anonymousUser, - isAnonymous: true, - }; - } + const authResult = await requireAuthOrApiKey(req); + return { + user: authResult.user, + apiKey: authResult.apiKey, + session_token: authResult.session_token, + }; } /** @@ -149,9 +121,17 @@ async function handlePOST(req: NextRequest) { let imageServiceUnavailable = false; try { - // Authenticate - supports both authenticated and anonymous users - const authContext = await authenticateUser(req); - const { user, apiKey, isAnonymous } = authContext; + // Authenticate - require valid credentials, no anonymous fallback + let authContext: AuthContext; + try { + authContext = await authenticateUser(req); + } catch { + return Response.json( + { error: "Authentication required. Provide a valid session or API key." }, + { status: 401 }, + ); + } + const { user, apiKey } = authContext; const requestBody = await req.json(); const { @@ -200,7 +180,7 @@ async function handlePOST(req: NextRequest) { // Reserve credits BEFORE generation to prevent TOCTOU race condition let reservation: CreditReservation; - if (!isAnonymous && user.organization_id) { + if (user.organization_id) { try { reservation = await creditsService.reserve({ organizationId: user.organization_id, @@ -221,11 +201,13 @@ async function handlePOST(req: NextRequest) { throw error; } } else { + // Authenticated user without an organization - this shouldn't normally happen + // but handle gracefully by creating a no-op reservation reservation = creditsService.createAnonymousReservation(); } - // Only create generation record for authenticated users with an organization - if (!isAnonymous && user.organization_id) { + // Create generation record for authenticated users with an organization + if (user.organization_id) { const generation = await generationsService.create({ organization_id: user.organization_id, user_id: user.id, @@ -456,8 +438,7 @@ async function handlePOST(req: NextRequest) { // Reconcile with 0 cost (full refund) await reservation.reconcile(0); - // Only create usage record for authenticated users - if (!isAnonymous && user.organization_id) { + if (user.organization_id) { const usageRecord = await usageService.create({ organization_id: user.organization_id, user_id: user.id, @@ -503,10 +484,9 @@ async function handlePOST(req: NextRequest) { dimensions: imagePricingDimensions, }); - // Only create usage record for authenticated users let usageRecordId: string | undefined; let actualCostBilled = imageCost.totalCost; - if (!isAnonymous && user.organization_id) { + if (user.organization_id) { const billing = await billFlatUsage( { organizationId: user.organization_id, @@ -622,7 +602,6 @@ async function handlePOST(req: NextRequest) { }); // Update generation record if we created one - // Note: generationId only exists if user.organization_id was present at creation time if (generationId && usageRecordId) { // For multi-image generations, create separate records for each image // so they all appear in the gallery (which filters by storage_url) @@ -700,9 +679,8 @@ async function handlePOST(req: NextRequest) { } } - // Log to Discord only for authenticated users with organization + // Log to Discord if ( - !isAnonymous && user.organization_id && user.organization && uploadResults.length > 0 && diff --git a/app/api/v1/generate-video/route.ts b/app/api/v1/generate-video/route.ts index e6579dbcc..2e7cbbff4 100644 --- a/app/api/v1/generate-video/route.ts +++ b/app/api/v1/generate-video/route.ts @@ -43,6 +43,9 @@ async function handlePOST(request: NextRequest) { let generationId: string | undefined; let reservation: CreditReservation | undefined; let selectedModel = "fal-ai/veo3"; + let quotedVideoCost: + | Awaited> + | undefined; try { const { user, apiKey } = await requireAuthOrApiKeyWithOrg(request); @@ -76,7 +79,7 @@ async function handlePOST(request: NextRequest) { } const billingDefaults = getDefaultVideoBillingDimensions(model); - const quotedVideoCost = await calculateVideoGenerationCostFromCatalog({ + quotedVideoCost = await calculateVideoGenerationCostFromCatalog({ model, durationSeconds: billingDefaults.durationSeconds, dimensions: billingDefaults.dimensions, @@ -129,8 +132,8 @@ async function handlePOST(request: NextRequest) { if (!data?.video?.url) { logger.error("[VIDEO GENERATION] No video URL in response:", data); - // Reconcile with 0 cost (full refund) - await reservation.reconcile(0); + // Partial charge (~10% of quoted cost) — fal.ai may still bill for compute + await reservation.reconcile(Math.ceil(quotedVideoCost.totalCost * 0.1 * 1e6) / 1e6); return NextResponse.json( { error: "No video URL was returned from the generation service" }, { status: 500 }, @@ -162,8 +165,8 @@ async function handlePOST(request: NextRequest) { blobFileSize = BigInt(uploadResult.size); } catch (blobError) { logger.error("[VIDEO GENERATION] Failed to upload to Vercel Blob:", blobError); - // Reconcile with 0 cost (full refund) - video generated but storage failed - await reservation.reconcile(0); + // Partial charge (~10% of quoted cost) — fal.ai already billed for the generation + await reservation.reconcile(Math.ceil(quotedVideoCost.totalCost * 0.1 * 1e6) / 1e6); return NextResponse.json( { error: "Failed to store video in our storage. Please try again." }, { status: 500 }, @@ -288,10 +291,12 @@ async function handlePOST(request: NextRequest) { const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; - // If reservation was made, refund the reservation when generation fails - if (reservation) { + // If reservation was made, charge ~10% — fal.ai may still bill for the compute attempt + if (reservation && quotedVideoCost) { + await reservation.reconcile(Math.ceil(quotedVideoCost.totalCost * 0.1 * 1e6) / 1e6); + logger.info("[VIDEO GENERATION] Partial charge applied after failure (~10% of quoted cost)"); + } else if (reservation) { await reservation.reconcile(0); - logger.info("[VIDEO GENERATION] Credits refunded after failure"); } try { diff --git a/app/api/v1/pricing/summary/route.ts b/app/api/v1/pricing/summary/route.ts index c3bf59c02..dca98cc0f 100644 --- a/app/api/v1/pricing/summary/route.ts +++ b/app/api/v1/pricing/summary/route.ts @@ -25,96 +25,160 @@ async function buildRange(values: number[]) { }; } +async function safeCost( + fn: () => Promise, + label: string, +): Promise<{ value: T | null; error: string | null }> { + try { + return { value: await fn(), error: null }; + } catch (error) { + const message = error instanceof Error ? error.message : String(error); + console.warn(`[PRICING SUMMARY] Failed to fetch ${label}: ${message}`); + return { value: null, error: message }; + } +} + export async function GET() { - const imageCosts = await Promise.all( + const warnings: string[] = []; + + const imageResults = await Promise.all( SUPPORTED_IMAGE_MODELS.map(async (model) => { - const cost = await calculateImageGenerationCostFromCatalog({ - model: model.modelId, - provider: model.provider, - imageCount: 1, - dimensions: model.defaultDimensions, - }); - return cost.totalCost; + const result = await safeCost( + () => + calculateImageGenerationCostFromCatalog({ + model: model.modelId, + provider: model.provider, + imageCount: 1, + dimensions: model.defaultDimensions, + }), + `image:${model.modelId}`, + ); + if (result.error) warnings.push(`image:${model.modelId}: ${result.error}`); + return result.value?.totalCost ?? null; }), ); + const imageCosts = imageResults.filter((v): v is number => v !== null); - const videoCosts = await Promise.all( + const videoResults = await Promise.all( SUPPORTED_VIDEO_MODELS.map(async (model) => { - const defaults = getDefaultVideoBillingDimensions(model.modelId); - const cost = await calculateVideoGenerationCostFromCatalog({ - model: model.modelId, - durationSeconds: defaults.durationSeconds, - dimensions: defaults.dimensions, - }); - return cost.totalCost; + const result = await safeCost(() => { + const defaults = getDefaultVideoBillingDimensions(model.modelId); + return calculateVideoGenerationCostFromCatalog({ + model: model.modelId, + durationSeconds: defaults.durationSeconds, + dimensions: defaults.dimensions, + }); + }, `video:${model.modelId}`); + if (result.error) warnings.push(`video:${model.modelId}: ${result.error}`); + return result.value?.totalCost ?? null; }), ); + const videoCosts = videoResults.filter((v): v is number => v !== null); - const chatInputCosts = await Promise.all( + const chatResults = await Promise.all( MODEL_TIER_LIST.map(async (tier) => { - const provider = tier.provider; - const breakdown = await calculateCost(tier.modelId, provider, 1000, 0); - return breakdown.inputCost; + const result = await safeCost( + () => calculateCost(tier.modelId, tier.provider, 1000, 0), + `chat:${tier.modelId}`, + ); + if (result.error) warnings.push(`chat:${tier.modelId}: ${result.error}`); + return result.value?.inputCost ?? null; }), ); + const chatInputCosts = chatResults.filter((v): v is number => v !== null); - const ttsCosts = await Promise.all( + const ttsResults = await Promise.all( ["elevenlabs/eleven_flash_v2_5", "elevenlabs/eleven_multilingual_v2"].map(async (model) => { - const cost = await calculateTTSCostFromCatalog({ model, characterCount: 1000 }); - return cost.totalCost; + const result = await safeCost( + () => calculateTTSCostFromCatalog({ model, characterCount: 1000 }), + `tts:${model}`, + ); + if (result.error) warnings.push(`tts:${model}: ${result.error}`); + return result.value?.totalCost ?? null; }), ); + const ttsCosts = ttsResults.filter((v): v is number => v !== null); - const sttCost = await calculateSTTCostFromCatalog({ - model: "elevenlabs/scribe_v1", - durationSeconds: 60, - }); - const instantClone = await calculateVoiceCloneCostFromCatalog({ cloneType: "instant" }); - const professionalClone = await calculateVoiceCloneCostFromCatalog({ - cloneType: "professional", - }); + const sttResult = await safeCost( + () => calculateSTTCostFromCatalog({ model: "elevenlabs/scribe_v1", durationSeconds: 60 }), + "stt:scribe_v1", + ); + if (sttResult.error) warnings.push(`stt:scribe_v1: ${sttResult.error}`); + + const instantResult = await safeCost( + () => calculateVoiceCloneCostFromCatalog({ cloneType: "instant" }), + "voice_clone:instant", + ); + if (instantResult.error) warnings.push(`voice_clone:instant: ${instantResult.error}`); + + const professionalResult = await safeCost( + () => calculateVoiceCloneCostFromCatalog({ cloneType: "professional" }), + "voice_clone:professional", + ); + if (professionalResult.error) + warnings.push(`voice_clone:professional: ${professionalResult.error}`); + + const pricing: Record = {}; + + if (imageCosts.length > 0) { + pricing["generate-image"] = { + unit: "image", + isVariable: true, + estimatedRange: await buildRange(imageCosts), + description: "Live image model pricing per generated image", + }; + } + + if (videoCosts.length > 0) { + pricing["generate-video"] = { + unit: "video", + isVariable: true, + estimatedRange: await buildRange(videoCosts), + description: "Live video model pricing per default request", + }; + } + + if (chatInputCosts.length > 0) { + pricing["chat-completions"] = { + unit: "1k tokens", + isVariable: true, + estimatedRange: await buildRange(chatInputCosts), + description: "Input-token pricing across current curated chat models", + }; + } + + if (ttsCosts.length > 0) { + pricing["voice-tts"] = { + unit: "1k chars", + isVariable: true, + estimatedRange: await buildRange(ttsCosts), + description: "Live text-to-speech pricing per 1,000 characters", + }; + } + + if (sttResult.value) { + pricing["voice-stt"] = { + unit: "minute", + cost: sttResult.value.totalCost, + description: "Live speech-to-text pricing per minute", + }; + } + + if (instantResult.value && professionalResult.value) { + pricing["voice-clone"] = { + unit: "clone", + isVariable: true, + estimatedRange: { + min: instantResult.value.totalCost, + max: professionalResult.value.totalCost, + }, + description: "Live voice cloning pricing by clone tier", + }; + } return NextResponse.json({ asOf: new Date().toISOString(), - pricing: { - "generate-image": { - unit: "image", - isVariable: true, - estimatedRange: await buildRange(imageCosts), - description: "Live image model pricing per generated image", - }, - "generate-video": { - unit: "video", - isVariable: true, - estimatedRange: await buildRange(videoCosts), - description: "Live video model pricing per default request", - }, - "chat-completions": { - unit: "1k tokens", - isVariable: true, - estimatedRange: await buildRange(chatInputCosts), - description: "Input-token pricing across current curated chat models", - }, - "voice-tts": { - unit: "1k chars", - isVariable: true, - estimatedRange: await buildRange(ttsCosts), - description: "Live text-to-speech pricing per 1,000 characters", - }, - "voice-stt": { - unit: "minute", - cost: sttCost.totalCost, - description: "Live speech-to-text pricing per minute", - }, - "voice-clone": { - unit: "clone", - isVariable: true, - estimatedRange: { - min: instantClone.totalCost, - max: professionalClone.totalCost, - }, - description: "Live voice cloning pricing by clone tier", - }, - }, + pricing, + ...(warnings.length > 0 ? { warnings } : {}), }); } diff --git a/app/auth/cli-login/page.tsx b/app/auth/cli-login/page.tsx index 83d113e0a..8b5db65d4 100644 --- a/app/auth/cli-login/page.tsx +++ b/app/auth/cli-login/page.tsx @@ -1,13 +1,13 @@ "use client"; import { Button } from "@elizaos/cloud-ui/components/button"; -import { usePrivy } from "@privy-io/react-auth"; import { AlertCircle, CheckCircle2, Key, Loader2, Terminal } from "lucide-react"; import { useSearchParams } from "next/navigation"; import { Suspense, useCallback, useEffect, useMemo, useState } from "react"; +import { useSessionAuth } from "@/lib/hooks/use-session-auth"; function CliLoginContent() { - const { authenticated, login, user, ready } = usePrivy(); + const { authenticated, ready, user } = useSessionAuth(); const searchParams = useSearchParams(); const sessionId = searchParams.get("session"); @@ -30,7 +30,6 @@ function CliLoginContent() { >(initialStatus.status); const [errorMessage, setErrorMessage] = useState(initialStatus.errorMessage); const [apiKeyPrefix, setApiKeyPrefix] = useState(""); - const [isLoggingIn, setIsLoggingIn] = useState(false); const completeCliLogin = useCallback(async () => { if (!sessionId) { @@ -76,8 +75,7 @@ function CliLoginContent() { // Update status when props change (avoiding synchronous setState) useEffect(() => { - // Don't override "completing" or "success" states - they represent process progress - // that shouldn't be reset by initial status changes + // Don't override "completing" or "success" states if (status === "completing" || status === "success") { return; } @@ -85,9 +83,7 @@ function CliLoginContent() { const nextStatus = initialStatus.status; const nextErrorMessage = initialStatus.errorMessage; - // Only update if status changed to avoid unnecessary renders if (status !== nextStatus || errorMessage !== nextErrorMessage) { - // Use setTimeout to avoid synchronous setState in effect const timer = setTimeout(() => { setStatus(nextStatus); setErrorMessage(nextErrorMessage); @@ -99,7 +95,6 @@ function CliLoginContent() { // Separate effect for completing login when authenticated useEffect(() => { if (initialStatus.status === "loading" && authenticated && sessionId) { - // Use setTimeout to avoid synchronous setState in effect const timer = setTimeout(() => { completeCliLogin(); }, 0); @@ -107,6 +102,25 @@ function CliLoginContent() { } }, [initialStatus.status, authenticated, sessionId, completeCliLogin]); + const signInHref = useMemo(() => { + if (typeof window === "undefined") return "/login"; + const returnTo = `/auth/cli-login${window.location.search}`; + return `/login?returnTo=${encodeURIComponent(returnTo)}`; + }, []); + + // Pull email off the user object defensively — privy + steward user shapes differ + const userEmail: string | undefined = (() => { + if (!user) return undefined; + // steward user + if ("email" in user && typeof (user as { email?: unknown }).email === "string") { + return (user as { email: string }).email; + } + // privy user + const privyEmail = (user as { email?: { address?: string } | null })?.email?.address; + if (typeof privyEmail === "string") return privyEmail; + return undefined; + })(); + if (status === "loading") { return (
@@ -167,24 +181,21 @@ function CliLoginContent() { Sign in to connect your Milady app or CLI to Eliza Cloud

- + + + @@ -242,7 +253,7 @@ function CliLoginContent() {
Created for - {user?.email?.address || "Your account"} + {userEmail || "Your account"}
@@ -272,7 +283,8 @@ function CliLoginContent() { /** * CLI login page for authenticating command-line tool users. - * Handles Privy authentication and generates API keys for CLI access. + * Uses the shared session auth (Steward + Privy) to detect the active session, + * then generates an API key for CLI access. */ export default function CliLoginPage() { return ( diff --git a/app/dashboard/admin/page.tsx b/app/dashboard/admin/page.tsx index cd8a6f3aa..e357ab9cb 100644 --- a/app/dashboard/admin/page.tsx +++ b/app/dashboard/admin/page.tsx @@ -33,7 +33,6 @@ import { TabsList, TabsTrigger, } from "@elizaos/cloud-ui"; -import { usePrivy, useWallets } from "@privy-io/react-auth"; import { AlertTriangle, Ban, @@ -49,6 +48,7 @@ import { import { useRouter } from "next/navigation"; import { useCallback, useEffect, useState } from "react"; import { toast } from "sonner"; +import { useSessionAuth } from "@/lib/hooks/use-session-auth"; interface AdminOverview { recentViolations: Array<{ @@ -101,8 +101,7 @@ interface Violation { } export default function AdminPage() { - const { ready, authenticated } = usePrivy(); - const { wallets } = useWallets(); + const { ready, authenticated } = useSessionAuth(); const router = useRouter(); const [isAdmin, setIsAdmin] = useState(null); @@ -287,9 +286,7 @@ export default function AdminPage() {

Access Denied

You don't have admin privileges.

-

- Current wallet: {wallets[0]?.address?.slice(0, 10)}... -

+

Not authorized for admin access.

); } diff --git a/app/dashboard/layout.tsx b/app/dashboard/layout.tsx index 5c97cffdf..7efc99b27 100644 --- a/app/dashboard/layout.tsx +++ b/app/dashboard/layout.tsx @@ -1,10 +1,10 @@ "use client"; import { PageHeaderProvider, ScrollArea } from "@elizaos/cloud-ui"; -import { usePrivy } from "@privy-io/react-auth"; import { Loader2 } from "lucide-react"; import { usePathname, useRouter } from "next/navigation"; import { useCallback, useEffect, useRef, useState } from "react"; +import { useSessionAuth } from "@/lib/hooks/use-session-auth"; import Header from "@/packages/ui/src/components/layout/header"; import Sidebar from "@/packages/ui/src/components/layout/sidebar"; import { OnboardingOverlay } from "@/packages/ui/src/components/onboarding/onboarding-overlay"; @@ -44,7 +44,9 @@ const AUTH_LOSS_GRACE_MS = 5000; */ export default function DashboardLayout({ children }: { children: React.ReactNode }) { const [sidebarOpen, setSidebarOpen] = useState(false); - const { ready, authenticated } = usePrivy(); + // Unified auth state (Privy + Steward). Reactive to cross-tab storage changes + // and steward-token-sync custom events, so no manual cookie polling needed. + const { ready, authenticated } = useSessionAuth(); const router = useRouter(); const pathname = usePathname(); const _isAppCreatePage = pathname?.startsWith("/dashboard/apps/create"); diff --git a/app/invite/accept/page.tsx b/app/invite/accept/page.tsx index e55f77636..0a54002f6 100644 --- a/app/invite/accept/page.tsx +++ b/app/invite/accept/page.tsx @@ -11,7 +11,6 @@ import { CardHeader, CardTitle, } from "@elizaos/cloud-ui"; -import { usePrivy } from "@privy-io/react-auth"; import { format } from "date-fns"; import { AlertCircle, @@ -26,6 +25,7 @@ import { import { useRouter, useSearchParams } from "next/navigation"; import { Suspense, useEffect, useState } from "react"; import { toast } from "sonner"; +import { useSessionAuth } from "@/lib/hooks/use-session-auth"; interface InviteDetails { organization_name: string; @@ -38,7 +38,7 @@ interface InviteDetails { function InviteAcceptContent() { const searchParams = useSearchParams(); const router = useRouter(); - const { authenticated } = usePrivy(); + const { authenticated } = useSessionAuth(); const token = searchParams.get("token"); const [isValidating, setIsValidating] = useState(true); diff --git a/app/login/steward-login-section.tsx b/app/login/steward-login-section.tsx index 32235cd5a..5c57adba7 100644 --- a/app/login/steward-login-section.tsx +++ b/app/login/steward-login-section.tsx @@ -1,8 +1,10 @@ "use client"; +import { Alert, AlertDescription } from "@elizaos/cloud-ui"; import { StewardAuth } from "@stwd/sdk"; -import { useSearchParams } from "next/navigation"; -import { useCallback, useEffect, useMemo, useState } from "react"; +import { AlertCircle } from "lucide-react"; +import { usePathname, useRouter, useSearchParams } from "next/navigation"; +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { toast } from "sonner"; const STEWARD_API_URL = process.env.NEXT_PUBLIC_STEWARD_API_URL || "https://eliza.steward.fi"; @@ -10,6 +12,17 @@ const STEWARD_API_URL = process.env.NEXT_PUBLIC_STEWARD_API_URL || "https://eliz type AuthStep = "idle" | "loading" | "email-sent" | "success"; type Provider = "passkey" | "email" | "google" | "discord" | "twitter"; +// Human-readable copy for callback failure reason codes returned by the +// steward email/oauth callback. Unknown codes fall through to a generic +// message (see CALLBACK_UNKNOWN_MESSAGE below). +const CALLBACK_REASON_MESSAGES: Record = { + invalid_token: "That login link is invalid. Try signing in again.", + expired_token: "That login link has expired. Request a new one below.", + email_mismatch: "The link doesn't match the email you entered. Try again.", + server_error: "Something went wrong on our end. Try again in a moment.", +}; +const CALLBACK_UNKNOWN_MESSAGE = "Couldn't complete sign-in. Try again."; + function getSafeReturnTo(sp: { get(n: string): string | null }): string { const r = sp.get("returnTo"); return r && r.startsWith("/") && !r.startsWith("//") ? r : "/dashboard/milady"; @@ -17,16 +30,21 @@ function getSafeReturnTo(sp: { get(n: string): string | null }): string { export default function StewardLoginSection() { const searchParams = useSearchParams(); + const router = useRouter(); + const pathname = usePathname(); const auth = useMemo( () => new StewardAuth({ baseUrl: STEWARD_API_URL, tenantId: "elizacloud" }), [], ); + const emailInputRef = useRef(null); + const [email, setEmail] = useState(""); const [step, setStep] = useState("idle"); const [loading, setLoading] = useState(null); const [error, setError] = useState(null); + const [callbackError, setCallbackError] = useState(null); const [providers, setProviders] = useState>({}); const setSessionCookie = useCallback(async (token: string) => { @@ -47,16 +65,103 @@ export default function StewardLoginSection() { .catch(() => {}); }, [auth]); - // Check if already authenticated + // Handle OAuth callback: steward redirects back to /login with token+refreshToken + // in query params. We store them in localStorage (same keys the SDK uses) and + // redirect to the dashboard. useEffect(() => { - const session = auth.getSession(); - if (session?.token) { - setSessionCookie(session.token).then(() => { - window.location.href = getSafeReturnTo(searchParams); - }); + const token = searchParams.get("token"); + const refreshToken = searchParams.get("refreshToken"); + if (!token) return; + + try { + localStorage.setItem("steward_session_token", token); + if (refreshToken) { + localStorage.setItem("steward_refresh_token", refreshToken); + } + } catch (err) { + console.warn("[steward] Failed to persist OAuth tokens", err); } + + setSessionCookie(token).then(() => { + // Strip the tokens from the URL before redirecting + window.location.href = getSafeReturnTo(searchParams); + }); + }, [searchParams, setSessionCookie]); + + // Check if already authenticated (e.g. page refresh while logged in), or + // if we can recover a session via the refresh token. This is the common + // path for "came back from lunch, server middleware redirected me to + // /login because the 15-min access token expired" — we still have a + // 30-day refresh token in localStorage, try that before showing login UI. + useEffect(() => { + // Skip if we're processing an OAuth callback (handled above) + if (searchParams.get("token")) return; + // Skip if there's a callback error, let the user see it and retry + if (searchParams.get("error")) return; + + let cancelled = false; + + const tryRecoverSession = async () => { + // Fast path: SDK already has a valid (non-expired) session in memory. + const session = auth.getSession(); + if (session?.token) { + await setSessionCookie(session.token); + if (!cancelled) window.location.href = getSafeReturnTo(searchParams); + return; + } + + // Slow path: access token expired/missing but refresh token may still + // be good. Try refreshing — if it works, we can bounce the user back + // to their original destination without making them sign in again. + try { + const refreshed = await auth.refreshSession(); + if (cancelled) return; + if (refreshed?.token) { + await setSessionCookie(refreshed.token); + if (!cancelled) window.location.href = getSafeReturnTo(searchParams); + } + } catch { + // No-op — refresh failed (no refresh token, or refresh token invalid). + // Fall through to the regular login UI. + } + }; + + void tryRecoverSession(); + + return () => { + cancelled = true; + }; }, [auth, searchParams, setSessionCookie]); + // Handle failed callback: steward (or oauth) redirects back with + // ?error=...&reason=... on failure. Show a friendly inline banner, then + // strip the error params from the URL so a refresh doesn't re-show it. + useEffect(() => { + const errorCode = searchParams.get("error"); + if (!errorCode) return; + + const reason = searchParams.get("reason"); + const message = + (reason && CALLBACK_REASON_MESSAGES[reason]) || CALLBACK_UNKNOWN_MESSAGE; + setCallbackError(message); + + // Nice touch: if this was an email-link failure, they'll likely want to + // type their address again and retry. + if (errorCode === "email_auth_failed") { + emailInputRef.current?.focus(); + } + + // Strip error + reason from the URL without triggering a full reload, + // matching how the success path cleans token/refreshToken. + const remaining = new URLSearchParams(searchParams.toString()); + remaining.delete("error"); + remaining.delete("reason"); + const qs = remaining.toString(); + router.replace(qs ? `${pathname}?${qs}` : pathname); + // We intentionally only run this on mount / when error params first appear. + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + async function handleSuccess(token: string) { setStep("success"); toast.success("Signed in!"); @@ -100,15 +205,15 @@ export default function StewardLoginSection() { async function handleOAuth(provider: string) { setLoading(provider as Provider); setError(null); - try { - const result = await auth.signInWithOAuth(provider, { - redirectUri: `${window.location.origin}/login`, - }); - if (result.token) await handleSuccess(result.token); - } catch (e: any) { - setError(e?.message || `${provider} login failed`); - setLoading(null); - } + // Use the server-side redirect flow: steward does the full OAuth exchange + // and redirects back with token/refreshToken query params. We don't use the + // SDK's popup flow because it expects the client to do the code exchange. + const redirectUri = `${window.location.origin}/login`; + const params = new URLSearchParams({ + redirect_uri: redirectUri, + tenantId: "elizacloud", + }); + window.location.href = `${STEWARD_API_URL}/auth/oauth/${provider}/authorize?${params.toString()}`; } if (step === "success") { @@ -145,8 +250,17 @@ export default function StewardLoginSection() { return (
+ {/* Callback error banner (from failed email/oauth redirect) */} + {callbackError && ( + + + {callbackError} + + )} + {/* Email input */} =18.0.0", "react-dom": ">=18.0.0" } }, "sha512-B2Hz2xupnNS7g8m4HPmo4D5an0ZH9p7NilX5V+3gvzF2fN9lSZw1pXVeUS1mg5r2AZ6PblUzhv/0oNxrrTQ2Dg=="], + "@stwd/react": ["@stwd/react@0.6.6", "", { "dependencies": { "@stwd/sdk": "^0.7.0" }, "peerDependencies": { "react": ">=18.0.0", "react-dom": ">=18.0.0" } }, "sha512-M6ud+fD3SNFgAL3K4knpwI6UjPzLV8UFbi/SZEr/+OJ72InPWliJip2JBAJipUM0w8Jc11EzjzrZitMOUFkwtg=="], "@stwd/sdk": ["@stwd/sdk@0.7.2", "", {}, "sha512-qu1gyULCZ7YKAWGYQ8wkVDrvsxDJsn/ffVYjhR6HNCoBEoK29LW4Gwekxr2PprBMeAXsEtxhkDkyTj/5ly/W/Q=="], diff --git a/package.json b/package.json index 0a8b4c826..9ad758d71 100644 --- a/package.json +++ b/package.json @@ -153,7 +153,7 @@ "@solana/web3.js": "^1.98.4", "@stripe/react-stripe-js": "^5.4.1", "@stripe/stripe-js": "^8.6.4", - "@stwd/react": "0.6.5", + "@stwd/react": "0.6.6", "@stwd/sdk": "0.7.2", "@sapphire/snowflake": "^3.5.5", "@tabler/icons-react": "^3.36.1", diff --git a/packages/db/migrations/0064_add_ai_pricing_catalog.sql b/packages/db/migrations/0064_add_ai_pricing_catalog.sql index 198c492b0..50465871e 100644 --- a/packages/db/migrations/0064_add_ai_pricing_catalog.sql +++ b/packages/db/migrations/0064_add_ai_pricing_catalog.sql @@ -1,4 +1,4 @@ -CREATE TABLE "ai_pricing_entries" ( +CREATE TABLE IF NOT EXISTS "ai_pricing_entries" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "billing_source" text NOT NULL, "provider" text NOT NULL, @@ -26,7 +26,7 @@ CREATE TABLE "ai_pricing_entries" ( "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint -CREATE TABLE "ai_pricing_refresh_runs" ( +CREATE TABLE IF NOT EXISTS "ai_pricing_refresh_runs" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "source" text NOT NULL, "status" text NOT NULL, @@ -41,8 +41,8 @@ CREATE TABLE "ai_pricing_refresh_runs" ( "created_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint -CREATE INDEX "ai_pricing_entries_lookup_idx" ON "ai_pricing_entries" USING btree ("billing_source","provider","model","product_family","charge_type","is_active");--> statement-breakpoint -CREATE INDEX "ai_pricing_entries_dimension_idx" ON "ai_pricing_entries" USING btree ("dimension_key","priority");--> statement-breakpoint -CREATE INDEX "ai_pricing_entries_freshness_idx" ON "ai_pricing_entries" USING btree ("source_kind","fetched_at","stale_after");--> statement-breakpoint -CREATE INDEX "ai_pricing_refresh_runs_source_status_idx" ON "ai_pricing_refresh_runs" USING btree ("source","status");--> statement-breakpoint -CREATE INDEX "ai_pricing_refresh_runs_started_idx" ON "ai_pricing_refresh_runs" USING btree ("started_at"); \ No newline at end of file +CREATE INDEX IF NOT EXISTS "ai_pricing_entries_lookup_idx" ON "ai_pricing_entries" USING btree ("billing_source","provider","model","product_family","charge_type","is_active");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "ai_pricing_entries_dimension_idx" ON "ai_pricing_entries" USING btree ("dimension_key","priority");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "ai_pricing_entries_freshness_idx" ON "ai_pricing_entries" USING btree ("source_kind","fetched_at","stale_after");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "ai_pricing_refresh_runs_source_status_idx" ON "ai_pricing_refresh_runs" USING btree ("source","status");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "ai_pricing_refresh_runs_started_idx" ON "ai_pricing_refresh_runs" USING btree ("started_at"); \ No newline at end of file diff --git a/packages/db/migrations/0065_add_generations_is_public.sql b/packages/db/migrations/0065_add_generations_is_public.sql new file mode 100644 index 000000000..7b97b0f6f --- /dev/null +++ b/packages/db/migrations/0065_add_generations_is_public.sql @@ -0,0 +1,3 @@ +ALTER TABLE "generations" ADD COLUMN "is_public" boolean DEFAULT false NOT NULL; +--> statement-breakpoint +CREATE INDEX "generations_is_public_idx" ON "generations" USING btree ("is_public") WHERE "is_public" = true; diff --git a/packages/db/migrations/meta/0065_snapshot.json b/packages/db/migrations/meta/0065_snapshot.json new file mode 100644 index 000000000..bbda7be7a --- /dev/null +++ b/packages/db/migrations/meta/0065_snapshot.json @@ -0,0 +1,25152 @@ +{ + "id": "a4821afb-bcd2-4109-a994-01b7cb27da36", + "prevId": "b28e1ed8-518b-46a1-a762-6af603684131", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.ad_accounts": { + "name": "ad_accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "connected_by_user_id": { + "name": "connected_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "platform": { + "name": "platform", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "external_account_id": { + "name": "external_account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "account_name": { + "name": "account_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token_secret_id": { + "name": "access_token_secret_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "refresh_token_secret_id": { + "name": "refresh_token_secret_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "token_expires_at": { + "name": "token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ad_accounts_organization_idx": { + "name": "ad_accounts_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_accounts_platform_idx": { + "name": "ad_accounts_platform_idx", + "columns": [ + { + "expression": "platform", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_accounts_org_platform_idx": { + "name": "ad_accounts_org_platform_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "platform", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_accounts_external_id_idx": { + "name": "ad_accounts_external_id_idx", + "columns": [ + { + "expression": "external_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_accounts_status_idx": { + "name": "ad_accounts_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ad_accounts_organization_id_organizations_id_fk": { + "name": "ad_accounts_organization_id_organizations_id_fk", + "tableFrom": "ad_accounts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ad_accounts_connected_by_user_id_users_id_fk": { + "name": "ad_accounts_connected_by_user_id_users_id_fk", + "tableFrom": "ad_accounts", + "tableTo": "users", + "columnsFrom": [ + "connected_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ad_accounts_access_token_secret_id_secrets_id_fk": { + "name": "ad_accounts_access_token_secret_id_secrets_id_fk", + "tableFrom": "ad_accounts", + "tableTo": "secrets", + "columnsFrom": [ + "access_token_secret_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "ad_accounts_refresh_token_secret_id_secrets_id_fk": { + "name": "ad_accounts_refresh_token_secret_id_secrets_id_fk", + "tableFrom": "ad_accounts", + "tableTo": "secrets", + "columnsFrom": [ + "refresh_token_secret_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ad_campaigns": { + "name": "ad_campaigns", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "ad_account_id": { + "name": "ad_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "external_campaign_id": { + "name": "external_campaign_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "platform": { + "name": "platform", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "objective": { + "name": "objective", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "budget_type": { + "name": "budget_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "budget_amount": { + "name": "budget_amount", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "budget_currency": { + "name": "budget_currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'USD'" + }, + "credits_allocated": { + "name": "credits_allocated", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "credits_spent": { + "name": "credits_spent", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "start_date": { + "name": "start_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "end_date": { + "name": "end_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "targeting": { + "name": "targeting", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "total_spend": { + "name": "total_spend", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "total_impressions": { + "name": "total_impressions", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_clicks": { + "name": "total_clicks", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_conversions": { + "name": "total_conversions", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "app_id": { + "name": "app_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ad_campaigns_organization_idx": { + "name": "ad_campaigns_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_campaigns_ad_account_idx": { + "name": "ad_campaigns_ad_account_idx", + "columns": [ + { + "expression": "ad_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_campaigns_platform_idx": { + "name": "ad_campaigns_platform_idx", + "columns": [ + { + "expression": "platform", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_campaigns_status_idx": { + "name": "ad_campaigns_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_campaigns_external_id_idx": { + "name": "ad_campaigns_external_id_idx", + "columns": [ + { + "expression": "external_campaign_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_campaigns_app_idx": { + "name": "ad_campaigns_app_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_campaigns_created_at_idx": { + "name": "ad_campaigns_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_campaigns_org_status_idx": { + "name": "ad_campaigns_org_status_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ad_campaigns_organization_id_organizations_id_fk": { + "name": "ad_campaigns_organization_id_organizations_id_fk", + "tableFrom": "ad_campaigns", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ad_campaigns_ad_account_id_ad_accounts_id_fk": { + "name": "ad_campaigns_ad_account_id_ad_accounts_id_fk", + "tableFrom": "ad_campaigns", + "tableTo": "ad_accounts", + "columnsFrom": [ + "ad_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ad_campaigns_app_id_apps_id_fk": { + "name": "ad_campaigns_app_id_apps_id_fk", + "tableFrom": "ad_campaigns", + "tableTo": "apps", + "columnsFrom": [ + "app_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ad_creatives": { + "name": "ad_creatives", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "campaign_id": { + "name": "campaign_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "external_creative_id": { + "name": "external_creative_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "headline": { + "name": "headline", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "primary_text": { + "name": "primary_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "call_to_action": { + "name": "call_to_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "destination_url": { + "name": "destination_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "media": { + "name": "media", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ad_creatives_campaign_idx": { + "name": "ad_creatives_campaign_idx", + "columns": [ + { + "expression": "campaign_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_creatives_type_idx": { + "name": "ad_creatives_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_creatives_status_idx": { + "name": "ad_creatives_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_creatives_external_id_idx": { + "name": "ad_creatives_external_id_idx", + "columns": [ + { + "expression": "external_creative_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_creatives_created_at_idx": { + "name": "ad_creatives_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ad_creatives_campaign_id_ad_campaigns_id_fk": { + "name": "ad_creatives_campaign_id_ad_campaigns_id_fk", + "tableFrom": "ad_creatives", + "tableTo": "ad_campaigns", + "columnsFrom": [ + "campaign_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ad_transactions": { + "name": "ad_transactions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "campaign_id": { + "name": "campaign_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "credit_transaction_id": { + "name": "credit_transaction_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(12, 4)", + "primaryKey": false, + "notNull": true + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'USD'" + }, + "credits_amount": { + "name": "credits_amount", + "type": "numeric(12, 4)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "external_reference": { + "name": "external_reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ad_transactions_organization_idx": { + "name": "ad_transactions_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_transactions_campaign_idx": { + "name": "ad_transactions_campaign_idx", + "columns": [ + { + "expression": "campaign_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_transactions_credit_tx_idx": { + "name": "ad_transactions_credit_tx_idx", + "columns": [ + { + "expression": "credit_transaction_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_transactions_type_idx": { + "name": "ad_transactions_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_transactions_created_at_idx": { + "name": "ad_transactions_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ad_transactions_org_type_idx": { + "name": "ad_transactions_org_type_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ad_transactions_organization_id_organizations_id_fk": { + "name": "ad_transactions_organization_id_organizations_id_fk", + "tableFrom": "ad_transactions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ad_transactions_campaign_id_ad_campaigns_id_fk": { + "name": "ad_transactions_campaign_id_ad_campaigns_id_fk", + "tableFrom": "ad_transactions", + "tableTo": "ad_campaigns", + "columnsFrom": [ + "campaign_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "ad_transactions_credit_transaction_id_credit_transactions_id_fk": { + "name": "ad_transactions_credit_transaction_id_credit_transactions_id_fk", + "tableFrom": "ad_transactions", + "tableTo": "credit_transactions", + "columnsFrom": [ + "credit_transaction_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.admin_users": { + "name": "admin_users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "wallet_address": { + "name": "wallet_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "admin_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'moderator'" + }, + "granted_by": { + "name": "granted_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "granted_by_wallet": { + "name": "granted_by_wallet", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "admin_users_wallet_address_idx": { + "name": "admin_users_wallet_address_idx", + "columns": [ + { + "expression": "wallet_address", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "admin_users_user_id_idx": { + "name": "admin_users_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "admin_users_role_idx": { + "name": "admin_users_role_idx", + "columns": [ + { + "expression": "role", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "admin_users_is_active_idx": { + "name": "admin_users_is_active_idx", + "columns": [ + { + "expression": "is_active", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "admin_users_user_id_users_id_fk": { + "name": "admin_users_user_id_users_id_fk", + "tableFrom": "admin_users", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "admin_users_granted_by_users_id_fk": { + "name": "admin_users_granted_by_users_id_fk", + "tableFrom": "admin_users", + "tableTo": "users", + "columnsFrom": [ + "granted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "admin_users_wallet_address_unique": { + "name": "admin_users_wallet_address_unique", + "nullsNotDistinct": false, + "columns": [ + "wallet_address" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ai_pricing_entries": { + "name": "ai_pricing_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "billing_source": { + "name": "billing_source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "product_family": { + "name": "product_family", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "charge_type": { + "name": "charge_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit_price": { + "name": "unit_price", + "type": "numeric(20, 10)", + "primaryKey": false, + "notNull": true + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'USD'" + }, + "dimension_key": { + "name": "dimension_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'*'" + }, + "dimensions": { + "name": "dimensions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "source_kind": { + "name": "source_kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_url": { + "name": "source_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_hash": { + "name": "source_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fetched_at": { + "name": "fetched_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "stale_after": { + "name": "stale_after", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "effective_from": { + "name": "effective_from", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "effective_until": { + "name": "effective_until", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "priority": { + "name": "priority", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "is_override": { + "name": "is_override", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_pricing_entries_lookup_idx": { + "name": "ai_pricing_entries_lookup_idx", + "columns": [ + { + "expression": "billing_source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "model", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "product_family", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "charge_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "is_active", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ai_pricing_entries_dimension_idx": { + "name": "ai_pricing_entries_dimension_idx", + "columns": [ + { + "expression": "dimension_key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "priority", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ai_pricing_entries_freshness_idx": { + "name": "ai_pricing_entries_freshness_idx", + "columns": [ + { + "expression": "source_kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "fetched_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "stale_after", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ai_pricing_refresh_runs": { + "name": "ai_pricing_refresh_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_url": { + "name": "source_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fetched_entries": { + "name": "fetched_entries", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "upserted_entries": { + "name": "upserted_entries", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "deactivated_entries": { + "name": "deactivated_entries", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_pricing_refresh_runs_source_status_idx": { + "name": "ai_pricing_refresh_runs_source_status_idx", + "columns": [ + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ai_pricing_refresh_runs_started_idx": { + "name": "ai_pricing_refresh_runs_started_idx", + "columns": [ + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.affiliate_codes": { + "name": "affiliate_codes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parent_referral_id": { + "name": "parent_referral_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "markup_percent": { + "name": "markup_percent", + "type": "numeric(6, 2)", + "primaryKey": false, + "notNull": true, + "default": "'20.00'" + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "affiliate_codes_user_idx": { + "name": "affiliate_codes_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "affiliate_codes_code_idx": { + "name": "affiliate_codes_code_idx", + "columns": [ + { + "expression": "code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "affiliate_codes_user_id_users_id_fk": { + "name": "affiliate_codes_user_id_users_id_fk", + "tableFrom": "affiliate_codes", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "affiliate_codes_parent_referral_id_affiliate_codes_id_fk": { + "name": "affiliate_codes_parent_referral_id_affiliate_codes_id_fk", + "tableFrom": "affiliate_codes", + "tableTo": "affiliate_codes", + "columnsFrom": [ + "parent_referral_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "affiliate_codes_code_unique": { + "name": "affiliate_codes_code_unique", + "nullsNotDistinct": false, + "columns": [ + "code" + ] + } + }, + "policies": {}, + "checkConstraints": { + "markup_percent_range": { + "name": "markup_percent_range", + "value": "\"affiliate_codes\".\"markup_percent\" >= 0 AND \"affiliate_codes\".\"markup_percent\" <= 1000" + } + }, + "isRLSEnabled": false + }, + "public.user_affiliates": { + "name": "user_affiliates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "affiliate_code_id": { + "name": "affiliate_code_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "user_affiliates_user_idx": { + "name": "user_affiliates_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_affiliates_affiliate_idx": { + "name": "user_affiliates_affiliate_idx", + "columns": [ + { + "expression": "affiliate_code_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_affiliates_user_id_users_id_fk": { + "name": "user_affiliates_user_id_users_id_fk", + "tableFrom": "user_affiliates", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_affiliates_affiliate_code_id_affiliate_codes_id_fk": { + "name": "user_affiliates_affiliate_code_id_affiliate_codes_id_fk", + "tableFrom": "user_affiliates", + "tableTo": "affiliate_codes", + "columnsFrom": [ + "affiliate_code_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_budget_transactions": { + "name": "agent_budget_transactions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "budget_id": { + "name": "budget_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(12, 4)", + "primaryKey": false, + "notNull": true + }, + "balance_after": { + "name": "balance_after", + "type": "numeric(12, 4)", + "primaryKey": false, + "notNull": true + }, + "daily_spent_after": { + "name": "daily_spent_after", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "operation_type": { + "name": "operation_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tokens_used": { + "name": "tokens_used", + "type": "numeric(12, 0)", + "primaryKey": false, + "notNull": false + }, + "source_type": { + "name": "source_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_id": { + "name": "source_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "agent_budget_txns_budget_idx": { + "name": "agent_budget_txns_budget_idx", + "columns": [ + { + "expression": "budget_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_budget_txns_agent_idx": { + "name": "agent_budget_txns_agent_idx", + "columns": [ + { + "expression": "agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_budget_txns_type_idx": { + "name": "agent_budget_txns_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_budget_txns_created_at_idx": { + "name": "agent_budget_txns_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_budget_transactions_budget_id_agent_budgets_id_fk": { + "name": "agent_budget_transactions_budget_id_agent_budgets_id_fk", + "tableFrom": "agent_budget_transactions", + "tableTo": "agent_budgets", + "columnsFrom": [ + "budget_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "agent_budget_transactions_agent_id_user_characters_id_fk": { + "name": "agent_budget_transactions_agent_id_user_characters_id_fk", + "tableFrom": "agent_budget_transactions", + "tableTo": "user_characters", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_budgets": { + "name": "agent_budgets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "owner_org_id": { + "name": "owner_org_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "allocated_budget": { + "name": "allocated_budget", + "type": "numeric(12, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0.0000'" + }, + "spent_budget": { + "name": "spent_budget", + "type": "numeric(12, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0.0000'" + }, + "daily_limit": { + "name": "daily_limit", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "daily_spent": { + "name": "daily_spent", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0.0000'" + }, + "daily_reset_at": { + "name": "daily_reset_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "auto_refill_enabled": { + "name": "auto_refill_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "auto_refill_amount": { + "name": "auto_refill_amount", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "auto_refill_threshold": { + "name": "auto_refill_threshold", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "last_refill_at": { + "name": "last_refill_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "is_paused": { + "name": "is_paused", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "pause_on_depleted": { + "name": "pause_on_depleted", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "pause_reason": { + "name": "pause_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paused_at": { + "name": "paused_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "low_budget_threshold": { + "name": "low_budget_threshold", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false, + "default": "'5.0000'" + }, + "low_budget_alert_sent": { + "name": "low_budget_alert_sent", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "agent_budgets_agent_idx": { + "name": "agent_budgets_agent_idx", + "columns": [ + { + "expression": "agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_budgets_owner_org_idx": { + "name": "agent_budgets_owner_org_idx", + "columns": [ + { + "expression": "owner_org_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_budgets_paused_idx": { + "name": "agent_budgets_paused_idx", + "columns": [ + { + "expression": "is_paused", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_budgets_agent_id_user_characters_id_fk": { + "name": "agent_budgets_agent_id_user_characters_id_fk", + "tableFrom": "agent_budgets", + "tableTo": "user_characters", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "agent_budgets_owner_org_id_organizations_id_fk": { + "name": "agent_budgets_owner_org_id_organizations_id_fk", + "tableFrom": "agent_budgets", + "tableTo": "organizations", + "columnsFrom": [ + "owner_org_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "agent_budgets_agent_id_unique": { + "name": "agent_budgets_agent_id_unique", + "nullsNotDistinct": false, + "columns": [ + "agent_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_events": { + "name": "agent_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'info'" + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "duration_ms": { + "name": "duration_ms", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "container_id": { + "name": "container_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "agent_events_agent_idx": { + "name": "agent_events_agent_idx", + "columns": [ + { + "expression": "agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_events_organization_idx": { + "name": "agent_events_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_events_event_type_idx": { + "name": "agent_events_event_type_idx", + "columns": [ + { + "expression": "event_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_events_level_idx": { + "name": "agent_events_level_idx", + "columns": [ + { + "expression": "level", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_events_created_at_idx": { + "name": "agent_events_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_events_agent_created_idx": { + "name": "agent_events_agent_created_idx", + "columns": [ + { + "expression": "agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_events_agent_id_user_characters_id_fk": { + "name": "agent_events_agent_id_user_characters_id_fk", + "tableFrom": "agent_events", + "tableTo": "user_characters", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "agent_events_organization_id_organizations_id_fk": { + "name": "agent_events_organization_id_organizations_id_fk", + "tableFrom": "agent_events", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_phone_numbers": { + "name": "agent_phone_numbers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "phone_number": { + "name": "phone_number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "friendly_name": { + "name": "friendly_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "phone_provider", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "phone_type": { + "name": "phone_type", + "type": "phone_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'sms'" + }, + "provider_phone_id": { + "name": "provider_phone_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "webhook_url": { + "name": "webhook_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "webhook_configured": { + "name": "webhook_configured", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "verified": { + "name": "verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "verified_at": { + "name": "verified_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "can_send_sms": { + "name": "can_send_sms", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "can_receive_sms": { + "name": "can_receive_sms", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "can_send_mms": { + "name": "can_send_mms", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "can_receive_mms": { + "name": "can_receive_mms", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "can_voice": { + "name": "can_voice", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "max_messages_per_minute": { + "name": "max_messages_per_minute", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'60'" + }, + "max_messages_per_day": { + "name": "max_messages_per_day", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'1000'" + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'{}'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_message_at": { + "name": "last_message_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "agent_phone_numbers_phone_org_idx": { + "name": "agent_phone_numbers_phone_org_idx", + "columns": [ + { + "expression": "phone_number", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_phone_numbers_organization_idx": { + "name": "agent_phone_numbers_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_phone_numbers_agent_idx": { + "name": "agent_phone_numbers_agent_idx", + "columns": [ + { + "expression": "agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_phone_numbers_provider_idx": { + "name": "agent_phone_numbers_provider_idx", + "columns": [ + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_phone_numbers_is_active_idx": { + "name": "agent_phone_numbers_is_active_idx", + "columns": [ + { + "expression": "is_active", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_phone_numbers_organization_id_organizations_id_fk": { + "name": "agent_phone_numbers_organization_id_organizations_id_fk", + "tableFrom": "agent_phone_numbers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.phone_message_log": { + "name": "phone_message_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "phone_number_id": { + "name": "phone_number_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "direction": { + "name": "direction", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_number": { + "name": "from_number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_number": { + "name": "to_number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message_body": { + "name": "message_body", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "message_type": { + "name": "message_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'sms'" + }, + "media_urls": { + "name": "media_urls", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_message_id": { + "name": "provider_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'received'" + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agent_response": { + "name": "agent_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "response_time_ms": { + "name": "response_time_ms", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'{}'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "responded_at": { + "name": "responded_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "phone_message_log_phone_number_idx": { + "name": "phone_message_log_phone_number_idx", + "columns": [ + { + "expression": "phone_number_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "phone_message_log_direction_idx": { + "name": "phone_message_log_direction_idx", + "columns": [ + { + "expression": "direction", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "phone_message_log_status_idx": { + "name": "phone_message_log_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "phone_message_log_created_at_idx": { + "name": "phone_message_log_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "phone_message_log_from_number_idx": { + "name": "phone_message_log_from_number_idx", + "columns": [ + { + "expression": "from_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "phone_message_log_conversation_idx": { + "name": "phone_message_log_conversation_idx", + "columns": [ + { + "expression": "from_number", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "to_number", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "phone_number_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "phone_message_log_phone_number_id_agent_phone_numbers_id_fk": { + "name": "phone_message_log_phone_number_id_agent_phone_numbers_id_fk", + "tableFrom": "phone_message_log", + "tableTo": "agent_phone_numbers", + "columnsFrom": [ + "phone_number_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_server_wallets": { + "name": "agent_server_wallets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "character_id": { + "name": "character_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "wallet_provider": { + "name": "wallet_provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'privy'" + }, + "privy_wallet_id": { + "name": "privy_wallet_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "steward_agent_id": { + "name": "steward_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "steward_tenant_id": { + "name": "steward_tenant_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address": { + "name": "address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "chain_type": { + "name": "chain_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "client_address": { + "name": "client_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "agent_server_wallets_organization_idx": { + "name": "agent_server_wallets_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_server_wallets_user_idx": { + "name": "agent_server_wallets_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_server_wallets_character_idx": { + "name": "agent_server_wallets_character_idx", + "columns": [ + { + "expression": "character_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_server_wallets_privy_wallet_idx": { + "name": "agent_server_wallets_privy_wallet_idx", + "columns": [ + { + "expression": "privy_wallet_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_server_wallets_address_idx": { + "name": "agent_server_wallets_address_idx", + "columns": [ + { + "expression": "address", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_server_wallets_client_address_idx": { + "name": "agent_server_wallets_client_address_idx", + "columns": [ + { + "expression": "client_address", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_server_wallets_steward_agent_idx": { + "name": "agent_server_wallets_steward_agent_idx", + "columns": [ + { + "expression": "steward_agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_server_wallets_wallet_provider_idx": { + "name": "agent_server_wallets_wallet_provider_idx", + "columns": [ + { + "expression": "wallet_provider", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_server_wallets_organization_id_organizations_id_fk": { + "name": "agent_server_wallets_organization_id_organizations_id_fk", + "tableFrom": "agent_server_wallets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "agent_server_wallets_user_id_users_id_fk": { + "name": "agent_server_wallets_user_id_users_id_fk", + "tableFrom": "agent_server_wallets", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "agent_server_wallets_character_id_user_characters_id_fk": { + "name": "agent_server_wallets_character_id_user_characters_id_fk", + "tableFrom": "agent_server_wallets", + "tableTo": "user_characters", + "columnsFrom": [ + "character_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "agent_server_wallets_client_address_unique": { + "name": "agent_server_wallets_client_address_unique", + "nullsNotDistinct": false, + "columns": [ + "client_address" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.alb_priorities": { + "name": "alb_priorities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_name": { + "name": "project_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + }, + "priority": { + "name": "priority", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "alb_priorities_user_project_idx": { + "name": "alb_priorities_user_project_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "project_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "alb_priorities_priority_unique": { + "name": "alb_priorities_priority_unique", + "nullsNotDistinct": false, + "columns": [ + "priority" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.anonymous_sessions": { + "name": "anonymous_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "session_token": { + "name": "session_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_count": { + "name": "message_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "messages_limit": { + "name": "messages_limit", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 10 + }, + "total_tokens_used": { + "name": "total_tokens_used", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_message_at": { + "name": "last_message_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "hourly_message_count": { + "name": "hourly_message_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "hourly_reset_at": { + "name": "hourly_reset_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fingerprint": { + "name": "fingerprint", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "signup_prompted_at": { + "name": "signup_prompted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "signup_prompt_count": { + "name": "signup_prompt_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "converted_at": { + "name": "converted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": { + "anon_sessions_token_idx": { + "name": "anon_sessions_token_idx", + "columns": [ + { + "expression": "session_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "anon_sessions_user_id_idx": { + "name": "anon_sessions_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "anon_sessions_expires_at_idx": { + "name": "anon_sessions_expires_at_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "anon_sessions_ip_address_idx": { + "name": "anon_sessions_ip_address_idx", + "columns": [ + { + "expression": "ip_address", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "anon_sessions_is_active_idx": { + "name": "anon_sessions_is_active_idx", + "columns": [ + { + "expression": "is_active", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "anonymous_sessions_user_id_users_id_fk": { + "name": "anonymous_sessions_user_id_users_id_fk", + "tableFrom": "anonymous_sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "anonymous_sessions_session_token_unique": { + "name": "anonymous_sessions_session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "session_token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.api_keys": { + "name": "api_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key_hash": { + "name": "key_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key_prefix": { + "name": "key_prefix", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "permissions": { + "name": "permissions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "rate_limit": { + "name": "rate_limit", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1000 + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "usage_count": { + "name": "usage_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "api_keys_key_idx": { + "name": "api_keys_key_idx", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "api_keys_key_hash_idx": { + "name": "api_keys_key_hash_idx", + "columns": [ + { + "expression": "key_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "api_keys_key_prefix_idx": { + "name": "api_keys_key_prefix_idx", + "columns": [ + { + "expression": "key_prefix", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "api_keys_organization_idx": { + "name": "api_keys_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "api_keys_user_idx": { + "name": "api_keys_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "api_keys_organization_id_organizations_id_fk": { + "name": "api_keys_organization_id_organizations_id_fk", + "tableFrom": "api_keys", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "api_keys_user_id_users_id_fk": { + "name": "api_keys_user_id_users_id_fk", + "tableFrom": "api_keys", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "api_keys_key_unique": { + "name": "api_keys_key_unique", + "nullsNotDistinct": false, + "columns": [ + "key" + ] + }, + "api_keys_key_hash_unique": { + "name": "api_keys_key_hash_unique", + "nullsNotDistinct": false, + "columns": [ + "key_hash" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.app_billing": { + "name": "app_billing", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "app_id": { + "name": "app_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "custom_pricing_enabled": { + "name": "custom_pricing_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "monetization_enabled": { + "name": "monetization_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "inference_markup_percentage": { + "name": "inference_markup_percentage", + "type": "numeric(7, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "purchase_share_percentage": { + "name": "purchase_share_percentage", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": true, + "default": "'10.00'" + }, + "platform_offset_amount": { + "name": "platform_offset_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'1.00'" + }, + "total_creator_earnings": { + "name": "total_creator_earnings", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true, + "default": "'0.000000'" + }, + "total_platform_revenue": { + "name": "total_platform_revenue", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true, + "default": "'0.000000'" + }, + "rate_limit_per_minute": { + "name": "rate_limit_per_minute", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 60 + }, + "rate_limit_per_hour": { + "name": "rate_limit_per_hour", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 1000 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "app_billing_app_idx": { + "name": "app_billing_app_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "app_billing_app_id_apps_id_fk": { + "name": "app_billing_app_id_apps_id_fk", + "tableFrom": "app_billing", + "tableTo": "apps", + "columnsFrom": [ + "app_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "app_billing_app_id_unique": { + "name": "app_billing_app_id_unique", + "nullsNotDistinct": false, + "columns": [ + "app_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.app_config": { + "name": "app_config", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "app_id": { + "name": "app_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "features_enabled": { + "name": "features_enabled", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"chat\":true,\"image\":false,\"video\":false,\"voice\":false,\"agents\":false,\"embedding\":false}'::jsonb" + }, + "twitter_automation": { + "name": "twitter_automation", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{\"enabled\":false,\"autoPost\":false,\"autoReply\":false,\"autoEngage\":false,\"discovery\":false,\"postIntervalMin\":90,\"postIntervalMax\":150}'::jsonb" + }, + "telegram_automation": { + "name": "telegram_automation", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{\"enabled\":false,\"autoReply\":true,\"autoAnnounce\":false,\"announceIntervalMin\":120,\"announceIntervalMax\":240}'::jsonb" + }, + "discord_automation": { + "name": "discord_automation", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{\"enabled\":false,\"autoAnnounce\":false,\"announceIntervalMin\":120,\"announceIntervalMax\":240}'::jsonb" + }, + "promotional_assets": { + "name": "promotional_assets", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "linked_character_ids": { + "name": "linked_character_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "github_repo": { + "name": "github_repo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "app_config_app_idx": { + "name": "app_config_app_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "app_config_app_id_apps_id_fk": { + "name": "app_config_app_id_apps_id_fk", + "tableFrom": "app_config", + "tableTo": "apps", + "columnsFrom": [ + "app_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "app_config_app_id_unique": { + "name": "app_config_app_id_unique", + "nullsNotDistinct": false, + "columns": [ + "app_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.app_credit_balances": { + "name": "app_credit_balances", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "app_id": { + "name": "app_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "credit_balance": { + "name": "credit_balance", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "total_purchased": { + "name": "total_purchased", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "total_spent": { + "name": "total_spent", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "app_credit_balances_app_user_idx": { + "name": "app_credit_balances_app_user_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_credit_balances_app_idx": { + "name": "app_credit_balances_app_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_credit_balances_user_idx": { + "name": "app_credit_balances_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_credit_balances_org_idx": { + "name": "app_credit_balances_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "app_credit_balances_app_id_apps_id_fk": { + "name": "app_credit_balances_app_id_apps_id_fk", + "tableFrom": "app_credit_balances", + "tableTo": "apps", + "columnsFrom": [ + "app_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "app_credit_balances_user_id_users_id_fk": { + "name": "app_credit_balances_user_id_users_id_fk", + "tableFrom": "app_credit_balances", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "app_credit_balances_organization_id_organizations_id_fk": { + "name": "app_credit_balances_organization_id_organizations_id_fk", + "tableFrom": "app_credit_balances", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.app_databases": { + "name": "app_databases", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "app_id": { + "name": "app_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_database_uri": { + "name": "user_database_uri", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_database_project_id": { + "name": "user_database_project_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_database_branch_id": { + "name": "user_database_branch_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_database_region": { + "name": "user_database_region", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'aws-us-east-1'" + }, + "user_database_status": { + "name": "user_database_status", + "type": "user_database_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'none'" + }, + "user_database_error": { + "name": "user_database_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "app_databases_app_idx": { + "name": "app_databases_app_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_databases_status_idx": { + "name": "app_databases_status_idx", + "columns": [ + { + "expression": "user_database_status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "app_databases_app_id_apps_id_fk": { + "name": "app_databases_app_id_apps_id_fk", + "tableFrom": "app_databases", + "tableTo": "apps", + "columnsFrom": [ + "app_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "app_databases_app_id_unique": { + "name": "app_databases_app_id_unique", + "nullsNotDistinct": false, + "columns": [ + "app_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.app_domains": { + "name": "app_domains", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "app_id": { + "name": "app_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "subdomain": { + "name": "subdomain", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "custom_domain": { + "name": "custom_domain", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "custom_domain_verified": { + "name": "custom_domain_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "verification_records": { + "name": "verification_records", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "ssl_status": { + "name": "ssl_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "ssl_error": { + "name": "ssl_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vercel_project_id": { + "name": "vercel_project_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vercel_domain_id": { + "name": "vercel_domain_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_primary": { + "name": "is_primary", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "verified_at": { + "name": "verified_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "app_domains_app_id_idx": { + "name": "app_domains_app_id_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_domains_subdomain_idx": { + "name": "app_domains_subdomain_idx", + "columns": [ + { + "expression": "subdomain", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_domains_custom_domain_idx": { + "name": "app_domains_custom_domain_idx", + "columns": [ + { + "expression": "custom_domain", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_domains_vercel_domain_idx": { + "name": "app_domains_vercel_domain_idx", + "columns": [ + { + "expression": "vercel_domain_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "app_domains_app_id_apps_id_fk": { + "name": "app_domains_app_id_apps_id_fk", + "tableFrom": "app_domains", + "tableTo": "apps", + "columnsFrom": [ + "app_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.app_earnings": { + "name": "app_earnings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "app_id": { + "name": "app_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "total_lifetime_earnings": { + "name": "total_lifetime_earnings", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true, + "default": "'0.000000'" + }, + "total_inference_earnings": { + "name": "total_inference_earnings", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true, + "default": "'0.000000'" + }, + "total_purchase_earnings": { + "name": "total_purchase_earnings", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true, + "default": "'0.000000'" + }, + "pending_balance": { + "name": "pending_balance", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true, + "default": "'0.000000'" + }, + "withdrawable_balance": { + "name": "withdrawable_balance", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true, + "default": "'0.000000'" + }, + "total_withdrawn": { + "name": "total_withdrawn", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true, + "default": "'0.000000'" + }, + "last_withdrawal_at": { + "name": "last_withdrawal_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "payout_threshold": { + "name": "payout_threshold", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'25.00'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "app_earnings_app_idx": { + "name": "app_earnings_app_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "app_earnings_app_id_apps_id_fk": { + "name": "app_earnings_app_id_apps_id_fk", + "tableFrom": "app_earnings", + "tableTo": "apps", + "columnsFrom": [ + "app_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.app_earnings_transactions": { + "name": "app_earnings_transactions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "app_id": { + "name": "app_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(10, 6)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "app_earnings_transactions_app_idx": { + "name": "app_earnings_transactions_app_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_earnings_transactions_app_created_idx": { + "name": "app_earnings_transactions_app_created_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_earnings_transactions_user_idx": { + "name": "app_earnings_transactions_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_earnings_transactions_type_idx": { + "name": "app_earnings_transactions_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "app_earnings_transactions_app_id_apps_id_fk": { + "name": "app_earnings_transactions_app_id_apps_id_fk", + "tableFrom": "app_earnings_transactions", + "tableTo": "apps", + "columnsFrom": [ + "app_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "app_earnings_transactions_user_id_users_id_fk": { + "name": "app_earnings_transactions_user_id_users_id_fk", + "tableFrom": "app_earnings_transactions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.app_builder_prompts": { + "name": "app_builder_prompts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "sandbox_session_id": { + "name": "sandbox_session_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "files_affected": { + "name": "files_affected", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "commit_sha": { + "name": "commit_sha", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "duration_ms": { + "name": "duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "app_builder_prompts_session_idx": { + "name": "app_builder_prompts_session_idx", + "columns": [ + { + "expression": "sandbox_session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_builder_prompts_created_at_idx": { + "name": "app_builder_prompts_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "app_builder_prompts_sandbox_session_id_app_sandbox_sessions_id_fk": { + "name": "app_builder_prompts_sandbox_session_id_app_sandbox_sessions_id_fk", + "tableFrom": "app_builder_prompts", + "tableTo": "app_sandbox_sessions", + "columnsFrom": [ + "sandbox_session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.app_sandbox_sessions": { + "name": "app_sandbox_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "app_id": { + "name": "app_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "sandbox_id": { + "name": "sandbox_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sandbox_url": { + "name": "sandbox_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "git_branch": { + "name": "git_branch", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'main'" + }, + "last_commit_sha": { + "name": "last_commit_sha", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'initializing'" + }, + "status_message": { + "name": "status_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "app_name": { + "name": "app_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "app_description": { + "name": "app_description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "initial_prompt": { + "name": "initial_prompt", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "template_type": { + "name": "template_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'blank'" + }, + "build_config": { + "name": "build_config", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "claude_session_id": { + "name": "claude_session_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claude_messages": { + "name": "claude_messages", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "generated_files": { + "name": "generated_files", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "cpu_seconds_used": { + "name": "cpu_seconds_used", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "memory_mb_peak": { + "name": "memory_mb_peak", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "stopped_at": { + "name": "stopped_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "app_sandbox_sessions_user_id_idx": { + "name": "app_sandbox_sessions_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_sandbox_sessions_org_id_idx": { + "name": "app_sandbox_sessions_org_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_sandbox_sessions_app_id_idx": { + "name": "app_sandbox_sessions_app_id_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_sandbox_sessions_sandbox_id_idx": { + "name": "app_sandbox_sessions_sandbox_id_idx", + "columns": [ + { + "expression": "sandbox_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_sandbox_sessions_status_idx": { + "name": "app_sandbox_sessions_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_sandbox_sessions_created_at_idx": { + "name": "app_sandbox_sessions_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "app_sandbox_sessions_user_id_users_id_fk": { + "name": "app_sandbox_sessions_user_id_users_id_fk", + "tableFrom": "app_sandbox_sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "app_sandbox_sessions_organization_id_organizations_id_fk": { + "name": "app_sandbox_sessions_organization_id_organizations_id_fk", + "tableFrom": "app_sandbox_sessions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "app_sandbox_sessions_app_id_apps_id_fk": { + "name": "app_sandbox_sessions_app_id_apps_id_fk", + "tableFrom": "app_sandbox_sessions", + "tableTo": "apps", + "columnsFrom": [ + "app_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "app_sandbox_sessions_sandbox_id_unique": { + "name": "app_sandbox_sessions_sandbox_id_unique", + "nullsNotDistinct": false, + "columns": [ + "sandbox_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.app_templates": { + "name": "app_templates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "preview_image_url": { + "name": "preview_image_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "github_repo": { + "name": "github_repo", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "github_branch": { + "name": "github_branch", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'main'" + }, + "features": { + "name": "features", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "system_prompt": { + "name": "system_prompt", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "example_prompts": { + "name": "example_prompts", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "usage_count": { + "name": "usage_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "is_featured": { + "name": "is_featured", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "app_templates_slug_idx": { + "name": "app_templates_slug_idx", + "columns": [ + { + "expression": "slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_templates_category_idx": { + "name": "app_templates_category_idx", + "columns": [ + { + "expression": "category", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_templates_is_active_idx": { + "name": "app_templates_is_active_idx", + "columns": [ + { + "expression": "is_active", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_templates_is_featured_idx": { + "name": "app_templates_is_featured_idx", + "columns": [ + { + "expression": "is_featured", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "app_templates_slug_unique": { + "name": "app_templates_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sandbox_template_snapshots": { + "name": "sandbox_template_snapshots", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "snapshot_id": { + "name": "snapshot_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "template_key": { + "name": "template_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "github_repo": { + "name": "github_repo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "github_commit_sha": { + "name": "github_commit_sha", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "node_modules_size_mb": { + "name": "node_modules_size_mb", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_files": { + "name": "total_files", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'creating'" + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "usage_count": { + "name": "usage_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "sandbox_snapshots_template_key_idx": { + "name": "sandbox_snapshots_template_key_idx", + "columns": [ + { + "expression": "template_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sandbox_snapshots_status_idx": { + "name": "sandbox_snapshots_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sandbox_snapshots_expires_at_idx": { + "name": "sandbox_snapshots_expires_at_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sandbox_snapshots_snapshot_id_idx": { + "name": "sandbox_snapshots_snapshot_id_idx", + "columns": [ + { + "expression": "snapshot_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "sandbox_template_snapshots_snapshot_id_unique": { + "name": "sandbox_template_snapshots_snapshot_id_unique", + "nullsNotDistinct": false, + "columns": [ + "snapshot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session_file_snapshots": { + "name": "session_file_snapshots", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "sandbox_session_id": { + "name": "sandbox_session_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "file_path": { + "name": "file_path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content_hash": { + "name": "content_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_size": { + "name": "file_size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "snapshot_type": { + "name": "snapshot_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'auto'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "session_file_snapshots_session_idx": { + "name": "session_file_snapshots_session_idx", + "columns": [ + { + "expression": "sandbox_session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "session_file_snapshots_session_path_idx": { + "name": "session_file_snapshots_session_path_idx", + "columns": [ + { + "expression": "sandbox_session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "file_path", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "session_file_snapshots_created_at_idx": { + "name": "session_file_snapshots_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "session_file_snapshots_sandbox_session_id_app_sandbox_sessions_id_fk": { + "name": "session_file_snapshots_sandbox_session_id_app_sandbox_sessions_id_fk", + "tableFrom": "session_file_snapshots", + "tableTo": "app_sandbox_sessions", + "columnsFrom": [ + "sandbox_session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session_restore_history": { + "name": "session_restore_history", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "sandbox_session_id": { + "name": "sandbox_session_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "old_sandbox_id": { + "name": "old_sandbox_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "new_sandbox_id": { + "name": "new_sandbox_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "files_restored": { + "name": "files_restored", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "restore_duration_ms": { + "name": "restore_duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "session_restore_history_session_idx": { + "name": "session_restore_history_session_idx", + "columns": [ + { + "expression": "sandbox_session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "session_restore_history_sandbox_session_id_app_sandbox_sessions_id_fk": { + "name": "session_restore_history_sandbox_session_id_app_sandbox_sessions_id_fk", + "tableFrom": "session_restore_history", + "tableTo": "app_sandbox_sessions", + "columnsFrom": [ + "sandbox_session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.app_analytics": { + "name": "app_analytics", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "app_id": { + "name": "app_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "period_start": { + "name": "period_start", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "period_end": { + "name": "period_end", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "period_type": { + "name": "period_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "total_requests": { + "name": "total_requests", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "successful_requests": { + "name": "successful_requests", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "failed_requests": { + "name": "failed_requests", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "unique_users": { + "name": "unique_users", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "new_users": { + "name": "new_users", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_input_tokens": { + "name": "total_input_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_output_tokens": { + "name": "total_output_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_cost": { + "name": "total_cost", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false, + "default": "'0.00'" + }, + "total_credits_used": { + "name": "total_credits_used", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false, + "default": "'0.00'" + }, + "chat_requests": { + "name": "chat_requests", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "image_requests": { + "name": "image_requests", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "video_requests": { + "name": "video_requests", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "voice_requests": { + "name": "voice_requests", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "agent_requests": { + "name": "agent_requests", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "avg_response_time_ms": { + "name": "avg_response_time_ms", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "app_analytics_app_id_idx": { + "name": "app_analytics_app_id_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_analytics_period_idx": { + "name": "app_analytics_period_idx", + "columns": [ + { + "expression": "period_start", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "period_end", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_analytics_period_type_idx": { + "name": "app_analytics_period_type_idx", + "columns": [ + { + "expression": "period_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_analytics_app_period_idx": { + "name": "app_analytics_app_period_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "period_start", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "app_analytics_app_id_apps_id_fk": { + "name": "app_analytics_app_id_apps_id_fk", + "tableFrom": "app_analytics", + "tableTo": "apps", + "columnsFrom": [ + "app_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.app_requests": { + "name": "app_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "app_id": { + "name": "app_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_type": { + "name": "request_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'api_key'" + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "country": { + "name": "country", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "output_tokens": { + "name": "output_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "credits_used": { + "name": "credits_used", + "type": "numeric(10, 6)", + "primaryKey": false, + "notNull": false, + "default": "'0.00'" + }, + "response_time_ms": { + "name": "response_time_ms", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'success'" + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "app_requests_app_id_idx": { + "name": "app_requests_app_id_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_requests_created_at_idx": { + "name": "app_requests_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_requests_type_idx": { + "name": "app_requests_type_idx", + "columns": [ + { + "expression": "request_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_requests_source_idx": { + "name": "app_requests_source_idx", + "columns": [ + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_requests_ip_idx": { + "name": "app_requests_ip_idx", + "columns": [ + { + "expression": "ip_address", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_requests_app_created_idx": { + "name": "app_requests_app_created_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "app_requests_app_id_apps_id_fk": { + "name": "app_requests_app_id_apps_id_fk", + "tableFrom": "app_requests", + "tableTo": "apps", + "columnsFrom": [ + "app_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "app_requests_user_id_users_id_fk": { + "name": "app_requests_user_id_users_id_fk", + "tableFrom": "app_requests", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.app_users": { + "name": "app_users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "app_id": { + "name": "app_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "signup_source": { + "name": "signup_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "referral_code_used": { + "name": "referral_code_used", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "total_requests": { + "name": "total_requests", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_credits_used": { + "name": "total_credits_used", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false, + "default": "'0.00'" + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + } + }, + "indexes": { + "app_users_app_user_idx": { + "name": "app_users_app_user_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_users_app_id_idx": { + "name": "app_users_app_id_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_users_user_id_idx": { + "name": "app_users_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_users_first_seen_idx": { + "name": "app_users_first_seen_idx", + "columns": [ + { + "expression": "first_seen_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "app_users_app_id_apps_id_fk": { + "name": "app_users_app_id_apps_id_fk", + "tableFrom": "app_users", + "tableTo": "apps", + "columnsFrom": [ + "app_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "app_users_user_id_users_id_fk": { + "name": "app_users_user_id_users_id_fk", + "tableFrom": "app_users", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.apps": { + "name": "apps", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "app_url": { + "name": "app_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "allowed_origins": { + "name": "allowed_origins", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "api_key_id": { + "name": "api_key_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "affiliate_code": { + "name": "affiliate_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "referral_bonus_credits": { + "name": "referral_bonus_credits", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false, + "default": "'0.00'" + }, + "total_requests": { + "name": "total_requests", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_users": { + "name": "total_users", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_credits_used": { + "name": "total_credits_used", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false, + "default": "'0.00'" + }, + "logo_url": { + "name": "logo_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "website_url": { + "name": "website_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contact_email": { + "name": "contact_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "deployment_status": { + "name": "deployment_status", + "type": "app_deployment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "production_url": { + "name": "production_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_deployed_at": { + "name": "last_deployed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "github_repo": { + "name": "github_repo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "linked_character_ids": { + "name": "linked_character_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "monetization_enabled": { + "name": "monetization_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "inference_markup_percentage": { + "name": "inference_markup_percentage", + "type": "real", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "purchase_share_percentage": { + "name": "purchase_share_percentage", + "type": "real", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "platform_offset_amount": { + "name": "platform_offset_amount", + "type": "real", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "custom_pricing_enabled": { + "name": "custom_pricing_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "total_creator_earnings": { + "name": "total_creator_earnings", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": false, + "default": "'0.000000'" + }, + "total_platform_revenue": { + "name": "total_platform_revenue", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": false, + "default": "'0.000000'" + }, + "discord_automation": { + "name": "discord_automation", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{\"enabled\":false,\"autoAnnounce\":false,\"announceIntervalMin\":120,\"announceIntervalMax\":240}'::jsonb" + }, + "telegram_automation": { + "name": "telegram_automation", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{\"enabled\":false,\"autoReply\":true,\"autoAnnounce\":false,\"announceIntervalMin\":120,\"announceIntervalMax\":240}'::jsonb" + }, + "twitter_automation": { + "name": "twitter_automation", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{\"enabled\":false,\"autoPost\":false,\"autoReply\":false,\"autoEngage\":false,\"discovery\":false,\"postIntervalMin\":90,\"postIntervalMax\":150}'::jsonb" + }, + "promotional_assets": { + "name": "promotional_assets", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "user_database_status": { + "name": "user_database_status", + "type": "user_database_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'none'" + }, + "user_database_uri": { + "name": "user_database_uri", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_database_project_id": { + "name": "user_database_project_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_database_branch_id": { + "name": "user_database_branch_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_database_region": { + "name": "user_database_region", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_database_error": { + "name": "user_database_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email_notifications": { + "name": "email_notifications", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "response_notifications": { + "name": "response_notifications", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "is_approved": { + "name": "is_approved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "apps_slug_idx": { + "name": "apps_slug_idx", + "columns": [ + { + "expression": "slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "apps_organization_idx": { + "name": "apps_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "apps_created_by_idx": { + "name": "apps_created_by_idx", + "columns": [ + { + "expression": "created_by_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "apps_affiliate_code_idx": { + "name": "apps_affiliate_code_idx", + "columns": [ + { + "expression": "affiliate_code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "apps_is_active_idx": { + "name": "apps_is_active_idx", + "columns": [ + { + "expression": "is_active", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "apps_created_at_idx": { + "name": "apps_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "apps_organization_id_organizations_id_fk": { + "name": "apps_organization_id_organizations_id_fk", + "tableFrom": "apps", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "apps_created_by_user_id_users_id_fk": { + "name": "apps_created_by_user_id_users_id_fk", + "tableFrom": "apps", + "tableTo": "users", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "apps_slug_unique": { + "name": "apps_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + }, + "apps_api_key_id_unique": { + "name": "apps_api_key_id_unique", + "nullsNotDistinct": false, + "columns": [ + "api_key_id" + ] + }, + "apps_affiliate_code_unique": { + "name": "apps_affiliate_code_unique", + "nullsNotDistinct": false, + "columns": [ + "affiliate_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.cli_auth_sessions": { + "name": "cli_auth_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "api_key_id": { + "name": "api_key_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "api_key_plain": { + "name": "api_key_plain", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "authenticated_at": { + "name": "authenticated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cli_auth_sessions_session_id_idx": { + "name": "cli_auth_sessions_session_id_idx", + "columns": [ + { + "expression": "session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "cli_auth_sessions_status_idx": { + "name": "cli_auth_sessions_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "cli_auth_sessions_user_id_idx": { + "name": "cli_auth_sessions_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "cli_auth_sessions_expires_at_idx": { + "name": "cli_auth_sessions_expires_at_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cli_auth_sessions_user_id_users_id_fk": { + "name": "cli_auth_sessions_user_id_users_id_fk", + "tableFrom": "cli_auth_sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "cli_auth_sessions_session_id_unique": { + "name": "cli_auth_sessions_session_id_unique", + "nullsNotDistinct": false, + "columns": [ + "session_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.container_billing_records": { + "name": "container_billing_records", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "container_id": { + "name": "container_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "billing_period_start": { + "name": "billing_period_start", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "billing_period_end": { + "name": "billing_period_end", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'success'" + }, + "credit_transaction_id": { + "name": "credit_transaction_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "container_billing_records_container_idx": { + "name": "container_billing_records_container_idx", + "columns": [ + { + "expression": "container_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "container_billing_records_org_idx": { + "name": "container_billing_records_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "container_billing_records_created_idx": { + "name": "container_billing_records_created_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "container_billing_records_status_idx": { + "name": "container_billing_records_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "container_billing_records_container_id_containers_id_fk": { + "name": "container_billing_records_container_id_containers_id_fk", + "tableFrom": "container_billing_records", + "tableTo": "containers", + "columnsFrom": [ + "container_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "container_billing_records_organization_id_organizations_id_fk": { + "name": "container_billing_records_organization_id_organizations_id_fk", + "tableFrom": "container_billing_records", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "container_billing_records_credit_transaction_id_credit_transactions_id_fk": { + "name": "container_billing_records_credit_transaction_id_credit_transactions_id_fk", + "tableFrom": "container_billing_records", + "tableTo": "credit_transactions", + "columnsFrom": [ + "credit_transaction_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.containers": { + "name": "containers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_name": { + "name": "project_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "api_key_id": { + "name": "api_key_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "character_id": { + "name": "character_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cloudformation_stack_name": { + "name": "cloudformation_stack_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ecr_repository_uri": { + "name": "ecr_repository_uri", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ecr_image_tag": { + "name": "ecr_image_tag", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ecs_cluster_arn": { + "name": "ecs_cluster_arn", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ecs_service_arn": { + "name": "ecs_service_arn", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ecs_task_definition_arn": { + "name": "ecs_task_definition_arn", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ecs_task_arn": { + "name": "ecs_task_arn", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "load_balancer_url": { + "name": "load_balancer_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_update": { + "name": "is_update", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'false'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "image_tag": { + "name": "image_tag", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dockerfile_path": { + "name": "dockerfile_path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "environment_vars": { + "name": "environment_vars", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "desired_count": { + "name": "desired_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "cpu": { + "name": "cpu", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1792 + }, + "memory": { + "name": "memory", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1792 + }, + "port": { + "name": "port", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 3000 + }, + "health_check_path": { + "name": "health_check_path", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'/health'" + }, + "architecture": { + "name": "architecture", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'arm64'" + }, + "last_deployed_at": { + "name": "last_deployed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_health_check": { + "name": "last_health_check", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "deployment_log": { + "name": "deployment_log", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "last_billed_at": { + "name": "last_billed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "next_billing_at": { + "name": "next_billing_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "billing_status": { + "name": "billing_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "shutdown_warning_sent_at": { + "name": "shutdown_warning_sent_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scheduled_shutdown_at": { + "name": "scheduled_shutdown_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "total_billed": { + "name": "total_billed", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "containers_organization_idx": { + "name": "containers_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "containers_user_idx": { + "name": "containers_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "containers_status_idx": { + "name": "containers_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "containers_character_idx": { + "name": "containers_character_idx", + "columns": [ + { + "expression": "character_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "containers_ecs_service_idx": { + "name": "containers_ecs_service_idx", + "columns": [ + { + "expression": "ecs_service_arn", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "containers_ecr_repository_idx": { + "name": "containers_ecr_repository_idx", + "columns": [ + { + "expression": "ecr_repository_uri", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "containers_project_name_idx": { + "name": "containers_project_name_idx", + "columns": [ + { + "expression": "project_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "containers_user_project_idx": { + "name": "containers_user_project_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "project_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "containers_billing_status_idx": { + "name": "containers_billing_status_idx", + "columns": [ + { + "expression": "billing_status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "containers_next_billing_idx": { + "name": "containers_next_billing_idx", + "columns": [ + { + "expression": "next_billing_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "containers_scheduled_shutdown_idx": { + "name": "containers_scheduled_shutdown_idx", + "columns": [ + { + "expression": "scheduled_shutdown_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "containers_organization_id_organizations_id_fk": { + "name": "containers_organization_id_organizations_id_fk", + "tableFrom": "containers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "containers_user_id_users_id_fk": { + "name": "containers_user_id_users_id_fk", + "tableFrom": "containers", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "containers_api_key_id_api_keys_id_fk": { + "name": "containers_api_key_id_api_keys_id_fk", + "tableFrom": "containers", + "tableTo": "api_keys", + "columnsFrom": [ + "api_key_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "containers_character_id_user_characters_id_fk": { + "name": "containers_character_id_user_characters_id_fk", + "tableFrom": "containers", + "tableTo": "user_characters", + "columnsFrom": [ + "character_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversation_messages": { + "name": "conversation_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sequence_number": { + "name": "sequence_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tokens": { + "name": "tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "cost": { + "name": "cost", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false, + "default": "'0.00'" + }, + "usage_record_id": { + "name": "usage_record_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "api_request": { + "name": "api_request", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "api_response": { + "name": "api_response", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "processing_time": { + "name": "processing_time", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "conv_messages_conversation_idx": { + "name": "conv_messages_conversation_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "conv_messages_sequence_idx": { + "name": "conv_messages_sequence_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sequence_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "conv_messages_created_idx": { + "name": "conv_messages_created_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "conversation_messages_conversation_id_conversations_id_fk": { + "name": "conversation_messages_conversation_id_conversations_id_fk", + "tableFrom": "conversation_messages", + "tableTo": "conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "conversation_messages_usage_record_id_usage_records_id_fk": { + "name": "conversation_messages_usage_record_id_usage_records_id_fk", + "tableFrom": "conversation_messages", + "tableTo": "usage_records", + "columnsFrom": [ + "usage_record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversations": { + "name": "conversations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "settings": { + "name": "settings", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"temperature\":0.7,\"maxTokens\":2000,\"topP\":1,\"frequencyPenalty\":0,\"presencePenalty\":0,\"systemPrompt\":\"You are a helpful AI assistant.\"}'::jsonb" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "message_count": { + "name": "message_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_cost": { + "name": "total_cost", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "last_message_at": { + "name": "last_message_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "conversations_organization_idx": { + "name": "conversations_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "conversations_user_idx": { + "name": "conversations_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "conversations_updated_idx": { + "name": "conversations_updated_idx", + "columns": [ + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "conversations_status_idx": { + "name": "conversations_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "conversations_organization_id_organizations_id_fk": { + "name": "conversations_organization_id_organizations_id_fk", + "tableFrom": "conversations", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "conversations_user_id_users_id_fk": { + "name": "conversations_user_id_users_id_fk", + "tableFrom": "conversations", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.credit_packs": { + "name": "credit_packs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "credits": { + "name": "credits", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price_cents": { + "name": "price_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "stripe_price_id": { + "name": "stripe_price_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "stripe_product_id": { + "name": "stripe_product_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credit_packs_stripe_price_idx": { + "name": "credit_packs_stripe_price_idx", + "columns": [ + { + "expression": "stripe_price_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credit_packs_active_idx": { + "name": "credit_packs_active_idx", + "columns": [ + { + "expression": "is_active", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credit_packs_sort_idx": { + "name": "credit_packs_sort_idx", + "columns": [ + { + "expression": "sort_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "credit_packs_stripe_price_id_unique": { + "name": "credit_packs_stripe_price_id_unique", + "nullsNotDistinct": false, + "columns": [ + "stripe_price_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.credit_transactions": { + "name": "credit_transactions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "stripe_payment_intent_id": { + "name": "stripe_payment_intent_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credit_transactions_organization_idx": { + "name": "credit_transactions_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credit_transactions_user_idx": { + "name": "credit_transactions_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credit_transactions_type_idx": { + "name": "credit_transactions_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credit_transactions_created_at_idx": { + "name": "credit_transactions_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credit_transactions_stripe_payment_intent_idx": { + "name": "credit_transactions_stripe_payment_intent_idx", + "columns": [ + { + "expression": "stripe_payment_intent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credit_transactions_organization_id_organizations_id_fk": { + "name": "credit_transactions_organization_id_organizations_id_fk", + "tableFrom": "credit_transactions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_transactions_user_id_users_id_fk": { + "name": "credit_transactions_user_id_users_id_fk", + "tableFrom": "credit_transactions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.crypto_payments": { + "name": "crypto_payments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "payment_address": { + "name": "payment_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_address": { + "name": "token_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "network": { + "name": "network", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expected_amount": { + "name": "expected_amount", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "received_amount": { + "name": "received_amount", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "credits_to_add": { + "name": "credits_to_add", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "transaction_hash": { + "name": "transaction_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "block_number": { + "name": "block_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "confirmed_at": { + "name": "confirmed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + } + }, + "indexes": { + "crypto_payments_organization_id_idx": { + "name": "crypto_payments_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "crypto_payments_user_id_idx": { + "name": "crypto_payments_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "crypto_payments_payment_address_idx": { + "name": "crypto_payments_payment_address_idx", + "columns": [ + { + "expression": "payment_address", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "crypto_payments_status_idx": { + "name": "crypto_payments_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "crypto_payments_transaction_hash_unique_idx": { + "name": "crypto_payments_transaction_hash_unique_idx", + "columns": [ + { + "expression": "transaction_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "crypto_payments_network_idx": { + "name": "crypto_payments_network_idx", + "columns": [ + { + "expression": "network", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "crypto_payments_created_at_idx": { + "name": "crypto_payments_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "crypto_payments_expires_at_idx": { + "name": "crypto_payments_expires_at_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "crypto_payments_metadata_gin_idx": { + "name": "crypto_payments_metadata_gin_idx", + "columns": [ + { + "expression": "metadata", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + } + }, + "foreignKeys": { + "crypto_payments_organization_id_organizations_id_fk": { + "name": "crypto_payments_organization_id_organizations_id_fk", + "tableFrom": "crypto_payments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "crypto_payments_user_id_users_id_fk": { + "name": "crypto_payments_user_id_users_id_fk", + "tableFrom": "crypto_payments", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.daily_metrics": { + "name": "daily_metrics", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "date": { + "name": "date", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "platform": { + "name": "platform", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dau": { + "name": "dau", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "new_signups": { + "name": "new_signups", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_messages": { + "name": "total_messages", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "messages_per_user": { + "name": "messages_per_user", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false, + "default": "'0'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "daily_metrics_date_platform_idx": { + "name": "daily_metrics_date_platform_idx", + "columns": [ + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "platform", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "daily_metrics_date_idx": { + "name": "daily_metrics_date_idx", + "columns": [ + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.discord_channels": { + "name": "discord_channels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "guild_id": { + "name": "guild_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_name": { + "name": "channel_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_type": { + "name": "channel_type", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "parent_id": { + "name": "parent_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "can_send_messages": { + "name": "can_send_messages", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "can_embed_links": { + "name": "can_embed_links", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "can_attach_files": { + "name": "can_attach_files", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "is_nsfw": { + "name": "is_nsfw", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "discord_channels_organization_id_idx": { + "name": "discord_channels_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "discord_channels_guild_id_idx": { + "name": "discord_channels_guild_id_idx", + "columns": [ + { + "expression": "guild_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "discord_channels_channel_id_idx": { + "name": "discord_channels_channel_id_idx", + "columns": [ + { + "expression": "channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "discord_channels_guild_channel_idx": { + "name": "discord_channels_guild_channel_idx", + "columns": [ + { + "expression": "guild_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "discord_channels_organization_id_organizations_id_fk": { + "name": "discord_channels_organization_id_organizations_id_fk", + "tableFrom": "discord_channels", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.discord_connections": { + "name": "discord_connections", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "character_id": { + "name": "character_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "application_id": { + "name": "application_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_user_id": { + "name": "bot_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bot_token_encrypted": { + "name": "bot_token_encrypted", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "encrypted_dek": { + "name": "encrypted_dek", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_nonce": { + "name": "token_nonce", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_auth_tag": { + "name": "token_auth_tag", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "encryption_key_id": { + "name": "encryption_key_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "assigned_pod": { + "name": "assigned_pod", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "guild_count": { + "name": "guild_count", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "events_received": { + "name": "events_received", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "events_routed": { + "name": "events_routed", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "last_heartbeat": { + "name": "last_heartbeat", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "connected_at": { + "name": "connected_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "intents": { + "name": "intents", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 38401 + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "discord_connections_organization_id_idx": { + "name": "discord_connections_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "discord_connections_character_id_idx": { + "name": "discord_connections_character_id_idx", + "columns": [ + { + "expression": "character_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "discord_connections_org_app_unique_idx": { + "name": "discord_connections_org_app_unique_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "discord_connections_assigned_pod_idx": { + "name": "discord_connections_assigned_pod_idx", + "columns": [ + { + "expression": "assigned_pod", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "discord_connections_status_idx": { + "name": "discord_connections_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "discord_connections_is_active_idx": { + "name": "discord_connections_is_active_idx", + "columns": [ + { + "expression": "is_active", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "discord_connections_organization_id_organizations_id_fk": { + "name": "discord_connections_organization_id_organizations_id_fk", + "tableFrom": "discord_connections", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "discord_connections_character_id_user_characters_id_fk": { + "name": "discord_connections_character_id_user_characters_id_fk", + "tableFrom": "discord_connections", + "tableTo": "user_characters", + "columnsFrom": [ + "character_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.discord_guilds": { + "name": "discord_guilds", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "guild_id": { + "name": "guild_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "guild_name": { + "name": "guild_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "icon_hash": { + "name": "icon_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bot_permissions": { + "name": "bot_permissions", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bot_joined_at": { + "name": "bot_joined_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "discord_guilds_organization_id_idx": { + "name": "discord_guilds_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "discord_guilds_guild_id_idx": { + "name": "discord_guilds_guild_id_idx", + "columns": [ + { + "expression": "guild_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "discord_guilds_org_guild_idx": { + "name": "discord_guilds_org_guild_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "guild_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "discord_guilds_organization_id_organizations_id_fk": { + "name": "discord_guilds_organization_id_organizations_id_fk", + "tableFrom": "discord_guilds", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.docker_nodes": { + "name": "docker_nodes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "node_id": { + "name": "node_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "hostname": { + "name": "hostname", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ssh_port": { + "name": "ssh_port", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 22 + }, + "capacity": { + "name": "capacity", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 8 + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'unknown'" + }, + "allocated_count": { + "name": "allocated_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_health_check": { + "name": "last_health_check", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "ssh_user": { + "name": "ssh_user", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'root'" + }, + "host_key_fingerprint": { + "name": "host_key_fingerprint", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "docker_nodes_node_id_idx": { + "name": "docker_nodes_node_id_idx", + "columns": [ + { + "expression": "node_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "docker_nodes_status_idx": { + "name": "docker_nodes_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "docker_nodes_enabled_idx": { + "name": "docker_nodes_enabled_idx", + "columns": [ + { + "expression": "enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "docker_nodes_node_id_unique": { + "name": "docker_nodes_node_id_unique", + "nullsNotDistinct": false, + "columns": [ + "node_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agents": { + "name": "agents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "server_id": { + "name": "server_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "system": { + "name": "system", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "bio": { + "name": "bio", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "message_examples": { + "name": "message_examples", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "post_examples": { + "name": "post_examples", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "topics": { + "name": "topics", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "adjectives": { + "name": "adjectives", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "knowledge": { + "name": "knowledge", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "plugins": { + "name": "plugins", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "settings": { + "name": "settings", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "style": { + "name": "style", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.cache": { + "name": "cache", + "schema": "", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "cache_agent_id_agents_id_fk": { + "name": "cache_agent_id_agents_id_fk", + "tableFrom": "cache", + "tableTo": "agents", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "cache_key_agent_id_pk": { + "name": "cache_key_agent_id_pk", + "columns": [ + "key", + "agent_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.channel_participants": { + "name": "channel_participants", + "schema": "", + "columns": { + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "channel_participants_channel_id_channels_id_fk": { + "name": "channel_participants_channel_id_channels_id_fk", + "tableFrom": "channel_participants", + "tableTo": "channels", + "columnsFrom": [ + "channel_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "channel_participants_channel_id_entity_id_pk": { + "name": "channel_participants_channel_id_entity_id_pk", + "columns": [ + "channel_id", + "entity_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.channels": { + "name": "channels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "message_server_id": { + "name": "message_server_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_type": { + "name": "source_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_id": { + "name": "source_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "topic": { + "name": "topic", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "channels_message_server_id_message_servers_id_fk": { + "name": "channels_message_server_id_message_servers_id_fk", + "tableFrom": "channels", + "tableTo": "message_servers", + "columnsFrom": [ + "message_server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.components": { + "name": "components", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "world_id": { + "name": "world_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source_entity_id": { + "name": "source_entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "components_entity_id_entities_id_fk": { + "name": "components_entity_id_entities_id_fk", + "tableFrom": "components", + "tableTo": "entities", + "columnsFrom": [ + "entity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "components_agent_id_agents_id_fk": { + "name": "components_agent_id_agents_id_fk", + "tableFrom": "components", + "tableTo": "agents", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "components_room_id_rooms_id_fk": { + "name": "components_room_id_rooms_id_fk", + "tableFrom": "components", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "components_world_id_worlds_id_fk": { + "name": "components_world_id_worlds_id_fk", + "tableFrom": "components", + "tableTo": "worlds", + "columnsFrom": [ + "world_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "components_source_entity_id_entities_id_fk": { + "name": "components_source_entity_id_entities_id_fk", + "tableFrom": "components", + "tableTo": "entities", + "columnsFrom": [ + "source_entity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.embeddings": { + "name": "embeddings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "memory_id": { + "name": "memory_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "dim_384": { + "name": "dim_384", + "type": "vector(384)", + "primaryKey": false, + "notNull": false + }, + "dim_512": { + "name": "dim_512", + "type": "vector(512)", + "primaryKey": false, + "notNull": false + }, + "dim_768": { + "name": "dim_768", + "type": "vector(768)", + "primaryKey": false, + "notNull": false + }, + "dim_1024": { + "name": "dim_1024", + "type": "vector(1024)", + "primaryKey": false, + "notNull": false + }, + "dim_1536": { + "name": "dim_1536", + "type": "vector(1536)", + "primaryKey": false, + "notNull": false + }, + "dim_3072": { + "name": "dim_3072", + "type": "vector(3072)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "idx_embedding_memory": { + "name": "idx_embedding_memory", + "columns": [ + { + "expression": "memory_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "embeddings_memory_id_memories_id_fk": { + "name": "embeddings_memory_id_memories_id_fk", + "tableFrom": "embeddings", + "tableTo": "memories", + "columnsFrom": [ + "memory_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "fk_embedding_memory": { + "name": "fk_embedding_memory", + "tableFrom": "embeddings", + "tableTo": "memories", + "columnsFrom": [ + "memory_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "embedding_source_check": { + "name": "embedding_source_check", + "value": "\"memory_id\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.entities": { + "name": "entities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "names": { + "name": "names", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + } + }, + "indexes": {}, + "foreignKeys": { + "entities_agent_id_agents_id_fk": { + "name": "entities_agent_id_agents_id_fk", + "tableFrom": "entities", + "tableTo": "agents", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "id_agent_id_unique": { + "name": "id_agent_id_unique", + "nullsNotDistinct": false, + "columns": [ + "id", + "agent_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.logs": { + "name": "logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "logs_entity_id_entities_id_fk": { + "name": "logs_entity_id_entities_id_fk", + "tableFrom": "logs", + "tableTo": "entities", + "columnsFrom": [ + "entity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "logs_room_id_rooms_id_fk": { + "name": "logs_room_id_rooms_id_fk", + "tableFrom": "logs", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "fk_room": { + "name": "fk_room", + "tableFrom": "logs", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "fk_user": { + "name": "fk_user", + "tableFrom": "logs", + "tableTo": "entities", + "columnsFrom": [ + "entity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.long_term_memories": { + "name": "long_term_memories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(36)", + "primaryKey": true, + "notNull": true + }, + "agent_id": { + "name": "agent_id", + "type": "varchar(36)", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "varchar(36)", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "embedding": { + "name": "embedding", + "type": "real[]", + "primaryKey": false, + "notNull": false + }, + "confidence": { + "name": "confidence", + "type": "real", + "primaryKey": false, + "notNull": false, + "default": 1 + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_accessed_at": { + "name": "last_accessed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "access_count": { + "name": "access_count", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + } + }, + "indexes": { + "long_term_memories_agent_entity_idx": { + "name": "long_term_memories_agent_entity_idx", + "columns": [ + { + "expression": "agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "long_term_memories_category_idx": { + "name": "long_term_memories_category_idx", + "columns": [ + { + "expression": "category", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "long_term_memories_confidence_idx": { + "name": "long_term_memories_confidence_idx", + "columns": [ + { + "expression": "confidence", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "long_term_memories_created_at_idx": { + "name": "long_term_memories_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memory_access_logs": { + "name": "memory_access_logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(36)", + "primaryKey": true, + "notNull": true + }, + "agent_id": { + "name": "agent_id", + "type": "varchar(36)", + "primaryKey": false, + "notNull": true + }, + "memory_id": { + "name": "memory_id", + "type": "varchar(36)", + "primaryKey": false, + "notNull": true + }, + "memory_type": { + "name": "memory_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "accessed_at": { + "name": "accessed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "room_id": { + "name": "room_id", + "type": "varchar(36)", + "primaryKey": false, + "notNull": false + }, + "relevance_score": { + "name": "relevance_score", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "was_useful": { + "name": "was_useful", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "memory_access_logs_memory_idx": { + "name": "memory_access_logs_memory_idx", + "columns": [ + { + "expression": "memory_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "memory_access_logs_agent_idx": { + "name": "memory_access_logs_agent_idx", + "columns": [ + { + "expression": "agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "memory_access_logs_accessed_at_idx": { + "name": "memory_access_logs_accessed_at_idx", + "columns": [ + { + "expression": "accessed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memories": { + "name": "memories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "world_id": { + "name": "world_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "unique": { + "name": "unique", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + } + }, + "indexes": { + "idx_memories_type_room": { + "name": "idx_memories_type_room", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "room_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_memories_world_id": { + "name": "idx_memories_world_id", + "columns": [ + { + "expression": "world_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_memories_metadata_type": { + "name": "idx_memories_metadata_type", + "columns": [ + { + "expression": "((metadata->>'type'))", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_memories_document_id": { + "name": "idx_memories_document_id", + "columns": [ + { + "expression": "((metadata->>'documentId'))", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_fragments_order": { + "name": "idx_fragments_order", + "columns": [ + { + "expression": "((metadata->>'documentId'))", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "((metadata->>'position'))", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "memories_entity_id_entities_id_fk": { + "name": "memories_entity_id_entities_id_fk", + "tableFrom": "memories", + "tableTo": "entities", + "columnsFrom": [ + "entity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "memories_agent_id_agents_id_fk": { + "name": "memories_agent_id_agents_id_fk", + "tableFrom": "memories", + "tableTo": "agents", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "memories_room_id_rooms_id_fk": { + "name": "memories_room_id_rooms_id_fk", + "tableFrom": "memories", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "fk_room": { + "name": "fk_room", + "tableFrom": "memories", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "fk_user": { + "name": "fk_user", + "tableFrom": "memories", + "tableTo": "entities", + "columnsFrom": [ + "entity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "fk_agent": { + "name": "fk_agent", + "tableFrom": "memories", + "tableTo": "agents", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "fragment_metadata_check": { + "name": "fragment_metadata_check", + "value": "\n CASE \n WHEN metadata->>'type' = 'fragment' THEN\n metadata ? 'documentId' AND \n metadata ? 'position'\n ELSE true\n END\n " + }, + "document_metadata_check": { + "name": "document_metadata_check", + "value": "\n CASE \n WHEN metadata->>'type' = 'document' THEN\n metadata ? 'timestamp'\n ELSE true\n END\n " + } + }, + "isRLSEnabled": false + }, + "public.message_servers": { + "name": "message_servers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_type": { + "name": "source_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_id": { + "name": "source_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.central_messages": { + "name": "central_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "raw_message": { + "name": "raw_message", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "in_reply_to_root_message_id": { + "name": "in_reply_to_root_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_type": { + "name": "source_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_id": { + "name": "source_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "central_messages_channel_id_channels_id_fk": { + "name": "central_messages_channel_id_channels_id_fk", + "tableFrom": "central_messages", + "tableTo": "channels", + "columnsFrom": [ + "channel_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "central_messages_in_reply_to_root_message_id_central_messages_id_fk": { + "name": "central_messages_in_reply_to_root_message_id_central_messages_id_fk", + "tableFrom": "central_messages", + "tableTo": "central_messages", + "columnsFrom": [ + "in_reply_to_root_message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.participants": { + "name": "participants", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "room_state": { + "name": "room_state", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "idx_participants_user": { + "name": "idx_participants_user", + "columns": [ + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_participants_room": { + "name": "idx_participants_room", + "columns": [ + { + "expression": "room_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "participants_entity_id_entities_id_fk": { + "name": "participants_entity_id_entities_id_fk", + "tableFrom": "participants", + "tableTo": "entities", + "columnsFrom": [ + "entity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "participants_room_id_rooms_id_fk": { + "name": "participants_room_id_rooms_id_fk", + "tableFrom": "participants", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "participants_agent_id_agents_id_fk": { + "name": "participants_agent_id_agents_id_fk", + "tableFrom": "participants", + "tableTo": "agents", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "fk_room": { + "name": "fk_room", + "tableFrom": "participants", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "fk_user": { + "name": "fk_user", + "tableFrom": "participants", + "tableTo": "entities", + "columnsFrom": [ + "entity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.relationships": { + "name": "relationships", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "source_entity_id": { + "name": "source_entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "target_entity_id": { + "name": "target_entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "tags": { + "name": "tags", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "idx_relationships_users": { + "name": "idx_relationships_users", + "columns": [ + { + "expression": "source_entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "target_entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "relationships_source_entity_id_entities_id_fk": { + "name": "relationships_source_entity_id_entities_id_fk", + "tableFrom": "relationships", + "tableTo": "entities", + "columnsFrom": [ + "source_entity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "relationships_target_entity_id_entities_id_fk": { + "name": "relationships_target_entity_id_entities_id_fk", + "tableFrom": "relationships", + "tableTo": "entities", + "columnsFrom": [ + "target_entity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "relationships_agent_id_agents_id_fk": { + "name": "relationships_agent_id_agents_id_fk", + "tableFrom": "relationships", + "tableTo": "agents", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "fk_user_a": { + "name": "fk_user_a", + "tableFrom": "relationships", + "tableTo": "entities", + "columnsFrom": [ + "source_entity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "fk_user_b": { + "name": "fk_user_b", + "tableFrom": "relationships", + "tableTo": "entities", + "columnsFrom": [ + "target_entity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_relationship": { + "name": "unique_relationship", + "nullsNotDistinct": false, + "columns": [ + "source_entity_id", + "target_entity_id", + "agent_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.rooms": { + "name": "rooms", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message_server_id": { + "name": "message_server_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "world_id": { + "name": "world_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "rooms_agent_id_agents_id_fk": { + "name": "rooms_agent_id_agents_id_fk", + "tableFrom": "rooms", + "tableTo": "agents", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session_summaries": { + "name": "session_summaries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(36)", + "primaryKey": true, + "notNull": true + }, + "agent_id": { + "name": "agent_id", + "type": "varchar(36)", + "primaryKey": false, + "notNull": true + }, + "room_id": { + "name": "room_id", + "type": "varchar(36)", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "varchar(36)", + "primaryKey": false, + "notNull": false + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message_count": { + "name": "message_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_message_offset": { + "name": "last_message_offset", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "start_time": { + "name": "start_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "end_time": { + "name": "end_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "topics": { + "name": "topics", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "embedding": { + "name": "embedding", + "type": "real[]", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "session_summaries_agent_room_idx": { + "name": "session_summaries_agent_room_idx", + "columns": [ + { + "expression": "agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "room_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "session_summaries_entity_idx": { + "name": "session_summaries_entity_idx", + "columns": [ + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "session_summaries_start_time_idx": { + "name": "session_summaries_start_time_idx", + "columns": [ + { + "expression": "start_time", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tasks": { + "name": "tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "world_id": { + "name": "world_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "tags": { + "name": "tags", + "type": "text[]", + "primaryKey": false, + "notNull": false, + "default": "'{}'::text[]" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "tasks_agent_id_agents_id_fk": { + "name": "tasks_agent_id_agents_id_fk", + "tableFrom": "tasks", + "tableTo": "agents", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.worlds": { + "name": "worlds", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "message_server_id": { + "name": "message_server_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "worlds_agent_id_agents_id_fk": { + "name": "worlds_agent_id_agents_id_fk", + "tableFrom": "worlds", + "tableTo": "agents", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.eliza_room_characters": { + "name": "eliza_room_characters", + "schema": "", + "columns": { + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "character_id": { + "name": "character_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "eliza_room_characters_character_id_user_characters_id_fk": { + "name": "eliza_room_characters_character_id_user_characters_id_fk", + "tableFrom": "eliza_room_characters", + "tableTo": "user_characters", + "columnsFrom": [ + "character_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.entity_settings": { + "name": "entity_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "encrypted_value": { + "name": "encrypted_value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "encryption_key_id": { + "name": "encryption_key_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "encrypted_dek": { + "name": "encrypted_dek", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "nonce": { + "name": "nonce", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "auth_tag": { + "name": "auth_tag", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "entity_settings_user_agent_key_idx": { + "name": "entity_settings_user_agent_key_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "entity_settings_user_idx": { + "name": "entity_settings_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "entity_settings_user_agent_idx": { + "name": "entity_settings_user_agent_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "entity_settings_key_idx": { + "name": "entity_settings_key_idx", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "entity_settings_user_id_users_id_fk": { + "name": "entity_settings_user_id_users_id_fk", + "tableFrom": "entity_settings", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.generations": { + "name": "generations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "api_key_id": { + "name": "api_key_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "negative_prompt": { + "name": "negative_prompt", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result": { + "name": "result", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "storage_url": { + "name": "storage_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "thumbnail_url": { + "name": "thumbnail_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_size": { + "name": "file_size", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "parameters": { + "name": "parameters", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "settings": { + "name": "settings", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "dimensions": { + "name": "dimensions", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "tokens": { + "name": "tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "cost": { + "name": "cost", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "credits": { + "name": "credits", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "usage_record_id": { + "name": "usage_record_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "is_public": { + "name": "is_public", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": { + "generations_organization_idx": { + "name": "generations_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "generations_user_idx": { + "name": "generations_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "generations_api_key_idx": { + "name": "generations_api_key_idx", + "columns": [ + { + "expression": "api_key_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "generations_type_idx": { + "name": "generations_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "generations_status_idx": { + "name": "generations_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "generations_created_at_idx": { + "name": "generations_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "generations_org_type_status_idx": { + "name": "generations_org_type_status_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "generations_org_status_user_created_idx": { + "name": "generations_org_status_user_created_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "generations_is_public_idx": { + "name": "generations_is_public_idx", + "columns": [ + { + "expression": "is_public", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "generations_organization_id_organizations_id_fk": { + "name": "generations_organization_id_organizations_id_fk", + "tableFrom": "generations", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "generations_user_id_users_id_fk": { + "name": "generations_user_id_users_id_fk", + "tableFrom": "generations", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "generations_api_key_id_api_keys_id_fk": { + "name": "generations_api_key_id_api_keys_id_fk", + "tableFrom": "generations", + "tableTo": "api_keys", + "columnsFrom": [ + "api_key_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "generations_usage_record_id_usage_records_id_fk": { + "name": "generations_usage_record_id_usage_records_id_fk", + "tableFrom": "generations", + "tableTo": "usage_records", + "columnsFrom": [ + "usage_record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.idempotency_keys": { + "name": "idempotency_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "idempotency_keys_expires_idx": { + "name": "idempotency_keys_expires_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idempotency_keys_source_idx": { + "name": "idempotency_keys_source_idx", + "columns": [ + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "idempotency_keys_key_unique": { + "name": "idempotency_keys_key_unique", + "nullsNotDistinct": false, + "columns": [ + "key" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invoices": { + "name": "invoices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "stripe_invoice_id": { + "name": "stripe_invoice_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "stripe_payment_intent_id": { + "name": "stripe_payment_intent_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "amount_due": { + "name": "amount_due", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "amount_paid": { + "name": "amount_paid", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'usd'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invoice_type": { + "name": "invoice_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoice_pdf": { + "name": "invoice_pdf", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "hosted_invoice_url": { + "name": "hosted_invoice_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "credits_added": { + "name": "credits_added", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "due_date": { + "name": "due_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "paid_at": { + "name": "paid_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "invoices_organization_idx": { + "name": "invoices_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invoices_stripe_invoice_idx": { + "name": "invoices_stripe_invoice_idx", + "columns": [ + { + "expression": "stripe_invoice_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invoices_status_idx": { + "name": "invoices_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "invoices_stripe_invoice_id_unique": { + "name": "invoices_stripe_invoice_id_unique", + "nullsNotDistinct": false, + "columns": [ + "stripe_invoice_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.jobs": { + "name": "jobs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "data": { + "name": "data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "result": { + "name": "result", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "max_attempts": { + "name": "max_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 3 + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "api_key_id": { + "name": "api_key_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "generation_id": { + "name": "generation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "webhook_url": { + "name": "webhook_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "webhook_status": { + "name": "webhook_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "estimated_completion_at": { + "name": "estimated_completion_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scheduled_for": { + "name": "scheduled_for", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "jobs_type_idx": { + "name": "jobs_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "jobs_status_idx": { + "name": "jobs_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "jobs_scheduled_for_idx": { + "name": "jobs_scheduled_for_idx", + "columns": [ + { + "expression": "scheduled_for", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "jobs_organization_idx": { + "name": "jobs_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "jobs_organization_id_organizations_id_fk": { + "name": "jobs_organization_id_organizations_id_fk", + "tableFrom": "jobs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "jobs_user_id_users_id_fk": { + "name": "jobs_user_id_users_id_fk", + "tableFrom": "jobs", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "jobs_api_key_id_api_keys_id_fk": { + "name": "jobs_api_key_id_api_keys_id_fk", + "tableFrom": "jobs", + "tableTo": "api_keys", + "columnsFrom": [ + "api_key_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "jobs_generation_id_generations_id_fk": { + "name": "jobs_generation_id_generations_id_fk", + "tableFrom": "jobs", + "tableTo": "generations", + "columnsFrom": [ + "generation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.llm_trajectories": { + "name": "llm_trajectories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "api_key_id": { + "name": "api_key_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "request_id": { + "name": "request_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "system_prompt": { + "name": "system_prompt", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_prompt": { + "name": "user_prompt", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "response_text": { + "name": "response_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "output_tokens": { + "name": "output_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_tokens": { + "name": "total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "input_cost": { + "name": "input_cost", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": false, + "default": "'0.000000'" + }, + "output_cost": { + "name": "output_cost", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": false, + "default": "'0.000000'" + }, + "total_cost": { + "name": "total_cost", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": false, + "default": "'0.000000'" + }, + "latency_ms": { + "name": "latency_ms", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_successful": { + "name": "is_successful", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "llm_trajectories_org_created_idx": { + "name": "llm_trajectories_org_created_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "llm_trajectories_org_model_idx": { + "name": "llm_trajectories_org_model_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "model", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "llm_trajectories_purpose_idx": { + "name": "llm_trajectories_purpose_idx", + "columns": [ + { + "expression": "purpose", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "llm_trajectories_org_purpose_created_idx": { + "name": "llm_trajectories_org_purpose_created_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "purpose", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "llm_trajectories_organization_id_organizations_id_fk": { + "name": "llm_trajectories_organization_id_organizations_id_fk", + "tableFrom": "llm_trajectories", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "llm_trajectories_user_id_users_id_fk": { + "name": "llm_trajectories_user_id_users_id_fk", + "tableFrom": "llm_trajectories", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "llm_trajectories_api_key_id_api_keys_id_fk": { + "name": "llm_trajectories_api_key_id_api_keys_id_fk", + "tableFrom": "llm_trajectories", + "tableTo": "api_keys", + "columnsFrom": [ + "api_key_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.managed_domains": { + "name": "managed_domains", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "domain": { + "name": "domain", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "registrar": { + "name": "registrar", + "type": "domain_registrar", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'vercel'" + }, + "vercel_domain_id": { + "name": "vercel_domain_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "registered_at": { + "name": "registered_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "auto_renew": { + "name": "auto_renew", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "status": { + "name": "status", + "type": "domain_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "registrant_info": { + "name": "registrant_info", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "resource_type": { + "name": "resource_type", + "type": "domain_resource_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "app_id": { + "name": "app_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "container_id": { + "name": "container_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "mcp_id": { + "name": "mcp_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "nameserver_mode": { + "name": "nameserver_mode", + "type": "domain_nameserver_mode", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'vercel'" + }, + "dns_records": { + "name": "dns_records", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "ssl_status": { + "name": "ssl_status", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'pending'" + }, + "ssl_expires_at": { + "name": "ssl_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "verified": { + "name": "verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "verification_token": { + "name": "verification_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "verified_at": { + "name": "verified_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "moderation_status": { + "name": "moderation_status", + "type": "domain_moderation_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'clean'" + }, + "moderation_flags": { + "name": "moderation_flags", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "last_health_check": { + "name": "last_health_check", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "is_live": { + "name": "is_live", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "health_check_error": { + "name": "health_check_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "content_hash": { + "name": "content_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_content_scan_at": { + "name": "last_content_scan_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_ai_scan_at": { + "name": "last_ai_scan_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "ai_scan_model": { + "name": "ai_scan_model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "content_scan_confidence": { + "name": "content_scan_confidence", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "content_scan_cache": { + "name": "content_scan_cache", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "suspended_at": { + "name": "suspended_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "suspension_reason": { + "name": "suspension_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "suspension_notification": { + "name": "suspension_notification", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "owner_notified_at": { + "name": "owner_notified_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "purchase_price": { + "name": "purchase_price", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "renewal_price": { + "name": "renewal_price", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payment_method": { + "name": "payment_method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_payment_intent_id": { + "name": "stripe_payment_intent_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "managed_domains_org_idx": { + "name": "managed_domains_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "managed_domains_domain_idx": { + "name": "managed_domains_domain_idx", + "columns": [ + { + "expression": "domain", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "managed_domains_app_idx": { + "name": "managed_domains_app_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "managed_domains_container_idx": { + "name": "managed_domains_container_idx", + "columns": [ + { + "expression": "container_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "managed_domains_agent_idx": { + "name": "managed_domains_agent_idx", + "columns": [ + { + "expression": "agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "managed_domains_mcp_idx": { + "name": "managed_domains_mcp_idx", + "columns": [ + { + "expression": "mcp_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "managed_domains_status_idx": { + "name": "managed_domains_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "managed_domains_moderation_idx": { + "name": "managed_domains_moderation_idx", + "columns": [ + { + "expression": "moderation_status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "managed_domains_expires_idx": { + "name": "managed_domains_expires_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "managed_domains_content_scan_idx": { + "name": "managed_domains_content_scan_idx", + "columns": [ + { + "expression": "last_content_scan_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "managed_domains_suspended_idx": { + "name": "managed_domains_suspended_idx", + "columns": [ + { + "expression": "suspended_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "managed_domains_organization_id_organizations_id_fk": { + "name": "managed_domains_organization_id_organizations_id_fk", + "tableFrom": "managed_domains", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "managed_domains_app_id_apps_id_fk": { + "name": "managed_domains_app_id_apps_id_fk", + "tableFrom": "managed_domains", + "tableTo": "apps", + "columnsFrom": [ + "app_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "managed_domains_container_id_containers_id_fk": { + "name": "managed_domains_container_id_containers_id_fk", + "tableFrom": "managed_domains", + "tableTo": "containers", + "columnsFrom": [ + "container_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "managed_domains_agent_id_user_characters_id_fk": { + "name": "managed_domains_agent_id_user_characters_id_fk", + "tableFrom": "managed_domains", + "tableTo": "user_characters", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "managed_domains_mcp_id_user_mcps_id_fk": { + "name": "managed_domains_mcp_id_user_mcps_id_fk", + "tableFrom": "managed_domains", + "tableTo": "user_mcps", + "columnsFrom": [ + "mcp_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "managed_domains_domain_unique": { + "name": "managed_domains_domain_unique", + "nullsNotDistinct": false, + "columns": [ + "domain" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.milady_pairing_tokens": { + "name": "milady_pairing_tokens", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "instance_url": { + "name": "instance_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expected_origin": { + "name": "expected_origin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "milady_pairing_tokens_token_hash_idx": { + "name": "milady_pairing_tokens_token_hash_idx", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "milady_pairing_tokens_expires_at_idx": { + "name": "milady_pairing_tokens_expires_at_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "milady_pairing_tokens_agent_id_idx": { + "name": "milady_pairing_tokens_agent_id_idx", + "columns": [ + { + "expression": "agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "milady_pairing_tokens_organization_id_organizations_id_fk": { + "name": "milady_pairing_tokens_organization_id_organizations_id_fk", + "tableFrom": "milady_pairing_tokens", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "milady_pairing_tokens_user_id_users_id_fk": { + "name": "milady_pairing_tokens_user_id_users_id_fk", + "tableFrom": "milady_pairing_tokens", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "milady_pairing_tokens_agent_id_milady_sandboxes_id_fk": { + "name": "milady_pairing_tokens_agent_id_milady_sandboxes_id_fk", + "tableFrom": "milady_pairing_tokens", + "tableTo": "milady_sandboxes", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "milady_pairing_tokens_token_hash_unique": { + "name": "milady_pairing_tokens_token_hash_unique", + "nullsNotDistinct": false, + "columns": [ + "token_hash" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.milady_sandbox_backups": { + "name": "milady_sandbox_backups", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "sandbox_record_id": { + "name": "sandbox_record_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "snapshot_type": { + "name": "snapshot_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state_data": { + "name": "state_data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "vercel_snapshot_id": { + "name": "vercel_snapshot_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "size_bytes": { + "name": "size_bytes", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "milady_sandbox_backups_sandbox_idx": { + "name": "milady_sandbox_backups_sandbox_idx", + "columns": [ + { + "expression": "sandbox_record_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "milady_sandbox_backups_created_at_idx": { + "name": "milady_sandbox_backups_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "milady_sandbox_backups_sandbox_record_id_milady_sandboxes_id_fk": { + "name": "milady_sandbox_backups_sandbox_record_id_milady_sandboxes_id_fk", + "tableFrom": "milady_sandbox_backups", + "tableTo": "milady_sandboxes", + "columnsFrom": [ + "sandbox_record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.milady_sandboxes": { + "name": "milady_sandboxes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "character_id": { + "name": "character_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "sandbox_id": { + "name": "sandbox_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "bridge_url": { + "name": "bridge_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "health_url": { + "name": "health_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agent_config": { + "name": "agent_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "neon_project_id": { + "name": "neon_project_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "neon_branch_id": { + "name": "neon_branch_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "database_uri": { + "name": "database_uri", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "database_status": { + "name": "database_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'none'" + }, + "database_error": { + "name": "database_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "snapshot_id": { + "name": "snapshot_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_backup_at": { + "name": "last_backup_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_heartbeat_at": { + "name": "last_heartbeat_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error_count": { + "name": "error_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "environment_vars": { + "name": "environment_vars", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "node_id": { + "name": "node_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "container_name": { + "name": "container_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bridge_port": { + "name": "bridge_port", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "web_ui_port": { + "name": "web_ui_port", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "headscale_ip": { + "name": "headscale_ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "docker_image": { + "name": "docker_image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "billing_status": { + "name": "billing_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "last_billed_at": { + "name": "last_billed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "hourly_rate": { + "name": "hourly_rate", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false, + "default": "'0.0100'" + }, + "total_billed": { + "name": "total_billed", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "shutdown_warning_sent_at": { + "name": "shutdown_warning_sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "scheduled_shutdown_at": { + "name": "scheduled_shutdown_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "milady_sandboxes_organization_idx": { + "name": "milady_sandboxes_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "milady_sandboxes_user_idx": { + "name": "milady_sandboxes_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "milady_sandboxes_status_idx": { + "name": "milady_sandboxes_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "milady_sandboxes_character_idx": { + "name": "milady_sandboxes_character_idx", + "columns": [ + { + "expression": "character_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "milady_sandboxes_sandbox_id_idx": { + "name": "milady_sandboxes_sandbox_id_idx", + "columns": [ + { + "expression": "sandbox_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "milady_sandboxes_billing_status_idx": { + "name": "milady_sandboxes_billing_status_idx", + "columns": [ + { + "expression": "billing_status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "milady_sandboxes_organization_id_organizations_id_fk": { + "name": "milady_sandboxes_organization_id_organizations_id_fk", + "tableFrom": "milady_sandboxes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "milady_sandboxes_user_id_users_id_fk": { + "name": "milady_sandboxes_user_id_users_id_fk", + "tableFrom": "milady_sandboxes", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "milady_sandboxes_character_id_user_characters_id_fk": { + "name": "milady_sandboxes_character_id_user_characters_id_fk", + "tableFrom": "milady_sandboxes", + "tableTo": "user_characters", + "columnsFrom": [ + "character_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.model_pricing": { + "name": "model_pricing", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "input_cost_per_1k": { + "name": "input_cost_per_1k", + "type": "numeric(10, 6)", + "primaryKey": false, + "notNull": true + }, + "output_cost_per_1k": { + "name": "output_cost_per_1k", + "type": "numeric(10, 6)", + "primaryKey": false, + "notNull": true + }, + "input_cost_per_token": { + "name": "input_cost_per_token", + "type": "numeric(10, 6)", + "primaryKey": false, + "notNull": false + }, + "output_cost_per_token": { + "name": "output_cost_per_token", + "type": "numeric(10, 6)", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "effective_from": { + "name": "effective_from", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "effective_until": { + "name": "effective_until", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "model_pricing_provider_model_idx": { + "name": "model_pricing_provider_model_idx", + "columns": [ + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "model", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "model_pricing_active_idx": { + "name": "model_pricing_active_idx", + "columns": [ + { + "expression": "is_active", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.moderation_violations": { + "name": "moderation_violations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "room_id": { + "name": "room_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "message_text": { + "name": "message_text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "categories": { + "name": "categories", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "scores": { + "name": "scores", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "action": { + "name": "action", + "type": "moderation_action", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "reviewed_by": { + "name": "reviewed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "review_notes": { + "name": "review_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "moderation_violations_user_id_idx": { + "name": "moderation_violations_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "moderation_violations_action_idx": { + "name": "moderation_violations_action_idx", + "columns": [ + { + "expression": "action", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "moderation_violations_created_at_idx": { + "name": "moderation_violations_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "moderation_violations_room_id_idx": { + "name": "moderation_violations_room_id_idx", + "columns": [ + { + "expression": "room_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "moderation_violations_user_id_users_id_fk": { + "name": "moderation_violations_user_id_users_id_fk", + "tableFrom": "moderation_violations", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "moderation_violations_reviewed_by_users_id_fk": { + "name": "moderation_violations_reviewed_by_users_id_fk", + "tableFrom": "moderation_violations", + "tableTo": "users", + "columnsFrom": [ + "reviewed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_moderation_status": { + "name": "user_moderation_status", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "user_mod_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'clean'" + }, + "total_violations": { + "name": "total_violations", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "warning_count": { + "name": "warning_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "risk_score": { + "name": "risk_score", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "banned_by": { + "name": "banned_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "banned_at": { + "name": "banned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "ban_reason": { + "name": "ban_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_violation_at": { + "name": "last_violation_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_warning_at": { + "name": "last_warning_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "user_moderation_status_user_id_idx": { + "name": "user_moderation_status_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_moderation_status_status_idx": { + "name": "user_moderation_status_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_moderation_status_risk_score_idx": { + "name": "user_moderation_status_risk_score_idx", + "columns": [ + { + "expression": "risk_score", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_moderation_status_total_violations_idx": { + "name": "user_moderation_status_total_violations_idx", + "columns": [ + { + "expression": "total_violations", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_moderation_status_user_id_users_id_fk": { + "name": "user_moderation_status_user_id_users_id_fk", + "tableFrom": "user_moderation_status", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_moderation_status_banned_by_users_id_fk": { + "name": "user_moderation_status_banned_by_users_id_fk", + "tableFrom": "user_moderation_status", + "tableTo": "users", + "columnsFrom": [ + "banned_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_moderation_status_user_id_unique": { + "name": "user_moderation_status_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.org_rate_limit_overrides": { + "name": "org_rate_limit_overrides", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "completions_rpm": { + "name": "completions_rpm", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "embeddings_rpm": { + "name": "embeddings_rpm", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "standard_rpm": { + "name": "standard_rpm", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "strict_rpm": { + "name": "strict_rpm", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "org_rate_limit_overrides_organization_id_organizations_id_fk": { + "name": "org_rate_limit_overrides_organization_id_organizations_id_fk", + "tableFrom": "org_rate_limit_overrides", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "org_rate_limit_overrides_organization_id_unique": { + "name": "org_rate_limit_overrides_organization_id_unique", + "nullsNotDistinct": false, + "columns": [ + "organization_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization_billing": { + "name": "organization_billing", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "billing_email": { + "name": "billing_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tax_id_type": { + "name": "tax_id_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tax_id_value": { + "name": "tax_id_value", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "billing_address": { + "name": "billing_address", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "stripe_payment_method_id": { + "name": "stripe_payment_method_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_default_payment_method": { + "name": "stripe_default_payment_method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auto_top_up_enabled": { + "name": "auto_top_up_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "auto_top_up_amount": { + "name": "auto_top_up_amount", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": false + }, + "auto_top_up_threshold": { + "name": "auto_top_up_threshold", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": false, + "default": "'0.000000'" + }, + "auto_top_up_subscription_id": { + "name": "auto_top_up_subscription_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "org_billing_organization_idx": { + "name": "org_billing_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "org_billing_stripe_customer_idx": { + "name": "org_billing_stripe_customer_idx", + "columns": [ + { + "expression": "stripe_customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "org_billing_auto_top_up_enabled_idx": { + "name": "org_billing_auto_top_up_enabled_idx", + "columns": [ + { + "expression": "auto_top_up_enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "organization_billing_organization_id_organizations_id_fk": { + "name": "organization_billing_organization_id_organizations_id_fk", + "tableFrom": "organization_billing", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organization_billing_organization_id_unique": { + "name": "organization_billing_organization_id_unique", + "nullsNotDistinct": false, + "columns": [ + "organization_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization_config": { + "name": "organization_config", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "webhook_url": { + "name": "webhook_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "webhook_secret": { + "name": "webhook_secret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "max_api_requests": { + "name": "max_api_requests", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 1000 + }, + "max_tokens_per_request": { + "name": "max_tokens_per_request", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "allowed_models": { + "name": "allowed_models", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "allowed_providers": { + "name": "allowed_providers", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "settings": { + "name": "settings", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "org_config_organization_idx": { + "name": "org_config_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "organization_config_organization_id_organizations_id_fk": { + "name": "organization_config_organization_id_organizations_id_fk", + "tableFrom": "organization_config", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organization_config_organization_id_unique": { + "name": "organization_config_organization_id_unique", + "nullsNotDistinct": false, + "columns": [ + "organization_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization_encryption_keys": { + "name": "organization_encryption_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "encrypted_dek": { + "name": "encrypted_dek", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key_version": { + "name": "key_version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "algorithm": { + "name": "algorithm", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'aes-256-gcm'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "rotated_at": { + "name": "rotated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "org_encryption_keys_org_idx": { + "name": "org_encryption_keys_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "organization_encryption_keys_organization_id_organizations_id_fk": { + "name": "organization_encryption_keys_organization_id_organizations_id_fk", + "tableFrom": "organization_encryption_keys", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organization_encryption_keys_org_unique": { + "name": "organization_encryption_keys_org_unique", + "nullsNotDistinct": false, + "columns": [ + "organization_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization_invites": { + "name": "organization_invites", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "inviter_user_id": { + "name": "inviter_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "invited_email": { + "name": "invited_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invited_role": { + "name": "invited_role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "accepted_at": { + "name": "accepted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "accepted_by_user_id": { + "name": "accepted_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "organization_invites_org_id_idx": { + "name": "organization_invites_org_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "organization_invites_email_idx": { + "name": "organization_invites_email_idx", + "columns": [ + { + "expression": "invited_email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "organization_invites_token_idx": { + "name": "organization_invites_token_idx", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "organization_invites_status_idx": { + "name": "organization_invites_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "organization_invites_organization_id_organizations_id_fk": { + "name": "organization_invites_organization_id_organizations_id_fk", + "tableFrom": "organization_invites", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "organization_invites_inviter_user_id_users_id_fk": { + "name": "organization_invites_inviter_user_id_users_id_fk", + "tableFrom": "organization_invites", + "tableTo": "users", + "columnsFrom": [ + "inviter_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "organization_invites_accepted_by_user_id_users_id_fk": { + "name": "organization_invites_accepted_by_user_id_users_id_fk", + "tableFrom": "organization_invites", + "tableTo": "users", + "columnsFrom": [ + "accepted_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organization_invites_token_hash_unique": { + "name": "organization_invites_token_hash_unique", + "nullsNotDistinct": false, + "columns": [ + "token_hash" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organizations": { + "name": "organizations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "credit_balance": { + "name": "credit_balance", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true, + "default": "'100.000000'" + }, + "settings": { + "name": "settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "billing_email": { + "name": "billing_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_payment_method_id": { + "name": "stripe_payment_method_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_default_payment_method": { + "name": "stripe_default_payment_method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auto_top_up_enabled": { + "name": "auto_top_up_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "auto_top_up_threshold": { + "name": "auto_top_up_threshold", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "auto_top_up_amount": { + "name": "auto_top_up_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "steward_tenant_id": { + "name": "steward_tenant_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "steward_tenant_api_key": { + "name": "steward_tenant_api_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "organizations_slug_idx": { + "name": "organizations_slug_idx", + "columns": [ + { + "expression": "slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organizations_slug_unique": { + "name": "organizations_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + }, + "organizations_steward_tenant_id_unique": { + "name": "organizations_steward_tenant_id_unique", + "nullsNotDistinct": false, + "columns": [ + "steward_tenant_id" + ] + } + }, + "policies": {}, + "checkConstraints": { + "credit_balance_non_negative": { + "name": "credit_balance_non_negative", + "value": "\"organizations\".\"credit_balance\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.platform_credential_sessions": { + "name": "platform_credential_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "app_id": { + "name": "app_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "requesting_user_id": { + "name": "requesting_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "platform": { + "name": "platform", + "type": "platform_credential_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "requested_scopes": { + "name": "requested_scopes", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "oauth_state": { + "name": "oauth_state", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "callback_url": { + "name": "callback_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "callback_type": { + "name": "callback_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "callback_context": { + "name": "callback_context", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "credential_id": { + "name": "credential_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "error_code": { + "name": "error_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "platform_credential_sessions_session_idx": { + "name": "platform_credential_sessions_session_idx", + "columns": [ + { + "expression": "session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "platform_credential_sessions_org_idx": { + "name": "platform_credential_sessions_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "platform_credential_sessions_oauth_state_idx": { + "name": "platform_credential_sessions_oauth_state_idx", + "columns": [ + { + "expression": "oauth_state", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "platform_credential_sessions_status_idx": { + "name": "platform_credential_sessions_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "platform_credential_sessions_expires_idx": { + "name": "platform_credential_sessions_expires_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "platform_credential_sessions_organization_id_organizations_id_fk": { + "name": "platform_credential_sessions_organization_id_organizations_id_fk", + "tableFrom": "platform_credential_sessions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "platform_credential_sessions_app_id_apps_id_fk": { + "name": "platform_credential_sessions_app_id_apps_id_fk", + "tableFrom": "platform_credential_sessions", + "tableTo": "apps", + "columnsFrom": [ + "app_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "platform_credential_sessions_requesting_user_id_users_id_fk": { + "name": "platform_credential_sessions_requesting_user_id_users_id_fk", + "tableFrom": "platform_credential_sessions", + "tableTo": "users", + "columnsFrom": [ + "requesting_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "platform_credential_sessions_credential_id_platform_credentials_id_fk": { + "name": "platform_credential_sessions_credential_id_platform_credentials_id_fk", + "tableFrom": "platform_credential_sessions", + "tableTo": "platform_credentials", + "columnsFrom": [ + "credential_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "platform_credential_sessions_session_id_unique": { + "name": "platform_credential_sessions_session_id_unique", + "nullsNotDistinct": false, + "columns": [ + "session_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.platform_credentials": { + "name": "platform_credentials", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "app_id": { + "name": "app_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "platform": { + "name": "platform", + "type": "platform_credential_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "platform_user_id": { + "name": "platform_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "platform_username": { + "name": "platform_username", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "platform_display_name": { + "name": "platform_display_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "platform_avatar_url": { + "name": "platform_avatar_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "platform_email": { + "name": "platform_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "platform_credential_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_secret_id": { + "name": "access_token_secret_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "refresh_token_secret_id": { + "name": "refresh_token_secret_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "token_expires_at": { + "name": "token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scopes": { + "name": "scopes", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "api_key_secret_id": { + "name": "api_key_secret_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "granted_permissions": { + "name": "granted_permissions", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "source_type": { + "name": "source_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_context": { + "name": "source_context", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "profile_data": { + "name": "profile_data", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "linked_at": { + "name": "linked_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_refreshed_at": { + "name": "last_refreshed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "platform_credentials_org_idx": { + "name": "platform_credentials_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "platform_credentials_user_idx": { + "name": "platform_credentials_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "platform_credentials_app_idx": { + "name": "platform_credentials_app_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "platform_credentials_platform_user_idx": { + "name": "platform_credentials_platform_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "platform", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "platform_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "platform_credentials_user_platform_idx": { + "name": "platform_credentials_user_platform_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "platform", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"platform_credentials\".\"user_id\" is not null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "platform_credentials_status_idx": { + "name": "platform_credentials_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "platform_credentials_organization_id_organizations_id_fk": { + "name": "platform_credentials_organization_id_organizations_id_fk", + "tableFrom": "platform_credentials", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "platform_credentials_user_id_users_id_fk": { + "name": "platform_credentials_user_id_users_id_fk", + "tableFrom": "platform_credentials", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "platform_credentials_app_id_apps_id_fk": { + "name": "platform_credentials_app_id_apps_id_fk", + "tableFrom": "platform_credentials", + "tableTo": "apps", + "columnsFrom": [ + "app_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.provider_health": { + "name": "provider_health", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'healthy'" + }, + "last_checked": { + "name": "last_checked", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "response_time": { + "name": "response_time", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "error_rate": { + "name": "error_rate", + "type": "numeric(5, 4)", + "primaryKey": false, + "notNull": false, + "default": "'0'" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "provider_health_provider_idx": { + "name": "provider_health_provider_idx", + "columns": [ + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "provider_health_status_idx": { + "name": "provider_health_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.redeemable_earnings": { + "name": "redeemable_earnings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "total_earned": { + "name": "total_earned", + "type": "numeric(18, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0.0000'" + }, + "total_redeemed": { + "name": "total_redeemed", + "type": "numeric(18, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0.0000'" + }, + "total_pending": { + "name": "total_pending", + "type": "numeric(18, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0.0000'" + }, + "available_balance": { + "name": "available_balance", + "type": "numeric(18, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0.0000'" + }, + "earned_from_miniapps": { + "name": "earned_from_miniapps", + "type": "numeric(18, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0.0000'" + }, + "earned_from_agents": { + "name": "earned_from_agents", + "type": "numeric(18, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0.0000'" + }, + "earned_from_mcps": { + "name": "earned_from_mcps", + "type": "numeric(18, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0.0000'" + }, + "earned_from_affiliates": { + "name": "earned_from_affiliates", + "type": "numeric(18, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0.0000'" + }, + "earned_from_app_owner_shares": { + "name": "earned_from_app_owner_shares", + "type": "numeric(18, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0.0000'" + }, + "earned_from_creator_shares": { + "name": "earned_from_creator_shares", + "type": "numeric(18, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0.0000'" + }, + "last_earning_at": { + "name": "last_earning_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_redemption_at": { + "name": "last_redemption_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "numeric(10, 0)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "redeemable_earnings_user_idx": { + "name": "redeemable_earnings_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "redeemable_earnings_user_id_users_id_fk": { + "name": "redeemable_earnings_user_id_users_id_fk", + "tableFrom": "redeemable_earnings", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "redeemable_earnings_user_id_unique": { + "name": "redeemable_earnings_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": { + "available_balance_non_negative": { + "name": "available_balance_non_negative", + "value": "\"redeemable_earnings\".\"available_balance\" >= 0" + }, + "totals_consistent": { + "name": "totals_consistent", + "value": "\"redeemable_earnings\".\"total_earned\" >= \"redeemable_earnings\".\"total_redeemed\" + \"redeemable_earnings\".\"total_pending\"" + } + }, + "isRLSEnabled": false + }, + "public.redeemable_earnings_ledger": { + "name": "redeemable_earnings_ledger", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "entry_type": { + "name": "entry_type", + "type": "ledger_entry_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(18, 4)", + "primaryKey": false, + "notNull": true + }, + "balance_after": { + "name": "balance_after", + "type": "numeric(18, 4)", + "primaryKey": false, + "notNull": true + }, + "earnings_source": { + "name": "earnings_source", + "type": "earnings_source", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "source_id": { + "name": "source_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "redemption_id": { + "name": "redemption_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "redeemable_earnings_ledger_user_idx": { + "name": "redeemable_earnings_ledger_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "redeemable_earnings_ledger_user_created_idx": { + "name": "redeemable_earnings_ledger_user_created_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "redeemable_earnings_ledger_type_idx": { + "name": "redeemable_earnings_ledger_type_idx", + "columns": [ + { + "expression": "entry_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "redeemable_earnings_ledger_redemption_idx": { + "name": "redeemable_earnings_ledger_redemption_idx", + "columns": [ + { + "expression": "redemption_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "redeemable_earnings_ledger_source_idx": { + "name": "redeemable_earnings_ledger_source_idx", + "columns": [ + { + "expression": "earnings_source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "redeemable_earnings_ledger_user_id_users_id_fk": { + "name": "redeemable_earnings_ledger_user_id_users_id_fk", + "tableFrom": "redeemable_earnings_ledger", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.redeemed_earnings_tracking": { + "name": "redeemed_earnings_tracking", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "ledger_entry_id": { + "name": "ledger_entry_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "redemption_id": { + "name": "redemption_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "amount_redeemed": { + "name": "amount_redeemed", + "type": "numeric(18, 4)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "redeemed_tracking_ledger_idx": { + "name": "redeemed_tracking_ledger_idx", + "columns": [ + { + "expression": "ledger_entry_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "redeemed_tracking_redemption_idx": { + "name": "redeemed_tracking_redemption_idx", + "columns": [ + { + "expression": "redemption_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "redeemed_earnings_tracking_ledger_entry_id_unique": { + "name": "redeemed_earnings_tracking_ledger_entry_id_unique", + "nullsNotDistinct": false, + "columns": [ + "ledger_entry_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.referral_codes": { + "name": "referral_codes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parent_referral_id": { + "name": "parent_referral_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "total_referrals": { + "name": "total_referrals", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_signup_earnings": { + "name": "total_signup_earnings", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "total_qualified_earnings": { + "name": "total_qualified_earnings", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "total_commission_earnings": { + "name": "total_commission_earnings", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "referral_codes_user_idx": { + "name": "referral_codes_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "referral_codes_code_idx": { + "name": "referral_codes_code_idx", + "columns": [ + { + "expression": "code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "referral_codes_user_id_users_id_fk": { + "name": "referral_codes_user_id_users_id_fk", + "tableFrom": "referral_codes", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "referral_codes_code_unique": { + "name": "referral_codes_code_unique", + "nullsNotDistinct": false, + "columns": [ + "code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.referral_signups": { + "name": "referral_signups", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "referral_code_id": { + "name": "referral_code_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "referrer_user_id": { + "name": "referrer_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "referred_user_id": { + "name": "referred_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "app_owner_id": { + "name": "app_owner_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "creator_id": { + "name": "creator_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "signup_bonus_credited": { + "name": "signup_bonus_credited", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "signup_bonus_amount": { + "name": "signup_bonus_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false, + "default": "'0.00'" + }, + "qualified_at": { + "name": "qualified_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "qualified_bonus_credited": { + "name": "qualified_bonus_credited", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "qualified_bonus_amount": { + "name": "qualified_bonus_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false, + "default": "'0.00'" + }, + "total_commission_earned": { + "name": "total_commission_earned", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "referral_signups_referred_user_idx": { + "name": "referral_signups_referred_user_idx", + "columns": [ + { + "expression": "referred_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "referral_signups_referrer_idx": { + "name": "referral_signups_referrer_idx", + "columns": [ + { + "expression": "referrer_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "referral_signups_code_idx": { + "name": "referral_signups_code_idx", + "columns": [ + { + "expression": "referral_code_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "referral_signups_referral_code_id_referral_codes_id_fk": { + "name": "referral_signups_referral_code_id_referral_codes_id_fk", + "tableFrom": "referral_signups", + "tableTo": "referral_codes", + "columnsFrom": [ + "referral_code_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "referral_signups_referrer_user_id_users_id_fk": { + "name": "referral_signups_referrer_user_id_users_id_fk", + "tableFrom": "referral_signups", + "tableTo": "users", + "columnsFrom": [ + "referrer_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "referral_signups_referred_user_id_users_id_fk": { + "name": "referral_signups_referred_user_id_users_id_fk", + "tableFrom": "referral_signups", + "tableTo": "users", + "columnsFrom": [ + "referred_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "referral_signups_app_owner_id_users_id_fk": { + "name": "referral_signups_app_owner_id_users_id_fk", + "tableFrom": "referral_signups", + "tableTo": "users", + "columnsFrom": [ + "app_owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "referral_signups_creator_id_users_id_fk": { + "name": "referral_signups_creator_id_users_id_fk", + "tableFrom": "referral_signups", + "tableTo": "users", + "columnsFrom": [ + "creator_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.social_share_rewards": { + "name": "social_share_rewards", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "platform": { + "name": "platform", + "type": "social_platform", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "share_type": { + "name": "share_type", + "type": "share_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "share_url": { + "name": "share_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "share_intent_at": { + "name": "share_intent_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "verified": { + "name": "verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "credits_awarded": { + "name": "credits_awarded", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "social_share_rewards_user_idx": { + "name": "social_share_rewards_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "social_share_rewards_platform_idx": { + "name": "social_share_rewards_platform_idx", + "columns": [ + { + "expression": "platform", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "social_share_rewards_user_platform_date_idx": { + "name": "social_share_rewards_user_platform_date_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "platform", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "social_share_rewards_user_id_users_id_fk": { + "name": "social_share_rewards_user_id_users_id_fk", + "tableFrom": "social_share_rewards", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.retention_cohorts": { + "name": "retention_cohorts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "cohort_date": { + "name": "cohort_date", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "platform": { + "name": "platform", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cohort_size": { + "name": "cohort_size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "d1_retained": { + "name": "d1_retained", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "d7_retained": { + "name": "d7_retained", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "d30_retained": { + "name": "d30_retained", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "retention_cohorts_cohort_platform_idx": { + "name": "retention_cohorts_cohort_platform_idx", + "columns": [ + { + "expression": "cohort_date", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "platform", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.app_secret_requirements": { + "name": "app_secret_requirements", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "app_id": { + "name": "app_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "secret_name": { + "name": "secret_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "required": { + "name": "required", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "approved": { + "name": "approved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "approved_by": { + "name": "approved_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "approved_at": { + "name": "approved_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "app_secret_requirements_app_secret_idx": { + "name": "app_secret_requirements_app_secret_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "secret_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_secret_requirements_app_idx": { + "name": "app_secret_requirements_app_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "app_secret_requirements_approved_idx": { + "name": "app_secret_requirements_approved_idx", + "columns": [ + { + "expression": "approved", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "app_secret_requirements_app_id_apps_id_fk": { + "name": "app_secret_requirements_app_id_apps_id_fk", + "tableFrom": "app_secret_requirements", + "tableTo": "apps", + "columnsFrom": [ + "app_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "app_secret_requirements_approved_by_users_id_fk": { + "name": "app_secret_requirements_approved_by_users_id_fk", + "tableFrom": "app_secret_requirements", + "tableTo": "users", + "columnsFrom": [ + "approved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_sessions": { + "name": "oauth_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_account_id": { + "name": "provider_account_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "encrypted_access_token": { + "name": "encrypted_access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "encrypted_refresh_token": { + "name": "encrypted_refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "token_type": { + "name": "token_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'Bearer'" + }, + "encryption_key_id": { + "name": "encryption_key_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "encrypted_dek": { + "name": "encrypted_dek", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "nonce": { + "name": "nonce", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "auth_tag": { + "name": "auth_tag", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_encrypted_dek": { + "name": "refresh_encrypted_dek", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_nonce": { + "name": "refresh_nonce", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_auth_tag": { + "name": "refresh_auth_tag", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scopes": { + "name": "scopes", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "encrypted_provider_data": { + "name": "encrypted_provider_data", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_data_nonce": { + "name": "provider_data_nonce", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_data_auth_tag": { + "name": "provider_data_auth_tag", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_refreshed_at": { + "name": "last_refreshed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refresh_count": { + "name": "refresh_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "is_valid": { + "name": "is_valid", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "revoke_reason": { + "name": "revoke_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "oauth_sessions_org_provider_idx": { + "name": "oauth_sessions_org_provider_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "oauth_sessions_user_provider_idx": { + "name": "oauth_sessions_user_provider_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "oauth_sessions_provider_idx": { + "name": "oauth_sessions_provider_idx", + "columns": [ + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "oauth_sessions_expires_idx": { + "name": "oauth_sessions_expires_idx", + "columns": [ + { + "expression": "access_token_expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "oauth_sessions_valid_idx": { + "name": "oauth_sessions_valid_idx", + "columns": [ + { + "expression": "is_valid", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "oauth_sessions_organization_id_organizations_id_fk": { + "name": "oauth_sessions_organization_id_organizations_id_fk", + "tableFrom": "oauth_sessions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "oauth_sessions_user_id_users_id_fk": { + "name": "oauth_sessions_user_id_users_id_fk", + "tableFrom": "oauth_sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.secret_audit_log": { + "name": "secret_audit_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "secret_id": { + "name": "secret_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "oauth_session_id": { + "name": "oauth_session_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "action": { + "name": "action", + "type": "secret_audit_action", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "secret_name": { + "name": "secret_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actor_type": { + "name": "actor_type", + "type": "secret_actor_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_email": { + "name": "actor_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "request_id": { + "name": "request_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "secret_audit_log_secret_idx": { + "name": "secret_audit_log_secret_idx", + "columns": [ + { + "expression": "secret_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "secret_audit_log_oauth_idx": { + "name": "secret_audit_log_oauth_idx", + "columns": [ + { + "expression": "oauth_session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "secret_audit_log_org_idx": { + "name": "secret_audit_log_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "secret_audit_log_action_idx": { + "name": "secret_audit_log_action_idx", + "columns": [ + { + "expression": "action", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "secret_audit_log_actor_idx": { + "name": "secret_audit_log_actor_idx", + "columns": [ + { + "expression": "actor_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "actor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "secret_audit_log_created_at_idx": { + "name": "secret_audit_log_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "secret_audit_log_org_action_time_idx": { + "name": "secret_audit_log_org_action_time_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "action", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.secret_bindings": { + "name": "secret_bindings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "secret_id": { + "name": "secret_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "project_type": { + "name": "project_type", + "type": "secret_project_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "secret_bindings_secret_project_idx": { + "name": "secret_bindings_secret_project_idx", + "columns": [ + { + "expression": "secret_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "project_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "secret_bindings_org_idx": { + "name": "secret_bindings_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "secret_bindings_project_idx": { + "name": "secret_bindings_project_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "project_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "secret_bindings_secret_idx": { + "name": "secret_bindings_secret_idx", + "columns": [ + { + "expression": "secret_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "secret_bindings_organization_id_organizations_id_fk": { + "name": "secret_bindings_organization_id_organizations_id_fk", + "tableFrom": "secret_bindings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "secret_bindings_secret_id_secrets_id_fk": { + "name": "secret_bindings_secret_id_secrets_id_fk", + "tableFrom": "secret_bindings", + "tableTo": "secrets", + "columnsFrom": [ + "secret_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "secret_bindings_created_by_users_id_fk": { + "name": "secret_bindings_created_by_users_id_fk", + "tableFrom": "secret_bindings", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.secrets": { + "name": "secrets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "scope": { + "name": "scope", + "type": "secret_scope", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'organization'" + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "project_type": { + "name": "project_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "environment": { + "name": "environment", + "type": "secret_environment", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "secret_provider", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "provider_metadata": { + "name": "provider_metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "encrypted_value": { + "name": "encrypted_value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "encryption_key_id": { + "name": "encryption_key_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "encrypted_dek": { + "name": "encrypted_dek", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "nonce": { + "name": "nonce", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "auth_tag": { + "name": "auth_tag", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "last_rotated_at": { + "name": "last_rotated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "last_accessed_at": { + "name": "last_accessed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "access_count": { + "name": "access_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "secrets_org_name_project_env_idx": { + "name": "secrets_org_name_project_env_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "environment", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "secrets_org_idx": { + "name": "secrets_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "secrets_project_idx": { + "name": "secrets_project_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "secrets_scope_idx": { + "name": "secrets_scope_idx", + "columns": [ + { + "expression": "scope", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "secrets_env_idx": { + "name": "secrets_env_idx", + "columns": [ + { + "expression": "environment", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "secrets_name_idx": { + "name": "secrets_name_idx", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "secrets_expires_idx": { + "name": "secrets_expires_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "secrets_provider_idx": { + "name": "secrets_provider_idx", + "columns": [ + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "secrets_organization_id_organizations_id_fk": { + "name": "secrets_organization_id_organizations_id_fk", + "tableFrom": "secrets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "secrets_created_by_users_id_fk": { + "name": "secrets_created_by_users_id_fk", + "tableFrom": "secrets", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.seo_artifacts": { + "name": "seo_artifacts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "seo_artifact_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "seo_provider", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "seo_artifacts_request_idx": { + "name": "seo_artifacts_request_idx", + "columns": [ + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "seo_artifacts_type_idx": { + "name": "seo_artifacts_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "seo_artifacts_request_id_seo_requests_id_fk": { + "name": "seo_artifacts_request_id_seo_requests_id_fk", + "tableFrom": "seo_artifacts", + "tableTo": "seo_requests", + "columnsFrom": [ + "request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.seo_provider_calls": { + "name": "seo_provider_calls", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "seo_provider", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "operation": { + "name": "operation", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "seo_provider_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cost": { + "name": "cost", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "request_payload": { + "name": "request_payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response_payload": { + "name": "response_payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "seo_provider_calls_request_idx": { + "name": "seo_provider_calls_request_idx", + "columns": [ + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "seo_provider_calls_provider_idx": { + "name": "seo_provider_calls_provider_idx", + "columns": [ + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "seo_provider_calls_status_idx": { + "name": "seo_provider_calls_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "seo_provider_calls_request_id_seo_requests_id_fk": { + "name": "seo_provider_calls_request_id_seo_requests_id_fk", + "tableFrom": "seo_provider_calls", + "tableTo": "seo_requests", + "columnsFrom": [ + "request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.seo_requests": { + "name": "seo_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "app_id": { + "name": "app_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "api_key_id": { + "name": "api_key_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "seo_request_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "seo_request_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "page_url": { + "name": "page_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "locale": { + "name": "locale", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en-US'" + }, + "search_engine": { + "name": "search_engine", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'google'" + }, + "device": { + "name": "device", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'desktop'" + }, + "environment": { + "name": "environment", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'production'" + }, + "agent_identifier": { + "name": "agent_identifier", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "keywords": { + "name": "keywords", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "prompt_context": { + "name": "prompt_context", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "total_cost": { + "name": "total_cost", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "seo_requests_org_idx": { + "name": "seo_requests_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "seo_requests_app_idx": { + "name": "seo_requests_app_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "seo_requests_type_idx": { + "name": "seo_requests_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "seo_requests_status_idx": { + "name": "seo_requests_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "seo_requests_idempotency_idx": { + "name": "seo_requests_idempotency_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "seo_requests_organization_id_organizations_id_fk": { + "name": "seo_requests_organization_id_organizations_id_fk", + "tableFrom": "seo_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "seo_requests_app_id_apps_id_fk": { + "name": "seo_requests_app_id_apps_id_fk", + "tableFrom": "seo_requests", + "tableTo": "apps", + "columnsFrom": [ + "app_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "seo_requests_user_id_users_id_fk": { + "name": "seo_requests_user_id_users_id_fk", + "tableFrom": "seo_requests", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "seo_requests_api_key_id_api_keys_id_fk": { + "name": "seo_requests_api_key_id_api_keys_id_fk", + "tableFrom": "seo_requests", + "tableTo": "api_keys", + "columnsFrom": [ + "api_key_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.service_pricing": { + "name": "service_pricing", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "service_id": { + "name": "service_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "cost": { + "name": "cost", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "service_pricing_service_method_idx": { + "name": "service_pricing_service_method_idx", + "columns": [ + { + "expression": "service_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "method", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.service_pricing_audit": { + "name": "service_pricing_audit", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "service_pricing_id": { + "name": "service_pricing_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "service_id": { + "name": "service_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "old_cost": { + "name": "old_cost", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": false + }, + "new_cost": { + "name": "new_cost", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true + }, + "change_type": { + "name": "change_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "changed_by": { + "name": "changed_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "service_pricing_audit_service_idx": { + "name": "service_pricing_audit_service_idx", + "columns": [ + { + "expression": "service_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "service_pricing_audit_pricing_created_idx": { + "name": "service_pricing_audit_pricing_created_idx", + "columns": [ + { + "expression": "service_pricing_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "service_pricing_audit_service_pricing_id_service_pricing_id_fk": { + "name": "service_pricing_audit_service_pricing_id_service_pricing_id_fk", + "tableFrom": "service_pricing_audit", + "tableTo": "service_pricing", + "columnsFrom": [ + "service_pricing_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.telegram_chats": { + "name": "telegram_chats", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "chat_id": { + "name": "chat_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "chat_type": { + "name": "chat_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_admin": { + "name": "is_admin", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "can_post_messages": { + "name": "can_post_messages", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "telegram_chats_organization_id_idx": { + "name": "telegram_chats_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "telegram_chats_chat_id_idx": { + "name": "telegram_chats_chat_id_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "telegram_chats_organization_id_organizations_id_fk": { + "name": "telegram_chats_organization_id_organizations_id_fk", + "tableFrom": "telegram_chats", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.eliza_token_prices": { + "name": "eliza_token_prices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "network": { + "name": "network", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "price_usd": { + "name": "price_usd", + "type": "numeric(18, 8)", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "fetched_at": { + "name": "fetched_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + } + }, + "indexes": { + "eliza_token_prices_network_source_idx": { + "name": "eliza_token_prices_network_source_idx", + "columns": [ + { + "expression": "network", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "eliza_token_prices_expires_idx": { + "name": "eliza_token_prices_expires_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.redemption_limits": { + "name": "redemption_limits", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "daily_usd_total": { + "name": "daily_usd_total", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "redemption_count": { + "name": "redemption_count", + "type": "numeric(5, 0)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "redemption_limits_user_date_idx": { + "name": "redemption_limits_user_date_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "redemption_limits_user_id_users_id_fk": { + "name": "redemption_limits_user_id_users_id_fk", + "tableFrom": "redemption_limits", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.token_redemptions": { + "name": "token_redemptions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "app_id": { + "name": "app_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "points_amount": { + "name": "points_amount", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "usd_value": { + "name": "usd_value", + "type": "numeric(12, 4)", + "primaryKey": false, + "notNull": true + }, + "eliza_price_usd": { + "name": "eliza_price_usd", + "type": "numeric(18, 8)", + "primaryKey": false, + "notNull": true + }, + "eliza_amount": { + "name": "eliza_amount", + "type": "numeric(24, 8)", + "primaryKey": false, + "notNull": true + }, + "price_quote_expires_at": { + "name": "price_quote_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "network": { + "name": "network", + "type": "redemption_network", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "payout_address": { + "name": "payout_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "address_signature": { + "name": "address_signature", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "redemption_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "processing_started_at": { + "name": "processing_started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "processing_worker_id": { + "name": "processing_worker_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tx_hash": { + "name": "tx_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "retry_count": { + "name": "retry_count", + "type": "numeric(3, 0)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "requires_review": { + "name": "requires_review", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reviewed_by": { + "name": "reviewed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "review_notes": { + "name": "review_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "token_redemptions_user_idx": { + "name": "token_redemptions_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "token_redemptions_app_idx": { + "name": "token_redemptions_app_idx", + "columns": [ + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "token_redemptions_status_idx": { + "name": "token_redemptions_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "token_redemptions_status_created_idx": { + "name": "token_redemptions_status_created_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "token_redemptions_network_idx": { + "name": "token_redemptions_network_idx", + "columns": [ + { + "expression": "network", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "token_redemptions_payout_idx": { + "name": "token_redemptions_payout_idx", + "columns": [ + { + "expression": "payout_address", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "token_redemptions_pending_user_idx": { + "name": "token_redemptions_pending_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "status = 'pending'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "token_redemptions_user_id_users_id_fk": { + "name": "token_redemptions_user_id_users_id_fk", + "tableFrom": "token_redemptions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "token_redemptions_app_id_apps_id_fk": { + "name": "token_redemptions_app_id_apps_id_fk", + "tableFrom": "token_redemptions", + "tableTo": "apps", + "columnsFrom": [ + "app_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "token_redemptions_reviewed_by_users_id_fk": { + "name": "token_redemptions_reviewed_by_users_id_fk", + "tableFrom": "token_redemptions", + "tableTo": "users", + "columnsFrom": [ + "reviewed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.usage_quotas": { + "name": "usage_quotas", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "quota_type": { + "name": "quota_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "model_name": { + "name": "model_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "period_type": { + "name": "period_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'weekly'" + }, + "credits_limit": { + "name": "credits_limit", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "current_usage": { + "name": "current_usage", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "period_start": { + "name": "period_start", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "period_end": { + "name": "period_end", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "usage_quotas_org_id_idx": { + "name": "usage_quotas_org_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_quotas_quota_type_idx": { + "name": "usage_quotas_quota_type_idx", + "columns": [ + { + "expression": "quota_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_quotas_period_idx": { + "name": "usage_quotas_period_idx", + "columns": [ + { + "expression": "period_start", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "period_end", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_quotas_active_idx": { + "name": "usage_quotas_active_idx", + "columns": [ + { + "expression": "is_active", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "usage_quotas_organization_id_organizations_id_fk": { + "name": "usage_quotas_organization_id_organizations_id_fk", + "tableFrom": "usage_quotas", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.usage_records": { + "name": "usage_records", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "api_key_id": { + "name": "api_key_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "input_tokens": { + "name": "input_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "output_tokens": { + "name": "output_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "input_cost": { + "name": "input_cost", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": false, + "default": "'0.000000'" + }, + "output_cost": { + "name": "output_cost", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": false, + "default": "'0.000000'" + }, + "markup": { + "name": "markup", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": false, + "default": "'0.000000'" + }, + "request_id": { + "name": "request_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "duration_ms": { + "name": "duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_successful": { + "name": "is_successful", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "usage_records_organization_idx": { + "name": "usage_records_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_records_user_idx": { + "name": "usage_records_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_records_api_key_idx": { + "name": "usage_records_api_key_idx", + "columns": [ + { + "expression": "api_key_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_records_type_idx": { + "name": "usage_records_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_records_provider_idx": { + "name": "usage_records_provider_idx", + "columns": [ + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_records_created_at_idx": { + "name": "usage_records_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_records_org_created_idx": { + "name": "usage_records_org_created_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_records_org_type_created_idx": { + "name": "usage_records_org_type_created_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "usage_records_organization_id_organizations_id_fk": { + "name": "usage_records_organization_id_organizations_id_fk", + "tableFrom": "usage_records", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "usage_records_user_id_users_id_fk": { + "name": "usage_records_user_id_users_id_fk", + "tableFrom": "usage_records", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "usage_records_api_key_id_api_keys_id_fk": { + "name": "usage_records_api_key_id_api_keys_id_fk", + "tableFrom": "usage_records", + "tableTo": "api_keys", + "columnsFrom": [ + "api_key_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_characters": { + "name": "user_characters", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "system": { + "name": "system", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bio": { + "name": "bio", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "message_examples": { + "name": "message_examples", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "post_examples": { + "name": "post_examples", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "topics": { + "name": "topics", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "adjectives": { + "name": "adjectives", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "knowledge": { + "name": "knowledge", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "plugins": { + "name": "plugins", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "settings": { + "name": "settings", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "secrets": { + "name": "secrets", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "style": { + "name": "style", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "character_data": { + "name": "character_data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "is_template": { + "name": "is_template", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_public": { + "name": "is_public", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "avatar_url": { + "name": "avatar_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "featured": { + "name": "featured", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "view_count": { + "name": "view_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "interaction_count": { + "name": "interaction_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "popularity_score": { + "name": "popularity_score", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'cloud'" + }, + "token_address": { + "name": "token_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "token_chain": { + "name": "token_chain", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "token_name": { + "name": "token_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "token_ticker": { + "name": "token_ticker", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "erc8004_registered": { + "name": "erc8004_registered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "erc8004_network": { + "name": "erc8004_network", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "erc8004_agent_id": { + "name": "erc8004_agent_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "erc8004_agent_uri": { + "name": "erc8004_agent_uri", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "erc8004_tx_hash": { + "name": "erc8004_tx_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "erc8004_registered_at": { + "name": "erc8004_registered_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "monetization_enabled": { + "name": "monetization_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "inference_markup_percentage": { + "name": "inference_markup_percentage", + "type": "numeric(7, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "payout_wallet_address": { + "name": "payout_wallet_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "total_inference_requests": { + "name": "total_inference_requests", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_creator_earnings": { + "name": "total_creator_earnings", + "type": "numeric(12, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0.0000'" + }, + "total_platform_revenue": { + "name": "total_platform_revenue", + "type": "numeric(12, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0.0000'" + }, + "a2a_enabled": { + "name": "a2a_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "mcp_enabled": { + "name": "mcp_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "user_characters_organization_idx": { + "name": "user_characters_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_characters_user_idx": { + "name": "user_characters_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_characters_name_idx": { + "name": "user_characters_name_idx", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_characters_username_idx": { + "name": "user_characters_username_idx", + "columns": [ + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_characters_category_idx": { + "name": "user_characters_category_idx", + "columns": [ + { + "expression": "category", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_characters_featured_idx": { + "name": "user_characters_featured_idx", + "columns": [ + { + "expression": "featured", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_characters_is_template_idx": { + "name": "user_characters_is_template_idx", + "columns": [ + { + "expression": "is_template", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_characters_is_public_idx": { + "name": "user_characters_is_public_idx", + "columns": [ + { + "expression": "is_public", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_characters_popularity_idx": { + "name": "user_characters_popularity_idx", + "columns": [ + { + "expression": "popularity_score", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_characters_source_idx": { + "name": "user_characters_source_idx", + "columns": [ + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_characters_erc8004_idx": { + "name": "user_characters_erc8004_idx", + "columns": [ + { + "expression": "erc8004_registered", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_characters_erc8004_agent_idx": { + "name": "user_characters_erc8004_agent_idx", + "columns": [ + { + "expression": "erc8004_network", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "erc8004_agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_characters_monetization_idx": { + "name": "user_characters_monetization_idx", + "columns": [ + { + "expression": "monetization_enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_characters_token_address_idx": { + "name": "user_characters_token_address_idx", + "columns": [ + { + "expression": "token_address", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_characters_organization_id_organizations_id_fk": { + "name": "user_characters_organization_id_organizations_id_fk", + "tableFrom": "user_characters", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_characters_user_id_users_id_fk": { + "name": "user_characters_user_id_users_id_fk", + "tableFrom": "user_characters", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_characters_username_unique": { + "name": "user_characters_username_unique", + "nullsNotDistinct": false, + "columns": [ + "username" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_identities": { + "name": "user_identities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "steward_user_id": { + "name": "steward_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "privy_user_id": { + "name": "privy_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_anonymous": { + "name": "is_anonymous", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "anonymous_session_id": { + "name": "anonymous_session_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "telegram_id": { + "name": "telegram_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "telegram_username": { + "name": "telegram_username", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "telegram_first_name": { + "name": "telegram_first_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "telegram_photo_url": { + "name": "telegram_photo_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone_number": { + "name": "phone_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone_verified": { + "name": "phone_verified", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "discord_id": { + "name": "discord_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "discord_username": { + "name": "discord_username", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "discord_global_name": { + "name": "discord_global_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "discord_avatar_url": { + "name": "discord_avatar_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "whatsapp_id": { + "name": "whatsapp_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "whatsapp_name": { + "name": "whatsapp_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "user_identities_user_idx": { + "name": "user_identities_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_identities_steward_user_id_idx": { + "name": "user_identities_steward_user_id_idx", + "columns": [ + { + "expression": "steward_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_identities_privy_user_id_idx": { + "name": "user_identities_privy_user_id_idx", + "columns": [ + { + "expression": "privy_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_identities_is_anonymous_idx": { + "name": "user_identities_is_anonymous_idx", + "columns": [ + { + "expression": "is_anonymous", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_identities_anonymous_session_idx": { + "name": "user_identities_anonymous_session_idx", + "columns": [ + { + "expression": "anonymous_session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_identities_expires_at_idx": { + "name": "user_identities_expires_at_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_identities_telegram_id_idx": { + "name": "user_identities_telegram_id_idx", + "columns": [ + { + "expression": "telegram_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_identities_phone_number_idx": { + "name": "user_identities_phone_number_idx", + "columns": [ + { + "expression": "phone_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_identities_discord_id_idx": { + "name": "user_identities_discord_id_idx", + "columns": [ + { + "expression": "discord_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_identities_whatsapp_id_idx": { + "name": "user_identities_whatsapp_id_idx", + "columns": [ + { + "expression": "whatsapp_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_identities_user_id_users_id_fk": { + "name": "user_identities_user_id_users_id_fk", + "tableFrom": "user_identities", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_identities_user_id_unique": { + "name": "user_identities_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + }, + "user_identities_steward_user_id_unique": { + "name": "user_identities_steward_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "steward_user_id" + ] + }, + "user_identities_privy_user_id_unique": { + "name": "user_identities_privy_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "privy_user_id" + ] + }, + "user_identities_anonymous_session_id_unique": { + "name": "user_identities_anonymous_session_id_unique", + "nullsNotDistinct": false, + "columns": [ + "anonymous_session_id" + ] + }, + "user_identities_telegram_id_unique": { + "name": "user_identities_telegram_id_unique", + "nullsNotDistinct": false, + "columns": [ + "telegram_id" + ] + }, + "user_identities_phone_number_unique": { + "name": "user_identities_phone_number_unique", + "nullsNotDistinct": false, + "columns": [ + "phone_number" + ] + }, + "user_identities_discord_id_unique": { + "name": "user_identities_discord_id_unique", + "nullsNotDistinct": false, + "columns": [ + "discord_id" + ] + }, + "user_identities_whatsapp_id_unique": { + "name": "user_identities_whatsapp_id_unique", + "nullsNotDistinct": false, + "columns": [ + "whatsapp_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mcp_usage": { + "name": "mcp_usage", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "mcp_id": { + "name": "mcp_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "tool_name": { + "name": "tool_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "request_count": { + "name": "request_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "credits_charged": { + "name": "credits_charged", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false, + "default": "'0.0000'" + }, + "x402_amount_usd": { + "name": "x402_amount_usd", + "type": "numeric(10, 6)", + "primaryKey": false, + "notNull": false, + "default": "'0.000000'" + }, + "payment_type": { + "name": "payment_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'credits'" + }, + "creator_earnings": { + "name": "creator_earnings", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false, + "default": "'0.0000'" + }, + "platform_earnings": { + "name": "platform_earnings", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false, + "default": "'0.0000'" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mcp_usage_mcp_id_idx": { + "name": "mcp_usage_mcp_id_idx", + "columns": [ + { + "expression": "mcp_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mcp_usage_organization_idx": { + "name": "mcp_usage_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mcp_usage_user_idx": { + "name": "mcp_usage_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mcp_usage_created_at_idx": { + "name": "mcp_usage_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mcp_usage_mcp_org_idx": { + "name": "mcp_usage_mcp_org_idx", + "columns": [ + { + "expression": "mcp_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mcp_usage_mcp_id_user_mcps_id_fk": { + "name": "mcp_usage_mcp_id_user_mcps_id_fk", + "tableFrom": "mcp_usage", + "tableTo": "user_mcps", + "columnsFrom": [ + "mcp_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mcp_usage_organization_id_organizations_id_fk": { + "name": "mcp_usage_organization_id_organizations_id_fk", + "tableFrom": "mcp_usage", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mcp_usage_user_id_users_id_fk": { + "name": "mcp_usage_user_id_users_id_fk", + "tableFrom": "mcp_usage", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_mcps": { + "name": "user_mcps", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'1.0.0'" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "endpoint_type": { + "name": "endpoint_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'container'" + }, + "container_id": { + "name": "container_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "external_endpoint": { + "name": "external_endpoint", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "endpoint_path": { + "name": "endpoint_path", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'/mcp'" + }, + "transport_type": { + "name": "transport_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'streamable-http'" + }, + "mcp_version": { + "name": "mcp_version", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'2025-06-18'" + }, + "tools": { + "name": "tools", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'utilities'" + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'puzzle'" + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'#6366F1'" + }, + "pricing_type": { + "name": "pricing_type", + "type": "mcp_pricing_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'credits'" + }, + "credits_per_request": { + "name": "credits_per_request", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false, + "default": "'1.0000'" + }, + "x402_price_usd": { + "name": "x402_price_usd", + "type": "numeric(10, 6)", + "primaryKey": false, + "notNull": false, + "default": "'0.000100'" + }, + "x402_enabled": { + "name": "x402_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "creator_share_percentage": { + "name": "creator_share_percentage", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": true, + "default": "'80.00'" + }, + "platform_share_percentage": { + "name": "platform_share_percentage", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": true, + "default": "'20.00'" + }, + "total_requests": { + "name": "total_requests", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_credits_earned": { + "name": "total_credits_earned", + "type": "numeric(12, 4)", + "primaryKey": false, + "notNull": false, + "default": "'0.0000'" + }, + "total_x402_earned_usd": { + "name": "total_x402_earned_usd", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": false, + "default": "'0.000000'" + }, + "unique_users": { + "name": "unique_users", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "status": { + "name": "status", + "type": "mcp_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "is_public": { + "name": "is_public", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "is_featured": { + "name": "is_featured", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_verified": { + "name": "is_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "verified_at": { + "name": "verified_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "verified_by": { + "name": "verified_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "documentation_url": { + "name": "documentation_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_code_url": { + "name": "source_code_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "support_email": { + "name": "support_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "erc8004_registered": { + "name": "erc8004_registered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "erc8004_network": { + "name": "erc8004_network", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "erc8004_agent_id": { + "name": "erc8004_agent_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "erc8004_agent_uri": { + "name": "erc8004_agent_uri", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "erc8004_tx_hash": { + "name": "erc8004_tx_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "erc8004_registered_at": { + "name": "erc8004_registered_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "user_mcps_slug_org_idx": { + "name": "user_mcps_slug_org_idx", + "columns": [ + { + "expression": "slug", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_mcps_organization_idx": { + "name": "user_mcps_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_mcps_created_by_idx": { + "name": "user_mcps_created_by_idx", + "columns": [ + { + "expression": "created_by_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_mcps_container_idx": { + "name": "user_mcps_container_idx", + "columns": [ + { + "expression": "container_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_mcps_category_idx": { + "name": "user_mcps_category_idx", + "columns": [ + { + "expression": "category", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_mcps_status_idx": { + "name": "user_mcps_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_mcps_is_public_idx": { + "name": "user_mcps_is_public_idx", + "columns": [ + { + "expression": "is_public", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_mcps_created_at_idx": { + "name": "user_mcps_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_mcps_erc8004_registered_idx": { + "name": "user_mcps_erc8004_registered_idx", + "columns": [ + { + "expression": "erc8004_registered", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_mcps_organization_id_organizations_id_fk": { + "name": "user_mcps_organization_id_organizations_id_fk", + "tableFrom": "user_mcps", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_mcps_created_by_user_id_users_id_fk": { + "name": "user_mcps_created_by_user_id_users_id_fk", + "tableFrom": "user_mcps", + "tableTo": "users", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_mcps_container_id_containers_id_fk": { + "name": "user_mcps_container_id_containers_id_fk", + "tableFrom": "user_mcps", + "tableTo": "containers", + "columnsFrom": [ + "container_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "user_mcps_verified_by_users_id_fk": { + "name": "user_mcps_verified_by_users_id_fk", + "tableFrom": "user_mcps", + "tableTo": "users", + "columnsFrom": [ + "verified_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_preferences": { + "name": "user_preferences", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "nickname": { + "name": "nickname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "work_function": { + "name": "work_function", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "preferences": { + "name": "preferences", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "response_notifications": { + "name": "response_notifications", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "email_notifications": { + "name": "email_notifications", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "user_preferences_user_idx": { + "name": "user_preferences_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_preferences_work_function_idx": { + "name": "user_preferences_work_function_idx", + "columns": [ + { + "expression": "work_function", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_preferences_user_id_users_id_fk": { + "name": "user_preferences_user_id_users_id_fk", + "tableFrom": "user_preferences", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_preferences_user_id_unique": { + "name": "user_preferences_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_sessions": { + "name": "user_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "session_token": { + "name": "session_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "credits_used": { + "name": "credits_used", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0.00'" + }, + "requests_made": { + "name": "requests_made", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "tokens_consumed": { + "name": "tokens_consumed", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_activity_at": { + "name": "last_activity_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ended_at": { + "name": "ended_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "device_info": { + "name": "device_info", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "user_sessions_user_id_idx": { + "name": "user_sessions_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_sessions_org_id_idx": { + "name": "user_sessions_org_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_sessions_token_idx": { + "name": "user_sessions_token_idx", + "columns": [ + { + "expression": "session_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_sessions_started_at_idx": { + "name": "user_sessions_started_at_idx", + "columns": [ + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_sessions_active_idx": { + "name": "user_sessions_active_idx", + "columns": [ + { + "expression": "ended_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_sessions_user_id_users_id_fk": { + "name": "user_sessions_user_id_users_id_fk", + "tableFrom": "user_sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_sessions_organization_id_organizations_id_fk": { + "name": "user_sessions_organization_id_organizations_id_fk", + "tableFrom": "user_sessions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_sessions_session_token_unique": { + "name": "user_sessions_session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "session_token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_voices": { + "name": "user_voices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "elevenlabs_voice_id": { + "name": "elevenlabs_voice_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "clone_type": { + "name": "clone_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "settings": { + "name": "settings", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "sample_count": { + "name": "sample_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_audio_duration_seconds": { + "name": "total_audio_duration_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "audio_quality_score": { + "name": "audio_quality_score", + "type": "numeric(3, 2)", + "primaryKey": false, + "notNull": false + }, + "usage_count": { + "name": "usage_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "is_public": { + "name": "is_public", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "creation_cost": { + "name": "creation_cost", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "user_voices_organization_idx": { + "name": "user_voices_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_voices_user_idx": { + "name": "user_voices_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_voices_org_type_idx": { + "name": "user_voices_org_type_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "clone_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_voices_org_usage_idx": { + "name": "user_voices_org_usage_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "usage_count", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_used_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_voices_organization_id_organizations_id_fk": { + "name": "user_voices_organization_id_organizations_id_fk", + "tableFrom": "user_voices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_voices_user_id_users_id_fk": { + "name": "user_voices_user_id_users_id_fk", + "tableFrom": "user_voices", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_voices_elevenlabs_voice_id_unique": { + "name": "user_voices_elevenlabs_voice_id_unique", + "nullsNotDistinct": false, + "columns": [ + "elevenlabs_voice_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.voice_cloning_jobs": { + "name": "voice_cloning_jobs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "job_type": { + "name": "job_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "voice_name": { + "name": "voice_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "voice_description": { + "name": "voice_description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "progress": { + "name": "progress", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "user_voice_id": { + "name": "user_voice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "elevenlabs_voice_id": { + "name": "elevenlabs_voice_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "retry_count": { + "name": "retry_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "voice_cloning_jobs_organization_id_organizations_id_fk": { + "name": "voice_cloning_jobs_organization_id_organizations_id_fk", + "tableFrom": "voice_cloning_jobs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "voice_cloning_jobs_user_id_users_id_fk": { + "name": "voice_cloning_jobs_user_id_users_id_fk", + "tableFrom": "voice_cloning_jobs", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "voice_cloning_jobs_user_voice_id_user_voices_id_fk": { + "name": "voice_cloning_jobs_user_voice_id_user_voices_id_fk", + "tableFrom": "voice_cloning_jobs", + "tableTo": "user_voices", + "columnsFrom": [ + "user_voice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.voice_samples": { + "name": "voice_samples", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_voice_id": { + "name": "user_voice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "job_id": { + "name": "job_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_size": { + "name": "file_size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "file_type": { + "name": "file_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "blob_url": { + "name": "blob_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "duration_seconds": { + "name": "duration_seconds", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "sample_rate": { + "name": "sample_rate", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "channels": { + "name": "channels", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "quality_score": { + "name": "quality_score", + "type": "numeric(3, 2)", + "primaryKey": false, + "notNull": false + }, + "is_processed": { + "name": "is_processed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "transcription": { + "name": "transcription", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "voice_samples_user_voice_id_user_voices_id_fk": { + "name": "voice_samples_user_voice_id_user_voices_id_fk", + "tableFrom": "voice_samples", + "tableTo": "user_voices", + "columnsFrom": [ + "user_voice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "voice_samples_job_id_voice_cloning_jobs_id_fk": { + "name": "voice_samples_job_id_voice_cloning_jobs_id_fk", + "tableFrom": "voice_samples", + "tableTo": "voice_cloning_jobs", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "voice_samples_organization_id_organizations_id_fk": { + "name": "voice_samples_organization_id_organizations_id_fk", + "tableFrom": "voice_samples", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "voice_samples_user_id_users_id_fk": { + "name": "voice_samples_user_id_users_id_fk", + "tableFrom": "voice_samples", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "wallet_address": { + "name": "wallet_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "wallet_chain_type": { + "name": "wallet_chain_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "wallet_verified": { + "name": "wallet_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "avatar": { + "name": "avatar", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "steward_user_id": { + "name": "steward_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "privy_user_id": { + "name": "privy_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "telegram_id": { + "name": "telegram_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "telegram_username": { + "name": "telegram_username", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "telegram_first_name": { + "name": "telegram_first_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "telegram_photo_url": { + "name": "telegram_photo_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "discord_id": { + "name": "discord_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "discord_username": { + "name": "discord_username", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "discord_global_name": { + "name": "discord_global_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "discord_avatar_url": { + "name": "discord_avatar_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "whatsapp_id": { + "name": "whatsapp_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "whatsapp_name": { + "name": "whatsapp_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone_number": { + "name": "phone_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone_verified": { + "name": "phone_verified", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "is_anonymous": { + "name": "is_anonymous", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "anonymous_session_id": { + "name": "anonymous_session_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "nickname": { + "name": "nickname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "work_function": { + "name": "work_function", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "preferences": { + "name": "preferences", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email_notifications": { + "name": "email_notifications", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "response_notifications": { + "name": "response_notifications", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "users_email_idx": { + "name": "users_email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_wallet_address_idx": { + "name": "users_wallet_address_idx", + "columns": [ + { + "expression": "wallet_address", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_wallet_chain_type_idx": { + "name": "users_wallet_chain_type_idx", + "columns": [ + { + "expression": "wallet_chain_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_organization_idx": { + "name": "users_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_is_active_idx": { + "name": "users_is_active_idx", + "columns": [ + { + "expression": "is_active", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_steward_idx": { + "name": "users_steward_idx", + "columns": [ + { + "expression": "steward_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_privy_idx": { + "name": "users_privy_idx", + "columns": [ + { + "expression": "privy_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_telegram_idx": { + "name": "users_telegram_idx", + "columns": [ + { + "expression": "telegram_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_discord_idx": { + "name": "users_discord_idx", + "columns": [ + { + "expression": "discord_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_phone_idx": { + "name": "users_phone_idx", + "columns": [ + { + "expression": "phone_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_is_anonymous_idx": { + "name": "users_is_anonymous_idx", + "columns": [ + { + "expression": "is_anonymous", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "users_organization_id_organizations_id_fk": { + "name": "users_organization_id_organizations_id_fk", + "tableFrom": "users", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + }, + "users_wallet_address_unique": { + "name": "users_wallet_address_unique", + "nullsNotDistinct": false, + "columns": [ + "wallet_address" + ] + }, + "users_steward_user_id_unique": { + "name": "users_steward_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "steward_user_id" + ] + }, + "users_privy_user_id_unique": { + "name": "users_privy_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "privy_user_id" + ] + }, + "users_telegram_id_unique": { + "name": "users_telegram_id_unique", + "nullsNotDistinct": false, + "columns": [ + "telegram_id" + ] + }, + "users_discord_id_unique": { + "name": "users_discord_id_unique", + "nullsNotDistinct": false, + "columns": [ + "discord_id" + ] + }, + "users_whatsapp_id_unique": { + "name": "users_whatsapp_id_unique", + "nullsNotDistinct": false, + "columns": [ + "whatsapp_id" + ] + }, + "users_phone_number_unique": { + "name": "users_phone_number_unique", + "nullsNotDistinct": false, + "columns": [ + "phone_number" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.vertex_model_assignments": { + "name": "vertex_model_assignments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "scope": { + "name": "scope", + "type": "vertex_tuning_scope", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "slot": { + "name": "slot", + "type": "vertex_tuning_slot", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "tuned_model_id": { + "name": "tuned_model_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "assigned_by_user_id": { + "name": "assigned_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "activated_at": { + "name": "activated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "deactivated_at": { + "name": "deactivated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "vertex_model_assignments_tuned_model_idx": { + "name": "vertex_model_assignments_tuned_model_idx", + "columns": [ + { + "expression": "tuned_model_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_model_assignments_scope_idx": { + "name": "vertex_model_assignments_scope_idx", + "columns": [ + { + "expression": "scope", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_model_assignments_slot_idx": { + "name": "vertex_model_assignments_slot_idx", + "columns": [ + { + "expression": "slot", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_model_assignments_organization_idx": { + "name": "vertex_model_assignments_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_model_assignments_user_idx": { + "name": "vertex_model_assignments_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_model_assignments_active_idx": { + "name": "vertex_model_assignments_active_idx", + "columns": [ + { + "expression": "is_active", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_model_assignments_global_slot_active_idx": { + "name": "vertex_model_assignments_global_slot_active_idx", + "columns": [ + { + "expression": "slot", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"vertex_model_assignments\".\"scope\" = 'global' and \"vertex_model_assignments\".\"is_active\" = true", + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_model_assignments_org_slot_active_idx": { + "name": "vertex_model_assignments_org_slot_active_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "slot", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"vertex_model_assignments\".\"scope\" = 'organization' and \"vertex_model_assignments\".\"is_active\" = true", + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_model_assignments_user_slot_active_idx": { + "name": "vertex_model_assignments_user_slot_active_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "slot", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"vertex_model_assignments\".\"scope\" = 'user' and \"vertex_model_assignments\".\"is_active\" = true", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "vertex_model_assignments_organization_id_organizations_id_fk": { + "name": "vertex_model_assignments_organization_id_organizations_id_fk", + "tableFrom": "vertex_model_assignments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "vertex_model_assignments_user_id_users_id_fk": { + "name": "vertex_model_assignments_user_id_users_id_fk", + "tableFrom": "vertex_model_assignments", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "vertex_model_assignments_tuned_model_id_vertex_tuned_models_id_fk": { + "name": "vertex_model_assignments_tuned_model_id_vertex_tuned_models_id_fk", + "tableFrom": "vertex_model_assignments", + "tableTo": "vertex_tuned_models", + "columnsFrom": [ + "tuned_model_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "vertex_model_assignments_assigned_by_user_id_users_id_fk": { + "name": "vertex_model_assignments_assigned_by_user_id_users_id_fk", + "tableFrom": "vertex_model_assignments", + "tableTo": "users", + "columnsFrom": [ + "assigned_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "vertex_model_assignments_scope_owner_check": { + "name": "vertex_model_assignments_scope_owner_check", + "value": "(\n (\"vertex_model_assignments\".\"scope\" = 'global' and \"vertex_model_assignments\".\"organization_id\" is null and \"vertex_model_assignments\".\"user_id\" is null) or\n (\"vertex_model_assignments\".\"scope\" = 'organization' and \"vertex_model_assignments\".\"organization_id\" is not null and \"vertex_model_assignments\".\"user_id\" is null) or\n (\"vertex_model_assignments\".\"scope\" = 'user' and \"vertex_model_assignments\".\"organization_id\" is not null and \"vertex_model_assignments\".\"user_id\" is not null)\n )" + } + }, + "isRLSEnabled": false + }, + "public.vertex_tuned_models": { + "name": "vertex_tuned_models", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tuning_job_id": { + "name": "tuning_job_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "vertex_model_id": { + "name": "vertex_model_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "base_model": { + "name": "base_model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "region": { + "name": "region", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slot": { + "name": "slot", + "type": "vertex_tuning_slot", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "source_scope": { + "name": "source_scope", + "type": "vertex_tuning_scope", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "model_preferences": { + "name": "model_preferences", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "vertex_tuned_models_vertex_model_id_idx": { + "name": "vertex_tuned_models_vertex_model_id_idx", + "columns": [ + { + "expression": "vertex_model_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_tuned_models_tuning_job_idx": { + "name": "vertex_tuned_models_tuning_job_idx", + "columns": [ + { + "expression": "tuning_job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_tuned_models_slot_idx": { + "name": "vertex_tuned_models_slot_idx", + "columns": [ + { + "expression": "slot", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_tuned_models_source_scope_idx": { + "name": "vertex_tuned_models_source_scope_idx", + "columns": [ + { + "expression": "source_scope", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_tuned_models_organization_idx": { + "name": "vertex_tuned_models_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_tuned_models_user_idx": { + "name": "vertex_tuned_models_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "vertex_tuned_models_tuning_job_id_vertex_tuning_jobs_id_fk": { + "name": "vertex_tuned_models_tuning_job_id_vertex_tuning_jobs_id_fk", + "tableFrom": "vertex_tuned_models", + "tableTo": "vertex_tuning_jobs", + "columnsFrom": [ + "tuning_job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "vertex_tuned_models_organization_id_organizations_id_fk": { + "name": "vertex_tuned_models_organization_id_organizations_id_fk", + "tableFrom": "vertex_tuned_models", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "vertex_tuned_models_user_id_users_id_fk": { + "name": "vertex_tuned_models_user_id_users_id_fk", + "tableFrom": "vertex_tuned_models", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "vertex_tuned_models_scope_owner_check": { + "name": "vertex_tuned_models_scope_owner_check", + "value": "(\n (\"vertex_tuned_models\".\"source_scope\" = 'global' and \"vertex_tuned_models\".\"organization_id\" is null and \"vertex_tuned_models\".\"user_id\" is null) or\n (\"vertex_tuned_models\".\"source_scope\" = 'organization' and \"vertex_tuned_models\".\"organization_id\" is not null and \"vertex_tuned_models\".\"user_id\" is null) or\n (\"vertex_tuned_models\".\"source_scope\" = 'user' and \"vertex_tuned_models\".\"organization_id\" is not null and \"vertex_tuned_models\".\"user_id\" is not null)\n )" + } + }, + "isRLSEnabled": false + }, + "public.vertex_tuning_jobs": { + "name": "vertex_tuning_jobs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "vertex_job_name": { + "name": "vertex_job_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "region": { + "name": "region", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "base_model": { + "name": "base_model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slot": { + "name": "slot", + "type": "vertex_tuning_slot", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "scope": { + "name": "scope", + "type": "vertex_tuning_scope", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "training_data_path": { + "name": "training_data_path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "validation_data_path": { + "name": "validation_data_path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "training_data_uri": { + "name": "training_data_uri", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "validation_data_uri": { + "name": "validation_data_uri", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recommended_model_id": { + "name": "recommended_model_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tuned_model_display_name": { + "name": "tuned_model_display_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tuned_model_endpoint_name": { + "name": "tuned_model_endpoint_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "vertex_tuning_job_state", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'JOB_STATE_PENDING'" + }, + "error_code": { + "name": "error_code", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model_preference_patch": { + "name": "model_preference_patch", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "last_remote_payload": { + "name": "last_remote_payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "vertex_tuning_jobs_vertex_job_name_idx": { + "name": "vertex_tuning_jobs_vertex_job_name_idx", + "columns": [ + { + "expression": "vertex_job_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_tuning_jobs_status_idx": { + "name": "vertex_tuning_jobs_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_tuning_jobs_scope_idx": { + "name": "vertex_tuning_jobs_scope_idx", + "columns": [ + { + "expression": "scope", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_tuning_jobs_organization_idx": { + "name": "vertex_tuning_jobs_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_tuning_jobs_user_idx": { + "name": "vertex_tuning_jobs_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_tuning_jobs_created_by_idx": { + "name": "vertex_tuning_jobs_created_by_idx", + "columns": [ + { + "expression": "created_by_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_tuning_jobs_slot_idx": { + "name": "vertex_tuning_jobs_slot_idx", + "columns": [ + { + "expression": "slot", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "vertex_tuning_jobs_created_at_idx": { + "name": "vertex_tuning_jobs_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "vertex_tuning_jobs_organization_id_organizations_id_fk": { + "name": "vertex_tuning_jobs_organization_id_organizations_id_fk", + "tableFrom": "vertex_tuning_jobs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "vertex_tuning_jobs_user_id_users_id_fk": { + "name": "vertex_tuning_jobs_user_id_users_id_fk", + "tableFrom": "vertex_tuning_jobs", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "vertex_tuning_jobs_created_by_user_id_users_id_fk": { + "name": "vertex_tuning_jobs_created_by_user_id_users_id_fk", + "tableFrom": "vertex_tuning_jobs", + "tableTo": "users", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "vertex_tuning_jobs_scope_owner_check": { + "name": "vertex_tuning_jobs_scope_owner_check", + "value": "(\n (\"vertex_tuning_jobs\".\"scope\" = 'global' and \"vertex_tuning_jobs\".\"organization_id\" is null and \"vertex_tuning_jobs\".\"user_id\" is null) or\n (\"vertex_tuning_jobs\".\"scope\" = 'organization' and \"vertex_tuning_jobs\".\"organization_id\" is not null and \"vertex_tuning_jobs\".\"user_id\" is null) or\n (\"vertex_tuning_jobs\".\"scope\" = 'user' and \"vertex_tuning_jobs\".\"organization_id\" is not null and \"vertex_tuning_jobs\".\"user_id\" is not null)\n )" + } + }, + "isRLSEnabled": false + }, + "public.webhook_events": { + "name": "webhook_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "event_id": { + "name": "event_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payload_hash": { + "name": "payload_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_ip": { + "name": "source_ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "processed_at": { + "name": "processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "event_timestamp": { + "name": "event_timestamp", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "webhook_events_event_id_idx": { + "name": "webhook_events_event_id_idx", + "columns": [ + { + "expression": "event_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "webhook_events_provider_idx": { + "name": "webhook_events_provider_idx", + "columns": [ + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "webhook_events_processed_at_idx": { + "name": "webhook_events_processed_at_idx", + "columns": [ + { + "expression": "processed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "webhook_events_provider_processed_idx": { + "name": "webhook_events_provider_processed_idx", + "columns": [ + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "processed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "webhook_events_event_id_unique": { + "name": "webhook_events_event_id_unique", + "nullsNotDistinct": false, + "columns": [ + "event_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.admin_role": { + "name": "admin_role", + "schema": "public", + "values": [ + "super_admin", + "moderator", + "viewer" + ] + }, + "public.phone_provider": { + "name": "phone_provider", + "schema": "public", + "values": [ + "twilio", + "blooio", + "vonage", + "whatsapp", + "other" + ] + }, + "public.phone_type": { + "name": "phone_type", + "schema": "public", + "values": [ + "sms", + "voice", + "both", + "imessage", + "whatsapp" + ] + }, + "public.app_deployment_status": { + "name": "app_deployment_status", + "schema": "public", + "values": [ + "draft", + "building", + "deploying", + "deployed", + "failed" + ] + }, + "public.user_database_status": { + "name": "user_database_status", + "schema": "public", + "values": [ + "none", + "provisioning", + "ready", + "error" + ] + }, + "public.domain_moderation_status": { + "name": "domain_moderation_status", + "schema": "public", + "values": [ + "clean", + "pending_review", + "flagged", + "suspended" + ] + }, + "public.domain_nameserver_mode": { + "name": "domain_nameserver_mode", + "schema": "public", + "values": [ + "vercel", + "external" + ] + }, + "public.domain_registrar": { + "name": "domain_registrar", + "schema": "public", + "values": [ + "vercel", + "external" + ] + }, + "public.domain_resource_type": { + "name": "domain_resource_type", + "schema": "public", + "values": [ + "app", + "container", + "agent", + "mcp" + ] + }, + "public.domain_status": { + "name": "domain_status", + "schema": "public", + "values": [ + "pending", + "active", + "expired", + "suspended", + "transferring" + ] + }, + "public.moderation_action": { + "name": "moderation_action", + "schema": "public", + "values": [ + "refused", + "warned", + "flagged_for_ban", + "banned" + ] + }, + "public.user_mod_status": { + "name": "user_mod_status", + "schema": "public", + "values": [ + "clean", + "warned", + "spammer", + "scammer", + "banned" + ] + }, + "public.platform_credential_status": { + "name": "platform_credential_status", + "schema": "public", + "values": [ + "pending", + "active", + "expired", + "revoked", + "error" + ] + }, + "public.platform_credential_type": { + "name": "platform_credential_type", + "schema": "public", + "values": [ + "discord", + "telegram", + "twitter", + "gmail", + "slack", + "github", + "google", + "bluesky", + "reddit", + "facebook", + "instagram", + "tiktok", + "linkedin", + "mastodon", + "twilio", + "google_calendar", + "linear", + "notion", + "hubspot", + "salesforce", + "jira", + "asana", + "airtable", + "dropbox", + "spotify", + "zoom", + "microsoft" + ] + }, + "public.earnings_source": { + "name": "earnings_source", + "schema": "public", + "values": [ + "miniapp", + "agent", + "mcp", + "affiliate", + "app_owner_revenue_share", + "creator_revenue_share" + ] + }, + "public.ledger_entry_type": { + "name": "ledger_entry_type", + "schema": "public", + "values": [ + "earning", + "redemption", + "adjustment", + "refund" + ] + }, + "public.share_type": { + "name": "share_type", + "schema": "public", + "values": [ + "app_share", + "character_share", + "invite_share" + ] + }, + "public.social_platform": { + "name": "social_platform", + "schema": "public", + "values": [ + "x", + "farcaster", + "telegram", + "discord" + ] + }, + "public.secret_actor_type": { + "name": "secret_actor_type", + "schema": "public", + "values": [ + "user", + "api_key", + "system", + "deployment", + "workflow" + ] + }, + "public.secret_audit_action": { + "name": "secret_audit_action", + "schema": "public", + "values": [ + "created", + "read", + "updated", + "deleted", + "rotated" + ] + }, + "public.secret_environment": { + "name": "secret_environment", + "schema": "public", + "values": [ + "development", + "preview", + "production" + ] + }, + "public.secret_project_type": { + "name": "secret_project_type", + "schema": "public", + "values": [ + "character", + "app", + "workflow", + "container", + "mcp" + ] + }, + "public.secret_provider": { + "name": "secret_provider", + "schema": "public", + "values": [ + "openai", + "anthropic", + "google", + "elevenlabs", + "fal", + "stripe", + "discord", + "telegram", + "twitter", + "github", + "slack", + "aws", + "vercel", + "custom" + ] + }, + "public.secret_scope": { + "name": "secret_scope", + "schema": "public", + "values": [ + "organization", + "project", + "environment" + ] + }, + "public.seo_artifact_type": { + "name": "seo_artifact_type", + "schema": "public", + "values": [ + "keywords", + "meta", + "schema", + "serp_snapshot", + "health_report", + "indexnow_submission" + ] + }, + "public.seo_provider": { + "name": "seo_provider", + "schema": "public", + "values": [ + "dataforseo", + "serpapi", + "claude", + "indexnow", + "bing" + ] + }, + "public.seo_provider_status": { + "name": "seo_provider_status", + "schema": "public", + "values": [ + "pending", + "completed", + "failed" + ] + }, + "public.seo_request_status": { + "name": "seo_request_status", + "schema": "public", + "values": [ + "pending", + "in_progress", + "completed", + "failed" + ] + }, + "public.seo_request_type": { + "name": "seo_request_type", + "schema": "public", + "values": [ + "keyword_research", + "serp_snapshot", + "meta_generate", + "schema_generate", + "publish_bundle", + "index_now", + "health_check" + ] + }, + "public.redemption_network": { + "name": "redemption_network", + "schema": "public", + "values": [ + "ethereum", + "base", + "bnb", + "solana" + ] + }, + "public.redemption_status": { + "name": "redemption_status", + "schema": "public", + "values": [ + "pending", + "approved", + "processing", + "completed", + "failed", + "rejected", + "expired" + ] + }, + "public.mcp_pricing_type": { + "name": "mcp_pricing_type", + "schema": "public", + "values": [ + "free", + "credits", + "x402" + ] + }, + "public.mcp_status": { + "name": "mcp_status", + "schema": "public", + "values": [ + "draft", + "pending_review", + "live", + "suspended", + "deprecated" + ] + }, + "public.vertex_tuning_job_state": { + "name": "vertex_tuning_job_state", + "schema": "public", + "values": [ + "JOB_STATE_PENDING", + "JOB_STATE_RUNNING", + "JOB_STATE_SUCCEEDED", + "JOB_STATE_FAILED", + "JOB_STATE_CANCELLED" + ] + }, + "public.vertex_tuning_scope": { + "name": "vertex_tuning_scope", + "schema": "public", + "values": [ + "global", + "organization", + "user" + ] + }, + "public.vertex_tuning_slot": { + "name": "vertex_tuning_slot", + "schema": "public", + "values": [ + "should_respond", + "response_handler", + "action_planner", + "planner", + "response", + "media_description" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/packages/db/migrations/meta/_journal.json b/packages/db/migrations/meta/_journal.json index 854d9f186..e050fb437 100644 --- a/packages/db/migrations/meta/_journal.json +++ b/packages/db/migrations/meta/_journal.json @@ -439,6 +439,13 @@ { "idx": 62, "version": "7", + "when": 1776209920938, + "tag": "0065_add_generations_is_public", + "breakpoints": true + }, + { + "idx": 63, + "version": "7", "when": 1776499320000, "tag": "0067_allow_multiple_oauth_connections_per_user", "breakpoints": true diff --git a/packages/db/repositories/generations.ts b/packages/db/repositories/generations.ts index f4231bf1f..35fc69b46 100644 --- a/packages/db/repositories/generations.ts +++ b/packages/db/repositories/generations.ts @@ -94,13 +94,15 @@ export class GenerationsRepository { } /** - * Lists random completed images from all users (for explore/discover). + * Lists random completed images that users have explicitly marked as public. + * Only returns images where is_public = true to prevent leaking private generations. */ async listRandomPublicImages(limit: number = 20): Promise { return await dbRead.query.generations.findMany({ where: and( eq(generations.status, "completed"), eq(generations.type, "image"), + eq(generations.is_public, true), sql`${generations.storage_url} IS NOT NULL`, ), orderBy: sql`RANDOM()`, diff --git a/packages/db/schemas/generations.ts b/packages/db/schemas/generations.ts index 6167bdd8c..150293ad3 100644 --- a/packages/db/schemas/generations.ts +++ b/packages/db/schemas/generations.ts @@ -1,6 +1,7 @@ import type { InferInsertModel, InferSelectModel } from "drizzle-orm"; import { bigint, + boolean, index, integer, jsonb, @@ -60,6 +61,7 @@ export const generations = pgTable( usage_record_id: uuid("usage_record_id").references(() => usageRecords.id, { onDelete: "set null", }), + is_public: boolean("is_public").notNull().default(false), job_id: text("job_id"), created_at: timestamp("created_at").notNull().defaultNow(), updated_at: timestamp("updated_at").notNull().defaultNow(), diff --git a/packages/lib/blob.ts b/packages/lib/blob.ts index bd09dec0b..d75e4c651 100644 --- a/packages/lib/blob.ts +++ b/packages/lib/blob.ts @@ -82,6 +82,12 @@ export async function uploadToBlob( ? `${folder}/${userId}/${timestamp}-${filename}` : `${folder}/${timestamp}-${filename}`; + // TODO: Vercel Blob only supports `access: "public"` as of 2026-04. + // Private blob access is in beta and not yet available for production use. + // All uploaded blobs are publicly accessible via their URL with no auth or expiry. + // The proper fix is an auth-gated proxy route that validates user sessions before + // serving blob content, but that requires a larger architectural change. + // See: https://vercel.com/docs/storage/vercel-blob#access const blob = await put(pathname, content, { access: "public", contentType, diff --git a/packages/lib/hooks/use-admin.ts b/packages/lib/hooks/use-admin.ts index 6b4a3a73e..830bf124b 100644 --- a/packages/lib/hooks/use-admin.ts +++ b/packages/lib/hooks/use-admin.ts @@ -15,8 +15,9 @@ "use client"; -import { usePrivy, useWallets } from "@privy-io/react-auth"; +import { useWallets } from "@privy-io/react-auth"; import { useEffect, useRef, useState } from "react"; +import { useSessionAuth } from "@/lib/hooks/use-session-auth"; // Default anvil wallet for devnet admin access const ANVIL_DEFAULT_WALLET = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"; @@ -129,7 +130,7 @@ async function fetchAdminStatus( * Deduplicates concurrent requests across multiple component instances. */ export function useAdmin(): UseAdminResult { - const { authenticated } = usePrivy(); + const { authenticated, authSource, user } = useSessionAuth(); const { wallets } = useWallets(); const [isAdmin, setIsAdmin] = useState(false); const [adminRole, setAdminRole] = useState(null); @@ -138,7 +139,9 @@ export function useAdmin(): UseAdminResult { const mountedRef = useRef(true); const fetchCountRef = useRef(0); - const walletAddress = wallets?.[0]?.address; + const walletAddress = + wallets?.[0]?.address || + (authSource === "steward" && user && "walletAddress" in user ? user.walletAddress : undefined); useEffect(() => { mountedRef.current = true; diff --git a/packages/lib/hooks/use-session-auth.ts b/packages/lib/hooks/use-session-auth.ts new file mode 100644 index 000000000..3bd563433 --- /dev/null +++ b/packages/lib/hooks/use-session-auth.ts @@ -0,0 +1,144 @@ +"use client"; + +import { usePrivy } from "@privy-io/react-auth"; +import { StewardAuthContext } from "@stwd/react"; +import { useContext, useEffect, useState } from "react"; + +export type SessionAuthSource = "none" | "privy" | "steward" | "both"; + +export type PrivySessionUser = ReturnType["user"]; +export type StewardSessionUser = { id: string; email: string; walletAddress?: string } | null; +export type SessionUser = PrivySessionUser | StewardSessionUser; + +/** Default state when StewardProvider is not mounted */ +const STEWARD_AUTH_FALLBACK = { + isAuthenticated: false, + isLoading: false, + user: null as StewardSessionUser, + session: null, + signOut: () => {}, + getToken: () => null, +} as const; + +const STEWARD_TOKEN_KEY = "steward_session_token"; + +function decodeStewardToken(token: string): { + id: string; + email: string; + walletAddress?: string; + exp?: number; +} | null { + try { + const parts = token.split("."); + if (parts.length !== 3) return null; + const base64 = parts[1].replace(/-/g, "+").replace(/_/g, "/"); + const padded = base64.padEnd(base64.length + ((4 - (base64.length % 4)) % 4), "="); + const payload = JSON.parse(atob(padded)); + return { + id: payload.userId ?? payload.sub ?? "", + email: payload.email ?? "", + walletAddress: payload.address ?? undefined, + exp: payload.exp, + }; + } catch { + return null; + } +} + +/** Read a valid non-expired Steward session directly from localStorage. */ +function readStewardSessionFromStorage(): StewardSessionUser { + if (typeof window === "undefined") return null; + try { + const token = localStorage.getItem(STEWARD_TOKEN_KEY); + if (!token) return null; + const decoded = decodeStewardToken(token); + if (!decoded) return null; + if (decoded.exp && decoded.exp * 1000 < Date.now()) { + return null; + } + if (!decoded.id) return null; + return { + id: decoded.id, + email: decoded.email, + walletAddress: decoded.walletAddress, + }; + } catch { + return null; + } +} + +/** + * Safe wrapper around @stwd/react useAuth that returns fallback defaults + * when called outside . + */ +/** + * Safe wrapper around the Steward auth context that returns a fallback when + * StewardProvider is not mounted. Reads the context directly instead of + * calling useAuth() inside try/catch (which violates Rules of Hooks). + */ +export function useStewardAuth() { + const ctx = useContext(StewardAuthContext); + return ctx ?? STEWARD_AUTH_FALLBACK; +} + +export interface SessionAuthState { + ready: boolean; + authenticated: boolean; + authSource: SessionAuthSource; + privyAuthenticated: boolean; + stewardAuthenticated: boolean; + privyUser: PrivySessionUser; + stewardUser: StewardSessionUser; + user: SessionUser; +} + +export function useSessionAuth(): SessionAuthState { + const { ready: privyReady, authenticated: privyAuthenticated, user: privyUser } = usePrivy(); + const providerAuth = useStewardAuth(); + + // Read directly from localStorage as a fallback / source of truth when the + // @stwd/react provider is slow or flaky to initialize from storage. + const [storageUser, setStorageUser] = useState(null); + + useEffect(() => { + // Sync on mount + setStorageUser(readStewardSessionFromStorage()); + + // Keep in sync across tabs + when our own code updates the token + const handler = () => setStorageUser(readStewardSessionFromStorage()); + window.addEventListener("storage", handler); + window.addEventListener("steward-token-sync", handler); + // Poll once more after a tick in case login just completed + const t = setTimeout(handler, 250); + return () => { + window.removeEventListener("storage", handler); + window.removeEventListener("steward-token-sync", handler); + clearTimeout(t); + }; + }, []); + + const stewardUser = providerAuth.user ?? storageUser; + const stewardAuthenticated = providerAuth.isAuthenticated || storageUser !== null; + + const ready = privyReady && !providerAuth.isLoading; + const authenticated = privyAuthenticated || stewardAuthenticated; + + const authSource: SessionAuthSource = privyAuthenticated + ? stewardAuthenticated + ? "both" + : "privy" + : stewardAuthenticated + ? "steward" + : "none"; + + return { + ready, + authenticated, + authSource, + privyAuthenticated, + stewardAuthenticated, + privyUser, + stewardUser: stewardUser as StewardSessionUser, + user: privyUser || (stewardUser as StewardSessionUser), + }; +} diff --git a/packages/lib/providers/CreditsProvider.tsx b/packages/lib/providers/CreditsProvider.tsx index dad2427a6..695dd5513 100644 --- a/packages/lib/providers/CreditsProvider.tsx +++ b/packages/lib/providers/CreditsProvider.tsx @@ -19,6 +19,7 @@ import { useRef, useState, } from "react"; +import { useSessionAuth } from "@/lib/hooks/use-session-auth"; import { logger } from "@/lib/utils/logger"; interface CreditsContextValue { @@ -36,7 +37,8 @@ const POLL_INTERVAL = 30000; // Increased from 10s to 30s const MAX_AUTH_ERRORS = 3; export function CreditsProvider({ children }: { children: ReactNode }) { - const { authenticated, ready, getAccessToken, logout } = usePrivy(); + const { authenticated, ready, privyAuthenticated } = useSessionAuth(); + const { getAccessToken, logout } = usePrivy(); const pathname = usePathname(); const [creditBalance, setCreditBalance] = useState(null); const [isLoading, setIsLoading] = useState(true); @@ -55,11 +57,11 @@ export function CreditsProvider({ children }: { children: ReactNode }) { const isLoggingOutRef = useRef(false); const shouldDeferAuthenticatedFetches = pathname === "/login"; - // Store Privy functions in refs to avoid recreating callbacks on every render + // Store Privy helpers in refs so authenticated Privy sessions can still refresh cookies on 401. + // Steward sessions stay cookie-based and do not use this path. const getAccessTokenRef = useRef(getAccessToken); const logoutRef = useRef(logout); - // Update refs in effect to avoid updating during render useEffect(() => { getAccessTokenRef.current = getAccessToken; logoutRef.current = logout; @@ -127,34 +129,28 @@ export function CreditsProvider({ children }: { children: ReactNode }) { let response = await doFetch(); - // On 401, try to refresh the session and retry once - if (response.status === 401) { - logger.info("[CreditsProvider] Session may be stale, refreshing..."); + // On 401, try to refresh the session and retry once for Privy sessions. + // Steward sessions are already cookie-backed, so there is no separate token refresh path. + if (response.status === 401 && privyAuthenticated) { + logger.info("[CreditsProvider] Session may be stale, refreshing Privy session..."); - // getAccessToken() triggers Privy to refresh the session/cookies const freshToken = await getAccessTokenRef.current().catch(() => null); if (!freshToken) { - // Token refresh failed - session is truly expired - logger.warn("[CreditsProvider] Session refresh failed, logging out"); + logger.warn("[CreditsProvider] Privy session refresh failed, pausing polling"); if (isMountedRef.current) { setError("Session expired"); setIsConnected(false); setCreditBalance(null); setIsLoading(false); } - // Set logout flag BEFORE stopping polling to prevent race conditions isLoggingOutRef.current = true; stopPolling(); logoutRef.current(); return; } - // Token refresh succeeded - reset error counter before retry - // This acknowledges the auth system is working, giving a fresh set of retries authErrorCountRef.current = 0; - - // Retry with refreshed session response = await doFetch(); } @@ -163,12 +159,11 @@ export function CreditsProvider({ children }: { children: ReactNode }) { authErrorCountRef.current++; if (authErrorCountRef.current >= MAX_AUTH_ERRORS) { - logger.warn("[CreditsProvider] Too many auth errors after refresh, logging out"); + logger.warn("[CreditsProvider] Too many auth errors, pausing credit polling"); // Set logout flag BEFORE stopping polling to prevent race conditions isLoggingOutRef.current = true; stopPolling(); - logoutRef.current(); - // Early return after triggering logout to prevent further processing + // Early return after pausing to prevent further processing if (isMountedRef.current) { setError("Unauthorized"); setIsConnected(false); @@ -208,7 +203,7 @@ export function CreditsProvider({ children }: { children: ReactNode }) { timestamp: new Date().toISOString(), }); } - }, [authenticated, shouldDeferAuthenticatedFetches, stopPolling]); + }, [authenticated, shouldDeferAuthenticatedFetches, stopPolling, privyAuthenticated]); // Setup BroadcastChannel for cross-tab sync useEffect(() => { diff --git a/packages/lib/providers/PostHogProvider.tsx b/packages/lib/providers/PostHogProvider.tsx index 394d24f7c..e9cc0b2be 100644 --- a/packages/lib/providers/PostHogProvider.tsx +++ b/packages/lib/providers/PostHogProvider.tsx @@ -2,7 +2,7 @@ import { usePrivy } from "@privy-io/react-auth"; import { usePathname, useSearchParams } from "next/navigation"; -import { Suspense, useEffect, useRef } from "react"; +import { Suspense, useEffect, useMemo, useRef } from "react"; import { getPostHog, getSignupMethod, @@ -12,6 +12,7 @@ import { resetUser, trackEvent, } from "@/lib/analytics/posthog"; +import { useSessionAuth } from "@/lib/hooks/use-session-auth"; function PageViewTracker(): null { const pathname = usePathname(); @@ -34,11 +35,47 @@ function PageViewTracker(): null { } function UserIdentifier(): null { - const { ready, authenticated, user } = usePrivy(); + const { user: privyUser } = usePrivy(); + const { ready, authenticated, authSource, user } = useSessionAuth(); const pathname = usePathname(); const identifiedRef = useRef(false); const previousAuthState = useRef(null); + const authInfo: PrivyUserAuthInfo = useMemo( + () => ({ + email: privyUser?.email ? { address: privyUser.email.address ?? undefined } : null, + google: privyUser?.google + ? { + email: privyUser.google.email ?? undefined, + name: privyUser.google.name ?? undefined, + } + : null, + discord: privyUser?.discord + ? { + email: privyUser.discord.email ?? undefined, + username: privyUser.discord.username ?? undefined, + } + : null, + github: privyUser?.github ? { username: privyUser.github.username ?? undefined } : null, + wallet: privyUser?.wallet ? { address: privyUser.wallet.address ?? undefined } : null, + }), + [privyUser], + ); + + const email = + authSource === "steward" + ? user && "email" in user && typeof user.email === "string" + ? user.email + : undefined + : (authInfo.email?.address ?? authInfo.google?.email ?? authInfo.discord?.email); + const name = + authSource === "steward" + ? email?.split("@")[0] + : (authInfo.google?.name ?? authInfo.discord?.username ?? authInfo.github?.username); + const method = authSource === "steward" ? "email" : getSignupMethod(authInfo); + const walletAddress = authSource === "steward" ? undefined : privyUser?.wallet?.address; + const createdAt = authSource === "steward" ? undefined : privyUser?.createdAt?.toISOString(); + useEffect(() => { // AbortController cancels in-flight requests on cleanup (logout/unmount) const abortController = new AbortController(); @@ -61,26 +98,6 @@ function UserIdentifier(): null { // Handle login - fetch internal user ID for consistent identification if (authenticated && user && !identifiedRef.current) { - const authInfo: PrivyUserAuthInfo = { - email: user.email ? { address: user.email.address ?? undefined } : null, - google: user.google - ? { - email: user.google.email ?? undefined, - name: user.google.name ?? undefined, - } - : null, - discord: user.discord - ? { - email: user.discord.email ?? undefined, - username: user.discord.username ?? undefined, - } - : null, - github: user.github ? { username: user.github.username ?? undefined } : null, - wallet: user.wallet ? { address: user.wallet.address ?? undefined } : null, - }; - const email = authInfo.email?.address ?? authInfo.google?.email ?? authInfo.discord?.email; - const name = authInfo.google?.name ?? authInfo.discord?.username ?? authInfo.github?.username; - const method = getSignupMethod(authInfo); const isFirstLogin = previousAuthState.current === false; // Fetch internal user ID from API @@ -97,9 +114,9 @@ function UserIdentifier(): null { identifyUser(data.data.id, { email, name, - wallet_address: user.wallet?.address, + wallet_address: walletAddress, signup_method: method, - created_at: user.createdAt?.toISOString(), + created_at: createdAt, }); identifiedRef.current = true; @@ -122,7 +139,7 @@ function UserIdentifier(): null { return () => { abortController.abort(); }; - }, [ready, authenticated, pathname, user]); + }, [ready, authenticated, pathname, user, email, name, method, walletAddress, createdAt]); return null; } diff --git a/packages/lib/providers/StewardProvider.tsx b/packages/lib/providers/StewardProvider.tsx index ef11e71b5..4149ef821 100644 --- a/packages/lib/providers/StewardProvider.tsx +++ b/packages/lib/providers/StewardProvider.tsx @@ -1,7 +1,7 @@ "use client"; import { StewardProvider, useAuth as useStewardAuth } from "@stwd/react"; -import { StewardClient } from "@stwd/sdk"; +import { StewardAuth, StewardClient } from "@stwd/sdk"; import { useEffect, useMemo, useRef } from "react"; /** @@ -30,39 +30,181 @@ function isPlaceholderValue(value: string | undefined): boolean { * Inner wrapper that syncs the Steward JWT to a global API client * so authenticated requests outside React components work correctly. */ +const STEWARD_TOKEN_KEY = "steward_session_token"; + +function readStoredToken(): string | null { + if (typeof window === "undefined") return null; + try { + return localStorage.getItem(STEWARD_TOKEN_KEY); + } catch { + return null; + } +} + +function tokenIsExpired(token: string): boolean { + try { + const parts = token.split("."); + if (parts.length !== 3) return true; + const base64 = parts[1].replace(/-/g, "+").replace(/_/g, "/"); + const padded = base64.padEnd(base64.length + ((4 - (base64.length % 4)) % 4), "="); + const payload = JSON.parse(atob(padded)); + if (!payload.exp) return false; + return payload.exp * 1000 < Date.now(); + } catch { + return true; + } +} + +/** + * Syncs the Steward JWT from localStorage to a server cookie so Next.js + * server components can read it. Works independent of @stwd/react's internal + * auth state (which can be slow/flaky to initialize from storage during + * hydration) by reading localStorage directly. + */ +/** How often to check token expiry and trigger refresh (ms) */ +const REFRESH_CHECK_INTERVAL_MS = 60_000; // 1 min +/** Refresh when fewer than this many seconds remain */ +const REFRESH_AHEAD_SECS = 120; + +function tokenSecsRemaining(token: string): number | null { + try { + const parts = token.split("."); + if (parts.length !== 3) return null; + const base64 = parts[1].replace(/-/g, "+").replace(/_/g, "/"); + const padded = base64.padEnd(base64.length + ((4 - (base64.length % 4)) % 4), "="); + const payload = JSON.parse(atob(padded)); + if (!payload.exp) return null; + return payload.exp - Date.now() / 1000; + } catch { + return null; + } +} + function AuthTokenSync({ children }: { children: React.ReactNode }) { - const { isAuthenticated, getToken, user } = useStewardAuth(); + const { isAuthenticated, user } = useStewardAuth(); const lastSyncedToken = useRef(null); + const wasAuthenticated = useRef(false); + const authInstanceRef = useRef | null>(null); + + const apiUrl = process.env.NEXT_PUBLIC_STEWARD_API_URL ?? "http://localhost:3200"; + const tenantId = process.env.NEXT_PUBLIC_STEWARD_TENANT_ID; + // Create a standalone StewardAuth for refresh purposes (uses localStorage) useEffect(() => { - if (!isAuthenticated) { - lastSyncedToken.current = null; - // Clear the server-side cookie on sign out - fetch("/api/auth/steward-session", { method: "DELETE" }).catch(() => {}); - return; - } - - const token = getToken(); - if (token && token !== lastSyncedToken.current) { + if (typeof window === "undefined") return; + authInstanceRef.current = new StewardAuth({ + baseUrl: apiUrl, + ...(tenantId ? { tenantId } : {}), + }); + }, [apiUrl, tenantId]); + + // Sync localStorage token → cookie and keep it alive via auto-refresh + // biome-ignore lint/correctness/useExhaustiveDependencies: intentional re-run trigger + useEffect(() => { + const syncToken = () => { + const token = readStoredToken(); + if (!token) { + // No token at all — clear the server cookie if we had one + if (wasAuthenticated.current && lastSyncedToken.current) { + lastSyncedToken.current = null; + wasAuthenticated.current = false; + fetch("/api/auth/steward-session", { method: "DELETE" }).catch( + () => {}, + ); + } + return; + } + + // If the token is expired, don't push it to the server (the server would + // reject it anyway), but don't delete the cookie either — the refresh + // path may recover. Only explicit sign-out clears cookies. + if (tokenIsExpired(token)) return; + + if (token === lastSyncedToken.current) return; lastSyncedToken.current = token; + wasAuthenticated.current = true; - // Set the server-side session cookie so Next.js server components - // can read the steward JWT (localStorage is client-only) fetch("/api/auth/steward-session", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ token }), - }).catch((err) => console.warn("[steward] Failed to set session cookie", err)); + }).catch((err) => + console.warn("[steward] Failed to set session cookie", err), + ); - // Dispatch a custom event so non-React code (fetch wrappers, etc.) - // can pick up the fresh JWT without coupling to React context. window.dispatchEvent( new CustomEvent("steward-token-sync", { detail: { token, userId: user?.id }, }), ); - } - }, [isAuthenticated, getToken, user]); + }; + + const checkAndRefresh = async () => { + const token = readStoredToken(); + if (!token) return; + + const secs = tokenSecsRemaining(token); + + // Refresh eagerly when the token is within the lookahead window OR + // already expired (e.g. tab was idle longer than 15 min). Dropping + // the `secs > 0` guard is the key fix for the silent-logout bug: + // previously, once the access token expired we stopped trying to + // refresh even though the refresh token was still good. + if (secs !== null && secs >= REFRESH_AHEAD_SECS) return; + + const auth = authInstanceRef.current; + if (!auth) return; + + try { + const newSession = await auth.refreshSession(); + if (newSession) { + // refreshSession already updated localStorage, now sync the new token to cookie + syncToken(); + } else if (secs !== null && secs <= 0) { + // Refresh returned null AND the access token is truly expired — + // now it's safe to clear the server cookie; the user is logged out. + if (wasAuthenticated.current && lastSyncedToken.current) { + lastSyncedToken.current = null; + wasAuthenticated.current = false; + fetch("/api/auth/steward-session", { method: "DELETE" }).catch( + () => {}, + ); + } + } + } catch (err) { + console.warn("[steward] Auto-refresh failed", err); + } + }; + + // Initial sync + eager refresh check (covers returning-from-idle tabs) + syncToken(); + void checkAndRefresh(); + + // Periodic refresh check + const refreshInterval = setInterval(() => { + void checkAndRefresh(); + }, REFRESH_CHECK_INTERVAL_MS); + + // Run another refresh check whenever the tab becomes visible — covers + // the common case of coming back to a tab that was idle for > 15 min, + // since browsers throttle setInterval in background tabs. + const visibilityHandler = () => { + if (document.visibilityState === "visible") { + void checkAndRefresh(); + } + }; + document.addEventListener("visibilitychange", visibilityHandler); + + // Also sync on storage events (cross-tab, login flow) + const handler = () => syncToken(); + window.addEventListener("storage", handler); + + return () => { + clearInterval(refreshInterval); + window.removeEventListener("storage", handler); + document.removeEventListener("visibilitychange", visibilityHandler); + }; + }, [isAuthenticated, user]); return children; } @@ -84,6 +226,10 @@ export function StewardAuthProvider({ children }: { children: React.ReactNode }) [apiUrl, tenantId], ); + // Stabilize the auth prop so the inner doesn't recreate its + // StewardAuth instance on every render (which would thrash auth state). + const authConfig = useMemo(() => ({ baseUrl: apiUrl }), [apiUrl]); + useEffect(() => { if (typeof window === "undefined" || hasValidUrl || hasLoggedConfigError.current) return; hasLoggedConfigError.current = true; @@ -102,7 +248,7 @@ export function StewardAuthProvider({ children }: { children: React.ReactNode }) {children} diff --git a/packages/lib/services/ai-pricing-definitions.ts b/packages/lib/services/ai-pricing-definitions.ts index 139532d7c..392d90c05 100644 --- a/packages/lib/services/ai-pricing-definitions.ts +++ b/packages/lib/services/ai-pricing-definitions.ts @@ -281,6 +281,32 @@ export const SUPPORTED_VIDEO_MODELS: SupportedVideoModelDefinition[] = [ audio: false, }, }, + { + modelId: "bytedance/seedance-2.0/text-to-video", + provider: "fal", + billingSource: "fal", + label: "Seedance 2.0", + pageUrl: "https://fal.ai/models/bytedance/seedance-2.0/text-to-video", + pricingParser: "seedance", + defaultParameters: { + durationSeconds: 8, + resolution: "720p", + audio: true, + }, + }, + { + modelId: "bytedance/seedance-2.0/fast/text-to-video", + provider: "fal", + billingSource: "fal", + label: "Seedance 2.0 Fast", + pageUrl: "https://fal.ai/models/bytedance/seedance-2.0/fast/text-to-video", + pricingParser: "seedance", + defaultParameters: { + durationSeconds: 8, + resolution: "720p", + audio: true, + }, + }, ] as const; export const ELEVENLABS_SNAPSHOT_PRICING: ElevenLabsSnapshotEntry[] = [ diff --git a/packages/lib/services/ai-pricing.ts b/packages/lib/services/ai-pricing.ts index 39b48323c..57b972336 100644 --- a/packages/lib/services/ai-pricing.ts +++ b/packages/lib/services/ai-pricing.ts @@ -691,8 +691,15 @@ function parseFalPricingEntries( } break; } - case "seedance": - throw new Error("Seedance pricing parser is not implemented yet"); + case "seedance": { + const match = paragraph.match(/\$([\d.]+)\/second/); + if (!match) { + throw new Error(`Unable to parse Seedance pricing paragraph: ${paragraph}`); + } + + entries.push(buildFalEntry(model, "second", Number(match[1]), { resolution: "720p" })); + break; + } } return entries; @@ -730,6 +737,15 @@ async function fetchText(url: string): Promise { return await response.text(); } +function evictExpiredCacheEntries(): void { + const now = Date.now(); + for (const [key, value] of externalCatalogCache) { + if (value.expiresAt <= now) { + externalCatalogCache.delete(key); + } + } +} + async function getCachedExternalEntries( cacheKey: string, loader: () => Promise, @@ -739,6 +755,9 @@ async function getCachedExternalEntries( return cached.entries; } + // Evict expired entries before adding new ones to prevent unbounded growth + evictExpiredCacheEntries(); + const entries = await loader(); externalCatalogCache.set(cacheKey, { entries, @@ -767,9 +786,33 @@ async function fetchFalCatalogEntries(): Promise { return await getCachedExternalEntries("fal", async () => { const entryArrays = await Promise.all( SUPPORTED_VIDEO_MODELS.map(async (model) => { - const html = await fetchText(model.pageUrl); - const paragraph = extractFalPricingParagraph(html); - return parseFalPricingEntries(model, paragraph); + try { + const html = await fetchText(model.pageUrl); + const paragraph = extractFalPricingParagraph(html); + return parseFalPricingEntries(model, paragraph); + } catch (error) { + const message = error instanceof Error ? error.message : String(error); + logger.warn("[AI Pricing] fal parse failed, falling back to DB", { + model: model.modelId, + error: message, + }); + + // Fallback: return last known active DB entries for this model + const dbEntries = await aiPricingRepository.listActiveEntries({ + billingSource: "fal", + provider: "fal", + model: model.modelId, + productFamily: "video", + chargeType: "generation", + }); + + if (dbEntries.length > 0) { + return dbEntries.map((entry) => aiEntryToPrepared(entry)); + } + + logger.error("[AI Pricing] No DB fallback available", { model: model.modelId }); + return []; + } }), ); diff --git a/packages/ui/src/components/chat/character-build-mode.tsx b/packages/ui/src/components/chat/character-build-mode.tsx index b8b32e632..f390629ae 100644 --- a/packages/ui/src/components/chat/character-build-mode.tsx +++ b/packages/ui/src/components/chat/character-build-mode.tsx @@ -15,12 +15,12 @@ import { ResizablePanel, ResizablePanelGroup, } from "@elizaos/cloud-ui"; -import { usePrivy } from "@privy-io/react-auth"; import Image from "next/image"; import { useRouter } from "next/navigation"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { toast } from "sonner"; import { createCharacter, getCharacter, updateCharacter } from "@/app/actions/characters"; +import { useSessionAuth } from "@/lib/hooks/use-session-auth"; import { useChatStore } from "@/lib/stores/chat-store"; import type { ElizaCharacter } from "@/lib/types"; import type { PreUploadedFile } from "@/lib/types/knowledge"; @@ -43,7 +43,7 @@ export function CharacterBuildMode({ // Parent uses key={initialCharacterId} to force remount on character change const effectiveCharacterId = initialCharacterId || null; - const { user } = usePrivy(); + const { user } = useSessionAuth(); const userId = user?.id || ""; const router = useRouter(); diff --git a/packages/ui/src/components/chat/eliza-chat-interface.tsx b/packages/ui/src/components/chat/eliza-chat-interface.tsx index f4c686415..685e39986 100644 --- a/packages/ui/src/components/chat/eliza-chat-interface.tsx +++ b/packages/ui/src/components/chat/eliza-chat-interface.tsx @@ -39,6 +39,7 @@ import { import { useRouter } from "next/navigation"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { toast } from "sonner"; +import { useSessionAuth } from "@/lib/hooks/use-session-auth"; import type { ReasoningChunkData, StreamChunkData, @@ -65,7 +66,6 @@ import { DropdownMenuTrigger, } from "@elizaos/cloud-ui"; import { ContentType, type Media } from "@elizaos/core"; -import { usePrivy } from "@privy-io/react-auth"; import { ADDITIONAL_IMAGE_MODELS, ADDITIONAL_MODELS, @@ -165,7 +165,7 @@ export function ElizaChatInterface({ } = useChatStore(); // Check authentication status for features that require it - const { authenticated } = usePrivy(); + const { authenticated } = useSessionAuth(); const _router = useRouter(); const [messages, setMessages] = useState([]); diff --git a/packages/ui/src/components/landing/landing-page-new.tsx b/packages/ui/src/components/landing/landing-page-new.tsx index e1ad4b051..715f80111 100644 --- a/packages/ui/src/components/landing/landing-page-new.tsx +++ b/packages/ui/src/components/landing/landing-page-new.tsx @@ -6,12 +6,12 @@ "use client"; -import { usePrivy } from "@privy-io/react-auth"; import { Loader2 } from "lucide-react"; import { useRouter } from "next/navigation"; import { useEffect, useRef } from "react"; // import DiscoverAgents from "./discover-agents"; import { toast } from "sonner"; +import { useSessionAuth } from "@/lib/hooks/use-session-auth"; import Footer from "@/packages/ui/src/components/landing/Footer"; import LandingHeader from "@/packages/ui/src/components/layout/landing-header"; import HeroSection from "./hero-section"; @@ -21,7 +21,7 @@ interface LandingPageProps { } export function LandingPage({ accessError }: LandingPageProps) { - const { ready, authenticated } = usePrivy(); + const { ready, authenticated } = useSessionAuth(); const router = useRouter(); const hasRedirectedRef = useRef(false); const errorShownRef = useRef(false); diff --git a/packages/ui/src/components/layout/chat-header.tsx b/packages/ui/src/components/layout/chat-header.tsx index 285e54191..8eeba0516 100644 --- a/packages/ui/src/components/layout/chat-header.tsx +++ b/packages/ui/src/components/layout/chat-header.tsx @@ -16,7 +16,6 @@ import { DropdownMenuSeparator, DropdownMenuTrigger, } from "@elizaos/cloud-ui"; -import { usePrivy } from "@privy-io/react-auth"; import { Check, ChevronDown, @@ -35,6 +34,7 @@ import Link from "next/link"; import { usePathname, useRouter } from "next/navigation"; import { useEffect, useState } from "react"; import { toast } from "sonner"; +import { useSessionAuth } from "@/lib/hooks/use-session-auth"; import { useChatStore } from "@/lib/stores/chat-store"; import { cn } from "@/lib/utils"; import { ElizaAvatar } from "@/packages/ui/src/components/chat/eliza-avatar"; @@ -116,7 +116,7 @@ interface ChatHeaderProps { export function ChatHeader({ onToggleSidebar }: ChatHeaderProps) { const router = useRouter(); const pathname = usePathname(); - const { authenticated: isAuthenticated } = usePrivy(); + const { authenticated: isAuthenticated } = useSessionAuth(); const { selectedCharacterId, setSelectedCharacterId, diff --git a/packages/ui/src/components/layout/landing-header.tsx b/packages/ui/src/components/layout/landing-header.tsx index 3110b7ac1..f0c309272 100644 --- a/packages/ui/src/components/layout/landing-header.tsx +++ b/packages/ui/src/components/layout/landing-header.tsx @@ -6,14 +6,14 @@ "use client"; import { Button, ElizaCloudLockup } from "@elizaos/cloud-ui"; -import { usePrivy } from "@privy-io/react-auth"; import { motion } from "framer-motion"; import Link from "next/link"; import { useRouter } from "next/navigation"; +import { useSessionAuth } from "@/lib/hooks/use-session-auth"; import UserMenu from "@/packages/ui/src/components/layout/user-menu"; export default function LandingHeader() { - const { ready, authenticated } = usePrivy(); + const { ready, authenticated } = useSessionAuth(); const router = useRouter(); // No auto-redirect - let users stay on landing page even when logged in diff --git a/packages/ui/src/components/layout/sidebar-bottom-panel.tsx b/packages/ui/src/components/layout/sidebar-bottom-panel.tsx index bd67f0b68..4bba19145 100644 --- a/packages/ui/src/components/layout/sidebar-bottom-panel.tsx +++ b/packages/ui/src/components/layout/sidebar-bottom-panel.tsx @@ -9,9 +9,9 @@ "use client"; import { CornerBrackets } from "@elizaos/cloud-ui"; -import { usePrivy } from "@privy-io/react-auth"; import { LogIn, Settings, UserPlus } from "lucide-react"; import { usePathname } from "next/navigation"; +import { useSessionAuth } from "@/lib/hooks/use-session-auth"; import { cn } from "@/lib/utils"; interface SidebarBottomPanelProps { @@ -20,7 +20,7 @@ interface SidebarBottomPanelProps { } export function SidebarBottomPanel({ className, isCollapsed = false }: SidebarBottomPanelProps) { - const { ready, authenticated, user } = usePrivy(); + const { ready, authenticated, user } = useSessionAuth(); const pathname = usePathname(); // If not authenticated, show sign up/login CTA diff --git a/packages/ui/src/components/layout/sidebar-item.tsx b/packages/ui/src/components/layout/sidebar-item.tsx index 69240754c..8eaf81a69 100644 --- a/packages/ui/src/components/layout/sidebar-item.tsx +++ b/packages/ui/src/components/layout/sidebar-item.tsx @@ -9,10 +9,10 @@ "use client"; import { Tooltip, TooltipContent, TooltipTrigger } from "@elizaos/cloud-ui"; -import { usePrivy } from "@privy-io/react-auth"; import { Lock } from "lucide-react"; import Link from "next/link"; import { usePathname } from "next/navigation"; +import { useSessionAuth } from "@/lib/hooks/use-session-auth"; import { cn } from "@/lib/utils"; import type { SidebarItem } from "./sidebar-data"; @@ -23,7 +23,7 @@ interface SidebarNavigationItemProps { export function SidebarNavigationItem({ item, isCollapsed = false }: SidebarNavigationItemProps) { const pathname = usePathname(); - const { authenticated } = usePrivy(); + const { authenticated } = useSessionAuth(); // Use exact match for dashboard and admin root; startsWith for other routes const isActive = item.href === "/dashboard" || item.href === "/dashboard/admin" diff --git a/packages/ui/src/components/layout/user-menu.tsx b/packages/ui/src/components/layout/user-menu.tsx index 80a047b4b..b68e329de 100644 --- a/packages/ui/src/components/layout/user-menu.tsx +++ b/packages/ui/src/components/layout/user-menu.tsx @@ -34,6 +34,7 @@ import { } from "lucide-react"; import { usePathname, useRouter } from "next/navigation"; import { Component, type ErrorInfo, type ReactNode, useEffect, useState } from "react"; +import { useSessionAuth, useStewardAuth } from "@/lib/hooks/use-session-auth"; import { useCredits } from "@/lib/providers/CreditsProvider"; import { useChatStore } from "@/lib/stores/chat-store"; import { FeedbackModal } from "./feedback-modal"; @@ -43,6 +44,7 @@ interface UserProfile { name: string | null; avatar: string | null; email: string | null; + organizationCreditBalance?: number | null; } // --------------------------------------------------------------------------- @@ -277,6 +279,7 @@ function formatCreditBalance(balance: number | null): string { } type PrivyUser = ReturnType["user"]; +type StewardUser = ReturnType["user"]; interface UserMenuProps { preserveWhileUnauthed?: boolean; @@ -286,7 +289,15 @@ interface UserMenuProps { // Main component (inner) // --------------------------------------------------------------------------- function UserMenuInner({ preserveWhileUnauthed = false }: UserMenuProps) { - const { ready, authenticated, user } = usePrivy(); + const { + ready, + authenticated, + privyAuthenticated, + stewardAuthenticated, + stewardUser, + user: currentUser, + } = useSessionAuth(); + const { signOut: stewardSignOut } = useStewardAuth(); const pathname = usePathname(); const { logout } = useLogout(); const router = useRouter(); @@ -296,11 +307,13 @@ function UserMenuInner({ preserveWhileUnauthed = false }: UserMenuProps) { // User profile state for avatar const [userProfile, setUserProfile] = useState(null); const [feedbackOpen, setFeedbackOpen] = useState(false); - const [lastAuthenticatedUser, setLastAuthenticatedUser] = useState(null); + const [lastAuthenticatedUser, setLastAuthenticatedUser] = useState< + PrivyUser | StewardUser | null + >(null); useEffect(() => { - if (authenticated && user) { - setLastAuthenticatedUser(user); + if (authenticated && currentUser) { + setLastAuthenticatedUser(currentUser); return; } @@ -308,12 +321,15 @@ function UserMenuInner({ preserveWhileUnauthed = false }: UserMenuProps) { setLastAuthenticatedUser(null); setUserProfile(null); } - }, [authenticated, user, preserveWhileUnauthed]); + }, [authenticated, currentUser, preserveWhileUnauthed]); - const effectiveUser = - authenticated && user ? user : preserveWhileUnauthed ? lastAuthenticatedUser : null; + const effectiveUser = authenticated + ? currentUser + : preserveWhileUnauthed + ? lastAuthenticatedUser + : null; - // Fetch user profile from API to get avatar + // Fetch user profile from API to get avatar and org balance for both Privy and Steward sessions useEffect(() => { if (!authenticated) return; @@ -330,6 +346,10 @@ function UserMenuInner({ preserveWhileUnauthed = false }: UserMenuProps) { name: data.data.name ?? null, avatar: data.data.avatar ?? null, email: data.data.email ?? null, + organizationCreditBalance: + data.data.organization?.credit_balance !== undefined + ? Number(data.data.organization.credit_balance) + : null, }); } } @@ -346,11 +366,13 @@ function UserMenuInner({ preserveWhileUnauthed = false }: UserMenuProps) { }; window.addEventListener("user-avatar-updated", handleProfileRefresh); window.addEventListener("anon-migration-complete", handleProfileRefresh); + window.addEventListener("steward-token-sync", handleProfileRefresh); return () => { mounted = false; window.removeEventListener("user-avatar-updated", handleProfileRefresh); window.removeEventListener("anon-migration-complete", handleProfileRefresh); + window.removeEventListener("steward-token-sync", handleProfileRefresh); }; }, [authenticated]); @@ -394,8 +416,15 @@ function UserMenuInner({ preserveWhileUnauthed = false }: UserMenuProps) { // Clear chat data (rooms, entityId, localStorage) clearChatData(); - // Call Privy's logout to clear authentication state - await logout(); + if (stewardAuthenticated) { + stewardSignOut(); + await fetch("/api/auth/steward-session", { method: "DELETE" }).catch(() => {}); + } + + if (privyAuthenticated) { + // Call Privy's logout to clear authentication state + await logout(); + } // Use router.replace to avoid browser history pollution // This prevents back button issues after re-login @@ -407,12 +436,40 @@ function UserMenuInner({ preserveWhileUnauthed = false }: UserMenuProps) { } }; - // Pre-compute all display values safely (outside JSX to keep render clean) - const displayName = safeGetUserName(effectiveUser); - const displayIdentifier = safeGetUserIdentifier(effectiveUser); - const initials = safeGetInitials(userProfile, effectiveUser); + // Pre-compute all display values safely, preferring server profile for Steward sessions + const displayName = + userProfile?.name || + userProfile?.email?.split("@")[0] || + (stewardAuthenticated && stewardUser?.email + ? stewardUser.email.split("@")[0] + : safeGetUserName(effectiveUser as PrivyUser)); + const displayIdentifier = + userProfile?.email || + (stewardAuthenticated && stewardUser?.email ? stewardUser.email : null) || + safeGetUserIdentifier(effectiveUser as PrivyUser); + const initials = (() => { + if (userProfile?.name || userProfile?.email) { + const source = userProfile.name || userProfile.email || "U"; + const parts = source.trim().split(/\s+/).filter(Boolean); + if (parts.length > 1) + return parts + .map((n) => n[0]) + .join("") + .toUpperCase() + .slice(0, 2); + return source.slice(0, 2).toUpperCase(); + } + if (stewardAuthenticated && stewardUser?.email) { + return stewardUser.email.slice(0, 2).toUpperCase(); + } + return safeGetInitials(userProfile, effectiveUser as PrivyUser); + })(); const feedbackName = userProfile?.name || displayName; - const feedbackEmail = userProfile?.email || safeGetUserEmail(effectiveUser) || ""; + const feedbackEmail = + userProfile?.email || + (stewardAuthenticated && stewardUser?.email ? stewardUser.email : "") || + safeGetUserEmail(effectiveUser as PrivyUser) || + ""; // Signed in state return ( @@ -448,7 +505,9 @@ function UserMenuInner({ preserveWhileUnauthed = false }: UserMenuProps) {
- {loadingCredits && creditBalance === null ? ( + {loadingCredits && + creditBalance === null && + userProfile?.organizationCreditBalance == null ? (
Loading... @@ -461,7 +520,10 @@ function UserMenuInner({ preserveWhileUnauthed = false }: UserMenuProps) { > - ${formatCreditBalance(creditBalance)} + $ + {formatCreditBalance( + creditBalance ?? userProfile?.organizationCreditBalance ?? null, + )} balance diff --git a/packages/ui/src/components/settings/tabs/account-tab.tsx b/packages/ui/src/components/settings/tabs/account-tab.tsx index 412836bc6..d07ad7301 100644 --- a/packages/ui/src/components/settings/tabs/account-tab.tsx +++ b/packages/ui/src/components/settings/tabs/account-tab.tsx @@ -15,6 +15,7 @@ import { ArrowUpRight, Copy } from "lucide-react"; import { useRouter } from "next/navigation"; import { useEffect, useState } from "react"; import { toast } from "sonner"; +import { useStewardAuth } from "@/lib/hooks/use-session-auth"; import { useChatStore } from "@/lib/stores/chat-store"; import type { UserWithOrganization } from "@/lib/types"; import type { SettingsTab } from "../settings-page-client"; @@ -42,6 +43,7 @@ export function AccountTab({ user, onTabChange }: AccountTabProps) { const [stats, setStats] = useState(null); const [isLoadingStats, setIsLoadingStats] = useState(true); const { logout: privyLogout } = usePrivy(); + const { isAuthenticated: stewardAuthenticated, signOut: stewardSignOut } = useStewardAuth(); const router = useRouter(); const { clearChatData } = useChatStore(); @@ -75,6 +77,13 @@ export function AccountTab({ user, onTabChange }: AccountTabProps) { // Clear chat data (rooms, entityId, localStorage) clearChatData(); + if (stewardAuthenticated) { + stewardSignOut(); + await fetch("/api/auth/steward-session", { + method: "DELETE", + }).catch(() => {}); + } + await fetch("/api/auth/logout", { method: "POST", }); diff --git a/proxy.ts b/proxy.ts index 7b6d92f9a..bcb5e4aeb 100644 --- a/proxy.ts +++ b/proxy.ts @@ -373,6 +373,13 @@ export async function proxy(request: NextRequest) { const stewardToken = request.cookies.get("steward-token"); const authToken = privyToken || stewardToken; + const playwrightTestSession = + process.env.PLAYWRIGHT_TEST_AUTH === "true" + ? request.cookies.get(PLAYWRIGHT_TEST_SESSION_COOKIE_NAME) + : undefined; + const authHeader = request.headers.get("Authorization"); + const bearerToken = authHeader?.startsWith("Bearer ") ? authHeader.slice(7) : null; + // Steward tokens are HS256 (verified by getCurrentUser, not Privy) // Just pass them through the middleware without Privy verification if (stewardToken && !privyToken && !bearerToken) { @@ -380,12 +387,6 @@ export async function proxy(request: NextRequest) { headers: { "X-Proxy-Time": `${Date.now() - startTime}ms`, "X-Auth-Source": "steward" }, }); } - const playwrightTestSession = - process.env.PLAYWRIGHT_TEST_AUTH === "true" - ? request.cookies.get(PLAYWRIGHT_TEST_SESSION_COOKIE_NAME) - : undefined; - const authHeader = request.headers.get("Authorization"); - const bearerToken = authHeader?.startsWith("Bearer ") ? authHeader.slice(7) : null; const apiKey = request.headers.get("X-API-Key"); // Wallet-sig passthrough only for paths that verify the signature (getTopupRecipient or verifyWalletSignature)