UNPKG

@onvo-ai/js

Version:

The javascript SDK for Onvo AI dashboard builder

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