@onvo-ai/js
Version:
The javascript SDK for Onvo AI dashboard builder
1 lines • 50.8 kB
JavaScript
var F=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var ae=Object.prototype.hasOwnProperty;var se=(n,t)=>{for(var a in t)F(n,a,{get:t[a],enumerable:!0})},ie=(n,t,a,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of te(t))!ae.call(n,c)&&c!==a&&F(n,c,{get:()=>t[c],enumerable:!(i=ee(t,c))||i.enumerable});return n};var re=n=>ie(F({},"__esModule",{value:!0}),n);var je={};se(je,{APIKeyZod:()=>Oe,AccountZod:()=>de,AirtableOauthClient:()=>_,AutomationConditionZod:()=>G,AutomationRunZod:()=>he,AutomationZod:()=>ge,BaseOauthClient:()=>m,Constants:()=>ne,DashboardDatasourceZod:()=>ve,DashboardFilterZod:()=>le,DashboardMetaZod:()=>me,DashboardSettingsZod:()=>pe,DashboardTabZod:()=>ce,DashboardZod:()=>ue,DataSourceZod:()=>xe,EmbedUserZod:()=>De,GoogleSheetsOauthClient:()=>y,HubspotOauthClient:()=>x,IntegrationZod:()=>Ie,InviteZod:()=>fe,LLMHostingTypeZod:()=>Q,LLMSettingsZod:()=>Ae,LogType:()=>X,LogZod:()=>Re,MemberZod:()=>_e,MessageZod:()=>be,MetadataItemZod:()=>K,OauthClients:()=>Ne,Onvo:()=>H,OpenApiComponents:()=>Ee,QuestionZod:()=>Se,SessionZod:()=>ke,ShopifyOauthClient:()=>T,SubscriptionPlanZod:()=>we,SubscriptionZod:()=>Te,Table:()=>$,TeamZod:()=>ye,WidgetZod:()=>Pe,XeroOauthClient:()=>D,__ensureFileIsEmitted:()=>oe});module.exports=re(je);var O=require("@asteasolutions/zod-to-openapi"),e=require("zod");(0,O.extendZodWithOpenApi)(e.z);var o=new O.OpenAPIRegistry;var K=o.register("MetadataItem",e.z.object({label:e.z.string().openapi({description:"The label for the metadata item.",example:"User ID"}),value:e.z.string().openapi({description:"The value of the metadata item.",example:"usr_12345"}),secure:e.z.boolean().optional().openapi({description:"Indicates if the metadata value should be treated as secure.",example:!1})}).openapi({description:"A metadata item."}));var P=require("@asteasolutions/zod-to-openapi");var ne={public:{Enums:{"LLM hosting type":["default","openrouter","ollama"]}}};var $=(p=>(p.Countries="countries",p.Invites="invites",p.ItineraryInvites="itinerary_invites",p.Itineraries="itineraries",p.Members="members",p.Teams="teams",p.Travelers="travelers",p.Accounts="accounts",p.DataSources="datasources",p.EmbedUsers="embed_users",p.APIKeys="api_keys",p.Widgets="widgets",p.Dashboards="dashboards",p.DashboardDatasources="dashboard_datasources",p.Sessions="sessions",p.Questions="questions",p.Integrations="integrations",p.DecryptedIntegrations="decrypted_integrations",p.DecryptedSessions="decrypted_sessions",p.DecryptedWidgets="decrypted_widgets",p.DecryptedDatasources="decrypted_datasources",p.Subscriptions="subscriptions",p.SubscriptionPlans="subscription_plans",p.Automations="automations",p.AutomationRuns="automation_runs",p.Logs="logs",p.Messages="messages",p))($||{});var oe=!0;var de=o.register("Account",e.z.object({id:e.z.string().uuid().openapi({description:"The unique identifier for the account.",example:"5899f99d-a449-4bfa-8769-19c097aaf1f5"}),full_name:e.z.string().nullable().optional().openapi({description:"The full name of the account holder.",example:"Demo User"}),email:e.z.string().email().nullable().optional().openapi({description:"The email address associated with the account.",example:"info@onvo.ai"}),avatar_url:e.z.string().url().nullable().optional().openapi({description:"The URL of the account's avatar image.",example:"https://upload.wikimedia.org/wikipedia/commons/8/89/Portrait_Placeholder.png"}),phone_number:e.z.string().nullable().optional().openapi({description:"The phone number associated with the account.",example:"1234567890"}),updated_at:e.z.string().datetime().nullable().optional().openapi({description:"The date and time when the account was last updated.",readOnly:!0,example:"2024-01-17T10:14:12.62603+00:00"})}).openapi({description:"An account that represents a user or organization."}));var s=require("zod");var V=require("@asteasolutions/zod-to-openapi");(0,V.extendZodWithOpenApi)(s.z);var pe=o.register("DashboardSettings",s.z.object({filters:s.z.boolean().openapi({description:"Whether filters are enabled for the dashboard.",example:!0}),cache_refresh_interval:s.z.number().int().positive().optional().openapi({description:"Cache refresh interval in minutes.",example:30}),theme:s.z.enum(["dark","light","auto"]).openapi({description:"Color theme for the dashboard.",example:"auto"}),font:s.z.string().openapi({description:"Font used in the dashboard.",example:"Inter"}),dark_background:s.z.string().openapi({description:"Background color for dark theme.",example:"#18181b"}),dark_foreground:s.z.string().openapi({description:"Foreground color for dark theme.",example:"#23232a"}),dark_text:s.z.string().openapi({description:"Text color for dark theme.",example:"#fff"}),light_background:s.z.string().openapi({description:"Background color for light theme.",example:"#fff"}),light_foreground:s.z.string().openapi({description:"Foreground color for light theme.",example:"#f4f4f5"}),light_text:s.z.string().openapi({description:"Text color for light theme.",example:"#18181b"}),hide_header:s.z.boolean().openapi({description:"Whether to hide the dashboard header.",example:!1}),grid_spacing:s.z.number().int().openapi({description:"Spacing between grid items.",example:16}),grid_height:s.z.number().int().openapi({description:"Height of the dashboard grid.",example:8}),border_radius:s.z.number().openapi({description:"Border radius for dashboard elements.",example:8}),custom_css:s.z.string().openapi({description:"Custom CSS for the dashboard.",example:""}),copilot_title:s.z.string().openapi({description:"Title for the dashboard copilot.",example:"AI Copilot"}),copilot_description:s.z.string().openapi({description:"Description for the dashboard copilot.",example:"Ask questions about your data."}),help_url:s.z.string().url().optional().openapi({description:"URL for dashboard help.",example:"https://docs.onvo.ai"}),enable_advanced_widget_creator:s.z.boolean().optional().openapi({description:"Enables advanced widget creator.",example:!0}),enable_widget_insights:s.z.boolean().optional().openapi({description:"Enables widget insights.",example:!1}),can_ask_questions:s.z.boolean().openapi({description:"Whether users can ask questions.",example:!0}),can_edit_widgets:s.z.boolean().openapi({description:"Whether users can edit widgets.",example:!0}),can_edit_widget_layout:s.z.boolean().openapi({description:"Whether users can edit widget layout.",example:!0}),can_create_widgets:s.z.boolean().openapi({description:"Whether users can create widgets.",example:!0}),can_delete_widgets:s.z.boolean().openapi({description:"Whether users can delete widgets.",example:!1}),can_schedule_reports:s.z.boolean().optional().openapi({description:"Whether users can schedule reports.",example:!1}),disable_download_images:s.z.boolean().openapi({description:"Disable image downloads.",example:!1}),disable_download_reports:s.z.boolean().openapi({description:"Disable report downloads.",example:!1}),disable_download_documents:s.z.boolean().openapi({description:"Disable document downloads.",example:!1}),pdf_orientation:s.z.enum(["portrait","landscape"]).optional().openapi({description:"PDF orientation for downloads.",example:"portrait"})}).openapi({description:"Settings for a dashboard."})),le=o.register("DashboardFilter",s.z.discriminatedUnion("type",[s.z.object({label:s.z.string().openapi({description:"Filter label.",example:"Status"}),type:s.z.literal("text").openapi({description:"Text filter type."}),options:s.z.array(s.z.string()).openapi({description:"Available string options.",example:["Active","Inactive"]}),values:s.z.array(s.z.string()).openapi({description:"Selected string values.",example:["Active"]})}),s.z.object({label:s.z.string().openapi({description:"Filter label.",example:"Range"}),type:s.z.literal("number").openapi({description:"Number filter type."}),options:s.z.tuple([s.z.number(),s.z.number()]).openapi({description:"Available number range.",example:[0,100]}),values:s.z.tuple([s.z.number(),s.z.number()]).openapi({description:"Selected number range.",example:[10,90]})}),s.z.object({label:s.z.string().openapi({description:"Filter label.",example:"Date Range"}),type:s.z.literal("date").openapi({description:"Date filter type."}),options:s.z.tuple([s.z.string(),s.z.string()]).openapi({description:"Available date range.",example:["2023-01-01","2023-12-31"]}),values:s.z.tuple([s.z.string(),s.z.string()]).openapi({description:"Selected date range.",example:["2023-02-01","2023-02-28"]})})]).openapi({description:"A filter for a dashboard."})),ce=o.register("DashboardTab",s.z.object({id:s.z.number().int().openapi({description:"Tab ID.",example:1}),label:s.z.string().openapi({description:"Tab label.",example:"Overview"}),hidden:s.z.boolean().optional().openapi({description:"Whether the tab is hidden.",example:!1})}).openapi({description:"A tab in a dashboard."})),me=o.register("DashboardMeta",s.z.object({created_by:s.z.string().openapi({description:"ID of the account that created the dashboard.",example:"user_abc123"}),last_updated_by:s.z.string().optional().openapi({description:"ID of the account that last updated the dashboard.",example:"user_xyz789"}),widgets:s.z.number().openapi({description:"Number of widgets in the dashboard.",example:5}),datasources:s.z.number().openapi({description:"Number of datasources in the dashboard.",example:2})}).openapi({description:"Metadata associated with a dashboard."})),ue=o.register("Dashboard",s.z.object({id:s.z.string().uuid().openapi({description:"Unique dashboard ID.",example:"9b7deda3-7e2d-458e-84e9-632e47fbe682"}),created_at:s.z.string().openapi({description:"Creation timestamp.",example:"2024-01-17T10:14:12.62603+00:00"}),created_by:s.z.string().uuid().nullable().openapi({description:"ID of the account that created the dashboard.",example:"92c680a3-a9c4-4c02-bb2d-a5d049789662"}),description:s.z.string().nullable().openapi({description:"Dashboard description.",example:"A dashboard for sales analytics."}),filters:s.z.any().openapi({description:"Dashboard filters (arbitrary object)."}),last_updated_at:s.z.string().openapi({description:"Last update timestamp.",example:"2024-02-01T08:00:00.000Z"}),last_updated_by:s.z.string().uuid().nullable().openapi({description:"ID of the account that last updated the dashboard.",example:"92c680a3-a9c4-4c02-bb2d-a5d049789662"}),metadata:s.z.any().openapi({description:"Dashboard metadata (arbitrary object)."}),parent_dashboard:s.z.string().uuid().nullable().openapi({description:"Parent dashboard ID, if this dashboard is nested.",example:null}),settings:s.z.any().openapi({description:"Dashboard settings (arbitrary object)."}),tabs:s.z.any().openapi({description:"Dashboard tabs (arbitrary object)."}),team:s.z.string().uuid().openapi({description:"Team ID associated with the dashboard.",example:"92c680a3-a9c4-4c02-bb2d-a5d049789662"}),thumbnail:s.z.string().nullable().openapi({description:"URL to the dashboard's thumbnail image.",example:"https://example.com/thumbnail.png"}),title:s.z.string().openapi({description:"Dashboard title.",example:"Sales Dashboard"})}).openapi({description:"A dashboard that displays data in a visual format."}));var G=o.register("AutomationCondition",e.z.object({operand_id:e.z.string().openapi({description:"The ID of the operand (e.g., a widget or datasource field) to check."}),reference_type:e.z.enum(["static","dynamic"]).openapi({description:"Whether the reference value is static or dynamic (coming from another field)."}),reference_id:e.z.string().nullable().optional().openapi({description:"The ID of the dynamic reference field (required if reference_type is 'dynamic')."}),reference_value:e.z.string().nullable().optional().openapi({description:"The static reference value (required if reference_type is 'static')."}),operator:e.z.string().openapi({description:"The comparison operator (e.g., '=', '!=', '>', '<')."})}).openapi({description:"An automation condition that must be met for the automation to run."})),ge=o.register("Automation",e.z.object({id:e.z.string().uuid().openapi({description:"The unique identifier for the automation.",example:"09110e5b-ae18-4d19-82ca-6d90f5a33bfd"}),title:e.z.string().openapi({description:"The title of the automation.",example:"Daily Sales Report Automation"}),description:e.z.string().nullable().optional().openapi({description:"A description for the automation.",example:"Sends the daily sales report every morning."}),dashboard:e.z.string().uuid().openapi({description:"The ID of the dashboard associated with the automation.",example:"0f6ec2a8-b4d9-4cba-898d-df126e4b5051"}),team:e.z.string().uuid().openapi({description:"The ID of the team the automation belongs to."}),enabled:e.z.boolean().default(!0).openapi({description:"Whether the automation is currently active."}),schedule:e.z.string().openapi({description:"The cron schedule for the automation.",example:"0 9 * * 1-5"}),timezone:e.z.string().default("UTC").openapi({description:"The timezone for the schedule.",example:"America/New_York"}),method:e.z.string().openapi({description:"The delivery method (e.g., 'email', 'webhook').",example:"email"}),output_format:e.z.string().openapi({description:"The output format for reports (e.g., 'pdf', 'csv').",example:"pdf"}),email_to:e.z.string().email().nullable().optional().openapi({description:"Primary recipient email address (for method 'email').",example:"recipient@example.com"}),email_cc:e.z.array(e.z.string().email()).nullable().optional().openapi({description:"CC recipient email addresses (for method 'email')."}),email_subject:e.z.string().openapi({description:"Email subject line (for method 'email').",example:"Daily Sales Report"}),email_body:e.z.string().openapi({description:"Email body content (for method 'email').",example:"Please find attached the daily sales report."}),webhook_url:e.z.string().url().nullable().optional().openapi({description:"The URL for the webhook (for method 'webhook')."}),condition_operator:e.z.enum(["AND","OR"]).nullable().optional().openapi({description:"Logical operator to combine conditions ('AND' or 'OR')."}),conditions:e.z.array(G).openapi({description:"An array of conditions that must be met for the automation to run."}),created_at:e.z.string().datetime().openapi({description:"The date and time when the automation was created.",readOnly:!0,example:"2025-04-01T12:34:56.789Z"}),last_updated_at:e.z.string().datetime().openapi({description:"The date and time when the automation was last updated.",readOnly:!0,example:"2025-04-02T09:00:00.000Z"}),last_run_at:e.z.string().datetime().nullable().optional().openapi({description:"The date and time when the automation last ran.",readOnly:!0}),next_run_at:e.z.string().datetime().nullable().optional().openapi({description:"The date and time when the automation is scheduled to run next.",readOnly:!0})}).openapi({description:"An automation that runs at a scheduled time."})),he=o.register("AutomationRun",e.z.object({automation:e.z.string().uuid().openapi({description:"The ID of the associated automation.",example:"a1b2c3d4-e5f6-7890-1234-567890abcdef"}),conditions_passed:e.z.boolean().nullable().openapi({description:"Whether the automation conditions passed for this run.",example:!0}),error:e.z.string().nullable().openapi({description:"Any error message if the run failed.",example:"Webhook failed to send."}),id:e.z.string().uuid().openapi({description:"The unique identifier for the automation run.",example:"b2c3d4e5-f6a7-8901-2345-67890abcdef0"}),method:e.z.string().openapi({description:"The method used for the automation action (e.g., email, webhook).",example:"email"}),recipient_emails:e.z.array(e.z.string().email()).nullable().openapi({description:"List of recipient emails if the method was email.",example:["test@example.com","another@example.com"]}),run_at:e.z.string().datetime().openapi({description:"Timestamp of when the automation ran.",example:"2024-05-01T16:57:49.123Z"}),status:e.z.string().openapi({description:"The status of the automation run (e.g., success, failure).",example:"success"}),team:e.z.string().uuid().openapi({description:"The ID of the team associated with this run.",example:"c3d4e5f6-a7b8-9012-3456-7890abcdef01"}),webhook_sent:e.z.boolean().nullable().openapi({description:"Whether the webhook was successfully sent if the method was webhook.",example:null})}).openapi({description:"An automation run that has occurred."}));(0,P.extendZodWithOpenApi)(e.z);var X=(l=>(l.ViewDashboard="view-dashboard",l.EditDashboard="edit-dashboard",l.CreateWidget="create-widget",l.DeleteWidget="delete-widget",l.EditWidget="edit-widget",l))(X||{}),be=o.register("Message",e.z.object({id:e.z.string().uuid().openapi({description:"Message ID.",example:"9b7deda3-7e2d-458e-84e9-632e47fbe682"}),content:e.z.union([e.z.string(),e.z.array(e.z.union([e.z.object({text:e.z.string(),type:e.z.literal("text")}),e.z.object({type:e.z.literal("tool_user")})]))]).openapi({description:"Message content.",example:"Hello!"}),created_at:e.z.string().openapi({description:"Timestamp when the message was created.",example:"2024-05-01T16:58:00.000Z"}),dashboard:e.z.string().uuid().nullable().openapi({description:"Dashboard ID associated with the message, if any.",example:"9b7deda3-7e2d-458e-84e9-632e47fbe682"}),question:e.z.string().uuid().openapi({description:"Question ID associated with the message.",example:"question_123"}),role:e.z.enum(["user","assistant","tool"]).nullable().openapi({description:"Role of the message sender.",example:"user"}),team:e.z.string().uuid().openapi({description:"Team ID associated with the message.",example:"92c680a3-a9c4-4c02-bb2d-a5d049789662"}),tool_call_id:e.z.string().uuid().nullable().openapi({description:"Tool call ID associated with the message, if any.",example:"toolcall_123"}),tool_calls:e.z.array(e.z.any()).nullable().openapi({description:"Tool calls associated with the message.",example:[]})}).openapi({description:"A message in a conversation."})),fe=o.register("Invite",e.z.object({created_at:e.z.string().openapi({description:"Timestamp when the invite was created.",example:"2024-05-01T16:58:00.000Z"}),email:e.z.string().email().openapi({description:"The email address the invite was sent to.",example:"invitee@example.com"}),name:e.z.string().openapi({description:"The name of the invitee.",example:"Jane Doe"}),team:e.z.string().uuid().openapi({description:"The ID of the team the invite is for.",example:"92c680a3-a9c4-4c02-bb2d-a5d049789662"})}).openapi({description:"An invite to join a team."})),_e=o.register("Member",e.z.object({account:e.z.string().uuid().openapi({description:"The ID of the account that is a member.",example:"9b7deda3-7e2d-458e-84e9-632e47fbe682"}),team:e.z.string().uuid().openapi({description:"The ID of the team the member belongs to.",example:"92c680a3-a9c4-4c02-bb2d-a5d049789662"})}).openapi({description:"A member of a team."})),ye=o.register("Team",e.z.object({created_at:e.z.string().nullable().openapi({description:"Timestamp when the team was created.",example:"2024-05-01T16:58:00.000Z"}),email:e.z.string().email().nullable().openapi({description:"The team's contact email address.",example:"team@example.com"}),id:e.z.string().uuid().openapi({description:"Team ID.",example:"92c680a3-a9c4-4c02-bb2d-a5d049789662"}),logo:e.z.string().nullable().openapi({description:"URL to the team's logo.",example:"https://example.com/logo.png"}),name:e.z.string().nullable().openapi({description:"The team's name.",example:"Acme Corp"}),phone_number:e.z.string().nullable().openapi({description:"The team's contact phone number.",example:"+1234567890"}),stripe_id:e.z.string().nullable().openapi({description:"Stripe customer ID for the team.",example:"cus_abc123"})}).openapi({description:"A team that represents a group of users."})),xe=o.register("DataSource",e.z.object({columns:e.z.array(e.z.object({title:e.z.string().openapi({description:"Column title.",example:"Name"}),description:e.z.string().openapi({description:"Column description.",example:"The name of the entity."}),type:e.z.string().optional().openapi({description:"Column type.",example:"text"}),hidden:e.z.boolean().optional().openapi({description:"Column hidden.",example:!1})})).openapi({description:"Datasource columns."}),config:e.z.any().openapi({description:"Datasource config (arbitrary object)."}),created_at:e.z.string().openapi({description:"Timestamp when the datasource was created.",example:"2024-05-01T16:58:00.000Z"}),created_by:e.z.string().uuid().nullable().openapi({description:"ID of the account that created the datasource.",example:"9b7deda3-7e2d-458e-84e9-632e47fbe682"}),description:e.z.string().nullable().openapi({description:"Description of the datasource.",example:"This datasource contains sales data."}),filters:e.z.array(e.z.object({column:e.z.string().openapi({description:"Filter column.",example:"age"}),type:e.z.enum(["text","number","date"]).openapi({description:"Filter type.",example:"number"}),label:e.z.string().openapi({description:"Filter label.",example:"Age"})})).openapi({description:"Datasource filters."}),id:e.z.string().uuid().openapi({description:"Datasource ID.",example:"9b7deda3-7e2d-458e-84e9-632e47fbe682"}),integration:e.z.string().uuid().nullable().openapi({description:"Integration ID associated with the datasource, if any.",example:"9b7deda3-7e2d-458e-84e9-632e47fbe682"}),last_updated_at:e.z.string().openapi({description:"Timestamp when the datasource was last updated.",example:"2024-05-02T10:00:00.000Z"}),last_updated_by:e.z.string().uuid().nullable().openapi({description:"ID of the account that last updated the datasource.",example:"9b7deda3-7e2d-458e-84e9-632e47fbe682"}),metadata:e.z.array(K).openapi({description:"Datasource metadata."}),parameters:e.z.array(e.z.object({id:e.z.string().openapi({description:"Parameter ID.",example:"param1"}),wrap:e.z.string().optional().openapi({description:"Wrap option for parameter.",example:"quotes"}),default:e.z.string().openapi({description:"Default value for parameter.",example:"default_value"})})).openapi({description:"Datasource parameters."}),size:e.z.number().openapi({description:"Size of the datasource.",example:1e3}),source:e.z.string().openapi({description:"Source of the datasource.",example:"csv"}),team:e.z.string().uuid().openapi({description:"Team ID that owns the datasource.",example:"92c680a3-a9c4-4c02-bb2d-a5d049789662"}),title:e.z.string().openapi({description:"Title of the datasource.",example:"Sales Data"})}).openapi({description:"A datasource that provides data for visualizations."})),De=o.register("EmbedUser",e.z.object({created_at:e.z.string().openapi({description:"Timestamp when the embed user was created.",example:"2024-05-01T16:58:00.000Z"}),email:e.z.string().email().nullable().openapi({description:"Email address of the embed user.",example:"embeduser@example.com"}),id:e.z.string().uuid().openapi({description:"Embed user ID.",example:"9b7deda3-7e2d-458e-84e9-632e47fbe682"}),last_updated_at:e.z.string().openapi({description:"Timestamp when the embed user was last updated.",example:"2024-05-02T10:00:00.000Z"}),name:e.z.string().openapi({description:"Name of the embed user.",example:"John Doe"}),parameters:e.z.any().nullable().openapi({description:"Parameters for the embed user (arbitrary object)."}),team:e.z.string().uuid().openapi({description:"Team ID that the embed user belongs to.",example:"team_123"})}).openapi({description:"An embed user."})),Te=o.register("Subscription",e.z.object({amount:e.z.number().openapi({description:"Subscription amount.",example:1999}),created_at:e.z.string().openapi({description:"Timestamp when the subscription was created.",example:"2024-05-01T16:58:00.000Z"}),currency:e.z.string().openapi({description:"Currency of the subscription.",example:"USD"}),integrations:e.z.array(e.z.string()).openapi({description:"Integrations included in the subscription.",example:["slack","github"]}),interval:e.z.string().openapi({description:"Billing interval.",example:"month"}),period_end:e.z.string().openapi({description:"End of the current billing period.",example:"2024-06-01T16:58:00.000Z"}),period_start:e.z.string().openapi({description:"Start of the current billing period.",example:"2024-05-01T16:58:00.000Z"}),product_name:e.z.string().openapi({description:"Product name of the subscription.",example:"Pro Plan"}),stripe_customer_id:e.z.string().openapi({description:"Stripe customer ID.",example:"cus_abc123"}),stripe_product_id:e.z.string().openapi({description:"Stripe product ID.",example:"prod_abc123"}),stripe_subscription_id:e.z.string().openapi({description:"Stripe subscription ID.",example:"sub_abc123"}),team:e.z.string().uuid().openapi({description:"Team ID associated with the subscription.",example:"team_123"})})),we=o.register("SubscriptionPlan",e.z.object({accounts:e.z.number().nullable().openapi({description:"Number of accounts allowed in the plan.",example:10}),automations:e.z.boolean().openapi({description:"Whether automations are enabled in the plan.",example:!0}),connected_datasources:e.z.number().openapi({description:"Number of connected datasources allowed.",example:5}),copilot:e.z.boolean().openapi({description:"Whether copilot is enabled in the plan.",example:!0}),custom_llm:e.z.boolean().openapi({description:"Whether custom LLM is enabled in the plan.",example:!1}),embed_users:e.z.number().openapi({description:"Number of embed users allowed.",example:100}),name:e.z.string().openapi({description:"Name of the subscription plan.",example:"Pro"}),premium_integrations:e.z.number().openapi({description:"Number of premium integrations allowed.",example:2})}).openapi({description:"A subscription plan."})),Oe=o.register("APIKey",e.z.object({created_at:e.z.string().openapi({description:"Timestamp when the API key was created.",example:"2024-05-01T16:58:00.000Z"}),description:e.z.string().nullable().openapi({description:"Description of the API key.",example:"Key for production environment"}),id:e.z.string().uuid().openapi({description:"API Key ID.",example:"9b7deda3-7e2d-458e-84e9-632e47fbe682"}),key:e.z.string().openapi({description:"The API key string.",example:"ey.1234567890"}),last_used_at:e.z.string().nullable().openapi({description:"Timestamp when the API key was last used.",example:"2024-05-02T12:00:00.000Z"}),team:e.z.string().uuid().openapi({description:"Team ID associated with the API key.",example:"92c680a3-a9c4-4c02-bb2d-a5d049789662"})}).openapi({description:"An API key."})),Pe=o.register("Widget",e.z.object({settings:e.z.object({css_id:e.z.string().optional().openapi({description:"Widget CSS ID.",example:"widget-123"}),css_classnames:e.z.string().optional().openapi({description:"Widget CSS class names.",example:"widget-class"})}).optional().openapi({description:"Widget settings."}),messages:e.z.array(e.z.object({role:e.z.enum(["user","assistant"]).openapi({description:"Widget message role.",example:"user"}),content:e.z.string().openapi({description:"Widget message content.",example:"Hello from widget!"})})).openapi({description:"Widget messages."}),layouts:e.z.object({lg:e.z.object({x:e.z.number().openapi({description:"X position.",example:0}),y:e.z.number().openapi({description:"Y position.",example:0}),w:e.z.number().openapi({description:"Width.",example:4}),h:e.z.number().openapi({description:"Height.",example:3})}),sm:e.z.object({x:e.z.number().openapi({description:"X position (sm).",example:0}),y:e.z.number().openapi({description:"Y position (sm).",example:0}),w:e.z.number().openapi({description:"Width (sm).",example:2}),h:e.z.number().openapi({description:"Height (sm).",example:2})}).optional()}).openapi({description:"Widget layouts."})}).openapi({description:"A widget."})),ve=o.register("DashboardDatasource",e.z.object({dashboard:e.z.string().uuid().openapi({description:"Dashboard ID associated with the datasource.",example:"9b7deda3-7e2d-458e-84e9-632e47fbe682"}),datasource:e.z.string().uuid().openapi({description:"Datasource ID associated with the dashboard.",example:"9b7deda3-7e2d-458e-84e9-632e47fbe682"}),team:e.z.string().uuid().openapi({description:"Team ID associated with the dashboard datasource.",example:"92c680a3-a9c4-4c02-bb2d-a5d049789662"})}).openapi({description:"A dashboard datasource."})),ke=o.register("Session",e.z.object({created_at:e.z.string().openapi({description:"Timestamp when the session was created.",example:"2024-05-01T16:58:00.000Z"}),dashboard:e.z.string().uuid().openapi({description:"Dashboard ID associated with the session.",example:"9b7deda3-7e2d-458e-84e9-632e47fbe682"}),embed_user:e.z.string().uuid().openapi({description:"Embed user ID associated with the session.",example:"9b7deda3-7e2d-458e-84e9-632e47fbe682"}),parameters:e.z.any().openapi({description:"Session parameters (arbitrary object)."}),team:e.z.string().uuid().openapi({description:"Team ID associated with the session.",example:"92c680a3-a9c4-4c02-bb2d-a5d049789662"})}).openapi({description:"A user session."})),Se=o.register("Question",e.z.object({created_at:e.z.string().openapi({description:"Timestamp when the question was created.",example:"2024-05-01T16:58:00.000Z"}),dashboard:e.z.string().uuid().openapi({description:"Dashboard ID associated with the question.",example:"9b7deda3-7e2d-458e-84e9-632e47fbe682"}),id:e.z.string().uuid().openapi({description:"Question ID.",example:"92c680a3-a9c4-4c02-bb2d-a5d049789662"}),messages:e.z.any().openapi({description:"Messages associated with the question (arbitrary object)."}),query:e.z.string().openapi({description:"Query text of the question.",example:"What were last month's sales?"}),team:e.z.string().uuid().nullable().openapi({description:"Team ID associated with the question, if any.",example:"92c680a3-a9c4-4c02-bb2d-a5d049789662"})}).openapi({description:"A question asked in the dashboard."})),Ie=o.register("Integration",e.z.object({config:e.z.any().openapi({description:"Integration config (arbitrary object)."}),created_at:e.z.string().openapi({description:"Timestamp when the integration was created.",example:"2024-05-01T16:58:00.000Z"}),id:e.z.string().uuid().openapi({description:"Integration ID.",example:"9b7deda3-7e2d-458e-84e9-632e47fbe682"}),provider:e.z.string().openapi({description:"Integration provider.",example:"slack"}),status:e.z.string().openapi({description:"Integration status.",example:"active"}),team:e.z.string().uuid().openapi({description:"Team ID associated with the integration.",example:"92c680a3-a9c4-4c02-bb2d-a5d049789662"}),title:e.z.string().nullable().openapi({description:"Title of the integration.",example:"Slack Integration"})}).openapi({description:"An integration with an external service."})),Q=e.z.enum(["default","openrouter","ollama"]).openapi({description:"Specifies if the LLM is hosted by Onvo or self-hosted."}),Ae=o.register("LLMSettings",e.z.object({analyst_agent_type:Q,programmer_agent_type:Q,ollama_api_url:e.z.string().url().nullable().openapi({description:"URL for self-hosted Ollama API.",example:"http://localhost:11434"}),openrouter_api_key:e.z.string().nullable().openapi({description:"API key for OpenRouter models (write-only).",example:"sk-...",format:"password"}),programmer_agent_model:e.z.string().openapi({description:"Model used for the programmer agent.",example:"openai/gpt-3.5-turbo"}),analyst_agent_model:e.z.string().openapi({description:"Model used for the analyst agent.",example:"openai/gpt-4-turbo"}),programmer_agent_prompt:e.z.string().nullable().openapi({description:"Custom prompt for the programmer agent.",example:"You are a helpful AI assistant specialized in code generation."}),analyst_agent_prompt:e.z.string().nullable().openapi({description:"Custom prompt for the analyst agent.",example:"You are a helpful AI assistant specialized in data analysis."}),team:e.z.string().uuid().openapi({description:"The ID of the team these settings belong to (read-only).",example:"d4e5f6a7-b8c9-0123-4567-890abcdef012",readOnly:!0}),updated:e.z.boolean().openapi({description:"Indicates if the settings have been updated from defaults (read-only).",example:!0,readOnly:!0})}).openapi({description:"LLM settings."})),Re=o.register("Log",e.z.object({account:e.z.string().uuid().nullable().openapi({description:"ID of the account that generated the log, if applicable.",example:"e5f6a7b8-c9d0-1234-5678-90abcdef0123"}),created_at:e.z.string().datetime().openapi({description:"Timestamp when the log was created.",example:"2024-05-01T16:58:00.000Z"}),dashboard:e.z.string().uuid().nullable().openapi({description:"ID of the dashboard related to the log, if applicable.",example:"f6a7b8c9-d0e1-2345-6789-0abcdef01234"}),embed_user:e.z.string().nullable().openapi({description:"ID of the embed user related to the log, if applicable.",example:"embed-user-xyz789"}),id:e.z.string().uuid().openapi({description:"The unique identifier for the log entry.",example:"01234567-89ab-cdef-0123-456789abcdef"}),team:e.z.string().uuid().nullable().openapi({description:"ID of the team associated with the log.",example:"12345678-9abc-def0-1234-56789abcdef0"}),type:e.z.string().openapi({description:"The type or category of the log event.",example:"widget_interaction"}),widget:e.z.string().uuid().nullable().openapi({description:"ID of the widget related to the log, if applicable.",example:"23456789-abcd-ef01-2345-6789abcdef01"})}).openapi({description:"A log entry recording an event within the system."})),Ce=new P.OpenApiGeneratorV3(o.definitions),Ee=Ce.generateComponents();var b=require("@badgateway/oauth2-client");var Y=require("nanoid"),m=class{id="";provider="";teamId;baseUrl="";authorizationEndpoint="";tokenEndpoint="";scopes=[];extraParams={};authenticationMethod;clientId="";clientSecret="";scope="";refreshToken="";oauthClient;fetcher;supabaseClient;actions={};constructor(t,a,i){this.teamId=t,this.supabaseClient=a,this.id=i||"",this.initializeOauthClient()}initializeOauthClient(){this.oauthClient=new b.OAuth2Client({clientId:this.clientId,clientSecret:this.clientSecret,authorizationEndpoint:this.authorizationEndpoint,tokenEndpoint:this.tokenEndpoint,server:this.baseUrl,authenticationMethod:this.authenticationMethod||void 0}),this.fetcher=new b.OAuth2Fetch({client:this.oauthClient,getNewToken:async()=>{if(!this.id||this.id==="")return null;let{data:t,error:a}=await this.supabaseClient.from("integrations").select().eq("id",this.id).maybeSingle();if(a||!t||!t.config)return null;let i=t.config;return await this.oauthClient.refreshToken({accessToken:i.access_token,refreshToken:i.refresh_token,expiresAt:new Date(i.access_expires_at).getTime()})},storeToken:async t=>{if(!this.supabaseClient)return null;let{error:a}=await this.supabaseClient.from("integrations").update({provider:this.provider,team:this.teamId,config:{access_token:t.accessToken,refresh_token:t.refreshToken||this.refreshToken,access_expires_at:new Date(t.expiresAt||new Date(2040,1,1).getTime()).toISOString()}}).eq("id",this.id)},getStoredToken:async()=>{if(!this.supabaseClient||!this.id||this.id==="")return null;let{data:t,error:a}=await this.supabaseClient.from("integrations").select().eq("id",this.id).maybeSingle();if(a||!t||!t.config)return null;let i=t.config;return this.refreshToken=i.refresh_token,{accessToken:i.access_token,refreshToken:i.refresh_token,expiresAt:new Date(i.access_expires_at).getTime()}}})}async startAuthFlow(){let t=(0,Y.nanoid)(16),a=await(0,b.generateCodeVerifier)();return{url:await this.oauthClient.authorizationCode.getAuthorizeUri({redirectUri:`${process.env.NEXT_PUBLIC_DASHBOARD_URL||""}/api/internal/oauth/${this.provider}/redirect`,scope:this.scopes,extraParams:this.extraParams,state:t,codeVerifier:a}),code_verifier:a,state:t}}async completeAuthFlow(t){let a=t.nextUrl.href,i=t.cookies.get("code_verifier")?.value,c=t.nextUrl.searchParams.get("state");if(!a)throw new Error("No code found in URL");if(!this.teamId)throw new Error("Not connected to an team");let l;try{l=await this.oauthClient.authorizationCode.getTokenFromCodeRedirect(a,{redirectUri:`${process.env.NEXT_PUBLIC_DASHBOARD_URL||""}/api/internal/oauth/${this.provider}/redirect`,codeVerifier:i||void 0,state:c||void 0})}catch(g){throw console.log("Failed to get token from code: ",g),new Error("Failed to get token from code: "+g.message)}let{data:u,error:d}=await this.supabaseClient.from("integrations").update({status:"healthy",config:{access_token:l.accessToken,refresh_token:l.refreshToken,access_expires_at:new Date(l.expiresAt).toISOString()}}).eq("id",this.id).select().single();if(this.refreshToken=l.refreshToken,d)throw new Error("Failed to save integration to DB: "+d.message);return{success:!0,...l}}};var _=class extends m{provider="airtable";baseUrl="https://www.airtable.com";clientId=process.env.AIRTABLE_CLIENT_ID||"";clientSecret=process.env.AIRTABLE_CLIENT_SECRET||"";authorizationEndpoint="/oauth2/v1/authorize";tokenEndpoint="/oauth2/v1/token";scopes=["schema.bases:read","data.records:read"];constructor(t,a,i){super(t,a,i),this.initializeOauthClient(),this.actions={getBases:async c=>(await this.fetcher.fetch("https://api.airtable.com/v0/meta/bases").then(d=>d.json())).bases.map(d=>({value:d.id,label:d.name})),getTables:async c=>(await this.fetcher.fetch("https://api.airtable.com/v0/meta/bases/"+c.baseId+"/tables").then(d=>d.json())).tables.map(d=>({value:d.id,label:d.name}))}}async getRecords(t,a){try{let l=[],u;do{let d=0;for(;;)try{let g=new URL(`https://api.airtable.com/v0/${t}/${a}`);u&&g.searchParams.append("offset",u);let f=await(await this.fetcher.fetch(g.toString())).json();if(f?.errors&&f?.errors[0]&&f?.errors[0].error==="RATE_LIMIT_REACHED"){if(d>=5)throw new Error("Rate limit exceeded. Max retries reached.");let w=1e3*Math.pow(2,d);await new Promise(h=>setTimeout(h,w)),d++;continue}l=l.concat(f.records.map(w=>{let h={_id:w.id,...w.fields};return Object.keys(h).forEach(W=>{Array.isArray(h[W])&&(h[W]=h[W].join(","))}),h})),u=f.offset;break}catch(g){throw console.log("AIRTABLE ERROR: ",g),g}}while(u);return l}catch(l){throw new Error(l.message)}}};var y=class extends m{provider="google_sheets";baseUrl="https://accounts.google.com";authorizationEndpoint="/o/oauth2/v2/auth";tokenEndpoint="https://oauth2.googleapis.com/token";clientId=process.env.GOOGLE_CLIENT_ID||"";clientSecret=process.env.GOOGLE_CLIENT_SECRET||"";scopes=["https://www.googleapis.com/auth/spreadsheets.readonly"];extraParams={access_type:"offline",prompt:"consent"};constructor(t,a,i){super(t,a,i),this.initializeOauthClient(),this.actions={getSheets:async c=>(await this.fetcher.fetch("https://sheets.googleapis.com/v4/spreadsheets/"+c.docId).then(d=>d.json())).sheets.map(d=>({value:d.properties.title,label:d.properties.title}))}}async getRecords(t,a){let i=`https://docs.google.com/spreadsheets/d/${t}/gviz/tq?tqx=out:csv&sheet=${a}`;return await this.fetcher.fetch(i)}};var x=class extends m{provider="hubspot";baseUrl="https://app.hubspot.com";authorizationEndpoint="/oauth/authorize";tokenEndpoint="https://api.hubapi.com/oauth/v1/token";authenticationMethod="client_secret_post";clientId=process.env.HUBSPOT_CLIENT_ID||"";clientSecret=process.env.HUBSPOT_CLIENT_SECRET||"";extraParams={optional_scope:["crm.lists.read","crm.objects.appointments.read","crm.objects.carts.read","crm.objects.commercepayments.read","crm.objects.companies.read","crm.objects.contacts.read","crm.objects.courses.read","crm.objects.custom.read","crm.objects.deals.read","crm.objects.feedback_submissions.read","crm.objects.goals.read","crm.objects.invoices.read","crm.objects.leads.read","crm.objects.line_items.read","crm.objects.listings.read","crm.objects.marketing_events.read","crm.objects.orders.read","crm.objects.owners.read","crm.objects.partner-clients.read","crm.objects.quotes.read","crm.objects.services.read","crm.objects.subscriptions.read","crm.objects.users.read","crm.pipelines.orders.read","crm.schemas.appointments.read","crm.schemas.carts.read","crm.schemas.commercepayments.read","crm.schemas.companies.read","crm.schemas.contacts.read","crm.schemas.courses.read","crm.schemas.custom.read","crm.schemas.deals.read","crm.schemas.invoices.read","crm.schemas.line_items.read","crm.schemas.listings.read","crm.schemas.orders.read","crm.schemas.quotes.read","crm.schemas.services.read","crm.schemas.subscriptions.read"].join(" ")};scopes=["oauth"];constructor(t,a,i){super(t,a,i),this.initializeOauthClient()}async getRecords(){return[]}};var D=class extends m{provider="xero";baseUrl="https://login.xero.com";authorizationEndpoint="/identity/connect/authorize";tokenEndpoint="https://identity.xero.com/connect/token";clientId=process.env.XERO_CLIENT_ID||"";clientSecret=process.env.XERO_CLIENT_SECRET||"";scopes=["accounting.attachments.read","accounting.budgets.read","accounting.contacts.read","accounting.journals.read","accounting.reports.read","accounting.reports.tenninetynine.read","accounting.settings.read","accounting.transactions.read","assets.read","offline_access"];constructor(t,a,i){super(t,a,i),this.initializeOauthClient(),this.actions={getConnections:async c=>(await this.fetcher.fetch("https://api.xero.com/connections").then(d=>d.json())).map(d=>({value:d.tenantId,label:d.tenantName}))}}async getRecords(){return[]}};var T=class extends m{provider="shopify";baseUrl="https://app.hubspot.com";authorizationEndpoint="/oauth/authorize";tokenEndpoint="https://api.hubapi.com/oauth/v1/token";authenticationMethod="client_secret_post";clientId=process.env.SHOPIFY_CLIENT_ID||"";clientSecret=process.env.SHOPIFY_CLIENT_SECRET||"";extraParams={optional_scope:["crm.lists.read","crm.objects.appointments.read","crm.objects.carts.read","crm.objects.commercepayments.read","crm.objects.companies.read","crm.objects.contacts.read","crm.objects.courses.read","crm.objects.custom.read","crm.objects.deals.read","crm.objects.feedback_submissions.read","crm.objects.goals.read","crm.objects.invoices.read","crm.objects.leads.read","crm.objects.line_items.read","crm.objects.listings.read","crm.objects.marketing_events.read","crm.objects.orders.read","crm.objects.owners.read","crm.objects.partner-clients.read","crm.objects.quotes.read","crm.objects.services.read","crm.objects.subscriptions.read","crm.objects.users.read","crm.pipelines.orders.read","crm.schemas.appointments.read","crm.schemas.carts.read","crm.schemas.commercepayments.read","crm.schemas.companies.read","crm.schemas.contacts.read","crm.schemas.courses.read","crm.schemas.custom.read","crm.schemas.deals.read","crm.schemas.invoices.read","crm.schemas.line_items.read","crm.schemas.listings.read","crm.schemas.orders.read","crm.schemas.quotes.read","crm.schemas.services.read","crm.schemas.subscriptions.read"].join(" ")};scopes=["oauth"];constructor(t,a,i){super(t,a,i),this.initializeOauthClient()}async getRecords(){return[]}};var Ne={airtable:_,google_sheets:y,hubspot:x,xero:D,shopify:T};var r=class{#e;endpoint;async fetchBase(t,a,i,c){let l={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS"};this.#e&&this.#e.trim()!==""&&(l["x-api-key"]=this.#e),c||(l["Content-Type"]="application/json");let u=await fetch(this.endpoint+t,{method:a||"GET",headers:l,body:c?i:i?JSON.stringify(i):void 0});if(u.ok)return await u.json();{let d=await u.json();throw new Error(d.message)}}async fetchBlob(t){try{let a={"Content-Type":"application/json","Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS"};return this.#e&&this.#e.trim()!==""&&(a["x-api-key"]=this.#e),await fetch(this.endpoint+t,{method:"GET",headers:a}).then(c=>c.blob())}catch(a){throw new Error("Error in making the request: "+a.message)}}constructor(t,a){if(t==null)throw new Error("API key is required");this.#e=t,this.endpoint=a?.endpoint||"https://dashboard.onvo.ai"}};var v=class extends r{list(){return this.fetchBase("/api/accounts")}get(t){return this.fetchBase("/api/accounts/"+t)}};var k=class extends r{list(){return this.fetchBase("/api/teams")}get(t){return this.fetchBase("/api/teams/"+t)}update(t,a){return this.fetchBase("/api/teams/"+t,"PUT",a)}};var S=class extends r{list(){return this.fetchBase("/api/embed-users")}get(t){return this.fetchBase("/api/embed-users/"+t)}delete(t){return this.fetchBase("/api/embed-users/"+t,"DELETE")}upsert(t,a){return this.fetchBase("/api/embed-users","POST",{id:t,name:a.name,email:a.email,metadata:a.metadata})}};var I=class extends r{list(t){return t&&t.dashboard?this.fetchBase("/api/datasources?dashboard="+t.dashboard):this.fetchBase("/api/datasources")}get(t){return this.fetchBase("/api/datasources/"+t)}delete(t){return this.fetchBase("/api/datasources/"+t,"DELETE")}update(t,a){return this.fetchBase("/api/datasources/"+t,"PUT",a)}create(t){return this.fetchBase("/api/datasources","POST",t)}};var A=class extends r{list(t){return t?this.fetchBase("/api/automations?dashboard="+t.dashboard):this.fetchBase("/api/automations")}get(t){return this.fetchBase("/api/automations/"+t)}delete(t){return this.fetchBase("/api/automations/"+t,"DELETE")}update(t,a){return this.fetchBase("/api/automations/"+t,"PUT",a)}create(t){return this.fetchBase("/api/automations","POST",t)}};var R=class extends r{list(){return this.fetchBase("/api/dashboards").catch(t=>{throw t})}get(t){return this.fetchBase("/api/dashboards/"+t).catch(a=>{throw a})}delete(t){return this.fetchBase("/api/dashboards/"+t,"DELETE")}update(t,a){return this.fetchBase("/api/dashboards/"+t,"PUT",a)}create(t){return this.fetchBase("/api/dashboards","POST",t)}};var C=class extends r{#e;constructor(t,a,i){super(a,i),this.#e=t}unlink(t){return this.fetchBase("/api/dashboards/"+this.#e+"/datasources/"+t,"DELETE")}link(t){return this.fetchBase("/api/dashboards/"+this.#e+"/datasources","POST",{datasourceId:t})}linkMultiple(t){return this.fetchBase("/api/dashboards/"+this.#e+"/datasources","POST",{datasourceIds:t})}};var E=class extends r{datasources;#e;constructor(t,a,i){super(a,i),this.#e=t,this.datasources=new C(t,a,i)}updateCache(){return this.fetchBase("/api/dashboards/"+this.#e+"/update-cache","POST")}export(t,a="light",i=0){return this.fetchBlob(`/api/dashboards/${this.#e}/export?theme=${a}&format=${t}&tab=${i}`)}summarize(t){return this.fetchBase(`/api/dashboards/${this.#e}/summarize`,"POST",{prompt:t})}};var N=class extends r{#e;constructor(t,a,i){super(a,i),this.#e=t}getAccessToken(){return this.fetchBase("/api/embed-users/"+this.#e+"/token")}};var j=class extends r{#e;constructor(t,a,i){super(a,i),this.#e=t}initialize(){return this.fetchBase("/api/datasources/"+this.#e+"/initialize")}uploadFile(t){let a=new FormData;return a.set("file",t),this.fetchBase("/api/datasources/"+this.#e+"/upload-file","POST",a,!0)}sample(){return this.fetchBase("/api/datasources/"+this.#e+"/sample")}};var B=class extends r{list(t){return this.fetchBase("/api/questions?dashboard="+t.dashboard)}create(t){return this.fetchBase("/api/questions","POST",{dashboard:t.dashboard,query:t.query||""})}delete(t){return this.fetchBase("/api/questions/"+t,"DELETE")}update(t,a){return this.fetchBase("/api/questions/"+t,"PUT",a)}};var U=class extends r{#e;constructor(t,a,i){super(a,i),this.#e=t}getRuns(){return this.fetchBase("/api/automations/"+this.#e+"/runs")}test(){return this.fetchBase("/api/automations/"+this.#e+"/test")}};var M=class extends r{#e;constructor(t,a,i){super(a,i),this.#e=t}export(t,a="light"){return this.fetchBlob(`/api/widgets/${this.#e}/export?theme=${a}&format=${t}`)}cache(t){let a=new URLSearchParams;t?.raw&&a.append("raw","true"),t?.page&&a.append("page",t.page.toString()),t?.pageSize&&a.append("pageSize",t.pageSize.toString()),t?.sortField&&a.append("sortField",t.sortField),t?.sortDirection&&a.append("sortDirection",t.sortDirection);let i=a.toString();return this.fetchBase(`/api/widgets/${this.#e}/cache${i?`?${i}`:""}`)}updatePrompts(t){return this.fetchBase("/api/widgets/"+this.#e,"PATCH",{messages:t})}updateCache(){return this.fetchBase("/api/widgets/"+this.#e+"/cache","POST")}};var Z=class extends r{list(t){return t.embed_user?this.fetchBase("/api/sessions?embed_user="+t.embed_user):this.fetchBase("/api/sessions?parent_dashboard="+t.parent_dashboard)}get(t){return this.fetchBase("/api/sessions?dashboard="+t.dashboard)}revoke(t){return this.fetchBase("/api/sessions?dashboard="+t.dashboard,"DELETE")}revokeAll(t){return this.fetchBase("/api/sessions?parent_dashboard="+t.parent_dashboard,"DELETE")}async upsert({embed_user:t,parent_dashboard:a,parameters:i}){return await this.fetchBase("/api/sessions","POST",{user:t,parameters:i,dashboard:a})}};var L=class extends r{list(t){return this.fetchBase(`/api/widgets?dashboard=${t.dashboard}&use_in_library=${t.use_in_library}`)}get(t){return this.fetchBase("/api/widgets/"+t)}delete(t){return this.fetchBase("/api/widgets/"+t,"DELETE")}update(t,a){return this.fetchBase("/api/widgets/"+t,"PUT",a)}create(t,a){return this.fetchBase("/api/widgets","POST",{...t,cache:a})}};var q=class extends r{#e;constructor(t,a,i){super(a,i),this.#e=t}exportMessage(t,a,i="light"){return this.fetchBlob(`/api/questions/${this.#e}/messages/${t}/export?theme=${i}&format=${a}`)}getMessages(){return this.fetchBase(`/api/questions/${this.#e}/messages`)}completion(t){return this.fetchBase(`/api/questions/${this.#e}/messages`,"POST",{content:t})}updateMessage(t,a){return this.fetchBase(`/api/questions/${this.#e}/messages/${t}`,"PUT",{content:a})}};var z=class extends r{async uploadFile(t){let a=new FormData;return a.set("file",t),this.fetchBase("/api/utils/upload-file","POST",a,!0)}};var J=class extends r{list(){return this.fetchBase("/api/logs")}create(t){return this.fetchBase("/api/logs","POST",t)}};var H=class extends r{accounts;teams;embed_users;datasources;automations;dashboards;questions;widgets;sessions;utils;logs;automation;dashboard;embed_user;datasource;widget;question;constructor(t,a){super(t,a),this.accounts=new v(t,a),this.teams=new k(t,a),this.embed_users=new S(t,a),this.datasources=new I(t,a),this.automations=new A(t,a),this.dashboards=new R(t,a),this.questions=new B(t,a),this.sessions=new Z(t,a),this.widgets=new L(t,a),this.utils=new z(t,a),this.logs=new J(t,a),this.dashboard=i=>new E(i,