UNPKG

@onvo-ai/js

Version:

The javascript SDK for Onvo AI dashboard builder

1,298 lines (1,296 loc) 98.6 kB
import * as openapi3_ts_oas30_js from 'openapi3-ts/oas30.js'; import { ZodRawShape, ZodTypeAny, z } from 'zod'; import { OAuth2Client, OAuth2Fetch } from '@badgateway/oauth2-client'; import { SupabaseClient } from '@supabase/supabase-js'; declare module 'zod' { interface ZodType<Output, Def extends ZodTypeDef = ZodTypeDef, Input = Output> { openapi(options: any): this; } interface ZodObject<T extends ZodRawShape> { openapi(options: any): this; } interface ZodArray<T extends ZodTypeAny> { openapi(options: any): this; } interface ZodOptional<T extends ZodTypeAny> { openapi(options: any): this; } interface ZodNullable<T extends ZodTypeAny> { openapi(options: any): this; } interface ZodEnum<T extends [string, ...string[]]> { openapi(options: any): this; } } type Json = string | number | boolean | null | { [key: string]: Json | undefined; } | Json[]; type Database = { public: { Tables: { accounts: { Row: { avatar_url: string | null; email: string | null; full_name: string | null; id: string; phone_number: string | null; updated_at: string | null; }; Insert: { avatar_url?: string | null; email?: string | null; full_name?: string | null; id: string; phone_number?: string | null; updated_at?: string | null; }; Update: { avatar_url?: string | null; email?: string | null; full_name?: string | null; id?: string; phone_number?: string | null; updated_at?: string | null; }; Relationships: []; }; api_keys: { Row: { created_at: string | null; hash: string; id: string; last_used_at: string | null; prefix: string; scopes: string[]; suffix: string; team: string; title: string; }; Insert: { created_at?: string | null; hash: string; id?: string; last_used_at?: string | null; prefix: string; scopes?: string[]; suffix: string; team: string; title: string; }; Update: { created_at?: string | null; hash?: string; id?: string; last_used_at?: string | null; prefix?: string; scopes?: string[]; suffix?: string; team?: string; title?: string; }; Relationships: [ { foreignKeyName: "public_api_keys_team_fkey"; columns: ["team"]; isOneToOne: false; referencedRelation: "teams"; referencedColumns: ["id"]; } ]; }; automation_runs: { Row: { automation: string; conditions_passed: boolean | null; error: string | null; id: string; method: string; recipient_emails: string[] | null; run_at: string; status: string; team: string; webhook_sent: boolean | null; }; Insert: { automation: string; conditions_passed?: boolean | null; error?: string | null; id?: string; method?: string; recipient_emails?: string[] | null; run_at?: string; status: string; team: string; webhook_sent?: boolean | null; }; Update: { automation?: string; conditions_passed?: boolean | null; error?: string | null; id?: string; method?: string; recipient_emails?: string[] | null; run_at?: string; status?: string; team?: string; webhook_sent?: boolean | null; }; Relationships: [ { foreignKeyName: "automation_runs_automation_fkey"; columns: ["automation"]; isOneToOne: false; referencedRelation: "automations"; referencedColumns: ["id"]; }, { foreignKeyName: "public_automation_runs_team_fkey"; columns: ["team"]; isOneToOne: false; referencedRelation: "teams"; referencedColumns: ["id"]; } ]; }; automations: { Row: { condition_operator: string | null; conditions: Json; created_at: string; dashboard: string; description: string | null; email_body: string; email_cc: string[] | null; email_subject: string; email_to: string | null; enabled: boolean; id: string; last_run_at: string | null; last_updated_at: string; method: string; next_run_at: string | null; output_format: string; schedule: string; team: string; timezone: string; title: string; webhook_url: string | null; }; Insert: { condition_operator?: string | null; conditions?: Json; created_at?: string; dashboard: string; description?: string | null; email_body: string; email_cc?: string[] | null; email_subject: string; email_to?: string | null; enabled?: boolean; id?: string; last_run_at?: string | null; last_updated_at?: string; method: string; next_run_at?: string | null; output_format: string; schedule: string; team: string; timezone?: string; title: string; webhook_url?: string | null; }; Update: { condition_operator?: string | null; conditions?: Json; created_at?: string; dashboard?: string; description?: string | null; email_body?: string; email_cc?: string[] | null; email_subject?: string; email_to?: string | null; enabled?: boolean; id?: string; last_run_at?: string | null; last_updated_at?: string; method?: string; next_run_at?: string | null; output_format?: string; schedule?: string; team?: string; timezone?: string; title?: string; webhook_url?: string | null; }; Relationships: [ { foreignKeyName: "automations_dashboard_fkey"; columns: ["dashboard"]; isOneToOne: false; referencedRelation: "dashboards"; referencedColumns: ["id"]; }, { foreignKeyName: "public_automations_team_fkey"; columns: ["team"]; isOneToOne: false; referencedRelation: "teams"; referencedColumns: ["id"]; } ]; }; dashboard_datasources: { Row: { dashboard: string; datasource: string; team: string; }; Insert: { dashboard: string; datasource: string; team: string; }; Update: { dashboard?: string; datasource?: string; team?: string; }; Relationships: [ { foreignKeyName: "dashboard_datasources_dashboard_fkey"; columns: ["dashboard"]; isOneToOne: false; referencedRelation: "dashboards"; referencedColumns: ["id"]; }, { foreignKeyName: "dashboard_datasources_datasource_fkey"; columns: ["datasource"]; isOneToOne: false; referencedRelation: "datasources"; referencedColumns: ["id"]; }, { foreignKeyName: "public_dashboard_datasources_team_fkey"; columns: ["team"]; isOneToOne: false; referencedRelation: "teams"; referencedColumns: ["id"]; } ]; }; dashboards: { Row: { created_at: string; created_by: string | null; description: string | null; filters: Json; id: string; last_updated_at: string; last_updated_by: string | null; metadata: Json; parent_dashboard: string | null; settings: Json; tabs: Json; team: string; thumbnail: string | null; title: string; }; Insert: { created_at?: string; created_by?: string | null; description?: string | null; filters?: Json; id?: string; last_updated_at?: string; last_updated_by?: string | null; metadata?: Json; parent_dashboard?: string | null; settings?: Json; tabs?: Json; team: string; thumbnail?: string | null; title: string; }; Update: { created_at?: string; created_by?: string | null; description?: string | null; filters?: Json; id?: string; last_updated_at?: string; last_updated_by?: string | null; metadata?: Json; parent_dashboard?: string | null; settings?: Json; tabs?: Json; team?: string; thumbnail?: string | null; title?: string; }; Relationships: [ { foreignKeyName: "dashboards_created_by_fkey"; columns: ["created_by"]; isOneToOne: false; referencedRelation: "accounts"; referencedColumns: ["id"]; }, { foreignKeyName: "dashboards_last_updated_by_fkey"; columns: ["last_updated_by"]; isOneToOne: false; referencedRelation: "accounts"; referencedColumns: ["id"]; }, { foreignKeyName: "dashboards_parent_dashboard_fkey"; columns: ["parent_dashboard"]; isOneToOne: false; referencedRelation: "dashboards"; referencedColumns: ["id"]; }, { foreignKeyName: "public_dashboards_team_fkey"; columns: ["team"]; isOneToOne: false; referencedRelation: "teams"; referencedColumns: ["id"]; } ]; }; datasources: { Row: { cache_duration: number; columns: Json | null; config: Json | null; created_at: string; created_by: string | null; description: string | null; filters: Json; id: string; integration: string | null; last_updated_at: string; last_updated_by: string | null; metadata: Json; method: Database["public"]["Enums"]["Datasource method"]; parameters: Json | null; size: number; source: string; team: string; title: string; }; Insert: { cache_duration?: number; columns?: Json | null; config?: Json | null; created_at?: string; created_by?: string | null; description?: string | null; filters?: Json; id?: string; integration?: string | null; last_updated_at?: string; last_updated_by?: string | null; metadata?: Json; method?: Database["public"]["Enums"]["Datasource method"]; parameters?: Json | null; size?: number; source: string; team: string; title: string; }; Update: { cache_duration?: number; columns?: Json | null; config?: Json | null; created_at?: string; created_by?: string | null; description?: string | null; filters?: Json; id?: string; integration?: string | null; last_updated_at?: string; last_updated_by?: string | null; metadata?: Json; method?: Database["public"]["Enums"]["Datasource method"]; parameters?: Json | null; size?: number; source?: string; team?: string; title?: string; }; Relationships: [ { foreignKeyName: "datasources_created_by_fkey"; columns: ["created_by"]; isOneToOne: false; referencedRelation: "accounts"; referencedColumns: ["id"]; }, { foreignKeyName: "datasources_integration_fkey"; columns: ["integration"]; isOneToOne: false; referencedRelation: "integrations"; referencedColumns: ["id"]; }, { foreignKeyName: "datasources_last_updated_by_fkey"; columns: ["last_updated_by"]; isOneToOne: false; referencedRelation: "accounts"; referencedColumns: ["id"]; }, { foreignKeyName: "public_datasources_team_fkey"; columns: ["team"]; isOneToOne: false; referencedRelation: "teams"; referencedColumns: ["id"]; } ]; }; embed_users: { Row: { created_at: string; email: string | null; id: string; last_updated_at: string; name: string; parameters: Json | null; team: string; }; Insert: { created_at?: string; email?: string | null; id: string; last_updated_at?: string; name: string; parameters?: Json | null; team: string; }; Update: { created_at?: string; email?: string | null; id?: string; last_updated_at?: string; name?: string; parameters?: Json | null; team?: string; }; Relationships: [ { foreignKeyName: "public_embed_users_team_fkey"; columns: ["team"]; isOneToOne: false; referencedRelation: "teams"; referencedColumns: ["id"]; } ]; }; integration_tables: { Row: { columns: Json | null; config: Json; dataset: string | null; datasource: string | null; description: string | null; errors: string | null; id: string; integration: string; rows: number; size: number; team: string; title: string; }; Insert: { columns?: Json | null; config?: Json; dataset?: string | null; datasource?: string | null; description?: string | null; errors?: string | null; id?: string; integration?: string; rows?: number; size?: number; team: string; title: string; }; Update: { columns?: Json | null; config?: Json; dataset?: string | null; datasource?: string | null; description?: string | null; errors?: string | null; id?: string; integration?: string; rows?: number; size?: number; team?: string; title?: string; }; Relationships: [ { foreignKeyName: "integration_tables_datasource_fkey"; columns: ["datasource"]; isOneToOne: false; referencedRelation: "datasources"; referencedColumns: ["id"]; }, { foreignKeyName: "integration_tables_integration_fkey"; columns: ["integration"]; isOneToOne: false; referencedRelation: "integrations"; referencedColumns: ["id"]; }, { foreignKeyName: "integration_tables_team_fkey"; columns: ["team"]; isOneToOne: false; referencedRelation: "teams"; referencedColumns: ["id"]; } ]; }; integrations: { Row: { config: Json; created_at: string; id: string; parameters: Json | null; provider: string; size: number; status: string; team: string; title: string | null; }; Insert: { config?: Json; created_at?: string; id?: string; parameters?: Json | null; provider: string; size?: number; status?: string; team: string; title?: string | null; }; Update: { config?: Json; created_at?: string; id?: string; parameters?: Json | null; provider?: string; size?: number; status?: string; team?: string; title?: string | null; }; Relationships: [ { foreignKeyName: "public_integrations_team_fkey"; columns: ["team"]; isOneToOne: false; referencedRelation: "teams"; referencedColumns: ["id"]; } ]; }; invites: { Row: { created_at: string; email: string; name: string; team: string; }; Insert: { created_at?: string; email: string; name: string; team: string; }; Update: { created_at?: string; email?: string; name?: string; team?: string; }; Relationships: [ { foreignKeyName: "public_invites_team_fkey"; columns: ["team"]; isOneToOne: false; referencedRelation: "teams"; referencedColumns: ["id"]; } ]; }; llm_settings: { Row: { analyst_agent_api_key: string | null; analyst_agent_api_url: string | null; analyst_agent_model: string; analyst_agent_prompt: string | null; analyst_agent_type: Database["public"]["Enums"]["LLM hosting type"]; programmer_agent_api_key: string | null; programmer_agent_api_url: string | null; programmer_agent_model: string; programmer_agent_prompt: string | null; programmer_agent_type: Database["public"]["Enums"]["LLM hosting type"]; team: string; updated: boolean; }; Insert: { analyst_agent_api_key?: string | null; analyst_agent_api_url?: string | null; analyst_agent_model?: string; analyst_agent_prompt?: string | null; analyst_agent_type?: Database["public"]["Enums"]["LLM hosting type"]; programmer_agent_api_key?: string | null; programmer_agent_api_url?: string | null; programmer_agent_model?: string; programmer_agent_prompt?: string | null; programmer_agent_type?: Database["public"]["Enums"]["LLM hosting type"]; team: string; updated?: boolean; }; Update: { analyst_agent_api_key?: string | null; analyst_agent_api_url?: string | null; analyst_agent_model?: string; analyst_agent_prompt?: string | null; analyst_agent_type?: Database["public"]["Enums"]["LLM hosting type"]; programmer_agent_api_key?: string | null; programmer_agent_api_url?: string | null; programmer_agent_model?: string; programmer_agent_prompt?: string | null; programmer_agent_type?: Database["public"]["Enums"]["LLM hosting type"]; team?: string; updated?: boolean; }; Relationships: [ { foreignKeyName: "public_llm_settings_team_fkey"; columns: ["team"]; isOneToOne: true; referencedRelation: "teams"; referencedColumns: ["id"]; } ]; }; logs: { Row: { account: string | null; created_at: string; dashboard: string | null; embed_user: string | null; id: string; team: string | null; type: string; widget: string | null; }; Insert: { account?: string | null; created_at?: string; dashboard?: string | null; embed_user?: string | null; id?: string; team?: string | null; type: string; widget?: string | null; }; Update: { account?: string | null; created_at?: string; dashboard?: string | null; embed_user?: string | null; id?: string; team?: string | null; type?: string; widget?: string | null; }; Relationships: [ { foreignKeyName: "public_logs_account_fkey"; columns: ["account"]; isOneToOne: false; referencedRelation: "accounts"; referencedColumns: ["id"]; }, { foreignKeyName: "public_logs_dashboard_fkey"; columns: ["dashboard"]; isOneToOne: false; referencedRelation: "dashboards"; referencedColumns: ["id"]; }, { foreignKeyName: "public_logs_embed_user_team_fkey"; columns: ["embed_user", "team"]; isOneToOne: false; referencedRelation: "embed_users"; referencedColumns: ["id", "team"]; }, { foreignKeyName: "public_logs_team_fkey"; columns: ["team"]; isOneToOne: false; referencedRelation: "teams"; referencedColumns: ["id"]; }, { foreignKeyName: "public_logs_widget_fkey"; columns: ["widget"]; isOneToOne: false; referencedRelation: "widgets"; referencedColumns: ["id"]; } ]; }; members: { Row: { account: string; team: string; }; Insert: { account: string; team: string; }; Update: { account?: string; team?: string; }; Relationships: [ { foreignKeyName: "members_user_fkey"; columns: ["account"]; isOneToOne: false; referencedRelation: "accounts"; referencedColumns: ["id"]; }, { foreignKeyName: "public_members_team_fkey"; columns: ["team"]; isOneToOne: false; referencedRelation: "teams"; referencedColumns: ["id"]; } ]; }; messages: { Row: { content: string | null; created_at: string; dashboard: string | null; id: string; question: string; role: string | null; team: string; tool_call_id: string | null; tool_calls: Json | null; widget: string | null; }; Insert: { content?: string | null; created_at?: string; dashboard?: string | null; id?: string; question?: string; role?: string | null; team: string; tool_call_id?: string | null; tool_calls?: Json | null; widget?: string | null; }; Update: { content?: string | null; created_at?: string; dashboard?: string | null; id?: string; question?: string; role?: string | null; team?: string; tool_call_id?: string | null; tool_calls?: Json | null; widget?: string | null; }; Relationships: [ { foreignKeyName: "messages_dashboard_fkey"; columns: ["dashboard"]; isOneToOne: false; referencedRelation: "dashboards"; referencedColumns: ["id"]; }, { foreignKeyName: "messages_question_fkey"; columns: ["question"]; isOneToOne: false; referencedRelation: "questions"; referencedColumns: ["id"]; }, { foreignKeyName: "messages_team_fkey"; columns: ["team"]; isOneToOne: false; referencedRelation: "teams"; referencedColumns: ["id"]; }, { foreignKeyName: "messages_widget_fkey"; columns: ["widget"]; isOneToOne: false; referencedRelation: "widgets"; referencedColumns: ["id"]; } ]; }; questions: { Row: { created_at: string; dashboard: string; id: string; messages: Json; query: string; team: string | null; }; Insert: { created_at?: string; dashboard: string; id?: string; messages?: Json; query: string; team?: string | null; }; Update: { created_at?: string; dashboard?: string; id?: string; messages?: Json; query?: string; team?: string | null; }; Relationships: [ { foreignKeyName: "public_questions_team_fkey"; columns: ["team"]; isOneToOne: false; referencedRelation: "teams"; referencedColumns: ["id"]; }, { foreignKeyName: "questions_dashboard_fkey"; columns: ["dashboard"]; isOneToOne: false; referencedRelation: "dashboards"; referencedColumns: ["id"]; } ]; }; self_hosting_settings: { Row: { airtable_credentials: Json; data_service_endpoint: string; data_service_secret: string; google_credentials: Json; s3_credentials: Json; team: string; }; Insert: { airtable_credentials: Json; data_service_endpoint: string; data_service_secret: string; google_credentials: Json; s3_credentials: Json; team?: string; }; Update: { airtable_credentials?: Json; data_service_endpoint?: string; data_service_secret?: string; google_credentials?: Json; s3_credentials?: Json; team?: string; }; Relationships: [ { foreignKeyName: "self_hosting_settings_team_fkey"; columns: ["team"]; isOneToOne: true; referencedRelation: "teams"; referencedColumns: ["id"]; } ]; }; sessions: { Row: { created_at: string; dashboard: string; embed_user: string; parameters: Json; team: string; }; Insert: { created_at?: string; dashboard: string; embed_user: string; parameters?: Json; team: string; }; Update: { created_at?: string; dashboard?: string; embed_user?: string; parameters?: Json; team?: string; }; Relationships: [ { foreignKeyName: "public_sessions_embed_user_team_fkey"; columns: ["embed_user", "team"]; isOneToOne: false; referencedRelation: "embed_users"; referencedColumns: ["id", "team"]; }, { foreignKeyName: "public_sessions_team_fkey"; columns: ["team"]; isOneToOne: false; referencedRelation: "teams"; referencedColumns: ["id"]; }, { foreignKeyName: "sessions_dashboard_fkey"; columns: ["dashboard"]; isOneToOne: false; referencedRelation: "dashboards"; referencedColumns: ["id"]; } ]; }; subscription_plans: { Row: { accounts: number | null; automations: boolean; connected_datasources: number; copilot: boolean; custom_llm: boolean; embed_users: number; name: string; premium_integrations: number; }; Insert: { accounts?: number | null; automations?: boolean; connected_datasources?: number; copilot?: boolean; custom_llm?: boolean; embed_users?: number; name: string; premium_integrations?: number; }; Update: { accounts?: number | null; automations?: boolean; connected_datasources?: number; copilot?: boolean; custom_llm?: boolean; embed_users?: number; name?: string; premium_integrations?: number; }; Relationships: []; }; subscriptions: { Row: { amount: number; created_at: string; currency: string; integrations: string[]; interval: string; period_end: string; period_start: string; product_name: string; stripe_customer_id: string; stripe_product_id: string; stripe_subscription_id: string; team: string; }; Insert: { amount: number; created_at?: string; currency: string; integrations?: string[]; interval: string; period_end: string; period_start?: string; product_name: string; stripe_customer_id: string; stripe_product_id: string; stripe_subscription_id: string; team: string; }; Update: { amount?: number; created_at?: string; currency?: string; integrations?: string[]; interval?: string; period_end?: string; period_start?: string; product_name?: string; stripe_customer_id?: string; stripe_product_id?: string; stripe_subscription_id?: string; team?: string; }; Relationships: [ { foreignKeyName: "public_subscriptions_team_fkey"; columns: ["team"]; isOneToOne: true; referencedRelation: "teams"; referencedColumns: ["id"]; }, { foreignKeyName: "subscriptions_product_name_fkey"; columns: ["product_name"]; isOneToOne: false; referencedRelation: "subscription_plans"; referencedColumns: ["name"]; } ]; }; teams: { Row: { created_at: string | null; email: string | null; id: string; logo: string | null; name: string | null; phone_number: string | null; stripe_id: string | null; }; Insert: { created_at?: string | null; email?: string | null; id?: string; logo?: string | null; name?: string | null; phone_number?: string | null; stripe_id?: string | null; }; Update: { created_at?: string | null; email?: string | null; id?: string; logo?: string | null; name?: string | null; phone_number?: string | null; stripe_id?: string | null; }; Relationships: []; }; widget_suggestions: { Row: { created_at: string; dashboard: string | null; datasource_hash: string | null; description: string | null; id: string; team: string | null; title: string | null; type: string | null; }; Insert: { created_at?: string; dashboard?: string | null; datasource_hash?: string | null; description?: string | null; id?: string; team?: string | null; title?: string | null; type?: string | null; }; Update: { created_at?: string; dashboard?: string | null; datasource_hash?: string | null; description?: string | null; id?: string; team?: string | null; title?: string | null; type?: string | null; }; Relationships: [ { foreignKeyName: "widget_suggestions_dashboard_fkey"; columns: ["dashboard"]; isOneToOne: false; referencedRelation: "dashboards"; referencedColumns: ["id"]; }, { foreignKeyName: "widget_suggestions_team_fkey"; columns: ["team"]; isOneToOne: false; referencedRelation: "teams"; referencedColumns: ["id"]; } ]; }; widgets: { Row: { code: string; config: Json; created_at: string; dashboard: string; engine: string; error: string | null; id: string; layouts: Json; messages: Json; settings: Json; tab: number; team: string; title: string; type: string; use_in_chat: boolean; use_in_library: boolean | null; }; Insert: { code: string; config?: Json; created_at?: string; dashboard: string; engine?: string; error?: string | null; id?: string; layouts?: Json; messages?: Json; settings?: Json; tab?: number; team: string; title: string; type?: string; use_in_chat?: boolean; use_in_library?: boolean | null; }; Update: { code?: string; config?: Json; created_at?: string; dashboard?: string; engine?: string; error?: string | null; id?: string; layouts?: Json; messages?: Json; settings?: Json; tab?: number; team?: string; title?: string; type?: string; use_in_chat?: boolean; use_in_library?: boolean | null; }; Relationships: [ { foreignKeyName: "public_widgets_team_fkey"; columns: ["team"]; isOneToOne: false; referencedRelation: "teams"; referencedColumns: ["id"]; }, { foreignKeyName: "widgets_dashboard_fkey"; columns: ["dashboard"]; isOneToOne: false; referencedRelation: "dashboards"; referencedColumns: ["id"]; } ]; }; }; Views: { [_ in never]: never; }; Functions: { check_id_in_dashboards: { Args: { id: string; json_data: Json; }; Returns: boolean; }; get_onboarding: { Args: { team_id: string; }; Returns: Json; }; string_to_uuid_array: { Args: { input_string: string; }; Returns: string[]; }; stripe_can_create_automation: { Args: { organisation: string; }; Returns: boolean; }; stripe_can_create_dashboard_datasource: { Args: { dashboard_id: string; organisation: string; }; Returns: boolean; }; stripe_can_create_embed_user: { Args: { organisation: string; }; Returns: boolean; }; stripe_can_create_invite: { Args: { organisation: string; }; Returns: boolean; }; stripe_can_create_llm_settings: { Args: { organisation: string; }; Returns: boolean; }; stripe_can_read_dashboard: { Args: { organisation: string; }; Returns: boolean; }; }; Enums: { "Datasource method": "table" | "query" | "ai"; "LLM hosting type": "default" | "custom" | "openai" | "anthropic" | "groq" | "ollama" | "gemini" | "openrouter" | "ai-gateway"; }; CompositeTypes: { [_ in never]: never; }; }; }; type DatabaseWithoutInternals = Omit<Database, "__InternalSupabase">; type DefaultSchema = DatabaseWithoutInternals[Extract<keyof Database, "public">]; type Tables<DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] & DefaultSchema["Views"]) | { schema: keyof DatabaseWithoutInternals; }, TableName extends DefaultSchemaTableNameOrOptions extends { schema: keyof DatabaseWithoutInternals; } ? keyof (DatabaseWithoutInternals[DefaultSchema