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