UNPKG

@onvo-ai/js

Version:

The javascript SDK for Onvo AI dashboard builder

1 lines 232 kB
{"version":3,"sources":["../../src/types/registry.ts","../../src/types/utils.ts","../../src/types/index.ts","../../src/types/database.types.ts","../../src/types/tables.ts","../../src/types/integrations.ts","../../src/types/account.ts","../../src/types/dashboard.ts","../../src/types/automations.ts","../../src/oauth/base.ts","../../src/oauth/airtable.ts","../../src/oauth/google_sheets.ts","../../src/oauth/index.ts","../../src/base.ts","../../src/accounts/index.ts","../../src/teams/index.ts","../../src/embed_users/index.ts","../../src/datasources/index.ts","../../src/automations/index.ts","../../src/dashboards/index.ts","../../src/dashboard_datasources/index.ts","../../src/widget_suggestions/index.ts","../../src/dashboard/index.ts","../../src/embed_user/index.ts","../../src/datasource/index.ts","../../src/questions/index.ts","../../src/automation/index.ts","../../src/widget/index.ts","../../src/sessions/index.ts","../../src/widgets/index.ts","../../src/question/index.ts","../../src/utils/index.ts","../../src/logs/index.ts","../../src/integrations/index.ts","../../src/integration_tables/index.ts","../../src/integration/index.ts","../../src/onvo.ts"],"sourcesContent":["import { OpenAPIRegistry, extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';\nimport { z, ZodTypeDef, ZodTypeAny, ZodRawShape } from 'zod';\n\n// Apply type assertion to fix \"Type instantiation is excessively deep and possibly infinite\" error\n// @ts-ignore\nextendZodWithOpenApi(z as any);\n\ndeclare module 'zod' {\n interface ZodType<Output, Def extends ZodTypeDef = ZodTypeDef, Input = Output> {\n openapi(options: any): this;\n }\n interface ZodObject<T extends ZodRawShape> {\n openapi(options: any): this;\n }\n interface ZodArray<T extends ZodTypeAny> {\n openapi(options: any): this;\n }\n interface ZodOptional<T extends ZodTypeAny> {\n openapi(options: any): this;\n }\n interface ZodNullable<T extends ZodTypeAny> {\n openapi(options: any): this;\n }\n /*\n interface ZodUnion<T extends ZodTypeAny[]> {\n openapi(options: any): this;\n }\n */\n interface ZodEnum<T extends [string, ...string[]]> {\n openapi(options: any): this;\n }\n}\n\n// Create a wrapped version of z with proper typing for OpenAPI extensions\ntype EnhancedZod = typeof z & {\n // Add missing openapi method to all Zod types\n ZodString: typeof z.ZodString & { prototype: { openapi: any } };\n ZodNumber: typeof z.ZodNumber & { prototype: { openapi: any } };\n ZodBoolean: typeof z.ZodBoolean & { prototype: { openapi: any } };\n ZodArray: typeof z.ZodArray & { prototype: { openapi: any } };\n ZodObject: typeof z.ZodObject & { prototype: { openapi: any } };\n ZodEnum: typeof z.ZodEnum & { prototype: { openapi: any } };\n ZodUnion: typeof z.ZodUnion & { prototype: { openapi: any } };\n ZodOptional: typeof z.ZodOptional & { prototype: { openapi: any } };\n ZodNullable: typeof z.ZodNullable & { prototype: { openapi: any } };\n ZodAny: typeof z.ZodAny & { prototype: { openapi: any } };\n};\n\n// Export the z instance (which is now extended)\nexport { z };\n\n// Create and export the registry\nexport const registry = new OpenAPIRegistry();\n\n// Add a helper function to register schemas with proper type assertions\nexport function registerSchema(name: string, schema: any) {\n return registry.register(name, schema as any);\n}\n","import { z, registry } from './registry.js';\ntype AnyObject = Record<string, any>;\n\ntype DeepPartialAny<T> = {\n /** Makes each property optional and turns each leaf property into any, allowing for type overrides by narrowing any. */\n [P in keyof T]?: T[P] extends AnyObject ? DeepPartialAny<T[P]> : any;\n};\n\n// Fixed version with proper recursion handling\nexport type Modify<A, B extends DeepPartialAny<A>> = {\n [K in keyof (A & B)]: K extends keyof B\n ? K extends keyof A\n ? A[K] extends AnyObject\n ? B[K] extends AnyObject\n ? Modify<A[K], B[K] & DeepPartialAny<A[K]>>\n : B[K]\n : B[K]\n : B[K]\n : K extends keyof A\n ? A[K]\n : never;\n};\n\nexport interface Metadata {\n label: string;\n value: string;\n secure?: boolean;\n}\n\n// @ts-ignore\nexport const MetadataItemZod = registry.register(\"MetadataItem\", z.object({\n label: z.string().openapi({ description: 'The label for the metadata item.', example: 'User ID' }),\n value: z.string().openapi({ description: 'The value of the metadata item.', example: 'usr_12345' }),\n secure: z.boolean().optional().openapi({ description: 'Indicates if the metadata value should be treated as secure.', example: false })\n}).openapi({ description: \"A metadata item.\" }));","import { z, registry } from \"./registry.js\";\nimport { Database } from \"./database.types.js\";\nimport { Metadata, Modify, MetadataItemZod } from \"./utils.js\";\nimport {\n OpenApiGeneratorV3,\n extendZodWithOpenApi,\n} from \"@asteasolutions/zod-to-openapi\";\nimport { Account } from \"./account.js\";\n\nextendZodWithOpenApi(z as any);\n\nexport * from \"./database.types.js\";\nexport * from \"./tables.js\";\nexport * from \"./utils.js\";\nexport * from \"./integrations.js\";\nexport * from \"./account.js\";\nexport * from \"./dashboard.js\";\nexport * from \"./automations.js\";\n\nexport enum LogType {\n ViewDashboard = \"view-dashboard\",\n EditDashboard = \"edit-dashboard\",\n CreateWidget = \"create-widget\",\n DeleteWidget = \"delete-widget\",\n EditWidget = \"edit-widget\",\n}\nexport type WidgetSettings = {\n css_id?: string;\n css_classnames?: string;\n link?: string;\n};\nexport interface DatasourceFilter {\n column: string;\n type: \"text\" | \"number\" | \"date\";\n label: string;\n max_days?: number;\n}\n\nexport type WidgetMessage = {\n role: \"user\" | \"assistant\";\n content: string;\n};\n\nexport type Message = Modify<\n Database[\"public\"][\"Tables\"][\"messages\"][\"Row\"],\n {\n role: \"user\" | \"assistant\" | \"tool\";\n content?: string;\n tool_calls?: any[];\n }\n>;\nexport const MessageZod = registry.register(\n \"Message\",\n z\n .object({\n id: z\n .string()\n .uuid()\n .openapi({\n description: \"Message ID.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n content: z\n .string()\n .optional()\n .openapi({ description: \"Message content.\", example: \"Hello!\" }),\n created_at: z\n .string()\n .openapi({\n description: \"Timestamp when the message was created.\",\n example: \"2024-05-01T16:58:00.000Z\",\n }),\n dashboard: z\n .string()\n .uuid()\n .nullable()\n .openapi({\n description: \"Dashboard ID associated with the message, if any.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n question: z\n .string()\n .uuid()\n .openapi({\n description: \"Question ID associated with the message.\",\n example: \"question_123\",\n }),\n role: z\n .enum([\"user\", \"assistant\", \"tool\"])\n .nullable()\n .openapi({\n description: \"Role of the message sender.\",\n example: \"user\",\n }),\n team: z\n .string()\n .uuid()\n .openapi({\n description: \"Team ID associated with the message.\",\n example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\",\n }),\n tool_call_id: z\n .string()\n .uuid()\n .nullable()\n .openapi({\n description: \"Tool call ID associated with the message, if any.\",\n example: \"toolcall_123\",\n }),\n tool_calls: z\n .array(z.any())\n .nullable()\n .openapi({\n description: \"Tool calls associated with the message.\",\n example: [],\n }),\n vote: z\n .enum([\"up\", \"down\"])\n .nullable()\n .openapi({\n description: \"Vote associated with the message.\",\n example: \"up\",\n }),\n vote_reason: z\n .string()\n .nullable()\n .openapi({\n description: \"Vote reason associated with the message.\",\n example: \"I like it!\",\n }),\n })\n .openapi({ description: \"A message in a conversation.\" }) as any,\n);\n\nexport type Invite = Database[\"public\"][\"Tables\"][\"invites\"][\"Row\"];\nexport const InviteZod = registry.register(\n \"Invite\",\n z\n .object({\n created_at: z\n .string()\n .openapi({\n description: \"Timestamp when the invite was created.\",\n example: \"2024-05-01T16:58:00.000Z\",\n }),\n email: z\n .string()\n .email()\n .openapi({\n description: \"The email address the invite was sent to.\",\n example: \"invitee@example.com\",\n }),\n name: z\n .string()\n .openapi({\n description: \"The name of the invitee.\",\n example: \"Jane Doe\",\n }),\n team: z\n .string()\n .uuid()\n .openapi({\n description: \"The ID of the team the invite is for.\",\n example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\",\n }),\n })\n .openapi({ description: \"An invite to join a team.\" }) as any,\n);\n\nexport type Member = Database[\"public\"][\"Tables\"][\"members\"][\"Row\"];\nexport const MemberZod = registry.register(\n \"Member\",\n z\n .object({\n account: z\n .string()\n .uuid()\n .openapi({\n description: \"The ID of the account that is a member.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n team: z\n .string()\n .uuid()\n .openapi({\n description: \"The ID of the team the member belongs to.\",\n example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\",\n }),\n })\n .openapi({ description: \"A member of a team.\" }) as any,\n);\n\nexport type Team = Database[\"public\"][\"Tables\"][\"teams\"][\"Row\"];\nexport const TeamZod = registry.register(\n \"Team\",\n z\n .object({\n created_at: z\n .string()\n .nullable()\n .openapi({\n description: \"Timestamp when the team was created.\",\n example: \"2024-05-01T16:58:00.000Z\",\n }),\n email: z\n .string()\n .email()\n .nullable()\n .openapi({\n description: \"The team's contact email address.\",\n example: \"team@example.com\",\n }),\n id: z\n .string()\n .uuid()\n .openapi({\n description: \"Team ID.\",\n example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\",\n }),\n logo: z\n .string()\n .nullable()\n .openapi({\n description: \"URL to the team's logo.\",\n example: \"https://example.com/logo.png\",\n }),\n name: z\n .string()\n .nullable()\n .openapi({ description: \"The team's name.\", example: \"Acme Corp\" }),\n phone_number: z\n .string()\n .nullable()\n .openapi({\n description: \"The team's contact phone number.\",\n example: \"+1234567890\",\n }),\n stripe_id: z\n .string()\n .nullable()\n .openapi({\n description: \"Stripe customer ID for the team.\",\n example: \"cus_abc123\",\n }),\n })\n .openapi({\n description: \"A team that represents a group of users.\",\n }) as any,\n);\n\nexport type DatasourceMeta = {\n dashboards: number;\n integration: {\n id: string;\n title: string;\n };\n created_by: Account;\n last_updated_by?: Account;\n};\nexport type DataSource = Modify<\n Database[\"public\"][\"Tables\"][\"datasources\"][\"Row\"],\n {\n columns: {\n title: string;\n description: string;\n type?: string;\n hidden?: boolean;\n }[];\n config: any;\n parameters: { id: string; wrap?: string; default: string }[];\n filters: DatasourceFilter[];\n metadata?: Metadata[];\n }\n>;\nexport const DataSourceZod = registry.register(\n \"DataSource\",\n z\n .object({\n columns: z\n .array(\n z.object({\n title: z\n .string()\n .openapi({ description: \"Column title.\", example: \"Name\" }),\n description: z\n .string()\n .openapi({\n description: \"Column description.\",\n example: \"The name of the entity.\",\n }),\n type: z\n .string()\n .optional()\n .openapi({ description: \"Column type.\", example: \"text\" }),\n hidden: z\n .boolean()\n .optional()\n .openapi({ description: \"Column hidden.\", example: false }),\n }),\n )\n .openapi({ description: \"Datasource columns.\" }),\n config: z\n .any()\n .openapi({ description: \"Datasource config (arbitrary object).\" }),\n created_at: z\n .string()\n .openapi({\n description: \"Timestamp when the datasource was created.\",\n example: \"2024-05-01T16:58:00.000Z\",\n }),\n created_by: z\n .string()\n .uuid()\n .nullable()\n .openapi({\n description: \"ID of the account that created the datasource.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n description: z\n .string()\n .nullable()\n .openapi({\n description: \"Description of the datasource.\",\n example: \"This datasource contains sales data.\",\n }),\n filters: z\n .array(\n z.object({\n column: z\n .string()\n .openapi({ description: \"Filter column.\", example: \"age\" }),\n type: z\n .enum([\"text\", \"number\", \"date\"])\n .openapi({ description: \"Filter type.\", example: \"number\" }),\n label: z\n .string()\n .openapi({ description: \"Filter label.\", example: \"Age\" }),\n max_days: z\n .number()\n .optional()\n .openapi({ description: \"Max selectable days.\", example: 30 }),\n }),\n )\n .openapi({ description: \"Datasource filters.\" }),\n id: z\n .string()\n .uuid()\n .openapi({\n description: \"Datasource ID.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n integration: z\n .string()\n .uuid()\n .nullable()\n .openapi({\n description: \"Integration ID associated with the datasource, if any.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n last_updated_at: z\n .string()\n .openapi({\n description: \"Timestamp when the datasource was last updated.\",\n example: \"2024-05-02T10:00:00.000Z\",\n }),\n last_updated_by: z\n .string()\n .uuid()\n .nullable()\n .openapi({\n description: \"ID of the account that last updated the datasource.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n metadata: z\n .array(MetadataItemZod)\n .openapi({ description: \"Datasource metadata.\" }),\n parameters: z\n .array(\n z.object({\n id: z\n .string()\n .openapi({ description: \"Parameter ID.\", example: \"param1\" }),\n wrap: z\n .string()\n .optional()\n .openapi({\n description: \"Wrap option for parameter.\",\n example: \"quotes\",\n }),\n default: z\n .string()\n .openapi({\n description: \"Default value for parameter.\",\n example: \"default_value\",\n }),\n }),\n )\n .openapi({ description: \"Datasource parameters.\" }),\n size: z\n .number()\n .openapi({ description: \"Size of the datasource.\", example: 1000 }),\n source: z\n .string()\n .openapi({ description: \"Source of the datasource.\", example: \"csv\" }),\n team: z\n .string()\n .uuid()\n .openapi({\n description: \"Team ID that owns the datasource.\",\n example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\",\n }),\n title: z\n .string()\n .openapi({\n description: \"Title of the datasource.\",\n example: \"Sales Data\",\n }),\n })\n .openapi({\n description: \"A datasource that provides data for visualizations.\",\n }) as any,\n);\n\nexport type EmbedUser = Modify<\n Database[\"public\"][\"Tables\"][\"embed_users\"][\"Row\"],\n { parameters: Metadata[] }\n>;\nexport const EmbedUserZod = registry.register(\n \"EmbedUser\",\n z\n .object({\n created_at: z\n .string()\n .openapi({\n description: \"Timestamp when the embed user was created.\",\n example: \"2024-05-01T16:58:00.000Z\",\n }),\n email: z\n .string()\n .email()\n .nullable()\n .openapi({\n description: \"Email address of the embed user.\",\n example: \"embeduser@example.com\",\n }),\n id: z\n .string()\n .uuid()\n .openapi({\n description: \"Embed user ID.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n last_updated_at: z\n .string()\n .openapi({\n description: \"Timestamp when the embed user was last updated.\",\n example: \"2024-05-02T10:00:00.000Z\",\n }),\n name: z\n .string()\n .openapi({\n description: \"Name of the embed user.\",\n example: \"John Doe\",\n }),\n parameters: z\n .any()\n .nullable()\n .openapi({\n description: \"Parameters for the embed user (arbitrary object).\",\n }),\n team: z\n .string()\n .uuid()\n .openapi({\n description: \"Team ID that the embed user belongs to.\",\n example: \"team_123\",\n }),\n })\n .openapi({ description: \"An embed user.\" }) as any,\n);\n\nexport type Subscription = Database[\"public\"][\"Tables\"][\"subscriptions\"][\"Row\"];\nexport const SubscriptionZod = registry.register(\n \"Subscription\",\n z.object({\n amount: z\n .number()\n .openapi({ description: \"Subscription amount.\", example: 1999 }),\n created_at: z\n .string()\n .openapi({\n description: \"Timestamp when the subscription was created.\",\n example: \"2024-05-01T16:58:00.000Z\",\n }),\n currency: z\n .string()\n .openapi({\n description: \"Currency of the subscription.\",\n example: \"USD\",\n }),\n integrations: z\n .array(z.string())\n .openapi({\n description: \"Integrations included in the subscription.\",\n example: [\"slack\", \"github\"],\n }),\n interval: z\n .string()\n .openapi({ description: \"Billing interval.\", example: \"month\" }),\n period_end: z\n .string()\n .openapi({\n description: \"End of the current billing period.\",\n example: \"2024-06-01T16:58:00.000Z\",\n }),\n period_start: z\n .string()\n .openapi({\n description: \"Start of the current billing period.\",\n example: \"2024-05-01T16:58:00.000Z\",\n }),\n product_name: z\n .string()\n .openapi({\n description: \"Product name of the subscription.\",\n example: \"Pro Plan\",\n }),\n stripe_customer_id: z\n .string()\n .openapi({ description: \"Stripe customer ID.\", example: \"cus_abc123\" }),\n stripe_product_id: z\n .string()\n .openapi({ description: \"Stripe product ID.\", example: \"prod_abc123\" }),\n stripe_subscription_id: z\n .string()\n .openapi({\n description: \"Stripe subscription ID.\",\n example: \"sub_abc123\",\n }),\n team: z\n .string()\n .uuid()\n .openapi({\n description: \"Team ID associated with the subscription.\",\n example: \"team_123\",\n }),\n }) as any,\n);\n\nexport type SubscriptionPlan =\n Database[\"public\"][\"Tables\"][\"subscription_plans\"][\"Row\"];\nexport const SubscriptionPlanZod = registry.register(\n \"SubscriptionPlan\",\n z\n .object({\n accounts: z\n .number()\n .nullable()\n .openapi({\n description: \"Number of accounts allowed in the plan.\",\n example: 10,\n }),\n automations: z\n .boolean()\n .openapi({\n description: \"Whether automations are enabled in the plan.\",\n example: true,\n }),\n connected_datasources: z\n .number()\n .openapi({\n description: \"Number of connected datasources allowed.\",\n example: 5,\n }),\n copilot: z\n .boolean()\n .openapi({\n description: \"Whether copilot is enabled in the plan.\",\n example: true,\n }),\n custom_llm: z\n .boolean()\n .openapi({\n description: \"Whether custom LLM is enabled in the plan.\",\n example: false,\n }),\n embed_users: z\n .number()\n .openapi({\n description: \"Number of embed users allowed.\",\n example: 100,\n }),\n name: z\n .string()\n .openapi({\n description: \"Name of the subscription plan.\",\n example: \"Pro\",\n }),\n premium_integrations: z\n .number()\n .openapi({\n description: \"Number of premium integrations allowed.\",\n example: 2,\n }),\n })\n .openapi({ description: \"A subscription plan.\" }) as any,\n);\n\nexport type APIKey = Database[\"public\"][\"Tables\"][\"api_keys\"][\"Row\"];\nexport const APIKeyZod = registry.register(\n \"APIKey\",\n z\n .object({\n created_at: z\n .string()\n .openapi({\n description: \"Timestamp when the API key was created.\",\n example: \"2024-05-01T16:58:00.000Z\",\n }),\n description: z\n .string()\n .nullable()\n .openapi({\n description: \"Description of the API key.\",\n example: \"Key for production environment\",\n }),\n id: z\n .string()\n .uuid()\n .openapi({\n description: \"API Key ID.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n key: z\n .string()\n .openapi({\n description: \"The API key string.\",\n example: \"ey.1234567890\",\n }),\n last_used_at: z\n .string()\n .nullable()\n .openapi({\n description: \"Timestamp when the API key was last used.\",\n example: \"2024-05-02T12:00:00.000Z\",\n }),\n team: z\n .string()\n .uuid()\n .openapi({\n description: \"Team ID associated with the API key.\",\n example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\",\n }),\n })\n .openapi({ description: \"An API key.\" }) as any,\n);\n\nexport type Widget = Modify<\n Database[\"public\"][\"Tables\"][\"widgets\"][\"Row\"],\n {\n settings?: WidgetSettings;\n messages: WidgetMessage[];\n layouts: {\n lg: { x: number; y: number; w: number; h: number };\n sm?: { x: number; y: number; w: number; h: number };\n };\n }\n>;\nexport const WidgetZod = registry.register(\n \"Widget\",\n z\n .object({\n settings: z\n .object({\n css_id: z\n .string()\n .optional()\n .openapi({ description: \"Widget CSS ID.\", example: \"widget-123\" }),\n css_classnames: z\n .string()\n .optional()\n .openapi({\n description: \"Widget CSS class names.\",\n example: \"widget-class\",\n }),\n })\n .optional()\n .openapi({ description: \"Widget settings.\" }),\n messages: z\n .array(\n z.object({\n role: z\n .enum([\"user\", \"assistant\"])\n .openapi({\n description: \"Widget message role.\",\n example: \"user\",\n }),\n content: z\n .string()\n .openapi({\n description: \"Widget message content.\",\n example: \"Hello from widget!\",\n }),\n }),\n )\n .openapi({ description: \"Widget messages.\" }),\n layouts: z\n .object({\n lg: z.object({\n x: z.number().openapi({ description: \"X position.\", example: 0 }),\n y: z.number().openapi({ description: \"Y position.\", example: 0 }),\n w: z.number().openapi({ description: \"Width.\", example: 4 }),\n h: z.number().openapi({ description: \"Height.\", example: 3 }),\n }),\n sm: z\n .object({\n x: z\n .number()\n .openapi({ description: \"X position (sm).\", example: 0 }),\n y: z\n .number()\n .openapi({ description: \"Y position (sm).\", example: 0 }),\n w: z.number().openapi({ description: \"Width (sm).\", example: 2 }),\n h: z\n .number()\n .openapi({ description: \"Height (sm).\", example: 2 }),\n })\n .optional(),\n })\n .openapi({ description: \"Widget layouts.\" }),\n drilldown_widget: z\n .string()\n .uuid()\n .nullable()\n .openapi({\n description:\n \"Drilldown widget ID associated with the widget, if any.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n })\n .openapi({ description: \"A widget.\" }) as any,\n);\n\nexport type WidgetSuggestion =\n Database[\"public\"][\"Tables\"][\"widget_suggestions\"][\"Row\"];\nexport const WidgetSuggestionZod = registry.register(\n \"WidgetSuggestions\",\n z\n .object({\n id: z\n .string()\n .uuid()\n .openapi({\n description: \"Widget suggestion ID.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n dashboard: z\n .string()\n .uuid()\n .openapi({\n description: \"Dashboard ID associated with the suggestion.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n team: z\n .string()\n .uuid()\n .openapi({\n description: \"Team ID associated with the suggestion.\",\n example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\",\n }),\n created_at: z\n .string()\n .openapi({\n description: \"Timestamp when the suggestion was created.\",\n example: \"2024-05-01T16:58:00.000Z\",\n }),\n widget: z\n .string()\n .uuid()\n .openapi({\n description: \"Widget ID associated with the suggestion.\",\n example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\",\n }),\n title: z\n .string()\n .openapi({\n description: \"Title of the widget suggestion.\",\n example: \"Widget Suggestion\",\n }),\n description: z\n .string()\n .openapi({\n description: \"Description of the widget suggestion.\",\n example: \"This is a widget suggestion.\",\n }),\n })\n .openapi({ description: \"A widget suggestion.\" }) as any,\n);\n\nexport type DashboardDatasource =\n Database[\"public\"][\"Tables\"][\"dashboard_datasources\"][\"Row\"];\nexport const DashboardDatasourceZod = registry.register(\n \"DashboardDatasource\",\n z\n .object({\n dashboard: z\n .string()\n .uuid()\n .openapi({\n description: \"Dashboard ID associated with the datasource.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n datasource: z\n .string()\n .uuid()\n .openapi({\n description: \"Datasource ID associated with the dashboard.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n team: z\n .string()\n .uuid()\n .openapi({\n description: \"Team ID associated with the dashboard datasource.\",\n example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\",\n }),\n })\n .openapi({ description: \"A dashboard datasource.\" }) as any,\n);\n\nexport type Session = Modify<\n Database[\"public\"][\"Tables\"][\"sessions\"][\"Row\"],\n {\n parameters: Metadata[];\n }\n>;\nexport const SessionZod = registry.register(\n \"Session\",\n z\n .object({\n created_at: z\n .string()\n .openapi({\n description: \"Timestamp when the session was created.\",\n example: \"2024-05-01T16:58:00.000Z\",\n }),\n dashboard: z\n .string()\n .uuid()\n .openapi({\n description: \"Dashboard ID associated with the session.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n embed_user: z\n .string()\n .uuid()\n .openapi({\n description: \"Embed user ID associated with the session.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n parameters: z\n .any()\n .openapi({ description: \"Session parameters (arbitrary object).\" }),\n team: z\n .string()\n .uuid()\n .openapi({\n description: \"Team ID associated with the session.\",\n example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\",\n }),\n })\n .openapi({ description: \"A user session.\" }) as any,\n);\n\nexport type Question = Database[\"public\"][\"Tables\"][\"questions\"][\"Row\"];\nexport const QuestionZod = registry.register(\n \"Question\",\n z\n .object({\n created_at: z\n .string()\n .openapi({\n description: \"Timestamp when the question was created.\",\n example: \"2024-05-01T16:58:00.000Z\",\n }),\n dashboard: z\n .string()\n .uuid()\n .openapi({\n description: \"Dashboard ID associated with the question.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n id: z\n .string()\n .uuid()\n .openapi({\n description: \"Question ID.\",\n example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\",\n }),\n messages: z\n .any()\n .openapi({\n description:\n \"Messages associated with the question (arbitrary object).\",\n }),\n query: z\n .string()\n .openapi({\n description: \"Query text of the question.\",\n example: \"What were last month's sales?\",\n }),\n team: z\n .string()\n .uuid()\n .nullable()\n .openapi({\n description: \"Team ID associated with the question, if any.\",\n example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\",\n }),\n })\n .openapi({ description: \"A question asked in the dashboard.\" }) as any,\n);\n\nexport type IntegrationMeta = {\n integration_tables: number;\n datasources: number;\n};\nexport type Integration = Modify<\n Database[\"public\"][\"Tables\"][\"integrations\"][\"Row\"],\n {\n config: any;\n parameters: { id: string; wrap?: string; default: string }[];\n }\n>;\nexport const IntegrationZod = registry.register(\n \"Integration\",\n z\n .object({\n config: z\n .any()\n .openapi({ description: \"Integration config (arbitrary object).\" }),\n created_at: z\n .string()\n .openapi({\n description: \"Timestamp when the integration was created.\",\n example: \"2024-05-01T16:58:00.000Z\",\n }),\n id: z\n .string()\n .uuid()\n .openapi({\n description: \"Integration ID.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n provider: z\n .string()\n .openapi({ description: \"Integration provider.\", example: \"slack\" }),\n status: z\n .string()\n .openapi({ description: \"Integration status.\", example: \"active\" }),\n team: z\n .string()\n .uuid()\n .openapi({\n description: \"Team ID associated with the integration.\",\n example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\",\n }),\n title: z\n .string()\n .nullable()\n .openapi({\n description: \"Title of the integration.\",\n example: \"Slack Integration\",\n }),\n parameters: z\n .array(\n z.object({\n id: z\n .string()\n .openapi({\n description: \"Parameter ID.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n wrap: z\n .string()\n .optional()\n .openapi({ description: \"Parameter wrap.\", example: \"slack\" }),\n default: z\n .string()\n .openapi({\n description: \"Parameter default.\",\n example: \"active\",\n }),\n }),\n )\n .openapi({ description: \"Integration parameters.\" }),\n })\n .openapi({\n description: \"An integration with an external service.\",\n }) as any,\n);\n\nexport type IntegrationTable = Modify<\n Database[\"public\"][\"Tables\"][\"integration_tables\"][\"Row\"],\n {\n columns: any[];\n }\n>;\nexport const IntegrationTableZod = registry.register(\n \"IntegrationTable\",\n z\n .object({\n id: z\n .string()\n .uuid()\n .openapi({\n description: \"Integration ID.\",\n example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\",\n }),\n columns: z\n .array(\n z.object({\n name: z\n .string()\n .openapi({ description: \"Field name.\", example: \"name\" }),\n type: z\n .string()\n .openapi({ description: \"Field type.\", example: \"text\" }),\n description: z\n .string()\n .openapi({\n description: \"Field description.\",\n example: \"The name of the entity.\",\n }),\n hidden: z\n .boolean()\n .optional()\n .openapi({ description: \"Field hidden.\", example: false }),\n }),\n )\n .openapi({ description: \"Integration fields.\" }),\n rows: z\n .number()\n .openapi({\n description: \"Number of rows in the integration table.\",\n example: 100,\n }),\n errors: z\n .string()\n .nullable()\n .openapi({\n description: \"Any errors in the integration table.\",\n example: \"\",\n }),\n team: z\n .string()\n .uuid()\n .openapi({\n description: \"Team ID associated with the integration table.\",\n example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\",\n }),\n title: z\n .string()\n .nullable()\n .openapi({\n description: \"Title of the integration table.\",\n example: \"Slack Integration Table\",\n }),\n description: z\n .string()\n .nullable()\n .openapi({\n description: \"Description of the integration table.\",\n example: \"This integration table is used to connect to Slack.\",\n }),\n })\n .openapi({ description: \"A table under an integration.\" }) as any,\n);\n\nexport const LLMHostingTypeZod = z\n .enum([\"default\", \"custom\"])\n .openapi({\n description: \"Specifies if the LLM is hosted by Onvo or self-hosted.\",\n });\n\nexport type LLMSettings = Database[\"public\"][\"Tables\"][\"llm_settings\"][\"Row\"];\nexport const LLMSettingsZod = registry.register(\n \"LLMSettings\",\n z\n .object({\n analyst_agent_type: LLMHostingTypeZod,\n programmer_agent_type: LLMHostingTypeZod,\n\n analyst_agent_api_url: z\n .string()\n .url()\n .nullable()\n .openapi({\n description: \"URL for self-hosted API.\",\n example: \"http://localhost:11434\",\n }),\n analyst_agent_api_key: z\n .string()\n .nullable()\n .openapi({\n description: \"API key for custom models (write-only).\",\n example: \"sk-...\",\n format: \"password\",\n }),\n\n programmer_agent_api_url: z\n .string()\n .url()\n .nullable()\n .openapi({\n description: \"URL for self-hosted API.\",\n example: \"http://localhost:11434\",\n }),\n programmer_agent_api_key: z\n .string()\n .nullable()\n .openapi({\n description: \"API key for custom models (write-only).\",\n example: \"sk-...\",\n format: \"password\",\n }),\n\n programmer_agent_model: z\n .string()\n .openapi({\n description: \"Model used for the programmer agent.\",\n example: \"openai/gpt-3.5-turbo\",\n }),\n analyst_agent_model: z\n .string()\n .openapi({\n description: \"Model used for the analyst agent.\",\n example: \"openai/gpt-4-turbo\",\n }),\n\n programmer_agent_prompt: z\n .string()\n .nullable()\n .openapi({\n description: \"Custom prompt for the programmer agent.\",\n example:\n \"You are a helpful AI assistant specialized in code generation.\",\n }),\n analyst_agent_prompt: z\n .string()\n .nullable()\n .openapi({\n description: \"Custom prompt for the analyst agent.\",\n example:\n \"You are a helpful AI assistant specialized in data analysis.\",\n }),\n\n team: z\n .string()\n .uuid()\n .openapi({\n description:\n \"The ID of the team these settings belong to (read-only).\",\n example: \"d4e5f6a7-b8c9-0123-4567-890abcdef012\",\n readOnly: true,\n }),\n updated: z\n .boolean()\n .openapi({\n description:\n \"Indicates if the settings have been updated from defaults (read-only).\",\n example: true,\n readOnly: true,\n }),\n })\n .openapi({ description: \"LLM settings\" }) as any,\n);\n\nexport type SelfHostingSettings =\n Database[\"public\"][\"Tables\"][\"self_hosting_settings\"][\"Row\"];\nexport const SelfHostingSettingsZod = registry.register(\n \"SelfHostingSettings\",\n z\n .object({\n team: z\n .string()\n .uuid()\n .openapi({\n description:\n \"The ID of the team these settings belong to (read-only).\",\n example: \"d4e5f6a7-b8c9-0123-4567-890abcdef012\",\n readOnly: true,\n }),\n data_service_endpoint: z\n .string()\n .openapi({\n description: \"The endpoint for the data service.\",\n example: \"https://data-service.example.com\",\n }),\n data_service_secret: z\n .string()\n .openapi({\n description: \"The secret for the data service.\",\n example: \"data-service-secret\",\n }),\n s3_credentials: z\n .string()\n .openapi({\n description: \"The credentials for the S3 service.\",\n example: \"s3-credentials\",\n }),\n google_sheets_credentials: z\n .string()\n .openapi({\n description: \"The credentials for the Google service.\",\n example: \"google-credentials\",\n }),\n airtable_credentials: z\n .string()\n .openapi({\n description: \"The credentials for the Airtable service.\",\n example: \"airtable-credentials\",\n }),\n })\n .openapi({ description: \"Self-hosting settings\" }) as any,\n);\n\nexport type Log = Database[\"public\"][\"Tables\"][\"logs\"][\"Row\"];\nexport const LogZod = registry.register(\n \"Log\",\n z\n .object({\n account: z\n .string()\n .uuid()\n .nullable()\n .openapi({\n description:\n \"ID of the account that generated the log, if applicable.\",\n example: \"e5f6a7b8-c9d0-1234-5678-90abcdef0123\",\n }),\n created_at: z\n .string()\n .datetime()\n .openapi({\n description: \"Timestamp when the log was created.\",\n example: \"2024-05-01T16:58:00.000Z\",\n }),\n dashboard: z\n .string()\n .uuid()\n .nullable()\n .openapi({\n description: \"ID of the dashboard related to the log, if applicable.\",\n example: \"f6a7b8c9-d0e1-2345-6789-0abcdef01234\",\n }),\n embed_user: z\n .string()\n .nullable()\n .openapi({\n description:\n \"ID of the embed user related to the log, if applicable.\",\n example: \"embed-user-xyz789\",\n }),\n id: z\n .string()\n .uuid()\n .openapi({\n description: \"The unique identifier for the log entry.\",\n example: \"01234567-89ab-cdef-0123-456789abcdef\",\n }),\n team: z\n .string()\n .uuid()\n .nullable()\n .openapi({\n description: \"ID of the team associated with the log.\",\n example: \"12345678-9abc-def0-1234-56789abcdef0\",\n }),\n type: z\n .string()\n .openapi({\n description: \"The type or category of the log event.\",\n example: \"widget_interaction\",\n }),\n widget: z\n .string()\n .uuid()\n .nullable()\n .openapi({\n description: \"ID of the widget related to the log, if applicable.\",\n example: \"23456789-abcd-ef01-2345-6789abcdef01\",\n }),\n })\n .openapi({\n description: \"A log entry recording an event within the system.\",\n }) as any,\n);\n\n// Generate OpenAPI components from Zod schemas\nconst generator = new OpenApiGeneratorV3(registry.definitions);\nexport const OpenApiComponents = generator.generateComponents();\n","export type Json =\n | string\n | number\n | boolean\n | null\n | { [key: string]: Json | undefined }\n | Json[]\n\nexport type Database = {\n public: {\n Tables: {\n accounts: {\n Row: {\n avatar_url: string | null\n email: string | null\n full_name: string | null\n id: string\n phone_number: string | null\n updated_at: string | null\n }\n Insert: {\n avatar_url?: string | null\n email?: string | null\n full_name?: string | null\n id: string\n phone_number?: string | null\n updated_at?: string | null\n }\n Update: {\n avatar_url?: string | null\n email?: string | null\n full_name?: string | null\n id?: string\n phone_number?: string | null\n updated_at?: string | null\n }\n Relationships: []\n }\n api_keys: {\n Row: {\n created_at: string | null\n hash: string\n id: string\n last_used_at: string | null\n prefix: string\n scopes: string[]\n suffix: string\n team: string\n title: string\n }\n Insert: {\n created_at?: string | null\n hash: string\n id?: string\n last_used_at?: string | null\n prefix: string\n scopes?: string[]\n suffix: string\n team: string\n title: string\n }\n Update: {\n created_at?: string | null\n hash?: string\n id?: string\n last_used_at?: string | null\n prefix?: string\n scopes?: string[]\n suffix?: string\n team?: string\n title?: string\n }\n Relationships: [\n {\n foreignKeyName: \"public_api_keys_team_fkey\"\n columns: [\"team\"]\n isOneToOne: false\n referencedRelation: \"teams\"\n referencedColumns: [\"id\"]\n },\n ]\n }\n automation_runs: {\n Row: {\n automation: string\n conditions_passed: boolean | null\n error: string | null\n id: string\n method: string\n recipient_emails: string[] | null\n run_at: string\n status: string\n team: string\n webhook_sent: boolean | null\n }\n Insert: {\n automation: string\n conditions_passed?: boolean | null\n error?: string | null\n id?: string\n method?: string\n recipient_emails?: string[] | null\n run_at?: string\n status: string\n team: string\n webhook_sent?: boolean | null\n }\n Update: {\n automation?: string\n conditions_passed?: boolean | null\n error?: string | null\n id?: string\n method?: string\n recipient_emails?: string[] | null\n run_at?: string\n status?: string\n team?: string\n webhook_sent?: boolean | null\n }\n Relationships: [\n {\n foreignKeyName: \"automation_runs_automation_fkey\"\n columns: [\"automation\"]\n isOneToOne: false\n referencedRelation: \"automations\"\n referencedColumns: [\"id\"]\n },\n {\n foreignKeyName: \"public_automation_runs_team_fkey\"\n columns: [\"team\"]\n isOneToOne: false\n referencedRelation: \"teams\"\n referencedColumns: [\"id\"]\n },\n ]\n }\n automations: {\n Row: {\n condition_operator: string | null\n conditions: Json\n created_at: string\n dashboard: string\n description: string | null\n email_body: string\n email_cc: string[] | null\n email_subject: string\n email_to: string | null\n enabled: boolean\n id: string\n last_run_at: string | null\n last_updated_at: string\n method: string\n next_run_at: string | null\n output_format: string\n schedule: string\n team: string\n timezone: string\n title: string\n webhook_url: string | null\n }\n Insert: {\n condition_operator?: string | null\n conditions?: Json\n created_at?: string\n dashboard: string\n description?: string | null\n email_body: string\n email_cc?: string[] | null\n email_subject: string\n email_to?: string | null\n enabled?: boolean\n id?: string\n last_run_at?: string | null\n last_updated_at?: string\n method: string\n next_run_at?: string | null\n output_format: string\n schedule: string\n team: string\n timezone?: string\n title: string\n webhook_url?: string | null\n }\n Update: {\n condition_operator?: string | null\n conditions?: Json\n created_at?: string\n dashboard?: string\n description?: string | null\n email_body?: string\n email_cc?: string[] | null\n email_subject?: string\n email_to?: string | null\n enabled?: boolean\n id?: string\n last_run_at?: string | null\n last_updated_at?: string\n method?: string\n next_run_at?: string | null\n output_format?: string\n schedule?: string\n team?: string\n timezone?: string\n title?: string\n webhook_url?: string | null\n }\n Relationships: [\n {\n foreignKeyName: \"automations_dashboard_fkey\"\n columns: [\"dashboard\"]\n isOneToOne: false\n referencedRelation: \"dashboards\"\n referencedColumns: [\"id\"]\n },\n {\n foreignKeyName: \"public_automations_team_fkey\"\n columns: [\"team\"]\n isOneToOne: false\n referencedRelation: \"teams\"\n referencedColumns: [\"id\"]\n },\n ]\n }\n dashboard_datasources: {\n Row: {\n dashboard: string\n datasource: string\n team: string\n }\n Insert: {\n dashboard: string\n datasource: string\n team: string\n }\n Update: {\n dashboard?: string\n datasource?: string\n team?: string\n }\