@onvo-ai/js
Version:
The javascript SDK for Onvo AI dashboard builder
1 lines • 198 kB
Source Map (JSON)
{"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/hubspot.ts","../../src/oauth/xero.ts","../../src/oauth/shopify.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/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 { OpenApiGeneratorV3, extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';\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}\n\nexport type WidgetMessage = {\n role: \"user\" | \"assistant\";\n content: string;\n};\n\n\n\nexport type Message = Modify<Database[\"public\"][\"Tables\"][\"messages\"][\"Row\"], {\n role: \"user\" | \"assistant\" | \"tool\";\n content?: string;\n tool_calls?: any[];\n}>;\nexport const MessageZod = registry.register(\"Message\", (z.object({\n id: z.string().uuid().openapi({ description: \"Message ID.\", example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\" }),\n content: z.string().optional().openapi({ description: \"Message content.\", example: \"Hello!\" }),\n created_at: z.string().openapi({ description: \"Timestamp when the message was created.\", example: \"2024-05-01T16:58:00.000Z\" }),\n dashboard: z.string().uuid().nullable().openapi({ description: \"Dashboard ID associated with the message, if any.\", example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\" }),\n question: z.string().uuid().openapi({ description: \"Question ID associated with the message.\", example: \"question_123\" }),\n role: z.enum([\"user\", \"assistant\", \"tool\"]).nullable().openapi({ description: \"Role of the message sender.\", example: \"user\" }),\n team: z.string().uuid().openapi({ description: \"Team ID associated with the message.\", example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\" }),\n tool_call_id: z.string().uuid().nullable().openapi({ description: \"Tool call ID associated with the message, if any.\", example: \"toolcall_123\" }),\n tool_calls: z.array(z.any()).nullable().openapi({ description: \"Tool calls associated with the message.\", example: [] })\n}).openapi({ description: \"A message in a conversation.\" })) as any);\n\nexport type Invite = Database[\"public\"][\"Tables\"][\"invites\"][\"Row\"];\nexport const InviteZod = registry.register(\"Invite\", (z.object({\n created_at: z.string().openapi({ description: \"Timestamp when the invite was created.\", example: \"2024-05-01T16:58:00.000Z\" }),\n email: z.string().email().openapi({ description: \"The email address the invite was sent to.\", example: \"invitee@example.com\" }),\n name: z.string().openapi({ description: \"The name of the invitee.\", example: \"Jane Doe\" }),\n team: z.string().uuid().openapi({ description: \"The ID of the team the invite is for.\", example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\" })\n}).openapi({ description: \"An invite to join a team.\" })) as any);\n\nexport type Member = Database[\"public\"][\"Tables\"][\"members\"][\"Row\"];\nexport const MemberZod = registry.register(\"Member\", (z.object({\n account: z.string().uuid().openapi({ description: \"The ID of the account that is a member.\", example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\" }),\n team: z.string().uuid().openapi({ description: \"The ID of the team the member belongs to.\", example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\" })\n}).openapi({ description: \"A member of a team.\" })) as any);\n\nexport type Team = Database[\"public\"][\"Tables\"][\"teams\"][\"Row\"];\nexport const TeamZod = registry.register(\"Team\", (z.object({\n created_at: z.string().nullable().openapi({ description: \"Timestamp when the team was created.\", example: \"2024-05-01T16:58:00.000Z\" }),\n email: z.string().email().nullable().openapi({ description: \"The team's contact email address.\", example: \"team@example.com\" }),\n id: z.string().uuid().openapi({ description: \"Team ID.\", example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\" }),\n logo: z.string().nullable().openapi({ description: \"URL to the team's logo.\", example: \"https://example.com/logo.png\" }),\n name: z.string().nullable().openapi({ description: \"The team's name.\", example: \"Acme Corp\" }),\n phone_number: z.string().nullable().openapi({ description: \"The team's contact phone number.\", example: \"+1234567890\" }),\n stripe_id: z.string().nullable().openapi({ description: \"Stripe customer ID for the team.\", example: \"cus_abc123\" })\n}).openapi({ description: \"A team that represents a group of users.\" })) as any);\n\nexport type DataSource = Modify<Database[\"public\"][\"Tables\"][\"datasources\"][\"Row\"], {\n columns: { title: string; description: string; type?: string; hidden?: boolean }[];\n config: any;\n parameters: { id: string; wrap?: string; default: string }[];\n filters: DatasourceFilter[];\n metadata?: Metadata[];\n}>;\nexport const DataSourceZod = registry.register(\"DataSource\", (z.object({\n columns: z.array(z.object({\n title: z.string().openapi({ description: \"Column title.\", example: \"Name\" }),\n description: z.string().openapi({ description: \"Column description.\", example: \"The name of the entity.\" }),\n type: z.string().optional().openapi({ description: \"Column type.\", example: \"text\" }),\n hidden: z.boolean().optional().openapi({ description: \"Column hidden.\", example: false })\n })).openapi({ description: \"Datasource columns.\" }),\n config: z.any().openapi({ description: \"Datasource config (arbitrary object).\" }),\n created_at: z.string().openapi({ description: \"Timestamp when the datasource was created.\", example: \"2024-05-01T16:58:00.000Z\" }),\n created_by: z.string().uuid().nullable().openapi({ description: \"ID of the account that created the datasource.\", example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\" }),\n description: z.string().nullable().openapi({ description: \"Description of the datasource.\", example: \"This datasource contains sales data.\" }),\n filters: z.array(z.object({\n column: z.string().openapi({ description: \"Filter column.\", example: \"age\" }),\n type: z.enum([\"text\", \"number\", \"date\"]).openapi({ description: \"Filter type.\", example: \"number\" }),\n label: z.string().openapi({ description: \"Filter label.\", example: \"Age\" })\n })).openapi({ description: \"Datasource filters.\" }),\n id: z.string().uuid().openapi({ description: \"Datasource ID.\", example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\" }),\n integration: z.string().uuid().nullable().openapi({ description: \"Integration ID associated with the datasource, if any.\", example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\" }),\n last_updated_at: z.string().openapi({ description: \"Timestamp when the datasource was last updated.\", example: \"2024-05-02T10:00:00.000Z\" }),\n last_updated_by: z.string().uuid().nullable().openapi({ description: \"ID of the account that last updated the datasource.\", example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\" }),\n metadata: z.array(MetadataItemZod).openapi({ description: \"Datasource metadata.\" }),\n parameters: z.array(z.object({\n id: z.string().openapi({ description: \"Parameter ID.\", example: \"param1\" }),\n wrap: z.string().optional().openapi({ description: \"Wrap option for parameter.\", example: \"quotes\" }),\n default: z.string().openapi({ description: \"Default value for parameter.\", example: \"default_value\" })\n })).openapi({ description: \"Datasource parameters.\" }),\n size: z.number().openapi({ description: \"Size of the datasource.\", example: 1000 }),\n source: z.string().openapi({ description: \"Source of the datasource.\", example: \"csv\" }),\n team: z.string().uuid().openapi({ description: \"Team ID that owns the datasource.\", example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\" }),\n title: z.string().openapi({ description: \"Title of the datasource.\", example: \"Sales Data\" })\n}).openapi({ description: \"A datasource that provides data for visualizations.\" })) as any);\n\nexport type EmbedUser = Modify<Database[\"public\"][\"Tables\"][\"embed_users\"][\"Row\"], { parameters: Metadata[] }>;\nexport const EmbedUserZod = registry.register(\"EmbedUser\", (z.object({\n created_at: z.string().openapi({ description: \"Timestamp when the embed user was created.\", example: \"2024-05-01T16:58:00.000Z\" }),\n email: z.string().email().nullable().openapi({ description: \"Email address of the embed user.\", example: \"embeduser@example.com\" }),\n id: z.string().uuid().openapi({ description: \"Embed user ID.\", example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\" }),\n last_updated_at: z.string().openapi({ description: \"Timestamp when the embed user was last updated.\", example: \"2024-05-02T10:00:00.000Z\" }),\n name: z.string().openapi({ description: \"Name of the embed user.\", example: \"John Doe\" }),\n parameters: z.any().nullable().openapi({ description: \"Parameters for the embed user (arbitrary object).\" }),\n team: z.string().uuid().openapi({ description: \"Team ID that the embed user belongs to.\", example: \"team_123\" })\n}).openapi({ description: \"An embed user.\" })) as any);\n\nexport type Subscription = Database[\"public\"][\"Tables\"][\"subscriptions\"][\"Row\"];\nexport const SubscriptionZod = registry.register(\"Subscription\", (z.object({\n amount: z.number().openapi({ description: \"Subscription amount.\", example: 1999 }),\n created_at: z.string().openapi({ description: \"Timestamp when the subscription was created.\", example: \"2024-05-01T16:58:00.000Z\" }),\n currency: z.string().openapi({ description: \"Currency of the subscription.\", example: \"USD\" }),\n integrations: z.array(z.string()).openapi({ description: \"Integrations included in the subscription.\", example: [\"slack\", \"github\"] }),\n interval: z.string().openapi({ description: \"Billing interval.\", example: \"month\" }),\n period_end: z.string().openapi({ description: \"End of the current billing period.\", example: \"2024-06-01T16:58:00.000Z\" }),\n period_start: z.string().openapi({ description: \"Start of the current billing period.\", example: \"2024-05-01T16:58:00.000Z\" }),\n product_name: z.string().openapi({ description: \"Product name of the subscription.\", example: \"Pro Plan\" }),\n stripe_customer_id: z.string().openapi({ description: \"Stripe customer ID.\", example: \"cus_abc123\" }),\n stripe_product_id: z.string().openapi({ description: \"Stripe product ID.\", example: \"prod_abc123\" }),\n stripe_subscription_id: z.string().openapi({ description: \"Stripe subscription ID.\", example: \"sub_abc123\" }),\n team: z.string().uuid().openapi({ description: \"Team ID associated with the subscription.\", example: \"team_123\" })\n})) as any);\n\nexport type SubscriptionPlan = Database[\"public\"][\"Tables\"][\"subscription_plans\"][\"Row\"];\nexport const SubscriptionPlanZod = registry.register(\"SubscriptionPlan\", (z.object({\n accounts: z.number().nullable().openapi({ description: \"Number of accounts allowed in the plan.\", example: 10 }),\n automations: z.boolean().openapi({ description: \"Whether automations are enabled in the plan.\", example: true }),\n connected_datasources: z.number().openapi({ description: \"Number of connected datasources allowed.\", example: 5 }),\n copilot: z.boolean().openapi({ description: \"Whether copilot is enabled in the plan.\", example: true }),\n custom_llm: z.boolean().openapi({ description: \"Whether custom LLM is enabled in the plan.\", example: false }),\n embed_users: z.number().openapi({ description: \"Number of embed users allowed.\", example: 100 }),\n name: z.string().openapi({ description: \"Name of the subscription plan.\", example: \"Pro\" }),\n premium_integrations: z.number().openapi({ description: \"Number of premium integrations allowed.\", example: 2 })\n}).openapi({ description: \"A subscription plan.\" })) as any);\n\nexport type APIKey = Database[\"public\"][\"Tables\"][\"api_keys\"][\"Row\"];\nexport const APIKeyZod = registry.register(\"APIKey\", (z.object({\n created_at: z.string().openapi({ description: \"Timestamp when the API key was created.\", example: \"2024-05-01T16:58:00.000Z\" }),\n description: z.string().nullable().openapi({ description: \"Description of the API key.\", example: \"Key for production environment\" }),\n id: z.string().uuid().openapi({ description: \"API Key ID.\", example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\" }),\n key: z.string().openapi({ description: \"The API key string.\", example: \"ey.1234567890\" }),\n last_used_at: z.string().nullable().openapi({ description: \"Timestamp when the API key was last used.\", example: \"2024-05-02T12:00:00.000Z\" }),\n team: z.string().uuid().openapi({ description: \"Team ID associated with the API key.\", example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\" })\n}).openapi({ description: \"An API key.\" })) as any);\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(\"Widget\", (z.object({\n settings: z.object({\n css_id: z.string().optional().openapi({ description: \"Widget CSS ID.\", example: \"widget-123\" }),\n css_classnames: z.string().optional().openapi({ description: \"Widget CSS class names.\", example: \"widget-class\" })\n }).optional().openapi({ description: \"Widget settings.\" }),\n messages: z.array(z.object({\n role: z.enum([\"user\", \"assistant\"]).openapi({ description: \"Widget message role.\", example: \"user\" }),\n content: z.string().openapi({ description: \"Widget message content.\", example: \"Hello from widget!\" })\n })).openapi({ description: \"Widget messages.\" }),\n layouts: z.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.object({\n x: z.number().openapi({ description: \"X position (sm).\", example: 0 }),\n y: z.number().openapi({ description: \"Y position (sm).\", example: 0 }),\n w: z.number().openapi({ description: \"Width (sm).\", example: 2 }),\n h: z.number().openapi({ description: \"Height (sm).\", example: 2 })\n }).optional()\n }).openapi({ description: \"Widget layouts.\" })\n}).openapi({ description: \"A widget.\" })) as any);\n\nexport type DashboardDatasource = Database[\"public\"][\"Tables\"][\"dashboard_datasources\"][\"Row\"];\nexport const DashboardDatasourceZod = registry.register(\"DashboardDatasource\", (z.object({\n dashboard: z.string().uuid().openapi({ description: \"Dashboard ID associated with the datasource.\", example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\" }),\n datasource: z.string().uuid().openapi({ description: \"Datasource ID associated with the dashboard.\", example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\" }),\n team: z.string().uuid().openapi({ description: \"Team ID associated with the dashboard datasource.\", example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\" })\n}).openapi({ description: \"A dashboard datasource.\" })) as any);\n\nexport type Session = Modify<\n Database[\"public\"][\"Tables\"][\"sessions\"][\"Row\"],\n {\n parameters: Metadata[];\n }\n>;\nexport const SessionZod = registry.register(\"Session\", (z.object({\n created_at: z.string().openapi({ description: \"Timestamp when the session was created.\", example: \"2024-05-01T16:58:00.000Z\" }),\n dashboard: z.string().uuid().openapi({ description: \"Dashboard ID associated with the session.\", example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\" }),\n embed_user: z.string().uuid().openapi({ description: \"Embed user ID associated with the session.\", example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\" }),\n parameters: z.any().openapi({ description: \"Session parameters (arbitrary object).\" }),\n team: z.string().uuid().openapi({ description: \"Team ID associated with the session.\", example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\" })\n}).openapi({ description: \"A user session.\" })) as any);\n\nexport type Question = Database[\"public\"][\"Tables\"][\"questions\"][\"Row\"];\nexport const QuestionZod = registry.register(\"Question\", (z.object({\n created_at: z.string().openapi({ description: \"Timestamp when the question was created.\", example: \"2024-05-01T16:58:00.000Z\" }),\n dashboard: z.string().uuid().openapi({ description: \"Dashboard ID associated with the question.\", example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\" }),\n id: z.string().uuid().openapi({ description: \"Question ID.\", example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\" }),\n messages: z.any().openapi({ description: \"Messages associated with the question (arbitrary object).\" }),\n query: z.string().openapi({ description: \"Query text of the question.\", example: \"What were last month's sales?\" }),\n team: z.string().uuid().nullable().openapi({ description: \"Team ID associated with the question, if any.\", example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\" })\n}).openapi({ description: \"A question asked in the dashboard.\" })) as any);\n\nexport type Integration = Modify<\n Database[\"public\"][\"Tables\"][\"integrations\"][\"Row\"],\n {\n config: any;\n }\n>;\nexport const IntegrationZod = registry.register(\"Integration\", (z.object({\n config: z.any().openapi({ description: \"Integration config (arbitrary object).\" }),\n created_at: z.string().openapi({ description: \"Timestamp when the integration was created.\", example: \"2024-05-01T16:58:00.000Z\" }),\n id: z.string().uuid().openapi({ description: \"Integration ID.\", example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\" }),\n provider: z.string().openapi({ description: \"Integration provider.\", example: \"slack\" }),\n status: z.string().openapi({ description: \"Integration status.\", example: \"active\" }),\n team: z.string().uuid().openapi({ description: \"Team ID associated with the integration.\", example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\" }),\n title: z.string().nullable().openapi({ description: \"Title of the integration.\", example: \"Slack Integration\" })\n}).openapi({ description: \"An integration with an external service.\" })) as any);\n\nexport type IntegrationTable = Modify<\n Database[\"public\"][\"Tables\"][\"integration_tables\"][\"Row\"],\n {\n fields: any[];\n }\n>;\nexport const IntegrationTableZod = registry.register(\"IntegrationTable\", (z.object({\n id: z.string().uuid().openapi({ description: \"Integration ID.\", example: \"9b7deda3-7e2d-458e-84e9-632e47fbe682\" }),\n fields: z.array(z.object({\n name: z.string().openapi({ description: \"Field name.\", example: \"name\" }),\n type: z.string().openapi({ description: \"Field type.\", example: \"text\" }),\n description: z.string().openapi({ description: \"Field description.\", example: \"The name of the entity.\" }),\n hidden: z.boolean().optional().openapi({ description: \"Field hidden.\", example: false })\n })).openapi({ description: \"Integration fields.\" }),\n team: z.string().uuid().openapi({ description: \"Team ID associated with the integration table.\", example: \"92c680a3-a9c4-4c02-bb2d-a5d049789662\" }),\n title: z.string().nullable().openapi({ description: \"Title of the integration table.\", example: \"Slack Integration Table\" }),\n description: z.string().nullable().openapi({ description: \"Description of the integration table.\", example: \"This integration table is used to connect to Slack.\" }),\n}).openapi({ description: \"A table under an integration.\" })) as any);\n\nexport const LLMHostingTypeZod = z.enum([\"default\", \"custom\"]).openapi({ description: 'Specifies if the LLM is hosted by Onvo or self-hosted.' });\n\n\n\n\nexport type LLMSettings = Database[\"public\"][\"Tables\"][\"llm_settings\"][\"Row\"];\nexport const LLMSettingsZod = registry.register(\"LLMSettings\", (z.object({\n analyst_agent_type: LLMHostingTypeZod,\n programmer_agent_type: LLMHostingTypeZod,\n\n custom_api_url: z.string().url().nullable().openapi({ description: 'URL for self-hosted API.', example: 'http://localhost:11434' }),\n custom_api_key: z.string().nullable().openapi({ description: 'API key for custom models (write-only).', example: 'sk-...', format: 'password' }),\n\n programmer_agent_model: z.string().openapi({ description: 'Model used for the programmer agent.', example: 'openai/gpt-3.5-turbo' }),\n analyst_agent_model: z.string().openapi({ description: 'Model used for the analyst agent.', example: 'openai/gpt-4-turbo' }),\n\n programmer_agent_prompt: z.string().nullable().openapi({ description: 'Custom prompt for the programmer agent.', example: 'You are a helpful AI assistant specialized in code generation.' }),\n analyst_agent_prompt: z.string().nullable().openapi({ description: 'Custom prompt for the analyst agent.', example: 'You are a helpful AI assistant specialized in data analysis.' }),\n\n team: z.string().uuid().openapi({ description: 'The ID of the team these settings belong to (read-only).', example: 'd4e5f6a7-b8c9-0123-4567-890abcdef012', readOnly: true }),\n updated: z.boolean().openapi({ description: 'Indicates if the settings have been updated from defaults (read-only).', example: true, readOnly: true }),\n}).openapi({ description: \"LLM settings.\" })) as any);\n\nexport type Log = Database[\"public\"][\"Tables\"][\"logs\"][\"Row\"];\nexport const LogZod = registry.register(\"Log\", (z.object({\n account: z.string().uuid().nullable().openapi({ description: 'ID of the account that generated the log, if applicable.', example: 'e5f6a7b8-c9d0-1234-5678-90abcdef0123' }),\n created_at: z.string().datetime().openapi({ description: 'Timestamp when the log was created.', example: '2024-05-01T16:58:00.000Z' }),\n dashboard: z.string().uuid().nullable().openapi({ description: 'ID of the dashboard related to the log, if applicable.', example: 'f6a7b8c9-d0e1-2345-6789-0abcdef01234' }),\n embed_user: z.string().nullable().openapi({ description: 'ID of the embed user related to the log, if applicable.', example: 'embed-user-xyz789' }),\n id: z.string().uuid().openapi({ description: 'The unique identifier for the log entry.', example: '01234567-89ab-cdef-0123-456789abcdef' }),\n team: z.string().uuid().nullable().openapi({ description: 'ID of the team associated with the log.', example: '12345678-9abc-def0-1234-56789abcdef0' }),\n type: z.string().openapi({ description: 'The type or category of the log event.', example: 'widget_interaction' }),\n widget: z.string().uuid().nullable().openapi({ description: 'ID of the widget related to the log, if applicable.', example: '23456789-abcd-ef01-2345-6789abcdef01' })\n}).openapi({ description: \"A log entry recording an event within the system.\" })) as any);\n\n// Generate OpenAPI components from Zod schemas\nconst generator = new OpenApiGeneratorV3(registry.definitions);\nexport const OpenApiComponents = generator.generateComponents();","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 }\n Relationships: [\n {\n foreignKeyName: \"dashboard_datasources_dashboard_fkey\"\n columns: [\"dashboard\"]\n isOneToOne: false\n referencedRelation: \"dashboards\"\n referencedColumns: [\"id\"]\n },\n {\n foreignKeyName: \"dashboard_datasources_datasource_fkey\"\n columns: [\"datasource\"]\n isOneToOne: false\n referencedRelation: \"datasources\"\n referencedColumns: [\"id\"]\n },\n {\n foreignKeyName: \"public_dashboard_datasources_team_fkey\"\n columns: [\"team\"]\n isOneToOne: false\n referencedRelation: \"teams\"\n referencedColumns: [\"id\"]\n },\n ]\n }\n dashboards: {\n Row: {\n created_at: string\n created_by: string | null\n description: string | null\n filters: Json\n id: string\n last_updated_at: string\n last_updated_by: string | null\n metadata: Json\n parent_dashboard: string | null\n settings: Json\n tabs: Json\n team: string\n thumbnail: string | null\n title: string\n }\n Insert: {\n created_at?: string\n created_by?: string | null\n description?: string | null\n filters?: Json\n id?: string\n last_updated_at?: string\n last_updated_by?: string | null\n metadata?: Json\n parent_dashboard?: string | null\n settings?: Json\n tabs?: Json\n team: string\n thumbnail?: string | null\n title: string\n }\n Update: {\n created_at?: string\n created_by?: string | null\n description?: string | null\n filters?: Json\n id?: string\n last_updated_at?: string\n last_updated_by?: string | null\n metadata?: Json\n parent_dashboard?: string | null\n settings?: Json\n tabs?: Json\n team?: string\n thumbnail?: string | null\n title?: string\n }\n Relationships: [\n {\n foreignKeyName: \"dashboards_created_by_fkey\"\n columns: [\"created_by\"]\n isOneToOne: false\n referencedRelation: \"accounts\"\n referencedColumns: [\"id\"]\n },\n {\n foreignKeyName: \"dashboards_last_updated_by_fkey\"\n columns: [\"last_updated_by\"]\n isOneToOne: false\n referencedRelation: \"accounts\"\n referencedColumns: [\"id\"]\n },\n {\n foreignKeyName: \"dashboards_parent_dashboard_fkey\"\n columns: [\"parent_dashboard\"]\n isOneToOne: false\n referencedRelation: \"dashboards\"\n referencedColumns: [\"id\"]\n },\n {\n foreignKeyName: \"public_dashboards_team_fkey\"\n columns: [\"team\"]\n isOneToOne: false\n referencedRelation: \"teams\"\n referencedColumns: [\"id\"]\n },\n ]\n }\n datasources: {\n Row: {\n cache_duration: number\n columns: Json | null\n config: Json | null\n created_at: string\n created_by: string | null\n description: string | null\n filters: Json\n id: string\n integration: string | null\n last_updated_at: string\n last_updated_by: string | null\n metadata: Json\n parameters: Json | null\n size: number\n source: string\n team: string\n title: string\n }\n Insert: {\n cache_duration?: number\n columns?: Json | null\n config?: Json | null\n created_at?: string\n created_by?: string | null\n description?: string | null\n filters?: Json\n id?: string\n integration?: string | null\n last_updated_at?: string\n last_updated_by?: string | null\n metadata?: Json\n parameters?: Json | null\n size?: number\n source: string\n team: string\n title: string\n }\n Update: {\n cache_duration?: number\n columns?: Json | null\n config?: Json | null\n created_at?: string\n created_by?: string | null\n description?: string | null\n filters?: Json\n id?: string\n integration?: string | null\n last_updated_at?: string\n last_updated_by?: string | null\n metadata?: Json\n parameters?: Json | null\n size?: number\n source?: string\n team?: string\n title?: string\n }\n Relationships: [\n {\n foreignKeyName: \"datasources_created_by_fkey\"\n columns: [\"created_by\"]\n isOneToOne: false\n referencedRelation: \"accounts\"\n referencedColumns: [\"id\"]\n },\n {\n foreignKeyName: \"datasources_integration_fkey\"\n columns: [\"integration\"]\n isOneToOne: false\n referencedRelation: \"integrations\"\n referencedColumns: [\"id\"]\n },\n {\n foreignKeyName: \"datasources_last_updated_by_fkey\"\n columns: [\"last_updated_by\"]\n isOneToOne: false\n referencedRelation: \"accounts\"\n referencedColumns: [\"id\"]\n },\n {\n foreignKeyName: \"public_datasources_team_fkey\"\n columns: [\"team\"]\n isOneToOne: false\n referencedRelation: \"teams\"\n referencedColumns: [\"id\"]\n },\n ]\n }\n embed_users: {\n Row: {\n created_at: string\n email: string | null\n id: string\n last_updated_at: string\n name: string\n parameters: Json | null\n team: string\n }\n Insert: {\n created_at?: string\n email?: string | null\n id: string\n last_updated_at?: string\n name: string\n parameters?: Json | null\n team: string\n }\n Update: {\n created_at?: string\n email?: string | null\n id?: string\n last_updated_at?: string\n name?: string\n parameters?: Json | null\n team?: string\n }\n Relationships: [\n {\n foreignKeyName: \"public_embed_users_team_fkey\"\n columns: [\"team\"]\n isOneToOne: false\n referencedRelation: \"teams\"\n referencedColumns: [\"id\"]\n },\n ]\n }\n integration_tables: {\n Row: {\n description: string | null\n fields: Json | null\n id: string\n integration: string\n team: string\n title: string\n }\n Insert: {\n description?: string | null\n fields?: Json | null\n id: string\n integration?: string\n team: string\n title: string\n }\n Update: {\n description?: string | null\n fields?: Json | null\n id?: string\n integration?: string\n team?: string\n title?: string\n }\n Relationships: [\n {\n foreignKeyName: \"integration_tables_integration_fkey\"\n columns: [\"integration\"]\n isOneToOne: false\n referencedRelation: \"integrations\"\n referencedColumns: [\"id\"]\n },\n {\n foreignKeyName: \"integration_tables_team_fkey\"\n columns: [\"team\"]\n isOneToOne: false\n referencedRelation: \"teams\"\n referencedColumns: [\"id\"]\n },\n ]\n }\n integrations: {\n Row: {\n config: Json\n created_at: string\n id: string\n provider: string\n status: string\n team: string\n title: string | null\n usage: number\n }\n Insert: {\n config?: Json\n created_at?: string\n id?: string\n provider: string\n status?: string\n team: string\n title?: string | null\n usage?: number\n }\n Update: {\n config?: Json\n created_at?: string\n id?: string\n provider?: string\n status?: string\n team?: string\n title?: string | null\n usage?: number\n }\n Relationships: [\n {\n foreignKeyName: \"public_integrations_team_fkey\"\n columns: [\"team\"]\n isOneToOne: false\n referencedRelation: \"teams\"\n referencedColumns: [\"id\"]\n },\n ]\n }\n invites: {\n Row: {\n created_at: string\n email: string\n name: string\n team: string\n }\n Insert: {\n created_at?: string\n email: string\n name: string\n team: string\n }\n Update: {\n created_at?: string\n email?: string\n name?: string\n team?: string\n }\n Relationships: [\n {\n foreignKeyName: \"public_invites_team_fkey\"\n columns: [\"team\"]\n isOneToOne: false\n referencedRelation: \"teams\"\n referencedColumns: [\"id\"]\n },\n ]\n }\n llm_settings: {\n Row: {\n analyst_agent_model: string\n analyst_agent_prompt: string | null\n analyst_agent_type: Database[\"public\"][\"Enums\"][\"LLM hosting type\"]\n custom_api_key: string | null\n custom_api_url: string | null\n programmer_agent_model: string\n programmer_agent_prompt: string | null\n programmer_agent_type: Database[\"public\"][\"Enums\"][\"LLM hosting type\"]\n team: string\n updated: boolean\n }\n Insert: {\n analyst_agent_model?: string\n analyst_agent_prompt?: string | null\n analyst_agent_type?: Database[\"public\"][\"Enums\"][\"LLM hosting type\"]\n custom_api_key?: string | null\n custom_api_url?: string | null\n programmer_agent_model?: string\n programmer_agent_prompt?: string | null\n programmer_agent_type?: Database[\"public\"][\"Enums\"][\"LLM hosting type\"]\n team: string\n updated?: boolean\n }\n Update: {\n analyst_agent_model?: string\n analyst_agent_prompt?: string | null\n analyst_agent_type?: Database[\"public\"][\"Enums\"][\"LLM hosting type\"]\n custom_api_key?: string | null\n custom_api_url?: string | null\n programmer_agent_model?: string\n programmer_agent_prompt?: string | null\n programmer_agent_type?: Database[\"public\"][\"Enums\"][\"LLM hosting type\"]\n team?: string\n updated?: boolean\n }\n Relationships: [\n {\n foreignKeyName: \"public_llm_settings_team_fkey\"\n columns: [\"team\"]\n isOneToOne: true\n referencedRelation: \"teams\"\n referencedColumns: [\"id\"]\n },\n ]\n }\n logs: {\n Row: {\n account: string | null\n created_at: string\n dashboard: string | null\n embed_user: string | null\n id: string\n team: string | null\n type: string\n widget: string | null\n }\n Insert: {\n account?: string | null\n created_at?: string\n dashboard?: string | null\n embed_user?: string | null\n id?: string\n team?: string | null\n type: string\n widget?: string | null\n }\n Update: {\n account?: string | null\n created_at?: string\n dashboard?: string | null\n embed_user?: string | null\n id?: string\n team?: string | null\n type?: string\n widget?: string | null\n }\n Relationships: [\n {\n foreignKeyName: \"public_logs_account_fkey\"\n columns: [\"account\"]\n isOneToOne: false\n referencedRelation: \"accounts\"\n referencedColumns: [\"id\"]\n },\n {\n foreignKeyName: \"public_logs_dashboard_fkey\"\n columns: [\"dashboard\"]\n isOneToOne: false\n referencedRelation: \"dashboards\"\n referencedColumns: [\"id\"]\n },\n {\n foreignKeyName: \"public_logs_embed_user_team_fkey\"\n columns: [\"embed_user\", \"team\"]\n isOneToOne: false\n referencedRelation: \"embed_users\"\n referencedColumns: [\"id\", \"team\"]\n },\n {\n foreignKeyName: \"public_logs_team_fkey\"\n columns: [\"team\"]\n isOneToOne: false\n referencedRelation: \"teams\"\n referencedColumns: [\"id\"]\n },\n {\n foreignKeyName: \"public_logs_widget_fkey\"\n columns: [\"widget\"]\n isOneToOne: false\n referencedRelation: \"widgets\"\n referencedColumns: [\"id\"]\n },\n ]\n }\n members: {\n Row: {\n account: string\n team: string\n }\n Insert: {\n account: string\n team: string\n }\n Update: {\n account?: string\n team?: string\n }\n Relationships: [\n {\n foreignKeyName: \"members_user_fkey\"\n columns: [\"account\"]\n isOneToOne: false\n referencedRelation: \"accounts\"\n referencedColumns: [\"id\"]\n },\n {\n foreignKeyName: \"public_members_team_fkey\"\n columns: [\"team\"]\n isOneToOne: false\n referencedRelation: \"teams\"\n referencedColumns: [\"id\"]\n },\n ]\n }\n