From b6d303f90ec04143ad917be1271c8199590b428e Mon Sep 17 00:00:00 2001 From: giancarlo Date: Mon, 22 Apr 2024 15:24:01 +0800 Subject: [PATCH] Refactor monitoring package and improve error handling The monitoring package has been significantly refactored to improve the granularity of error capture. Code from the 'capture-exception.ts' files in different locations have been deleted and replaced by a more unified approach in the 'use-baselime.ts' and 'use-sentry.ts' hooks. The README documentation has also been updated to reflect these changes and provide additional information about error monitoring setup and usage. --- README.md | 102 + apps/web/app/(marketing)/page.tsx | 2 + apps/web/lib/database.types.ts | 2015 ++++++++--------- packages/monitoring/README.md | 31 +- packages/monitoring/baselime/README.md | 2 +- packages/monitoring/baselime/package.json | 3 +- .../baselime/src/capture-exception.ts | 4 - packages/monitoring/baselime/src/client.ts | 1 + .../baselime/src/hooks/use-baselime.ts | 20 + .../src/hooks/use-capture-exception.ts | 12 - packages/monitoring/baselime/src/index.ts | 1 - .../baselime/src/monitoring-service.ts | 0 packages/monitoring/baselime/src/server.ts | 1 + .../baselime-server-monitoring.service.ts | 9 + packages/monitoring/package.json | 2 +- packages/monitoring/sentry/README.md | 2 +- packages/monitoring/sentry/package.json | 2 + .../sentry/src/capture-exception.ts | 5 - packages/monitoring/sentry/src/client.ts | 1 + .../monitoring/sentry/src/hooks/use-sentry.ts | 12 + packages/monitoring/sentry/src/index.ts | 1 - packages/monitoring/sentry/src/server.ts | 1 + .../sentry-server-monitoring.service.ts | 18 + packages/monitoring/src/capture-exception.ts | 44 - .../src/components/error-boundary.tsx | 6 +- .../monitoring/src/get-monitoring-provider.ts | 7 + packages/monitoring/src/hooks/index.ts | 1 + .../src/hooks/use-capture-exception.ts | 10 +- .../monitoring/src/hooks/use-monitoring.ts | 51 + packages/monitoring/src/index.ts | 1 - packages/monitoring/src/instrumentation.ts | 7 +- packages/monitoring/src/server.ts | 1 + .../services/console-monitoring.service.ts | 11 + .../services/get-server-monitoring-service.ts | 43 + .../src/services/monitoring.service.ts | 22 + packages/supabase/src/database.types.ts | 2015 ++++++++--------- turbo/generators/templates/package.json.hbs | 2 +- 37 files changed, 2362 insertions(+), 2106 deletions(-) delete mode 100644 packages/monitoring/baselime/src/capture-exception.ts create mode 100644 packages/monitoring/baselime/src/client.ts create mode 100644 packages/monitoring/baselime/src/hooks/use-baselime.ts delete mode 100644 packages/monitoring/baselime/src/hooks/use-capture-exception.ts delete mode 100644 packages/monitoring/baselime/src/index.ts create mode 100644 packages/monitoring/baselime/src/monitoring-service.ts create mode 100644 packages/monitoring/baselime/src/server.ts create mode 100644 packages/monitoring/baselime/src/services/baselime-server-monitoring.service.ts delete mode 100644 packages/monitoring/sentry/src/capture-exception.ts create mode 100644 packages/monitoring/sentry/src/client.ts create mode 100644 packages/monitoring/sentry/src/hooks/use-sentry.ts delete mode 100644 packages/monitoring/sentry/src/index.ts create mode 100644 packages/monitoring/sentry/src/server.ts create mode 100644 packages/monitoring/sentry/src/services/sentry-server-monitoring.service.ts delete mode 100644 packages/monitoring/src/capture-exception.ts create mode 100644 packages/monitoring/src/get-monitoring-provider.ts create mode 100644 packages/monitoring/src/hooks/use-monitoring.ts delete mode 100644 packages/monitoring/src/index.ts create mode 100644 packages/monitoring/src/server.ts create mode 100644 packages/monitoring/src/services/console-monitoring.service.ts create mode 100644 packages/monitoring/src/services/get-server-monitoring-service.ts create mode 100644 packages/monitoring/src/services/monitoring.service.ts diff --git a/README.md b/README.md index 06591ec62..ae98c29d7 100644 --- a/README.md +++ b/README.md @@ -1296,6 +1296,108 @@ Doing the opposite is also okay - but: My two cents - but you do you - anything that works for you is good. +## Monitoring + +Monitoring is crucial for any application. Makerkit uses Sentry or Baselime for error tracking. Additionally, Makerkit makes use of Next.js experimental instrumentation for performance monitoring. + +### Sentry + +To use Sentry, you need to set the following environment variables: + +```bash +NEXT_PUBLIC_SENTRY_DSN= +NEXT_PUBLIC_MONITORING_PROVIDER=sentry +``` + +### Baselime + +To use Baselime, you need to set the following environment variables: + +```bash +BASELIME_KEY=your_key +NEXT_PUBLIC_MONITORING_PROVIDER=baselime +``` + +### Next.js Instrumentation + +To enable instrumentation, you need to set the following environment variables: + +```bash +MONITORING_INSTRUMENTATION_ENABLED=true +``` + +That's it! Makerkit will take care of the rest. + +### Capturing Errors + +By default, Makerkit captures errors that are caught when rendering the upper `error.tsx` component. This is a good place to catch errors that are not caught by the error boundary. + +If you want to capture errors manually, you have two ways + +#### Capturing Errors using a hook + +```tsx +import { useMonitoring } from '@kit/monitoring/client'; + +function Component() { + const { captureException } = useMonitoring(); + + const onClick = () => { + try { + throw new Error('An error occurred'); + } catch (error) { + captureException(error); + } + }; + + return ( + + ); +} +``` + +Alternatively, directly use `useCaptureException`: + +```tsx +import { useCaptureException } from '@kit/monitoring/client'; + +function Component() { + const captureException = useCaptureException(); + + const onClick = () => { + try { + throw new Error('An error occurred'); + } catch (error) { + captureException(error); + } + }; + + return ( + + ); +} +``` + +### Server Errors + +To capture server errors, you can use the `captureException` function from the `monitoring` package: + +```tsx +import { getMonitoringService } from '@kit/monitoring/server'; + +async function serverSideFunction() { + try { + await someAsyncFunction(); + } catch (error) { + const monitoring = await getMonitoringService(); + + await monitoring.captureException(error); + } +} +``` + +In the future - this will be automatically captured by the `enhanceAction` and `enhanceRouteHandler` functions - so you won't need to do this manually unless you're swallowing the errors in the inner function (in which case, you should rethrow the error or capture manually). + ## Going to Production When you are ready to go to production, please follow the checklist below. This is an overview, a more detailed guide will be provided in the future. diff --git a/apps/web/app/(marketing)/page.tsx b/apps/web/app/(marketing)/page.tsx index 4999207df..d557ff982 100644 --- a/apps/web/app/(marketing)/page.tsx +++ b/apps/web/app/(marketing)/page.tsx @@ -20,6 +20,8 @@ import pathsConfig from '~/config/paths.config'; import { withI18n } from '~/lib/i18n/with-i18n'; function Home() { + throw new Error(`This is a test error`); + return (
diff --git a/apps/web/lib/database.types.ts b/apps/web/lib/database.types.ts index 936d36fdf..cc82ba9c3 100644 --- a/apps/web/lib/database.types.ts +++ b/apps/web/lib/database.types.ts @@ -4,1308 +4,1307 @@ export type Json = | boolean | null | { [key: string]: Json | undefined } - | Json[] + | Json[]; export type Database = { graphql_public: { Tables: { - [_ in never]: never - } + [_ in never]: never; + }; Views: { - [_ in never]: never - } + [_ in never]: never; + }; Functions: { graphql: { Args: { - operationName?: string - query?: string - variables?: Json - extensions?: Json - } - Returns: Json - } - } + operationName?: string; + query?: string; + variables?: Json; + extensions?: Json; + }; + Returns: Json; + }; + }; Enums: { - [_ in never]: never - } + [_ in never]: never; + }; CompositeTypes: { - [_ in never]: never - } - } + [_ in never]: never; + }; + }; public: { Tables: { accounts: { Row: { - created_at: string | null - created_by: string | null - email: string | null - id: string - is_personal_account: boolean - name: string - picture_url: string | null - primary_owner_user_id: string - public_data: Json - slug: string | null - updated_at: string | null - updated_by: string | null - } + created_at: string | null; + created_by: string | null; + email: string | null; + id: string; + is_personal_account: boolean; + name: string; + picture_url: string | null; + primary_owner_user_id: string; + public_data: Json; + slug: string | null; + updated_at: string | null; + updated_by: string | null; + }; Insert: { - created_at?: string | null - created_by?: string | null - email?: string | null - id?: string - is_personal_account?: boolean - name: string - picture_url?: string | null - primary_owner_user_id?: string - public_data?: Json - slug?: string | null - updated_at?: string | null - updated_by?: string | null - } + created_at?: string | null; + created_by?: string | null; + email?: string | null; + id?: string; + is_personal_account?: boolean; + name: string; + picture_url?: string | null; + primary_owner_user_id?: string; + public_data?: Json; + slug?: string | null; + updated_at?: string | null; + updated_by?: string | null; + }; Update: { - created_at?: string | null - created_by?: string | null - email?: string | null - id?: string - is_personal_account?: boolean - name?: string - picture_url?: string | null - primary_owner_user_id?: string - public_data?: Json - slug?: string | null - updated_at?: string | null - updated_by?: string | null - } + created_at?: string | null; + created_by?: string | null; + email?: string | null; + id?: string; + is_personal_account?: boolean; + name?: string; + picture_url?: string | null; + primary_owner_user_id?: string; + public_data?: Json; + slug?: string | null; + updated_at?: string | null; + updated_by?: string | null; + }; Relationships: [ { - foreignKeyName: "accounts_created_by_fkey" - columns: ["created_by"] - isOneToOne: false - referencedRelation: "users" - referencedColumns: ["id"] + foreignKeyName: 'accounts_created_by_fkey'; + columns: ['created_by']; + isOneToOne: false; + referencedRelation: 'users'; + referencedColumns: ['id']; }, { - foreignKeyName: "accounts_primary_owner_user_id_fkey" - columns: ["primary_owner_user_id"] - isOneToOne: false - referencedRelation: "users" - referencedColumns: ["id"] + foreignKeyName: 'accounts_primary_owner_user_id_fkey'; + columns: ['primary_owner_user_id']; + isOneToOne: false; + referencedRelation: 'users'; + referencedColumns: ['id']; }, { - foreignKeyName: "accounts_updated_by_fkey" - columns: ["updated_by"] - isOneToOne: false - referencedRelation: "users" - referencedColumns: ["id"] + foreignKeyName: 'accounts_updated_by_fkey'; + columns: ['updated_by']; + isOneToOne: false; + referencedRelation: 'users'; + referencedColumns: ['id']; }, - ] - } + ]; + }; accounts_memberships: { Row: { - account_id: string - account_role: string - created_at: string - created_by: string | null - updated_at: string - updated_by: string | null - user_id: string - } + account_id: string; + account_role: string; + created_at: string; + created_by: string | null; + updated_at: string; + updated_by: string | null; + user_id: string; + }; Insert: { - account_id: string - account_role: string - created_at?: string - created_by?: string | null - updated_at?: string - updated_by?: string | null - user_id: string - } + account_id: string; + account_role: string; + created_at?: string; + created_by?: string | null; + updated_at?: string; + updated_by?: string | null; + user_id: string; + }; Update: { - account_id?: string - account_role?: string - created_at?: string - created_by?: string | null - updated_at?: string - updated_by?: string | null - user_id?: string - } + account_id?: string; + account_role?: string; + created_at?: string; + created_by?: string | null; + updated_at?: string; + updated_by?: string | null; + user_id?: string; + }; Relationships: [ { - foreignKeyName: "accounts_memberships_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "accounts" - referencedColumns: ["id"] + foreignKeyName: 'accounts_memberships_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "accounts_memberships_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_account_workspace" - referencedColumns: ["id"] + foreignKeyName: 'accounts_memberships_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_account_workspace'; + referencedColumns: ['id']; }, { - foreignKeyName: "accounts_memberships_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_accounts" - referencedColumns: ["id"] + foreignKeyName: 'accounts_memberships_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "accounts_memberships_account_role_fkey" - columns: ["account_role"] - isOneToOne: false - referencedRelation: "roles" - referencedColumns: ["name"] + foreignKeyName: 'accounts_memberships_account_role_fkey'; + columns: ['account_role']; + isOneToOne: false; + referencedRelation: 'roles'; + referencedColumns: ['name']; }, { - foreignKeyName: "accounts_memberships_created_by_fkey" - columns: ["created_by"] - isOneToOne: false - referencedRelation: "users" - referencedColumns: ["id"] + foreignKeyName: 'accounts_memberships_created_by_fkey'; + columns: ['created_by']; + isOneToOne: false; + referencedRelation: 'users'; + referencedColumns: ['id']; }, { - foreignKeyName: "accounts_memberships_updated_by_fkey" - columns: ["updated_by"] - isOneToOne: false - referencedRelation: "users" - referencedColumns: ["id"] + foreignKeyName: 'accounts_memberships_updated_by_fkey'; + columns: ['updated_by']; + isOneToOne: false; + referencedRelation: 'users'; + referencedColumns: ['id']; }, { - foreignKeyName: "accounts_memberships_user_id_fkey" - columns: ["user_id"] - isOneToOne: false - referencedRelation: "users" - referencedColumns: ["id"] + foreignKeyName: 'accounts_memberships_user_id_fkey'; + columns: ['user_id']; + isOneToOne: false; + referencedRelation: 'users'; + referencedColumns: ['id']; }, - ] - } + ]; + }; billing_customers: { Row: { - account_id: string - customer_id: string - email: string | null - id: number - provider: Database["public"]["Enums"]["billing_provider"] - } + account_id: string; + customer_id: string; + email: string | null; + id: number; + provider: Database['public']['Enums']['billing_provider']; + }; Insert: { - account_id: string - customer_id: string - email?: string | null - id?: number - provider: Database["public"]["Enums"]["billing_provider"] - } + account_id: string; + customer_id: string; + email?: string | null; + id?: number; + provider: Database['public']['Enums']['billing_provider']; + }; Update: { - account_id?: string - customer_id?: string - email?: string | null - id?: number - provider?: Database["public"]["Enums"]["billing_provider"] - } + account_id?: string; + customer_id?: string; + email?: string | null; + id?: number; + provider?: Database['public']['Enums']['billing_provider']; + }; Relationships: [ { - foreignKeyName: "billing_customers_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "accounts" - referencedColumns: ["id"] + foreignKeyName: 'billing_customers_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "billing_customers_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_account_workspace" - referencedColumns: ["id"] + foreignKeyName: 'billing_customers_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_account_workspace'; + referencedColumns: ['id']; }, { - foreignKeyName: "billing_customers_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_accounts" - referencedColumns: ["id"] + foreignKeyName: 'billing_customers_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_accounts'; + referencedColumns: ['id']; }, - ] - } + ]; + }; config: { Row: { - billing_provider: Database["public"]["Enums"]["billing_provider"] - enable_account_billing: boolean - enable_team_account_billing: boolean - enable_team_accounts: boolean - } + billing_provider: Database['public']['Enums']['billing_provider']; + enable_account_billing: boolean; + enable_team_account_billing: boolean; + enable_team_accounts: boolean; + }; Insert: { - billing_provider?: Database["public"]["Enums"]["billing_provider"] - enable_account_billing?: boolean - enable_team_account_billing?: boolean - enable_team_accounts?: boolean - } + billing_provider?: Database['public']['Enums']['billing_provider']; + enable_account_billing?: boolean; + enable_team_account_billing?: boolean; + enable_team_accounts?: boolean; + }; Update: { - billing_provider?: Database["public"]["Enums"]["billing_provider"] - enable_account_billing?: boolean - enable_team_account_billing?: boolean - enable_team_accounts?: boolean - } - Relationships: [] - } + billing_provider?: Database['public']['Enums']['billing_provider']; + enable_account_billing?: boolean; + enable_team_account_billing?: boolean; + enable_team_accounts?: boolean; + }; + Relationships: []; + }; invitations: { Row: { - account_id: string - created_at: string - email: string - expires_at: string - id: number - invite_token: string - invited_by: string - role: string - updated_at: string - } + account_id: string; + created_at: string; + email: string; + expires_at: string; + id: number; + invite_token: string; + invited_by: string; + role: string; + updated_at: string; + }; Insert: { - account_id: string - created_at?: string - email: string - expires_at?: string - id?: number - invite_token: string - invited_by: string - role: string - updated_at?: string - } + account_id: string; + created_at?: string; + email: string; + expires_at?: string; + id?: number; + invite_token: string; + invited_by: string; + role: string; + updated_at?: string; + }; Update: { - account_id?: string - created_at?: string - email?: string - expires_at?: string - id?: number - invite_token?: string - invited_by?: string - role?: string - updated_at?: string - } + account_id?: string; + created_at?: string; + email?: string; + expires_at?: string; + id?: number; + invite_token?: string; + invited_by?: string; + role?: string; + updated_at?: string; + }; Relationships: [ { - foreignKeyName: "invitations_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "accounts" - referencedColumns: ["id"] + foreignKeyName: 'invitations_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "invitations_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_account_workspace" - referencedColumns: ["id"] + foreignKeyName: 'invitations_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_account_workspace'; + referencedColumns: ['id']; }, { - foreignKeyName: "invitations_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_accounts" - referencedColumns: ["id"] + foreignKeyName: 'invitations_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "invitations_invited_by_fkey" - columns: ["invited_by"] - isOneToOne: false - referencedRelation: "users" - referencedColumns: ["id"] + foreignKeyName: 'invitations_invited_by_fkey'; + columns: ['invited_by']; + isOneToOne: false; + referencedRelation: 'users'; + referencedColumns: ['id']; }, { - foreignKeyName: "invitations_role_fkey" - columns: ["role"] - isOneToOne: false - referencedRelation: "roles" - referencedColumns: ["name"] + foreignKeyName: 'invitations_role_fkey'; + columns: ['role']; + isOneToOne: false; + referencedRelation: 'roles'; + referencedColumns: ['name']; }, - ] - } + ]; + }; order_items: { Row: { - created_at: string - order_id: string - price_amount: number | null - product_id: string - quantity: number - updated_at: string - variant_id: string - } + created_at: string; + order_id: string; + price_amount: number | null; + product_id: string; + quantity: number; + updated_at: string; + variant_id: string; + }; Insert: { - created_at?: string - order_id: string - price_amount?: number | null - product_id: string - quantity?: number - updated_at?: string - variant_id: string - } + created_at?: string; + order_id: string; + price_amount?: number | null; + product_id: string; + quantity?: number; + updated_at?: string; + variant_id: string; + }; Update: { - created_at?: string - order_id?: string - price_amount?: number | null - product_id?: string - quantity?: number - updated_at?: string - variant_id?: string - } + created_at?: string; + order_id?: string; + price_amount?: number | null; + product_id?: string; + quantity?: number; + updated_at?: string; + variant_id?: string; + }; Relationships: [ { - foreignKeyName: "order_items_order_id_fkey" - columns: ["order_id"] - isOneToOne: false - referencedRelation: "orders" - referencedColumns: ["id"] + foreignKeyName: 'order_items_order_id_fkey'; + columns: ['order_id']; + isOneToOne: false; + referencedRelation: 'orders'; + referencedColumns: ['id']; }, - ] - } + ]; + }; orders: { Row: { - account_id: string - billing_customer_id: number - billing_provider: Database["public"]["Enums"]["billing_provider"] - created_at: string - currency: string - id: string - status: Database["public"]["Enums"]["payment_status"] - total_amount: number - updated_at: string - } + account_id: string; + billing_customer_id: number; + billing_provider: Database['public']['Enums']['billing_provider']; + created_at: string; + currency: string; + id: string; + status: Database['public']['Enums']['payment_status']; + total_amount: number; + updated_at: string; + }; Insert: { - account_id: string - billing_customer_id: number - billing_provider: Database["public"]["Enums"]["billing_provider"] - created_at?: string - currency: string - id: string - status: Database["public"]["Enums"]["payment_status"] - total_amount: number - updated_at?: string - } + account_id: string; + billing_customer_id: number; + billing_provider: Database['public']['Enums']['billing_provider']; + created_at?: string; + currency: string; + id: string; + status: Database['public']['Enums']['payment_status']; + total_amount: number; + updated_at?: string; + }; Update: { - account_id?: string - billing_customer_id?: number - billing_provider?: Database["public"]["Enums"]["billing_provider"] - created_at?: string - currency?: string - id?: string - status?: Database["public"]["Enums"]["payment_status"] - total_amount?: number - updated_at?: string - } + account_id?: string; + billing_customer_id?: number; + billing_provider?: Database['public']['Enums']['billing_provider']; + created_at?: string; + currency?: string; + id?: string; + status?: Database['public']['Enums']['payment_status']; + total_amount?: number; + updated_at?: string; + }; Relationships: [ { - foreignKeyName: "orders_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "accounts" - referencedColumns: ["id"] + foreignKeyName: 'orders_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "orders_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_account_workspace" - referencedColumns: ["id"] + foreignKeyName: 'orders_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_account_workspace'; + referencedColumns: ['id']; }, { - foreignKeyName: "orders_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_accounts" - referencedColumns: ["id"] + foreignKeyName: 'orders_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "orders_billing_customer_id_fkey" - columns: ["billing_customer_id"] - isOneToOne: false - referencedRelation: "billing_customers" - referencedColumns: ["id"] + foreignKeyName: 'orders_billing_customer_id_fkey'; + columns: ['billing_customer_id']; + isOneToOne: false; + referencedRelation: 'billing_customers'; + referencedColumns: ['id']; }, - ] - } + ]; + }; role_permissions: { Row: { - id: number - permission: Database["public"]["Enums"]["app_permissions"] - role: string - } + id: number; + permission: Database['public']['Enums']['app_permissions']; + role: string; + }; Insert: { - id?: number - permission: Database["public"]["Enums"]["app_permissions"] - role: string - } + id?: number; + permission: Database['public']['Enums']['app_permissions']; + role: string; + }; Update: { - id?: number - permission?: Database["public"]["Enums"]["app_permissions"] - role?: string - } + id?: number; + permission?: Database['public']['Enums']['app_permissions']; + role?: string; + }; Relationships: [ { - foreignKeyName: "role_permissions_role_fkey" - columns: ["role"] - isOneToOne: false - referencedRelation: "roles" - referencedColumns: ["name"] + foreignKeyName: 'role_permissions_role_fkey'; + columns: ['role']; + isOneToOne: false; + referencedRelation: 'roles'; + referencedColumns: ['name']; }, - ] - } + ]; + }; roles: { Row: { - account_id: string | null - hierarchy_level: number - name: string - } + account_id: string | null; + hierarchy_level: number; + name: string; + }; Insert: { - account_id?: string | null - hierarchy_level: number - name: string - } + account_id?: string | null; + hierarchy_level: number; + name: string; + }; Update: { - account_id?: string | null - hierarchy_level?: number - name?: string - } + account_id?: string | null; + hierarchy_level?: number; + name?: string; + }; Relationships: [ { - foreignKeyName: "roles_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "accounts" - referencedColumns: ["id"] + foreignKeyName: 'roles_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "roles_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_account_workspace" - referencedColumns: ["id"] + foreignKeyName: 'roles_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_account_workspace'; + referencedColumns: ['id']; }, { - foreignKeyName: "roles_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_accounts" - referencedColumns: ["id"] + foreignKeyName: 'roles_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_accounts'; + referencedColumns: ['id']; }, - ] - } + ]; + }; subscription_items: { Row: { - created_at: string - interval: string - interval_count: number - price_amount: number | null - product_id: string - quantity: number - subscription_id: string - type: Database["public"]["Enums"]["subscription_item_type"] - updated_at: string - variant_id: string - } + created_at: string; + interval: string; + interval_count: number; + price_amount: number | null; + product_id: string; + quantity: number; + subscription_id: string; + type: Database['public']['Enums']['subscription_item_type']; + updated_at: string; + variant_id: string; + }; Insert: { - created_at?: string - interval: string - interval_count: number - price_amount?: number | null - product_id: string - quantity?: number - subscription_id: string - type: Database["public"]["Enums"]["subscription_item_type"] - updated_at?: string - variant_id: string - } + created_at?: string; + interval: string; + interval_count: number; + price_amount?: number | null; + product_id: string; + quantity?: number; + subscription_id: string; + type: Database['public']['Enums']['subscription_item_type']; + updated_at?: string; + variant_id: string; + }; Update: { - created_at?: string - interval?: string - interval_count?: number - price_amount?: number | null - product_id?: string - quantity?: number - subscription_id?: string - type?: Database["public"]["Enums"]["subscription_item_type"] - updated_at?: string - variant_id?: string - } + created_at?: string; + interval?: string; + interval_count?: number; + price_amount?: number | null; + product_id?: string; + quantity?: number; + subscription_id?: string; + type?: Database['public']['Enums']['subscription_item_type']; + updated_at?: string; + variant_id?: string; + }; Relationships: [ { - foreignKeyName: "subscription_items_subscription_id_fkey" - columns: ["subscription_id"] - isOneToOne: false - referencedRelation: "subscriptions" - referencedColumns: ["id"] + foreignKeyName: 'subscription_items_subscription_id_fkey'; + columns: ['subscription_id']; + isOneToOne: false; + referencedRelation: 'subscriptions'; + referencedColumns: ['id']; }, - ] - } + ]; + }; subscriptions: { Row: { - account_id: string - active: boolean - billing_customer_id: number - billing_provider: Database["public"]["Enums"]["billing_provider"] - cancel_at_period_end: boolean - created_at: string - currency: string - id: string - period_ends_at: string - period_starts_at: string - status: Database["public"]["Enums"]["subscription_status"] - trial_ends_at: string | null - trial_starts_at: string | null - updated_at: string - } + account_id: string; + active: boolean; + billing_customer_id: number; + billing_provider: Database['public']['Enums']['billing_provider']; + cancel_at_period_end: boolean; + created_at: string; + currency: string; + id: string; + period_ends_at: string; + period_starts_at: string; + status: Database['public']['Enums']['subscription_status']; + trial_ends_at: string | null; + trial_starts_at: string | null; + updated_at: string; + }; Insert: { - account_id: string - active: boolean - billing_customer_id: number - billing_provider: Database["public"]["Enums"]["billing_provider"] - cancel_at_period_end: boolean - created_at?: string - currency: string - id: string - period_ends_at: string - period_starts_at: string - status: Database["public"]["Enums"]["subscription_status"] - trial_ends_at?: string | null - trial_starts_at?: string | null - updated_at?: string - } + account_id: string; + active: boolean; + billing_customer_id: number; + billing_provider: Database['public']['Enums']['billing_provider']; + cancel_at_period_end: boolean; + created_at?: string; + currency: string; + id: string; + period_ends_at: string; + period_starts_at: string; + status: Database['public']['Enums']['subscription_status']; + trial_ends_at?: string | null; + trial_starts_at?: string | null; + updated_at?: string; + }; Update: { - account_id?: string - active?: boolean - billing_customer_id?: number - billing_provider?: Database["public"]["Enums"]["billing_provider"] - cancel_at_period_end?: boolean - created_at?: string - currency?: string - id?: string - period_ends_at?: string - period_starts_at?: string - status?: Database["public"]["Enums"]["subscription_status"] - trial_ends_at?: string | null - trial_starts_at?: string | null - updated_at?: string - } + account_id?: string; + active?: boolean; + billing_customer_id?: number; + billing_provider?: Database['public']['Enums']['billing_provider']; + cancel_at_period_end?: boolean; + created_at?: string; + currency?: string; + id?: string; + period_ends_at?: string; + period_starts_at?: string; + status?: Database['public']['Enums']['subscription_status']; + trial_ends_at?: string | null; + trial_starts_at?: string | null; + updated_at?: string; + }; Relationships: [ { - foreignKeyName: "subscriptions_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "accounts" - referencedColumns: ["id"] + foreignKeyName: 'subscriptions_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "subscriptions_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_account_workspace" - referencedColumns: ["id"] + foreignKeyName: 'subscriptions_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_account_workspace'; + referencedColumns: ['id']; }, { - foreignKeyName: "subscriptions_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_accounts" - referencedColumns: ["id"] + foreignKeyName: 'subscriptions_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "subscriptions_billing_customer_id_fkey" - columns: ["billing_customer_id"] - isOneToOne: false - referencedRelation: "billing_customers" - referencedColumns: ["id"] + foreignKeyName: 'subscriptions_billing_customer_id_fkey'; + columns: ['billing_customer_id']; + isOneToOne: false; + referencedRelation: 'billing_customers'; + referencedColumns: ['id']; }, - ] - } - } + ]; + }; + }; Views: { user_account_workspace: { Row: { - id: string | null - name: string | null - picture_url: string | null - public_data: Json | null + id: string | null; + name: string | null; + picture_url: string | null; + public_data: Json | null; subscription_status: - | Database["public"]["Enums"]["subscription_status"] - | null - } - Relationships: [] - } + | Database['public']['Enums']['subscription_status'] + | null; + }; + Relationships: []; + }; user_accounts: { Row: { - id: string | null - name: string | null - picture_url: string | null - role: string | null - slug: string | null - } + id: string | null; + name: string | null; + picture_url: string | null; + role: string | null; + slug: string | null; + }; Relationships: [ { - foreignKeyName: "accounts_memberships_account_role_fkey" - columns: ["role"] - isOneToOne: false - referencedRelation: "roles" - referencedColumns: ["name"] + foreignKeyName: 'accounts_memberships_account_role_fkey'; + columns: ['role']; + isOneToOne: false; + referencedRelation: 'roles'; + referencedColumns: ['name']; }, - ] - } - } + ]; + }; + }; Functions: { accept_invitation: { Args: { - token: string - user_id: string - } - Returns: string - } + token: string; + user_id: string; + }; + Returns: string; + }; add_invitations_to_account: { Args: { - account_slug: string - invitations: Database["public"]["CompositeTypes"]["invitation"][] - } - Returns: Database["public"]["Tables"]["invitations"]["Row"][] - } + account_slug: string; + invitations: Database['public']['CompositeTypes']['invitation'][]; + }; + Returns: Database['public']['Tables']['invitations']['Row'][]; + }; can_action_account_member: { Args: { - target_team_account_id: string - target_user_id: string - } - Returns: boolean - } + target_team_account_id: string; + target_user_id: string; + }; + Returns: boolean; + }; create_invitation: { Args: { - account_id: string - email: string - role: string - } + account_id: string; + email: string; + role: string; + }; Returns: { - account_id: string - created_at: string - email: string - expires_at: string - id: number - invite_token: string - invited_by: string - role: string - updated_at: string - } - } + account_id: string; + created_at: string; + email: string; + expires_at: string; + id: number; + invite_token: string; + invited_by: string; + role: string; + updated_at: string; + }; + }; create_team_account: { Args: { - account_name: string - } + account_name: string; + }; Returns: { - created_at: string | null - created_by: string | null - email: string | null - id: string - is_personal_account: boolean - name: string - picture_url: string | null - primary_owner_user_id: string - public_data: Json - slug: string | null - updated_at: string | null - updated_by: string | null - } - } + created_at: string | null; + created_by: string | null; + email: string | null; + id: string; + is_personal_account: boolean; + name: string; + picture_url: string | null; + primary_owner_user_id: string; + public_data: Json; + slug: string | null; + updated_at: string | null; + updated_by: string | null; + }; + }; get_account_invitations: { Args: { - account_slug: string - } + account_slug: string; + }; Returns: { - id: number - email: string - account_id: string - invited_by: string - role: string - created_at: string - updated_at: string - expires_at: string - inviter_name: string - inviter_email: string - }[] - } + id: number; + email: string; + account_id: string; + invited_by: string; + role: string; + created_at: string; + updated_at: string; + expires_at: string; + inviter_name: string; + inviter_email: string; + }[]; + }; get_account_members: { Args: { - account_slug: string - } + account_slug: string; + }; Returns: { - id: string - user_id: string - account_id: string - role: string - role_hierarchy_level: number - primary_owner_user_id: string - name: string - email: string - picture_url: string - created_at: string - updated_at: string - }[] - } + id: string; + user_id: string; + account_id: string; + role: string; + role_hierarchy_level: number; + primary_owner_user_id: string; + name: string; + email: string; + picture_url: string; + created_at: string; + updated_at: string; + }[]; + }; get_config: { - Args: Record - Returns: Json - } + Args: Record; + Returns: Json; + }; get_upper_system_role: { - Args: Record - Returns: string - } + Args: Record; + Returns: string; + }; has_more_elevated_role: { Args: { - target_user_id: string - target_account_id: string - role_name: string - } - Returns: boolean - } + target_user_id: string; + target_account_id: string; + role_name: string; + }; + Returns: boolean; + }; has_permission: { Args: { - user_id: string - account_id: string - permission_name: Database["public"]["Enums"]["app_permissions"] - } - Returns: boolean - } + user_id: string; + account_id: string; + permission_name: Database['public']['Enums']['app_permissions']; + }; + Returns: boolean; + }; has_role_on_account: { Args: { - account_id: string - account_role?: string - } - Returns: boolean - } + account_id: string; + account_role?: string; + }; + Returns: boolean; + }; has_same_role_hierarchy_level: { Args: { - target_user_id: string - target_account_id: string - role_name: string - } - Returns: boolean - } + target_user_id: string; + target_account_id: string; + role_name: string; + }; + Returns: boolean; + }; is_account_owner: { Args: { - account_id: string - } - Returns: boolean - } + account_id: string; + }; + Returns: boolean; + }; is_set: { Args: { - field_name: string - } - Returns: boolean - } + field_name: string; + }; + Returns: boolean; + }; is_team_member: { Args: { - account_id: string - user_id: string - } - Returns: boolean - } + account_id: string; + user_id: string; + }; + Returns: boolean; + }; team_account_workspace: { Args: { - account_slug: string - } + account_slug: string; + }; Returns: { - id: string - name: string - picture_url: string - slug: string - role: string - role_hierarchy_level: number - primary_owner_user_id: string - subscription_status: Database["public"]["Enums"]["subscription_status"] - permissions: Database["public"]["Enums"]["app_permissions"][] - }[] - } + id: string; + name: string; + picture_url: string; + slug: string; + role: string; + role_hierarchy_level: number; + primary_owner_user_id: string; + subscription_status: Database['public']['Enums']['subscription_status']; + permissions: Database['public']['Enums']['app_permissions'][]; + }[]; + }; transfer_team_account_ownership: { Args: { - target_account_id: string - new_owner_id: string - } - Returns: undefined - } + target_account_id: string; + new_owner_id: string; + }; + Returns: undefined; + }; unaccent: { Args: { - "": string - } - Returns: string - } + '': string; + }; + Returns: string; + }; unaccent_init: { Args: { - "": unknown - } - Returns: unknown - } + '': unknown; + }; + Returns: unknown; + }; upsert_order: { Args: { - target_account_id: string - target_customer_id: string - target_order_id: string - status: Database["public"]["Enums"]["payment_status"] - billing_provider: Database["public"]["Enums"]["billing_provider"] - total_amount: number - currency: string - line_items: Json - } + target_account_id: string; + target_customer_id: string; + target_order_id: string; + status: Database['public']['Enums']['payment_status']; + billing_provider: Database['public']['Enums']['billing_provider']; + total_amount: number; + currency: string; + line_items: Json; + }; Returns: { - account_id: string - billing_customer_id: number - billing_provider: Database["public"]["Enums"]["billing_provider"] - created_at: string - currency: string - id: string - status: Database["public"]["Enums"]["payment_status"] - total_amount: number - updated_at: string - } - } + account_id: string; + billing_customer_id: number; + billing_provider: Database['public']['Enums']['billing_provider']; + created_at: string; + currency: string; + id: string; + status: Database['public']['Enums']['payment_status']; + total_amount: number; + updated_at: string; + }; + }; upsert_subscription: { Args: { - target_account_id: string - target_customer_id: string - target_subscription_id: string - active: boolean - status: Database["public"]["Enums"]["subscription_status"] - billing_provider: Database["public"]["Enums"]["billing_provider"] - cancel_at_period_end: boolean - currency: string - period_starts_at: string - period_ends_at: string - line_items: Json - trial_starts_at?: string - trial_ends_at?: string - } + target_account_id: string; + target_customer_id: string; + target_subscription_id: string; + active: boolean; + status: Database['public']['Enums']['subscription_status']; + billing_provider: Database['public']['Enums']['billing_provider']; + cancel_at_period_end: boolean; + currency: string; + period_starts_at: string; + period_ends_at: string; + line_items: Json; + trial_starts_at?: string; + trial_ends_at?: string; + }; Returns: { - account_id: string - active: boolean - billing_customer_id: number - billing_provider: Database["public"]["Enums"]["billing_provider"] - cancel_at_period_end: boolean - created_at: string - currency: string - id: string - period_ends_at: string - period_starts_at: string - status: Database["public"]["Enums"]["subscription_status"] - trial_ends_at: string | null - trial_starts_at: string | null - updated_at: string - } - } - } + account_id: string; + active: boolean; + billing_customer_id: number; + billing_provider: Database['public']['Enums']['billing_provider']; + cancel_at_period_end: boolean; + created_at: string; + currency: string; + id: string; + period_ends_at: string; + period_starts_at: string; + status: Database['public']['Enums']['subscription_status']; + trial_ends_at: string | null; + trial_starts_at: string | null; + updated_at: string; + }; + }; + }; Enums: { app_permissions: - | "roles.manage" - | "billing.manage" - | "settings.manage" - | "members.manage" - | "invites.manage" - billing_provider: "stripe" | "lemon-squeezy" | "paddle" - payment_status: "pending" | "succeeded" | "failed" - subscription_item_type: "flat" | "per_seat" | "metered" + | 'roles.manage' + | 'billing.manage' + | 'settings.manage' + | 'members.manage' + | 'invites.manage'; + billing_provider: 'stripe' | 'lemon-squeezy' | 'paddle'; + payment_status: 'pending' | 'succeeded' | 'failed'; + subscription_item_type: 'flat' | 'per_seat' | 'metered'; subscription_status: - | "active" - | "trialing" - | "past_due" - | "canceled" - | "unpaid" - | "incomplete" - | "incomplete_expired" - | "paused" - } + | 'active' + | 'trialing' + | 'past_due' + | 'canceled' + | 'unpaid' + | 'incomplete' + | 'incomplete_expired' + | 'paused'; + }; CompositeTypes: { invitation: { - email: string | null - role: string | null - } - } - } + email: string | null; + role: string | null; + }; + }; + }; storage: { Tables: { buckets: { Row: { - allowed_mime_types: string[] | null - avif_autodetection: boolean | null - created_at: string | null - file_size_limit: number | null - id: string - name: string - owner: string | null - owner_id: string | null - public: boolean | null - updated_at: string | null - } + allowed_mime_types: string[] | null; + avif_autodetection: boolean | null; + created_at: string | null; + file_size_limit: number | null; + id: string; + name: string; + owner: string | null; + owner_id: string | null; + public: boolean | null; + updated_at: string | null; + }; Insert: { - allowed_mime_types?: string[] | null - avif_autodetection?: boolean | null - created_at?: string | null - file_size_limit?: number | null - id: string - name: string - owner?: string | null - owner_id?: string | null - public?: boolean | null - updated_at?: string | null - } + allowed_mime_types?: string[] | null; + avif_autodetection?: boolean | null; + created_at?: string | null; + file_size_limit?: number | null; + id: string; + name: string; + owner?: string | null; + owner_id?: string | null; + public?: boolean | null; + updated_at?: string | null; + }; Update: { - allowed_mime_types?: string[] | null - avif_autodetection?: boolean | null - created_at?: string | null - file_size_limit?: number | null - id?: string - name?: string - owner?: string | null - owner_id?: string | null - public?: boolean | null - updated_at?: string | null - } - Relationships: [] - } + allowed_mime_types?: string[] | null; + avif_autodetection?: boolean | null; + created_at?: string | null; + file_size_limit?: number | null; + id?: string; + name?: string; + owner?: string | null; + owner_id?: string | null; + public?: boolean | null; + updated_at?: string | null; + }; + Relationships: []; + }; migrations: { Row: { - executed_at: string | null - hash: string - id: number - name: string - } + executed_at: string | null; + hash: string; + id: number; + name: string; + }; Insert: { - executed_at?: string | null - hash: string - id: number - name: string - } + executed_at?: string | null; + hash: string; + id: number; + name: string; + }; Update: { - executed_at?: string | null - hash?: string - id?: number - name?: string - } - Relationships: [] - } + executed_at?: string | null; + hash?: string; + id?: number; + name?: string; + }; + Relationships: []; + }; objects: { Row: { - bucket_id: string | null - created_at: string | null - id: string - last_accessed_at: string | null - metadata: Json | null - name: string | null - owner: string | null - owner_id: string | null - path_tokens: string[] | null - updated_at: string | null - version: string | null - } + bucket_id: string | null; + created_at: string | null; + id: string; + last_accessed_at: string | null; + metadata: Json | null; + name: string | null; + owner: string | null; + owner_id: string | null; + path_tokens: string[] | null; + updated_at: string | null; + version: string | null; + }; Insert: { - bucket_id?: string | null - created_at?: string | null - id?: string - last_accessed_at?: string | null - metadata?: Json | null - name?: string | null - owner?: string | null - owner_id?: string | null - path_tokens?: string[] | null - updated_at?: string | null - version?: string | null - } + bucket_id?: string | null; + created_at?: string | null; + id?: string; + last_accessed_at?: string | null; + metadata?: Json | null; + name?: string | null; + owner?: string | null; + owner_id?: string | null; + path_tokens?: string[] | null; + updated_at?: string | null; + version?: string | null; + }; Update: { - bucket_id?: string | null - created_at?: string | null - id?: string - last_accessed_at?: string | null - metadata?: Json | null - name?: string | null - owner?: string | null - owner_id?: string | null - path_tokens?: string[] | null - updated_at?: string | null - version?: string | null - } + bucket_id?: string | null; + created_at?: string | null; + id?: string; + last_accessed_at?: string | null; + metadata?: Json | null; + name?: string | null; + owner?: string | null; + owner_id?: string | null; + path_tokens?: string[] | null; + updated_at?: string | null; + version?: string | null; + }; Relationships: [ { - foreignKeyName: "objects_bucketId_fkey" - columns: ["bucket_id"] - isOneToOne: false - referencedRelation: "buckets" - referencedColumns: ["id"] + foreignKeyName: 'objects_bucketId_fkey'; + columns: ['bucket_id']; + isOneToOne: false; + referencedRelation: 'buckets'; + referencedColumns: ['id']; }, - ] - } + ]; + }; s3_multipart_uploads: { Row: { - bucket_id: string - created_at: string - id: string - in_progress_size: number - key: string - owner_id: string | null - upload_signature: string - version: string - } + bucket_id: string; + created_at: string; + id: string; + in_progress_size: number; + key: string; + owner_id: string | null; + upload_signature: string; + version: string; + }; Insert: { - bucket_id: string - created_at?: string - id: string - in_progress_size?: number - key: string - owner_id?: string | null - upload_signature: string - version: string - } + bucket_id: string; + created_at?: string; + id: string; + in_progress_size?: number; + key: string; + owner_id?: string | null; + upload_signature: string; + version: string; + }; Update: { - bucket_id?: string - created_at?: string - id?: string - in_progress_size?: number - key?: string - owner_id?: string | null - upload_signature?: string - version?: string - } + bucket_id?: string; + created_at?: string; + id?: string; + in_progress_size?: number; + key?: string; + owner_id?: string | null; + upload_signature?: string; + version?: string; + }; Relationships: [ { - foreignKeyName: "s3_multipart_uploads_bucket_id_fkey" - columns: ["bucket_id"] - isOneToOne: false - referencedRelation: "buckets" - referencedColumns: ["id"] + foreignKeyName: 's3_multipart_uploads_bucket_id_fkey'; + columns: ['bucket_id']; + isOneToOne: false; + referencedRelation: 'buckets'; + referencedColumns: ['id']; }, - ] - } + ]; + }; s3_multipart_uploads_parts: { Row: { - bucket_id: string - created_at: string - etag: string - id: string - key: string - owner_id: string | null - part_number: number - size: number - upload_id: string - version: string - } + bucket_id: string; + created_at: string; + etag: string; + id: string; + key: string; + owner_id: string | null; + part_number: number; + size: number; + upload_id: string; + version: string; + }; Insert: { - bucket_id: string - created_at?: string - etag: string - id?: string - key: string - owner_id?: string | null - part_number: number - size?: number - upload_id: string - version: string - } + bucket_id: string; + created_at?: string; + etag: string; + id?: string; + key: string; + owner_id?: string | null; + part_number: number; + size?: number; + upload_id: string; + version: string; + }; Update: { - bucket_id?: string - created_at?: string - etag?: string - id?: string - key?: string - owner_id?: string | null - part_number?: number - size?: number - upload_id?: string - version?: string - } + bucket_id?: string; + created_at?: string; + etag?: string; + id?: string; + key?: string; + owner_id?: string | null; + part_number?: number; + size?: number; + upload_id?: string; + version?: string; + }; Relationships: [ { - foreignKeyName: "s3_multipart_uploads_parts_bucket_id_fkey" - columns: ["bucket_id"] - isOneToOne: false - referencedRelation: "buckets" - referencedColumns: ["id"] + foreignKeyName: 's3_multipart_uploads_parts_bucket_id_fkey'; + columns: ['bucket_id']; + isOneToOne: false; + referencedRelation: 'buckets'; + referencedColumns: ['id']; }, { - foreignKeyName: "s3_multipart_uploads_parts_upload_id_fkey" - columns: ["upload_id"] - isOneToOne: false - referencedRelation: "s3_multipart_uploads" - referencedColumns: ["id"] + foreignKeyName: 's3_multipart_uploads_parts_upload_id_fkey'; + columns: ['upload_id']; + isOneToOne: false; + referencedRelation: 's3_multipart_uploads'; + referencedColumns: ['id']; }, - ] - } - } + ]; + }; + }; Views: { - [_ in never]: never - } + [_ in never]: never; + }; Functions: { can_insert_object: { Args: { - bucketid: string - name: string - owner: string - metadata: Json - } - Returns: undefined - } + bucketid: string; + name: string; + owner: string; + metadata: Json; + }; + Returns: undefined; + }; extension: { Args: { - name: string - } - Returns: string - } + name: string; + }; + Returns: string; + }; filename: { Args: { - name: string - } - Returns: string - } + name: string; + }; + Returns: string; + }; foldername: { Args: { - name: string - } - Returns: string[] - } + name: string; + }; + Returns: string[]; + }; get_size_by_bucket: { - Args: Record + Args: Record; Returns: { - size: number - bucket_id: string - }[] - } + size: number; + bucket_id: string; + }[]; + }; list_multipart_uploads_with_delimiter: { Args: { - bucket_id: string - prefix_param: string - delimiter_param: string - max_keys?: number - next_key_token?: string - next_upload_token?: string - } + bucket_id: string; + prefix_param: string; + delimiter_param: string; + max_keys?: number; + next_key_token?: string; + next_upload_token?: string; + }; Returns: { - key: string - id: string - created_at: string - }[] - } + key: string; + id: string; + created_at: string; + }[]; + }; list_objects_with_delimiter: { Args: { - bucket_id: string - prefix_param: string - delimiter_param: string - max_keys?: number - start_after?: string - next_token?: string - } + bucket_id: string; + prefix_param: string; + delimiter_param: string; + max_keys?: number; + start_after?: string; + next_token?: string; + }; Returns: { - name: string - id: string - metadata: Json - updated_at: string - }[] - } + name: string; + id: string; + metadata: Json; + updated_at: string; + }[]; + }; search: { Args: { - prefix: string - bucketname: string - limits?: number - levels?: number - offsets?: number - search?: string - sortcolumn?: string - sortorder?: string - } + prefix: string; + bucketname: string; + limits?: number; + levels?: number; + offsets?: number; + search?: string; + sortcolumn?: string; + sortorder?: string; + }; Returns: { - name: string - id: string - updated_at: string - created_at: string - last_accessed_at: string - metadata: Json - }[] - } - } + name: string; + id: string; + updated_at: string; + created_at: string; + last_accessed_at: string; + metadata: Json; + }[]; + }; + }; Enums: { - [_ in never]: never - } + [_ in never]: never; + }; CompositeTypes: { - [_ in never]: never - } - } -} + [_ in never]: never; + }; + }; +}; -type PublicSchema = Database[Extract] +type PublicSchema = Database[Extract]; export type Tables< PublicTableNameOrOptions extends - | keyof (PublicSchema["Tables"] & PublicSchema["Views"]) + | keyof (PublicSchema['Tables'] & PublicSchema['Views']) | { schema: keyof Database }, TableName extends PublicTableNameOrOptions extends { schema: keyof Database } - ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] & - Database[PublicTableNameOrOptions["schema"]]["Views"]) + ? keyof (Database[PublicTableNameOrOptions['schema']]['Tables'] & + Database[PublicTableNameOrOptions['schema']]['Views']) : never = never, > = PublicTableNameOrOptions extends { schema: keyof Database } - ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] & - Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends { - Row: infer R + ? (Database[PublicTableNameOrOptions['schema']]['Tables'] & + Database[PublicTableNameOrOptions['schema']]['Views'])[TableName] extends { + Row: infer R; } ? R : never - : PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] & - PublicSchema["Views"]) - ? (PublicSchema["Tables"] & - PublicSchema["Views"])[PublicTableNameOrOptions] extends { - Row: infer R + : PublicTableNameOrOptions extends keyof (PublicSchema['Tables'] & + PublicSchema['Views']) + ? (PublicSchema['Tables'] & + PublicSchema['Views'])[PublicTableNameOrOptions] extends { + Row: infer R; } ? R : never - : never + : never; export type TablesInsert< PublicTableNameOrOptions extends - | keyof PublicSchema["Tables"] + | keyof PublicSchema['Tables'] | { schema: keyof Database }, TableName extends PublicTableNameOrOptions extends { schema: keyof Database } - ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] + ? keyof Database[PublicTableNameOrOptions['schema']]['Tables'] : never = never, > = PublicTableNameOrOptions extends { schema: keyof Database } - ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Insert: infer I + ? Database[PublicTableNameOrOptions['schema']]['Tables'][TableName] extends { + Insert: infer I; } ? I : never - : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] - ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { - Insert: infer I + : PublicTableNameOrOptions extends keyof PublicSchema['Tables'] + ? PublicSchema['Tables'][PublicTableNameOrOptions] extends { + Insert: infer I; } ? I : never - : never + : never; export type TablesUpdate< PublicTableNameOrOptions extends - | keyof PublicSchema["Tables"] + | keyof PublicSchema['Tables'] | { schema: keyof Database }, TableName extends PublicTableNameOrOptions extends { schema: keyof Database } - ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] + ? keyof Database[PublicTableNameOrOptions['schema']]['Tables'] : never = never, > = PublicTableNameOrOptions extends { schema: keyof Database } - ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Update: infer U + ? Database[PublicTableNameOrOptions['schema']]['Tables'][TableName] extends { + Update: infer U; } ? U : never - : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] - ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { - Update: infer U + : PublicTableNameOrOptions extends keyof PublicSchema['Tables'] + ? PublicSchema['Tables'][PublicTableNameOrOptions] extends { + Update: infer U; } ? U : never - : never + : never; export type Enums< PublicEnumNameOrOptions extends - | keyof PublicSchema["Enums"] + | keyof PublicSchema['Enums'] | { schema: keyof Database }, EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database } - ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"] + ? keyof Database[PublicEnumNameOrOptions['schema']]['Enums'] : never = never, > = PublicEnumNameOrOptions extends { schema: keyof Database } - ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName] - : PublicEnumNameOrOptions extends keyof PublicSchema["Enums"] - ? PublicSchema["Enums"][PublicEnumNameOrOptions] - : never - + ? Database[PublicEnumNameOrOptions['schema']]['Enums'][EnumName] + : PublicEnumNameOrOptions extends keyof PublicSchema['Enums'] + ? PublicSchema['Enums'][PublicEnumNameOrOptions] + : never; diff --git a/packages/monitoring/README.md b/packages/monitoring/README.md index 8f6f7ac7d..c69428686 100644 --- a/packages/monitoring/README.md +++ b/packages/monitoring/README.md @@ -3,12 +3,37 @@ Please set the following environment variable to your preferred monitoring provider: ``` -MONITORING_INSTRUMENTATION_PROVIDER= +NEXT_PUBLIC_MONITORING_PROVIDER= +MONITORING_INSTRUMENTATION_ENABLED=true ``` ## Available Providers -To use a specific provider, set the `MONITORING_INSTRUMENTATION_PROVIDER` environment variable to one of the following values: +To use a specific provider, set the `NEXT_PUBLIC_MONITORING_PROVIDER` environment variable to one of the following values: 1. Baselime: `baselime` -2. Sentry: `sentry` \ No newline at end of file +2. Sentry: `sentry` + +## Baselime + +To use Baselime, set the `NEXT_PUBLIC_MONITORING_PROVIDER` environment variable to `baselime`. + +``` +NEXT_PUBLIC_MONITORING_PROVIDER=baselime +``` + +## Sentry + +To use Sentry, set the `NEXT_PUBLIC_MONITORING_PROVIDER` environment variable to `sentry`. + +``` +NEXT_PUBLIC_MONITORING_PROVIDER=sentry +``` + +## Instrumentation + +To enable instrumentation, set the `MONITORING_INSTRUMENTATION_ENABLED` environment variable to `true`. + +``` +MONITORING_INSTRUMENTATION_ENABLED=true +``` \ No newline at end of file diff --git a/packages/monitoring/baselime/README.md b/packages/monitoring/baselime/README.md index 4d0a4c4fb..d7856fd4e 100644 --- a/packages/monitoring/baselime/README.md +++ b/packages/monitoring/baselime/README.md @@ -4,5 +4,5 @@ Please set the following environment variables: ``` BASELIME_KEY=your_key -MONITORING_INSTRUMENTATION_PROVIDER=baselime +NEXT_PUBLIC_MONITORING_PROVIDER=baselime ``` \ No newline at end of file diff --git a/packages/monitoring/baselime/package.json b/packages/monitoring/baselime/package.json index 98d5cda9f..81d4df9e5 100644 --- a/packages/monitoring/baselime/package.json +++ b/packages/monitoring/baselime/package.json @@ -10,7 +10,8 @@ }, "prettier": "@kit/prettier-config", "exports": { - ".": "./src/index.ts", + "./server": "./src/server.ts", + "./client": "./src/client.ts", "./instrumentation": "./src/instrumentation.ts", "./provider": "./src/components/provider.tsx" }, diff --git a/packages/monitoring/baselime/src/capture-exception.ts b/packages/monitoring/baselime/src/capture-exception.ts deleted file mode 100644 index c9e1114dc..000000000 --- a/packages/monitoring/baselime/src/capture-exception.ts +++ /dev/null @@ -1,4 +0,0 @@ -export function captureException(error: Error) { - console.info(`No yet defined...`); - return console.error(`Caught exception: ${JSON.stringify(error)}`); -} diff --git a/packages/monitoring/baselime/src/client.ts b/packages/monitoring/baselime/src/client.ts new file mode 100644 index 000000000..32ca7fdee --- /dev/null +++ b/packages/monitoring/baselime/src/client.ts @@ -0,0 +1 @@ +export * from './hooks/use-baselime'; diff --git a/packages/monitoring/baselime/src/hooks/use-baselime.ts b/packages/monitoring/baselime/src/hooks/use-baselime.ts new file mode 100644 index 000000000..d582f33f5 --- /dev/null +++ b/packages/monitoring/baselime/src/hooks/use-baselime.ts @@ -0,0 +1,20 @@ +import { useBaselimeRum } from '@baselime/react-rum'; + +import { MonitoringService } from '../../../src/services/monitoring.service'; + +/** + * @name useBaselime + * @description Get the Baselime monitoring service for the browser. + */ +export function useBaselime(): MonitoringService { + const { captureException, setUser } = useBaselimeRum(); + + return { + captureException(error: Error, extra?: React.ErrorInfo | undefined) { + void captureException(error, extra); + }, + identifyUser(params) { + setUser(params.id); + }, + } satisfies MonitoringService; +} diff --git a/packages/monitoring/baselime/src/hooks/use-capture-exception.ts b/packages/monitoring/baselime/src/hooks/use-capture-exception.ts deleted file mode 100644 index 29bacd09d..000000000 --- a/packages/monitoring/baselime/src/hooks/use-capture-exception.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { useCallback } from 'react'; - -import { useBaselimeRum } from '@baselime/react-rum'; - -export function useCaptureException() { - const { captureException } = useBaselimeRum(); - - return useCallback( - (error: Error) => captureException(error), - [captureException], - ); -} diff --git a/packages/monitoring/baselime/src/index.ts b/packages/monitoring/baselime/src/index.ts deleted file mode 100644 index c258b27a8..000000000 --- a/packages/monitoring/baselime/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './capture-exception'; diff --git a/packages/monitoring/baselime/src/monitoring-service.ts b/packages/monitoring/baselime/src/monitoring-service.ts new file mode 100644 index 000000000..e69de29bb diff --git a/packages/monitoring/baselime/src/server.ts b/packages/monitoring/baselime/src/server.ts new file mode 100644 index 000000000..99e700903 --- /dev/null +++ b/packages/monitoring/baselime/src/server.ts @@ -0,0 +1 @@ +export * from './services/baselime-server-monitoring.service'; diff --git a/packages/monitoring/baselime/src/services/baselime-server-monitoring.service.ts b/packages/monitoring/baselime/src/services/baselime-server-monitoring.service.ts new file mode 100644 index 000000000..9599bcfda --- /dev/null +++ b/packages/monitoring/baselime/src/services/baselime-server-monitoring.service.ts @@ -0,0 +1,9 @@ +import { MonitoringService } from '../../../src/services/monitoring.service'; + +export class BaselimeServerMonitoringService implements MonitoringService { + captureException(error: Error | null) { + console.error(`Caught exception: ${JSON.stringify(error)}`); + } + + identifyUser(info: Info) {} +} diff --git a/packages/monitoring/package.json b/packages/monitoring/package.json index d6ea839e3..f2f3d1a5f 100644 --- a/packages/monitoring/package.json +++ b/packages/monitoring/package.json @@ -11,7 +11,7 @@ }, "prettier": "@kit/prettier-config", "exports": { - ".": "./src/index.ts", + "./server": "./src/server.ts", "./instrumentation": "./src/instrumentation.ts", "./hooks": "./src/hooks/index.ts", "./components": "./src/components/index.ts" diff --git a/packages/monitoring/sentry/README.md b/packages/monitoring/sentry/README.md index 7d0dca967..34551a07c 100644 --- a/packages/monitoring/sentry/README.md +++ b/packages/monitoring/sentry/README.md @@ -3,7 +3,7 @@ Please set the following environment variable: ``` -MONITORING_INSTRUMENTATION_PROVIDER=sentry +NEXT_PUBLIC_MONITORING_PROVIDER=sentry NEXT_PUBLIC_SENTRY_DSN=your_dsn ``` diff --git a/packages/monitoring/sentry/package.json b/packages/monitoring/sentry/package.json index 4ee24d3ae..3e43fb710 100644 --- a/packages/monitoring/sentry/package.json +++ b/packages/monitoring/sentry/package.json @@ -11,6 +11,8 @@ "prettier": "@kit/prettier-config", "exports": { ".": "./src/index.ts", + "./server": "./src/server.ts", + "./client": "./src/client.ts", "./instrumentation": "./src/instrumentation.ts", "./config/client": "./src/config/sentry.client.config.ts", "./config/server": "./src/config/sentry.server.config.ts", diff --git a/packages/monitoring/sentry/src/capture-exception.ts b/packages/monitoring/sentry/src/capture-exception.ts deleted file mode 100644 index 5342fa459..000000000 --- a/packages/monitoring/sentry/src/capture-exception.ts +++ /dev/null @@ -1,5 +0,0 @@ -import * as Sentry from '@sentry/nextjs'; - -export function captureException(error: Error & { digest?: string }) { - return Sentry.captureException(error); -} diff --git a/packages/monitoring/sentry/src/client.ts b/packages/monitoring/sentry/src/client.ts new file mode 100644 index 000000000..72a7600c0 --- /dev/null +++ b/packages/monitoring/sentry/src/client.ts @@ -0,0 +1 @@ +export * from './hooks/use-sentry'; diff --git a/packages/monitoring/sentry/src/hooks/use-sentry.ts b/packages/monitoring/sentry/src/hooks/use-sentry.ts new file mode 100644 index 000000000..3fa2bb502 --- /dev/null +++ b/packages/monitoring/sentry/src/hooks/use-sentry.ts @@ -0,0 +1,12 @@ +import { useMemo } from 'react'; + +import { SentryServerMonitoringService } from '../services/sentry-server-monitoring.service'; + +/** + * @name useSentry + * @description Get the Sentry monitoring service. Sentry can be used in the browser and server - so we don't need to differentiate between the two. + * @returns {SentryServerMonitoringService} + */ +export function useSentry(): SentryServerMonitoringService { + return useMemo(() => new SentryServerMonitoringService(), []); +} diff --git a/packages/monitoring/sentry/src/index.ts b/packages/monitoring/sentry/src/index.ts deleted file mode 100644 index c258b27a8..000000000 --- a/packages/monitoring/sentry/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './capture-exception'; diff --git a/packages/monitoring/sentry/src/server.ts b/packages/monitoring/sentry/src/server.ts new file mode 100644 index 000000000..400c7c280 --- /dev/null +++ b/packages/monitoring/sentry/src/server.ts @@ -0,0 +1 @@ +export * from './services/sentry-server-monitoring.service'; diff --git a/packages/monitoring/sentry/src/services/sentry-server-monitoring.service.ts b/packages/monitoring/sentry/src/services/sentry-server-monitoring.service.ts new file mode 100644 index 000000000..a0704e055 --- /dev/null +++ b/packages/monitoring/sentry/src/services/sentry-server-monitoring.service.ts @@ -0,0 +1,18 @@ +import * as Sentry from '@sentry/nextjs'; + +import { MonitoringService } from '../../../src/services/monitoring.service'; + +/** + * @class + * @implements {MonitoringService} + * ServerSentryMonitoringService is responsible for capturing exceptions and identifying users using the Sentry monitoring service. + */ +export class SentryServerMonitoringService implements MonitoringService { + captureException(error: Error | null) { + return Sentry.captureException(error); + } + + identifyUser(user: Sentry.User) { + Sentry.setUser(user); + } +} diff --git a/packages/monitoring/src/capture-exception.ts b/packages/monitoring/src/capture-exception.ts deleted file mode 100644 index f99873bfa..000000000 --- a/packages/monitoring/src/capture-exception.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { InstrumentationProvider } from './monitoring-providers.enum'; - -/** - * @name MONITORING_PROVIDER - * @description Register monitoring instrumentation based on the MONITORING_PROVIDER environment variable. - */ -const MONITORING_PROVIDER = process.env.MONITORING_PROVIDER as - | InstrumentationProvider - | undefined; - -/** - * @name captureException - * @description Capture an exception and send it to the monitoring provider defined. - * @param error - */ -export async function captureException(error: Error) { - if (!MONITORING_PROVIDER) { - console.info( - `No instrumentation provider specified. Logging to console...`, - ); - - return console.error(`Caught exception: ${JSON.stringify(error)}`); - } - - switch (MONITORING_PROVIDER) { - case InstrumentationProvider.Baselime: { - const { captureException } = await import('@kit/baselime'); - - return captureException(error); - } - - case InstrumentationProvider.Sentry: { - const { captureException } = await import('@kit/sentry'); - - return captureException(error); - } - - default: { - throw new Error( - `Please set the MONITORING_PROVIDER environment variable to register the monitoring instrumentation provider.`, - ); - } - } -} diff --git a/packages/monitoring/src/components/error-boundary.tsx b/packages/monitoring/src/components/error-boundary.tsx index 6a5b4f265..65f788d58 100644 --- a/packages/monitoring/src/components/error-boundary.tsx +++ b/packages/monitoring/src/components/error-boundary.tsx @@ -1,8 +1,6 @@ import type { ErrorInfo, ReactNode } from 'react'; import { Component } from 'react'; -import { captureException } from '../capture-exception'; - interface Props { onError?: (error: Error, info: ErrorInfo) => void; fallback: ReactNode; @@ -23,10 +21,8 @@ export class ErrorBoundary extends Component { }; } - async componentDidCatch(error: Error, info: ErrorInfo) { + componentDidCatch(error: Error, info: ErrorInfo) { this.props.onError?.(error, info); - - await captureException(error); } render() { diff --git a/packages/monitoring/src/get-monitoring-provider.ts b/packages/monitoring/src/get-monitoring-provider.ts new file mode 100644 index 000000000..ff7771790 --- /dev/null +++ b/packages/monitoring/src/get-monitoring-provider.ts @@ -0,0 +1,7 @@ +import { InstrumentationProvider } from './monitoring-providers.enum'; + +export function getMonitoringProvider() { + return process.env.NEXT_PUBLIC_MONITORING_PROVIDER as + | InstrumentationProvider + | undefined; +} diff --git a/packages/monitoring/src/hooks/index.ts b/packages/monitoring/src/hooks/index.ts index bb2203ca8..e90f756a9 100644 --- a/packages/monitoring/src/hooks/index.ts +++ b/packages/monitoring/src/hooks/index.ts @@ -1 +1,2 @@ +export * from './use-monitoring'; export * from './use-capture-exception'; diff --git a/packages/monitoring/src/hooks/use-capture-exception.ts b/packages/monitoring/src/hooks/use-capture-exception.ts index 68e780c7b..8c3b5cb4b 100644 --- a/packages/monitoring/src/hooks/use-capture-exception.ts +++ b/packages/monitoring/src/hooks/use-capture-exception.ts @@ -1,11 +1,7 @@ -import { useEffect } from 'react'; - -import { captureException } from '../capture-exception'; +import { useMonitoring } from './use-monitoring'; export function useCaptureException(error: Error) { - useEffect(() => { - void captureException(error); - }, [error]); + const service = useMonitoring(); - return null; + return service.captureException(error); } diff --git a/packages/monitoring/src/hooks/use-monitoring.ts b/packages/monitoring/src/hooks/use-monitoring.ts new file mode 100644 index 000000000..e660abc71 --- /dev/null +++ b/packages/monitoring/src/hooks/use-monitoring.ts @@ -0,0 +1,51 @@ +import { getMonitoringProvider } from '../get-monitoring-provider'; +import { InstrumentationProvider } from '../monitoring-providers.enum'; +import { ConsoleMonitoringService } from '../services/console-monitoring.service'; +import { MonitoringService } from '../services/monitoring.service'; + +const MONITORING = getMonitoringProvider(); + +let service: MonitoringService; + +/** + * @name useMonitoring + * @description Asynchronously load the monitoring service based on the MONITORING_PROVIDER environment variable. + * Use Suspense to suspend while loading the service. + */ +export function useMonitoring() { + if (!service) { + throw withMonitoringService(); + } + + console.log(service); + + return service; +} + +async function withMonitoringService() { + service = await loadMonitoringService(); +} + +async function loadMonitoringService() { + if (!MONITORING) { + return new ConsoleMonitoringService(); + } + + switch (MONITORING) { + case InstrumentationProvider.Baselime: { + const { useBaselime } = await import('@kit/baselime/client'); + + return useBaselime; + } + + case InstrumentationProvider.Sentry: { + const { useSentry } = await import('@kit/sentry/client'); + + return useSentry; + } + + default: { + throw new Error(`Unknown instrumentation provider: ${MONITORING}`); + } + } +} diff --git a/packages/monitoring/src/index.ts b/packages/monitoring/src/index.ts deleted file mode 100644 index c258b27a8..000000000 --- a/packages/monitoring/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './capture-exception'; diff --git a/packages/monitoring/src/instrumentation.ts b/packages/monitoring/src/instrumentation.ts index 355058a75..b32a6f940 100644 --- a/packages/monitoring/src/instrumentation.ts +++ b/packages/monitoring/src/instrumentation.ts @@ -1,5 +1,8 @@ +import { getMonitoringProvider } from './get-monitoring-provider'; import { InstrumentationProvider } from './monitoring-providers.enum'; +const PROVIDER = getMonitoringProvider(); + /** * @name registerMonitoringInstrumentation * @description Register monitoring instrumentation based on the MONITORING_PROVIDER environment variable. @@ -7,13 +10,13 @@ import { InstrumentationProvider } from './monitoring-providers.enum'; * Please set the MONITORING_PROVIDER environment variable to register the monitoring instrumentation provider. */ export async function registerMonitoringInstrumentation() { - if (!process.env.MONITORING_PROVIDER) { + if (!PROVIDER) { console.info(`No instrumentation provider specified. Skipping...`); return; } - switch (process.env.MONITORING_PROVIDER as InstrumentationProvider) { + switch (PROVIDER) { case InstrumentationProvider.Baselime: { const { registerInstrumentation } = await import( '@kit/baselime/instrumentation' diff --git a/packages/monitoring/src/server.ts b/packages/monitoring/src/server.ts new file mode 100644 index 000000000..71f70fa01 --- /dev/null +++ b/packages/monitoring/src/server.ts @@ -0,0 +1 @@ +export * from './services/get-server-monitoring-service'; diff --git a/packages/monitoring/src/services/console-monitoring.service.ts b/packages/monitoring/src/services/console-monitoring.service.ts new file mode 100644 index 000000000..854d44cf0 --- /dev/null +++ b/packages/monitoring/src/services/console-monitoring.service.ts @@ -0,0 +1,11 @@ +import { MonitoringService } from './monitoring.service'; + +export class ConsoleMonitoringService implements MonitoringService { + identifyUser() { + // noop + } + + captureException(error: Error) { + console.error(`Caught exception: ${JSON.stringify(error)}`); + } +} diff --git a/packages/monitoring/src/services/get-server-monitoring-service.ts b/packages/monitoring/src/services/get-server-monitoring-service.ts new file mode 100644 index 000000000..3a00ae359 --- /dev/null +++ b/packages/monitoring/src/services/get-server-monitoring-service.ts @@ -0,0 +1,43 @@ +import { getMonitoringProvider } from '../get-monitoring-provider'; +import { InstrumentationProvider } from '../monitoring-providers.enum'; +import { ConsoleMonitoringService } from './console-monitoring.service'; + +const MONITORING_PROVIDER = getMonitoringProvider(); + +/** + * @name getServerMonitoringService + * @description Get the monitoring service based on the MONITORING_PROVIDER environment variable. + */ +export async function getServerMonitoringService() { + if (!MONITORING_PROVIDER) { + console.info( + `No instrumentation provider specified. Returning console service...`, + ); + + return new ConsoleMonitoringService(); + } + + switch (MONITORING_PROVIDER) { + case InstrumentationProvider.Baselime: { + const { BaselimeServerMonitoringService } = await import( + '@kit/baselime/server' + ); + + return new BaselimeServerMonitoringService(); + } + + case InstrumentationProvider.Sentry: { + const { SentryServerMonitoringService } = await import( + '@kit/sentry/server' + ); + + return new SentryServerMonitoringService(); + } + + default: { + throw new Error( + `Please set the MONITORING_PROVIDER environment variable to register the monitoring instrumentation provider.`, + ); + } + } +} diff --git a/packages/monitoring/src/services/monitoring.service.ts b/packages/monitoring/src/services/monitoring.service.ts new file mode 100644 index 000000000..1efca0757 --- /dev/null +++ b/packages/monitoring/src/services/monitoring.service.ts @@ -0,0 +1,22 @@ +/** + * Monitoring service interface + * @description This service is used to capture exceptions and identify users in the monitoring service + * @example + */ +export abstract class MonitoringService { + /** + * Capture an exception + * @param error + * @param extra + */ + abstract captureException( + error: Error & { digest?: string }, + extra?: Extra, + ): unknown; + + /** + * Identify a user in the monitoring service - used for tracking user actions + * @param info + */ + abstract identifyUser(info: Info): unknown; +} diff --git a/packages/supabase/src/database.types.ts b/packages/supabase/src/database.types.ts index 936d36fdf..cc82ba9c3 100644 --- a/packages/supabase/src/database.types.ts +++ b/packages/supabase/src/database.types.ts @@ -4,1308 +4,1307 @@ export type Json = | boolean | null | { [key: string]: Json | undefined } - | Json[] + | Json[]; export type Database = { graphql_public: { Tables: { - [_ in never]: never - } + [_ in never]: never; + }; Views: { - [_ in never]: never - } + [_ in never]: never; + }; Functions: { graphql: { Args: { - operationName?: string - query?: string - variables?: Json - extensions?: Json - } - Returns: Json - } - } + operationName?: string; + query?: string; + variables?: Json; + extensions?: Json; + }; + Returns: Json; + }; + }; Enums: { - [_ in never]: never - } + [_ in never]: never; + }; CompositeTypes: { - [_ in never]: never - } - } + [_ in never]: never; + }; + }; public: { Tables: { accounts: { Row: { - created_at: string | null - created_by: string | null - email: string | null - id: string - is_personal_account: boolean - name: string - picture_url: string | null - primary_owner_user_id: string - public_data: Json - slug: string | null - updated_at: string | null - updated_by: string | null - } + created_at: string | null; + created_by: string | null; + email: string | null; + id: string; + is_personal_account: boolean; + name: string; + picture_url: string | null; + primary_owner_user_id: string; + public_data: Json; + slug: string | null; + updated_at: string | null; + updated_by: string | null; + }; Insert: { - created_at?: string | null - created_by?: string | null - email?: string | null - id?: string - is_personal_account?: boolean - name: string - picture_url?: string | null - primary_owner_user_id?: string - public_data?: Json - slug?: string | null - updated_at?: string | null - updated_by?: string | null - } + created_at?: string | null; + created_by?: string | null; + email?: string | null; + id?: string; + is_personal_account?: boolean; + name: string; + picture_url?: string | null; + primary_owner_user_id?: string; + public_data?: Json; + slug?: string | null; + updated_at?: string | null; + updated_by?: string | null; + }; Update: { - created_at?: string | null - created_by?: string | null - email?: string | null - id?: string - is_personal_account?: boolean - name?: string - picture_url?: string | null - primary_owner_user_id?: string - public_data?: Json - slug?: string | null - updated_at?: string | null - updated_by?: string | null - } + created_at?: string | null; + created_by?: string | null; + email?: string | null; + id?: string; + is_personal_account?: boolean; + name?: string; + picture_url?: string | null; + primary_owner_user_id?: string; + public_data?: Json; + slug?: string | null; + updated_at?: string | null; + updated_by?: string | null; + }; Relationships: [ { - foreignKeyName: "accounts_created_by_fkey" - columns: ["created_by"] - isOneToOne: false - referencedRelation: "users" - referencedColumns: ["id"] + foreignKeyName: 'accounts_created_by_fkey'; + columns: ['created_by']; + isOneToOne: false; + referencedRelation: 'users'; + referencedColumns: ['id']; }, { - foreignKeyName: "accounts_primary_owner_user_id_fkey" - columns: ["primary_owner_user_id"] - isOneToOne: false - referencedRelation: "users" - referencedColumns: ["id"] + foreignKeyName: 'accounts_primary_owner_user_id_fkey'; + columns: ['primary_owner_user_id']; + isOneToOne: false; + referencedRelation: 'users'; + referencedColumns: ['id']; }, { - foreignKeyName: "accounts_updated_by_fkey" - columns: ["updated_by"] - isOneToOne: false - referencedRelation: "users" - referencedColumns: ["id"] + foreignKeyName: 'accounts_updated_by_fkey'; + columns: ['updated_by']; + isOneToOne: false; + referencedRelation: 'users'; + referencedColumns: ['id']; }, - ] - } + ]; + }; accounts_memberships: { Row: { - account_id: string - account_role: string - created_at: string - created_by: string | null - updated_at: string - updated_by: string | null - user_id: string - } + account_id: string; + account_role: string; + created_at: string; + created_by: string | null; + updated_at: string; + updated_by: string | null; + user_id: string; + }; Insert: { - account_id: string - account_role: string - created_at?: string - created_by?: string | null - updated_at?: string - updated_by?: string | null - user_id: string - } + account_id: string; + account_role: string; + created_at?: string; + created_by?: string | null; + updated_at?: string; + updated_by?: string | null; + user_id: string; + }; Update: { - account_id?: string - account_role?: string - created_at?: string - created_by?: string | null - updated_at?: string - updated_by?: string | null - user_id?: string - } + account_id?: string; + account_role?: string; + created_at?: string; + created_by?: string | null; + updated_at?: string; + updated_by?: string | null; + user_id?: string; + }; Relationships: [ { - foreignKeyName: "accounts_memberships_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "accounts" - referencedColumns: ["id"] + foreignKeyName: 'accounts_memberships_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "accounts_memberships_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_account_workspace" - referencedColumns: ["id"] + foreignKeyName: 'accounts_memberships_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_account_workspace'; + referencedColumns: ['id']; }, { - foreignKeyName: "accounts_memberships_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_accounts" - referencedColumns: ["id"] + foreignKeyName: 'accounts_memberships_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "accounts_memberships_account_role_fkey" - columns: ["account_role"] - isOneToOne: false - referencedRelation: "roles" - referencedColumns: ["name"] + foreignKeyName: 'accounts_memberships_account_role_fkey'; + columns: ['account_role']; + isOneToOne: false; + referencedRelation: 'roles'; + referencedColumns: ['name']; }, { - foreignKeyName: "accounts_memberships_created_by_fkey" - columns: ["created_by"] - isOneToOne: false - referencedRelation: "users" - referencedColumns: ["id"] + foreignKeyName: 'accounts_memberships_created_by_fkey'; + columns: ['created_by']; + isOneToOne: false; + referencedRelation: 'users'; + referencedColumns: ['id']; }, { - foreignKeyName: "accounts_memberships_updated_by_fkey" - columns: ["updated_by"] - isOneToOne: false - referencedRelation: "users" - referencedColumns: ["id"] + foreignKeyName: 'accounts_memberships_updated_by_fkey'; + columns: ['updated_by']; + isOneToOne: false; + referencedRelation: 'users'; + referencedColumns: ['id']; }, { - foreignKeyName: "accounts_memberships_user_id_fkey" - columns: ["user_id"] - isOneToOne: false - referencedRelation: "users" - referencedColumns: ["id"] + foreignKeyName: 'accounts_memberships_user_id_fkey'; + columns: ['user_id']; + isOneToOne: false; + referencedRelation: 'users'; + referencedColumns: ['id']; }, - ] - } + ]; + }; billing_customers: { Row: { - account_id: string - customer_id: string - email: string | null - id: number - provider: Database["public"]["Enums"]["billing_provider"] - } + account_id: string; + customer_id: string; + email: string | null; + id: number; + provider: Database['public']['Enums']['billing_provider']; + }; Insert: { - account_id: string - customer_id: string - email?: string | null - id?: number - provider: Database["public"]["Enums"]["billing_provider"] - } + account_id: string; + customer_id: string; + email?: string | null; + id?: number; + provider: Database['public']['Enums']['billing_provider']; + }; Update: { - account_id?: string - customer_id?: string - email?: string | null - id?: number - provider?: Database["public"]["Enums"]["billing_provider"] - } + account_id?: string; + customer_id?: string; + email?: string | null; + id?: number; + provider?: Database['public']['Enums']['billing_provider']; + }; Relationships: [ { - foreignKeyName: "billing_customers_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "accounts" - referencedColumns: ["id"] + foreignKeyName: 'billing_customers_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "billing_customers_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_account_workspace" - referencedColumns: ["id"] + foreignKeyName: 'billing_customers_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_account_workspace'; + referencedColumns: ['id']; }, { - foreignKeyName: "billing_customers_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_accounts" - referencedColumns: ["id"] + foreignKeyName: 'billing_customers_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_accounts'; + referencedColumns: ['id']; }, - ] - } + ]; + }; config: { Row: { - billing_provider: Database["public"]["Enums"]["billing_provider"] - enable_account_billing: boolean - enable_team_account_billing: boolean - enable_team_accounts: boolean - } + billing_provider: Database['public']['Enums']['billing_provider']; + enable_account_billing: boolean; + enable_team_account_billing: boolean; + enable_team_accounts: boolean; + }; Insert: { - billing_provider?: Database["public"]["Enums"]["billing_provider"] - enable_account_billing?: boolean - enable_team_account_billing?: boolean - enable_team_accounts?: boolean - } + billing_provider?: Database['public']['Enums']['billing_provider']; + enable_account_billing?: boolean; + enable_team_account_billing?: boolean; + enable_team_accounts?: boolean; + }; Update: { - billing_provider?: Database["public"]["Enums"]["billing_provider"] - enable_account_billing?: boolean - enable_team_account_billing?: boolean - enable_team_accounts?: boolean - } - Relationships: [] - } + billing_provider?: Database['public']['Enums']['billing_provider']; + enable_account_billing?: boolean; + enable_team_account_billing?: boolean; + enable_team_accounts?: boolean; + }; + Relationships: []; + }; invitations: { Row: { - account_id: string - created_at: string - email: string - expires_at: string - id: number - invite_token: string - invited_by: string - role: string - updated_at: string - } + account_id: string; + created_at: string; + email: string; + expires_at: string; + id: number; + invite_token: string; + invited_by: string; + role: string; + updated_at: string; + }; Insert: { - account_id: string - created_at?: string - email: string - expires_at?: string - id?: number - invite_token: string - invited_by: string - role: string - updated_at?: string - } + account_id: string; + created_at?: string; + email: string; + expires_at?: string; + id?: number; + invite_token: string; + invited_by: string; + role: string; + updated_at?: string; + }; Update: { - account_id?: string - created_at?: string - email?: string - expires_at?: string - id?: number - invite_token?: string - invited_by?: string - role?: string - updated_at?: string - } + account_id?: string; + created_at?: string; + email?: string; + expires_at?: string; + id?: number; + invite_token?: string; + invited_by?: string; + role?: string; + updated_at?: string; + }; Relationships: [ { - foreignKeyName: "invitations_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "accounts" - referencedColumns: ["id"] + foreignKeyName: 'invitations_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "invitations_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_account_workspace" - referencedColumns: ["id"] + foreignKeyName: 'invitations_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_account_workspace'; + referencedColumns: ['id']; }, { - foreignKeyName: "invitations_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_accounts" - referencedColumns: ["id"] + foreignKeyName: 'invitations_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "invitations_invited_by_fkey" - columns: ["invited_by"] - isOneToOne: false - referencedRelation: "users" - referencedColumns: ["id"] + foreignKeyName: 'invitations_invited_by_fkey'; + columns: ['invited_by']; + isOneToOne: false; + referencedRelation: 'users'; + referencedColumns: ['id']; }, { - foreignKeyName: "invitations_role_fkey" - columns: ["role"] - isOneToOne: false - referencedRelation: "roles" - referencedColumns: ["name"] + foreignKeyName: 'invitations_role_fkey'; + columns: ['role']; + isOneToOne: false; + referencedRelation: 'roles'; + referencedColumns: ['name']; }, - ] - } + ]; + }; order_items: { Row: { - created_at: string - order_id: string - price_amount: number | null - product_id: string - quantity: number - updated_at: string - variant_id: string - } + created_at: string; + order_id: string; + price_amount: number | null; + product_id: string; + quantity: number; + updated_at: string; + variant_id: string; + }; Insert: { - created_at?: string - order_id: string - price_amount?: number | null - product_id: string - quantity?: number - updated_at?: string - variant_id: string - } + created_at?: string; + order_id: string; + price_amount?: number | null; + product_id: string; + quantity?: number; + updated_at?: string; + variant_id: string; + }; Update: { - created_at?: string - order_id?: string - price_amount?: number | null - product_id?: string - quantity?: number - updated_at?: string - variant_id?: string - } + created_at?: string; + order_id?: string; + price_amount?: number | null; + product_id?: string; + quantity?: number; + updated_at?: string; + variant_id?: string; + }; Relationships: [ { - foreignKeyName: "order_items_order_id_fkey" - columns: ["order_id"] - isOneToOne: false - referencedRelation: "orders" - referencedColumns: ["id"] + foreignKeyName: 'order_items_order_id_fkey'; + columns: ['order_id']; + isOneToOne: false; + referencedRelation: 'orders'; + referencedColumns: ['id']; }, - ] - } + ]; + }; orders: { Row: { - account_id: string - billing_customer_id: number - billing_provider: Database["public"]["Enums"]["billing_provider"] - created_at: string - currency: string - id: string - status: Database["public"]["Enums"]["payment_status"] - total_amount: number - updated_at: string - } + account_id: string; + billing_customer_id: number; + billing_provider: Database['public']['Enums']['billing_provider']; + created_at: string; + currency: string; + id: string; + status: Database['public']['Enums']['payment_status']; + total_amount: number; + updated_at: string; + }; Insert: { - account_id: string - billing_customer_id: number - billing_provider: Database["public"]["Enums"]["billing_provider"] - created_at?: string - currency: string - id: string - status: Database["public"]["Enums"]["payment_status"] - total_amount: number - updated_at?: string - } + account_id: string; + billing_customer_id: number; + billing_provider: Database['public']['Enums']['billing_provider']; + created_at?: string; + currency: string; + id: string; + status: Database['public']['Enums']['payment_status']; + total_amount: number; + updated_at?: string; + }; Update: { - account_id?: string - billing_customer_id?: number - billing_provider?: Database["public"]["Enums"]["billing_provider"] - created_at?: string - currency?: string - id?: string - status?: Database["public"]["Enums"]["payment_status"] - total_amount?: number - updated_at?: string - } + account_id?: string; + billing_customer_id?: number; + billing_provider?: Database['public']['Enums']['billing_provider']; + created_at?: string; + currency?: string; + id?: string; + status?: Database['public']['Enums']['payment_status']; + total_amount?: number; + updated_at?: string; + }; Relationships: [ { - foreignKeyName: "orders_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "accounts" - referencedColumns: ["id"] + foreignKeyName: 'orders_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "orders_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_account_workspace" - referencedColumns: ["id"] + foreignKeyName: 'orders_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_account_workspace'; + referencedColumns: ['id']; }, { - foreignKeyName: "orders_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_accounts" - referencedColumns: ["id"] + foreignKeyName: 'orders_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "orders_billing_customer_id_fkey" - columns: ["billing_customer_id"] - isOneToOne: false - referencedRelation: "billing_customers" - referencedColumns: ["id"] + foreignKeyName: 'orders_billing_customer_id_fkey'; + columns: ['billing_customer_id']; + isOneToOne: false; + referencedRelation: 'billing_customers'; + referencedColumns: ['id']; }, - ] - } + ]; + }; role_permissions: { Row: { - id: number - permission: Database["public"]["Enums"]["app_permissions"] - role: string - } + id: number; + permission: Database['public']['Enums']['app_permissions']; + role: string; + }; Insert: { - id?: number - permission: Database["public"]["Enums"]["app_permissions"] - role: string - } + id?: number; + permission: Database['public']['Enums']['app_permissions']; + role: string; + }; Update: { - id?: number - permission?: Database["public"]["Enums"]["app_permissions"] - role?: string - } + id?: number; + permission?: Database['public']['Enums']['app_permissions']; + role?: string; + }; Relationships: [ { - foreignKeyName: "role_permissions_role_fkey" - columns: ["role"] - isOneToOne: false - referencedRelation: "roles" - referencedColumns: ["name"] + foreignKeyName: 'role_permissions_role_fkey'; + columns: ['role']; + isOneToOne: false; + referencedRelation: 'roles'; + referencedColumns: ['name']; }, - ] - } + ]; + }; roles: { Row: { - account_id: string | null - hierarchy_level: number - name: string - } + account_id: string | null; + hierarchy_level: number; + name: string; + }; Insert: { - account_id?: string | null - hierarchy_level: number - name: string - } + account_id?: string | null; + hierarchy_level: number; + name: string; + }; Update: { - account_id?: string | null - hierarchy_level?: number - name?: string - } + account_id?: string | null; + hierarchy_level?: number; + name?: string; + }; Relationships: [ { - foreignKeyName: "roles_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "accounts" - referencedColumns: ["id"] + foreignKeyName: 'roles_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "roles_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_account_workspace" - referencedColumns: ["id"] + foreignKeyName: 'roles_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_account_workspace'; + referencedColumns: ['id']; }, { - foreignKeyName: "roles_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_accounts" - referencedColumns: ["id"] + foreignKeyName: 'roles_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_accounts'; + referencedColumns: ['id']; }, - ] - } + ]; + }; subscription_items: { Row: { - created_at: string - interval: string - interval_count: number - price_amount: number | null - product_id: string - quantity: number - subscription_id: string - type: Database["public"]["Enums"]["subscription_item_type"] - updated_at: string - variant_id: string - } + created_at: string; + interval: string; + interval_count: number; + price_amount: number | null; + product_id: string; + quantity: number; + subscription_id: string; + type: Database['public']['Enums']['subscription_item_type']; + updated_at: string; + variant_id: string; + }; Insert: { - created_at?: string - interval: string - interval_count: number - price_amount?: number | null - product_id: string - quantity?: number - subscription_id: string - type: Database["public"]["Enums"]["subscription_item_type"] - updated_at?: string - variant_id: string - } + created_at?: string; + interval: string; + interval_count: number; + price_amount?: number | null; + product_id: string; + quantity?: number; + subscription_id: string; + type: Database['public']['Enums']['subscription_item_type']; + updated_at?: string; + variant_id: string; + }; Update: { - created_at?: string - interval?: string - interval_count?: number - price_amount?: number | null - product_id?: string - quantity?: number - subscription_id?: string - type?: Database["public"]["Enums"]["subscription_item_type"] - updated_at?: string - variant_id?: string - } + created_at?: string; + interval?: string; + interval_count?: number; + price_amount?: number | null; + product_id?: string; + quantity?: number; + subscription_id?: string; + type?: Database['public']['Enums']['subscription_item_type']; + updated_at?: string; + variant_id?: string; + }; Relationships: [ { - foreignKeyName: "subscription_items_subscription_id_fkey" - columns: ["subscription_id"] - isOneToOne: false - referencedRelation: "subscriptions" - referencedColumns: ["id"] + foreignKeyName: 'subscription_items_subscription_id_fkey'; + columns: ['subscription_id']; + isOneToOne: false; + referencedRelation: 'subscriptions'; + referencedColumns: ['id']; }, - ] - } + ]; + }; subscriptions: { Row: { - account_id: string - active: boolean - billing_customer_id: number - billing_provider: Database["public"]["Enums"]["billing_provider"] - cancel_at_period_end: boolean - created_at: string - currency: string - id: string - period_ends_at: string - period_starts_at: string - status: Database["public"]["Enums"]["subscription_status"] - trial_ends_at: string | null - trial_starts_at: string | null - updated_at: string - } + account_id: string; + active: boolean; + billing_customer_id: number; + billing_provider: Database['public']['Enums']['billing_provider']; + cancel_at_period_end: boolean; + created_at: string; + currency: string; + id: string; + period_ends_at: string; + period_starts_at: string; + status: Database['public']['Enums']['subscription_status']; + trial_ends_at: string | null; + trial_starts_at: string | null; + updated_at: string; + }; Insert: { - account_id: string - active: boolean - billing_customer_id: number - billing_provider: Database["public"]["Enums"]["billing_provider"] - cancel_at_period_end: boolean - created_at?: string - currency: string - id: string - period_ends_at: string - period_starts_at: string - status: Database["public"]["Enums"]["subscription_status"] - trial_ends_at?: string | null - trial_starts_at?: string | null - updated_at?: string - } + account_id: string; + active: boolean; + billing_customer_id: number; + billing_provider: Database['public']['Enums']['billing_provider']; + cancel_at_period_end: boolean; + created_at?: string; + currency: string; + id: string; + period_ends_at: string; + period_starts_at: string; + status: Database['public']['Enums']['subscription_status']; + trial_ends_at?: string | null; + trial_starts_at?: string | null; + updated_at?: string; + }; Update: { - account_id?: string - active?: boolean - billing_customer_id?: number - billing_provider?: Database["public"]["Enums"]["billing_provider"] - cancel_at_period_end?: boolean - created_at?: string - currency?: string - id?: string - period_ends_at?: string - period_starts_at?: string - status?: Database["public"]["Enums"]["subscription_status"] - trial_ends_at?: string | null - trial_starts_at?: string | null - updated_at?: string - } + account_id?: string; + active?: boolean; + billing_customer_id?: number; + billing_provider?: Database['public']['Enums']['billing_provider']; + cancel_at_period_end?: boolean; + created_at?: string; + currency?: string; + id?: string; + period_ends_at?: string; + period_starts_at?: string; + status?: Database['public']['Enums']['subscription_status']; + trial_ends_at?: string | null; + trial_starts_at?: string | null; + updated_at?: string; + }; Relationships: [ { - foreignKeyName: "subscriptions_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "accounts" - referencedColumns: ["id"] + foreignKeyName: 'subscriptions_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "subscriptions_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_account_workspace" - referencedColumns: ["id"] + foreignKeyName: 'subscriptions_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_account_workspace'; + referencedColumns: ['id']; }, { - foreignKeyName: "subscriptions_account_id_fkey" - columns: ["account_id"] - isOneToOne: false - referencedRelation: "user_accounts" - referencedColumns: ["id"] + foreignKeyName: 'subscriptions_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_accounts'; + referencedColumns: ['id']; }, { - foreignKeyName: "subscriptions_billing_customer_id_fkey" - columns: ["billing_customer_id"] - isOneToOne: false - referencedRelation: "billing_customers" - referencedColumns: ["id"] + foreignKeyName: 'subscriptions_billing_customer_id_fkey'; + columns: ['billing_customer_id']; + isOneToOne: false; + referencedRelation: 'billing_customers'; + referencedColumns: ['id']; }, - ] - } - } + ]; + }; + }; Views: { user_account_workspace: { Row: { - id: string | null - name: string | null - picture_url: string | null - public_data: Json | null + id: string | null; + name: string | null; + picture_url: string | null; + public_data: Json | null; subscription_status: - | Database["public"]["Enums"]["subscription_status"] - | null - } - Relationships: [] - } + | Database['public']['Enums']['subscription_status'] + | null; + }; + Relationships: []; + }; user_accounts: { Row: { - id: string | null - name: string | null - picture_url: string | null - role: string | null - slug: string | null - } + id: string | null; + name: string | null; + picture_url: string | null; + role: string | null; + slug: string | null; + }; Relationships: [ { - foreignKeyName: "accounts_memberships_account_role_fkey" - columns: ["role"] - isOneToOne: false - referencedRelation: "roles" - referencedColumns: ["name"] + foreignKeyName: 'accounts_memberships_account_role_fkey'; + columns: ['role']; + isOneToOne: false; + referencedRelation: 'roles'; + referencedColumns: ['name']; }, - ] - } - } + ]; + }; + }; Functions: { accept_invitation: { Args: { - token: string - user_id: string - } - Returns: string - } + token: string; + user_id: string; + }; + Returns: string; + }; add_invitations_to_account: { Args: { - account_slug: string - invitations: Database["public"]["CompositeTypes"]["invitation"][] - } - Returns: Database["public"]["Tables"]["invitations"]["Row"][] - } + account_slug: string; + invitations: Database['public']['CompositeTypes']['invitation'][]; + }; + Returns: Database['public']['Tables']['invitations']['Row'][]; + }; can_action_account_member: { Args: { - target_team_account_id: string - target_user_id: string - } - Returns: boolean - } + target_team_account_id: string; + target_user_id: string; + }; + Returns: boolean; + }; create_invitation: { Args: { - account_id: string - email: string - role: string - } + account_id: string; + email: string; + role: string; + }; Returns: { - account_id: string - created_at: string - email: string - expires_at: string - id: number - invite_token: string - invited_by: string - role: string - updated_at: string - } - } + account_id: string; + created_at: string; + email: string; + expires_at: string; + id: number; + invite_token: string; + invited_by: string; + role: string; + updated_at: string; + }; + }; create_team_account: { Args: { - account_name: string - } + account_name: string; + }; Returns: { - created_at: string | null - created_by: string | null - email: string | null - id: string - is_personal_account: boolean - name: string - picture_url: string | null - primary_owner_user_id: string - public_data: Json - slug: string | null - updated_at: string | null - updated_by: string | null - } - } + created_at: string | null; + created_by: string | null; + email: string | null; + id: string; + is_personal_account: boolean; + name: string; + picture_url: string | null; + primary_owner_user_id: string; + public_data: Json; + slug: string | null; + updated_at: string | null; + updated_by: string | null; + }; + }; get_account_invitations: { Args: { - account_slug: string - } + account_slug: string; + }; Returns: { - id: number - email: string - account_id: string - invited_by: string - role: string - created_at: string - updated_at: string - expires_at: string - inviter_name: string - inviter_email: string - }[] - } + id: number; + email: string; + account_id: string; + invited_by: string; + role: string; + created_at: string; + updated_at: string; + expires_at: string; + inviter_name: string; + inviter_email: string; + }[]; + }; get_account_members: { Args: { - account_slug: string - } + account_slug: string; + }; Returns: { - id: string - user_id: string - account_id: string - role: string - role_hierarchy_level: number - primary_owner_user_id: string - name: string - email: string - picture_url: string - created_at: string - updated_at: string - }[] - } + id: string; + user_id: string; + account_id: string; + role: string; + role_hierarchy_level: number; + primary_owner_user_id: string; + name: string; + email: string; + picture_url: string; + created_at: string; + updated_at: string; + }[]; + }; get_config: { - Args: Record - Returns: Json - } + Args: Record; + Returns: Json; + }; get_upper_system_role: { - Args: Record - Returns: string - } + Args: Record; + Returns: string; + }; has_more_elevated_role: { Args: { - target_user_id: string - target_account_id: string - role_name: string - } - Returns: boolean - } + target_user_id: string; + target_account_id: string; + role_name: string; + }; + Returns: boolean; + }; has_permission: { Args: { - user_id: string - account_id: string - permission_name: Database["public"]["Enums"]["app_permissions"] - } - Returns: boolean - } + user_id: string; + account_id: string; + permission_name: Database['public']['Enums']['app_permissions']; + }; + Returns: boolean; + }; has_role_on_account: { Args: { - account_id: string - account_role?: string - } - Returns: boolean - } + account_id: string; + account_role?: string; + }; + Returns: boolean; + }; has_same_role_hierarchy_level: { Args: { - target_user_id: string - target_account_id: string - role_name: string - } - Returns: boolean - } + target_user_id: string; + target_account_id: string; + role_name: string; + }; + Returns: boolean; + }; is_account_owner: { Args: { - account_id: string - } - Returns: boolean - } + account_id: string; + }; + Returns: boolean; + }; is_set: { Args: { - field_name: string - } - Returns: boolean - } + field_name: string; + }; + Returns: boolean; + }; is_team_member: { Args: { - account_id: string - user_id: string - } - Returns: boolean - } + account_id: string; + user_id: string; + }; + Returns: boolean; + }; team_account_workspace: { Args: { - account_slug: string - } + account_slug: string; + }; Returns: { - id: string - name: string - picture_url: string - slug: string - role: string - role_hierarchy_level: number - primary_owner_user_id: string - subscription_status: Database["public"]["Enums"]["subscription_status"] - permissions: Database["public"]["Enums"]["app_permissions"][] - }[] - } + id: string; + name: string; + picture_url: string; + slug: string; + role: string; + role_hierarchy_level: number; + primary_owner_user_id: string; + subscription_status: Database['public']['Enums']['subscription_status']; + permissions: Database['public']['Enums']['app_permissions'][]; + }[]; + }; transfer_team_account_ownership: { Args: { - target_account_id: string - new_owner_id: string - } - Returns: undefined - } + target_account_id: string; + new_owner_id: string; + }; + Returns: undefined; + }; unaccent: { Args: { - "": string - } - Returns: string - } + '': string; + }; + Returns: string; + }; unaccent_init: { Args: { - "": unknown - } - Returns: unknown - } + '': unknown; + }; + Returns: unknown; + }; upsert_order: { Args: { - target_account_id: string - target_customer_id: string - target_order_id: string - status: Database["public"]["Enums"]["payment_status"] - billing_provider: Database["public"]["Enums"]["billing_provider"] - total_amount: number - currency: string - line_items: Json - } + target_account_id: string; + target_customer_id: string; + target_order_id: string; + status: Database['public']['Enums']['payment_status']; + billing_provider: Database['public']['Enums']['billing_provider']; + total_amount: number; + currency: string; + line_items: Json; + }; Returns: { - account_id: string - billing_customer_id: number - billing_provider: Database["public"]["Enums"]["billing_provider"] - created_at: string - currency: string - id: string - status: Database["public"]["Enums"]["payment_status"] - total_amount: number - updated_at: string - } - } + account_id: string; + billing_customer_id: number; + billing_provider: Database['public']['Enums']['billing_provider']; + created_at: string; + currency: string; + id: string; + status: Database['public']['Enums']['payment_status']; + total_amount: number; + updated_at: string; + }; + }; upsert_subscription: { Args: { - target_account_id: string - target_customer_id: string - target_subscription_id: string - active: boolean - status: Database["public"]["Enums"]["subscription_status"] - billing_provider: Database["public"]["Enums"]["billing_provider"] - cancel_at_period_end: boolean - currency: string - period_starts_at: string - period_ends_at: string - line_items: Json - trial_starts_at?: string - trial_ends_at?: string - } + target_account_id: string; + target_customer_id: string; + target_subscription_id: string; + active: boolean; + status: Database['public']['Enums']['subscription_status']; + billing_provider: Database['public']['Enums']['billing_provider']; + cancel_at_period_end: boolean; + currency: string; + period_starts_at: string; + period_ends_at: string; + line_items: Json; + trial_starts_at?: string; + trial_ends_at?: string; + }; Returns: { - account_id: string - active: boolean - billing_customer_id: number - billing_provider: Database["public"]["Enums"]["billing_provider"] - cancel_at_period_end: boolean - created_at: string - currency: string - id: string - period_ends_at: string - period_starts_at: string - status: Database["public"]["Enums"]["subscription_status"] - trial_ends_at: string | null - trial_starts_at: string | null - updated_at: string - } - } - } + account_id: string; + active: boolean; + billing_customer_id: number; + billing_provider: Database['public']['Enums']['billing_provider']; + cancel_at_period_end: boolean; + created_at: string; + currency: string; + id: string; + period_ends_at: string; + period_starts_at: string; + status: Database['public']['Enums']['subscription_status']; + trial_ends_at: string | null; + trial_starts_at: string | null; + updated_at: string; + }; + }; + }; Enums: { app_permissions: - | "roles.manage" - | "billing.manage" - | "settings.manage" - | "members.manage" - | "invites.manage" - billing_provider: "stripe" | "lemon-squeezy" | "paddle" - payment_status: "pending" | "succeeded" | "failed" - subscription_item_type: "flat" | "per_seat" | "metered" + | 'roles.manage' + | 'billing.manage' + | 'settings.manage' + | 'members.manage' + | 'invites.manage'; + billing_provider: 'stripe' | 'lemon-squeezy' | 'paddle'; + payment_status: 'pending' | 'succeeded' | 'failed'; + subscription_item_type: 'flat' | 'per_seat' | 'metered'; subscription_status: - | "active" - | "trialing" - | "past_due" - | "canceled" - | "unpaid" - | "incomplete" - | "incomplete_expired" - | "paused" - } + | 'active' + | 'trialing' + | 'past_due' + | 'canceled' + | 'unpaid' + | 'incomplete' + | 'incomplete_expired' + | 'paused'; + }; CompositeTypes: { invitation: { - email: string | null - role: string | null - } - } - } + email: string | null; + role: string | null; + }; + }; + }; storage: { Tables: { buckets: { Row: { - allowed_mime_types: string[] | null - avif_autodetection: boolean | null - created_at: string | null - file_size_limit: number | null - id: string - name: string - owner: string | null - owner_id: string | null - public: boolean | null - updated_at: string | null - } + allowed_mime_types: string[] | null; + avif_autodetection: boolean | null; + created_at: string | null; + file_size_limit: number | null; + id: string; + name: string; + owner: string | null; + owner_id: string | null; + public: boolean | null; + updated_at: string | null; + }; Insert: { - allowed_mime_types?: string[] | null - avif_autodetection?: boolean | null - created_at?: string | null - file_size_limit?: number | null - id: string - name: string - owner?: string | null - owner_id?: string | null - public?: boolean | null - updated_at?: string | null - } + allowed_mime_types?: string[] | null; + avif_autodetection?: boolean | null; + created_at?: string | null; + file_size_limit?: number | null; + id: string; + name: string; + owner?: string | null; + owner_id?: string | null; + public?: boolean | null; + updated_at?: string | null; + }; Update: { - allowed_mime_types?: string[] | null - avif_autodetection?: boolean | null - created_at?: string | null - file_size_limit?: number | null - id?: string - name?: string - owner?: string | null - owner_id?: string | null - public?: boolean | null - updated_at?: string | null - } - Relationships: [] - } + allowed_mime_types?: string[] | null; + avif_autodetection?: boolean | null; + created_at?: string | null; + file_size_limit?: number | null; + id?: string; + name?: string; + owner?: string | null; + owner_id?: string | null; + public?: boolean | null; + updated_at?: string | null; + }; + Relationships: []; + }; migrations: { Row: { - executed_at: string | null - hash: string - id: number - name: string - } + executed_at: string | null; + hash: string; + id: number; + name: string; + }; Insert: { - executed_at?: string | null - hash: string - id: number - name: string - } + executed_at?: string | null; + hash: string; + id: number; + name: string; + }; Update: { - executed_at?: string | null - hash?: string - id?: number - name?: string - } - Relationships: [] - } + executed_at?: string | null; + hash?: string; + id?: number; + name?: string; + }; + Relationships: []; + }; objects: { Row: { - bucket_id: string | null - created_at: string | null - id: string - last_accessed_at: string | null - metadata: Json | null - name: string | null - owner: string | null - owner_id: string | null - path_tokens: string[] | null - updated_at: string | null - version: string | null - } + bucket_id: string | null; + created_at: string | null; + id: string; + last_accessed_at: string | null; + metadata: Json | null; + name: string | null; + owner: string | null; + owner_id: string | null; + path_tokens: string[] | null; + updated_at: string | null; + version: string | null; + }; Insert: { - bucket_id?: string | null - created_at?: string | null - id?: string - last_accessed_at?: string | null - metadata?: Json | null - name?: string | null - owner?: string | null - owner_id?: string | null - path_tokens?: string[] | null - updated_at?: string | null - version?: string | null - } + bucket_id?: string | null; + created_at?: string | null; + id?: string; + last_accessed_at?: string | null; + metadata?: Json | null; + name?: string | null; + owner?: string | null; + owner_id?: string | null; + path_tokens?: string[] | null; + updated_at?: string | null; + version?: string | null; + }; Update: { - bucket_id?: string | null - created_at?: string | null - id?: string - last_accessed_at?: string | null - metadata?: Json | null - name?: string | null - owner?: string | null - owner_id?: string | null - path_tokens?: string[] | null - updated_at?: string | null - version?: string | null - } + bucket_id?: string | null; + created_at?: string | null; + id?: string; + last_accessed_at?: string | null; + metadata?: Json | null; + name?: string | null; + owner?: string | null; + owner_id?: string | null; + path_tokens?: string[] | null; + updated_at?: string | null; + version?: string | null; + }; Relationships: [ { - foreignKeyName: "objects_bucketId_fkey" - columns: ["bucket_id"] - isOneToOne: false - referencedRelation: "buckets" - referencedColumns: ["id"] + foreignKeyName: 'objects_bucketId_fkey'; + columns: ['bucket_id']; + isOneToOne: false; + referencedRelation: 'buckets'; + referencedColumns: ['id']; }, - ] - } + ]; + }; s3_multipart_uploads: { Row: { - bucket_id: string - created_at: string - id: string - in_progress_size: number - key: string - owner_id: string | null - upload_signature: string - version: string - } + bucket_id: string; + created_at: string; + id: string; + in_progress_size: number; + key: string; + owner_id: string | null; + upload_signature: string; + version: string; + }; Insert: { - bucket_id: string - created_at?: string - id: string - in_progress_size?: number - key: string - owner_id?: string | null - upload_signature: string - version: string - } + bucket_id: string; + created_at?: string; + id: string; + in_progress_size?: number; + key: string; + owner_id?: string | null; + upload_signature: string; + version: string; + }; Update: { - bucket_id?: string - created_at?: string - id?: string - in_progress_size?: number - key?: string - owner_id?: string | null - upload_signature?: string - version?: string - } + bucket_id?: string; + created_at?: string; + id?: string; + in_progress_size?: number; + key?: string; + owner_id?: string | null; + upload_signature?: string; + version?: string; + }; Relationships: [ { - foreignKeyName: "s3_multipart_uploads_bucket_id_fkey" - columns: ["bucket_id"] - isOneToOne: false - referencedRelation: "buckets" - referencedColumns: ["id"] + foreignKeyName: 's3_multipart_uploads_bucket_id_fkey'; + columns: ['bucket_id']; + isOneToOne: false; + referencedRelation: 'buckets'; + referencedColumns: ['id']; }, - ] - } + ]; + }; s3_multipart_uploads_parts: { Row: { - bucket_id: string - created_at: string - etag: string - id: string - key: string - owner_id: string | null - part_number: number - size: number - upload_id: string - version: string - } + bucket_id: string; + created_at: string; + etag: string; + id: string; + key: string; + owner_id: string | null; + part_number: number; + size: number; + upload_id: string; + version: string; + }; Insert: { - bucket_id: string - created_at?: string - etag: string - id?: string - key: string - owner_id?: string | null - part_number: number - size?: number - upload_id: string - version: string - } + bucket_id: string; + created_at?: string; + etag: string; + id?: string; + key: string; + owner_id?: string | null; + part_number: number; + size?: number; + upload_id: string; + version: string; + }; Update: { - bucket_id?: string - created_at?: string - etag?: string - id?: string - key?: string - owner_id?: string | null - part_number?: number - size?: number - upload_id?: string - version?: string - } + bucket_id?: string; + created_at?: string; + etag?: string; + id?: string; + key?: string; + owner_id?: string | null; + part_number?: number; + size?: number; + upload_id?: string; + version?: string; + }; Relationships: [ { - foreignKeyName: "s3_multipart_uploads_parts_bucket_id_fkey" - columns: ["bucket_id"] - isOneToOne: false - referencedRelation: "buckets" - referencedColumns: ["id"] + foreignKeyName: 's3_multipart_uploads_parts_bucket_id_fkey'; + columns: ['bucket_id']; + isOneToOne: false; + referencedRelation: 'buckets'; + referencedColumns: ['id']; }, { - foreignKeyName: "s3_multipart_uploads_parts_upload_id_fkey" - columns: ["upload_id"] - isOneToOne: false - referencedRelation: "s3_multipart_uploads" - referencedColumns: ["id"] + foreignKeyName: 's3_multipart_uploads_parts_upload_id_fkey'; + columns: ['upload_id']; + isOneToOne: false; + referencedRelation: 's3_multipart_uploads'; + referencedColumns: ['id']; }, - ] - } - } + ]; + }; + }; Views: { - [_ in never]: never - } + [_ in never]: never; + }; Functions: { can_insert_object: { Args: { - bucketid: string - name: string - owner: string - metadata: Json - } - Returns: undefined - } + bucketid: string; + name: string; + owner: string; + metadata: Json; + }; + Returns: undefined; + }; extension: { Args: { - name: string - } - Returns: string - } + name: string; + }; + Returns: string; + }; filename: { Args: { - name: string - } - Returns: string - } + name: string; + }; + Returns: string; + }; foldername: { Args: { - name: string - } - Returns: string[] - } + name: string; + }; + Returns: string[]; + }; get_size_by_bucket: { - Args: Record + Args: Record; Returns: { - size: number - bucket_id: string - }[] - } + size: number; + bucket_id: string; + }[]; + }; list_multipart_uploads_with_delimiter: { Args: { - bucket_id: string - prefix_param: string - delimiter_param: string - max_keys?: number - next_key_token?: string - next_upload_token?: string - } + bucket_id: string; + prefix_param: string; + delimiter_param: string; + max_keys?: number; + next_key_token?: string; + next_upload_token?: string; + }; Returns: { - key: string - id: string - created_at: string - }[] - } + key: string; + id: string; + created_at: string; + }[]; + }; list_objects_with_delimiter: { Args: { - bucket_id: string - prefix_param: string - delimiter_param: string - max_keys?: number - start_after?: string - next_token?: string - } + bucket_id: string; + prefix_param: string; + delimiter_param: string; + max_keys?: number; + start_after?: string; + next_token?: string; + }; Returns: { - name: string - id: string - metadata: Json - updated_at: string - }[] - } + name: string; + id: string; + metadata: Json; + updated_at: string; + }[]; + }; search: { Args: { - prefix: string - bucketname: string - limits?: number - levels?: number - offsets?: number - search?: string - sortcolumn?: string - sortorder?: string - } + prefix: string; + bucketname: string; + limits?: number; + levels?: number; + offsets?: number; + search?: string; + sortcolumn?: string; + sortorder?: string; + }; Returns: { - name: string - id: string - updated_at: string - created_at: string - last_accessed_at: string - metadata: Json - }[] - } - } + name: string; + id: string; + updated_at: string; + created_at: string; + last_accessed_at: string; + metadata: Json; + }[]; + }; + }; Enums: { - [_ in never]: never - } + [_ in never]: never; + }; CompositeTypes: { - [_ in never]: never - } - } -} + [_ in never]: never; + }; + }; +}; -type PublicSchema = Database[Extract] +type PublicSchema = Database[Extract]; export type Tables< PublicTableNameOrOptions extends - | keyof (PublicSchema["Tables"] & PublicSchema["Views"]) + | keyof (PublicSchema['Tables'] & PublicSchema['Views']) | { schema: keyof Database }, TableName extends PublicTableNameOrOptions extends { schema: keyof Database } - ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] & - Database[PublicTableNameOrOptions["schema"]]["Views"]) + ? keyof (Database[PublicTableNameOrOptions['schema']]['Tables'] & + Database[PublicTableNameOrOptions['schema']]['Views']) : never = never, > = PublicTableNameOrOptions extends { schema: keyof Database } - ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] & - Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends { - Row: infer R + ? (Database[PublicTableNameOrOptions['schema']]['Tables'] & + Database[PublicTableNameOrOptions['schema']]['Views'])[TableName] extends { + Row: infer R; } ? R : never - : PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] & - PublicSchema["Views"]) - ? (PublicSchema["Tables"] & - PublicSchema["Views"])[PublicTableNameOrOptions] extends { - Row: infer R + : PublicTableNameOrOptions extends keyof (PublicSchema['Tables'] & + PublicSchema['Views']) + ? (PublicSchema['Tables'] & + PublicSchema['Views'])[PublicTableNameOrOptions] extends { + Row: infer R; } ? R : never - : never + : never; export type TablesInsert< PublicTableNameOrOptions extends - | keyof PublicSchema["Tables"] + | keyof PublicSchema['Tables'] | { schema: keyof Database }, TableName extends PublicTableNameOrOptions extends { schema: keyof Database } - ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] + ? keyof Database[PublicTableNameOrOptions['schema']]['Tables'] : never = never, > = PublicTableNameOrOptions extends { schema: keyof Database } - ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Insert: infer I + ? Database[PublicTableNameOrOptions['schema']]['Tables'][TableName] extends { + Insert: infer I; } ? I : never - : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] - ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { - Insert: infer I + : PublicTableNameOrOptions extends keyof PublicSchema['Tables'] + ? PublicSchema['Tables'][PublicTableNameOrOptions] extends { + Insert: infer I; } ? I : never - : never + : never; export type TablesUpdate< PublicTableNameOrOptions extends - | keyof PublicSchema["Tables"] + | keyof PublicSchema['Tables'] | { schema: keyof Database }, TableName extends PublicTableNameOrOptions extends { schema: keyof Database } - ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] + ? keyof Database[PublicTableNameOrOptions['schema']]['Tables'] : never = never, > = PublicTableNameOrOptions extends { schema: keyof Database } - ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Update: infer U + ? Database[PublicTableNameOrOptions['schema']]['Tables'][TableName] extends { + Update: infer U; } ? U : never - : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] - ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { - Update: infer U + : PublicTableNameOrOptions extends keyof PublicSchema['Tables'] + ? PublicSchema['Tables'][PublicTableNameOrOptions] extends { + Update: infer U; } ? U : never - : never + : never; export type Enums< PublicEnumNameOrOptions extends - | keyof PublicSchema["Enums"] + | keyof PublicSchema['Enums'] | { schema: keyof Database }, EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database } - ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"] + ? keyof Database[PublicEnumNameOrOptions['schema']]['Enums'] : never = never, > = PublicEnumNameOrOptions extends { schema: keyof Database } - ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName] - : PublicEnumNameOrOptions extends keyof PublicSchema["Enums"] - ? PublicSchema["Enums"][PublicEnumNameOrOptions] - : never - + ? Database[PublicEnumNameOrOptions['schema']]['Enums'][EnumName] + : PublicEnumNameOrOptions extends keyof PublicSchema['Enums'] + ? PublicSchema['Enums'][PublicEnumNameOrOptions] + : never; diff --git a/turbo/generators/templates/package.json.hbs b/turbo/generators/templates/package.json.hbs index c640ee0fb..4f48a683c 100644 --- a/turbo/generators/templates/package.json.hbs +++ b/turbo/generators/templates/package.json.hbs @@ -3,7 +3,7 @@ "private": true, "version": "0.1.0", "exports": { - ".": "./index.ts" + ".": "./server.ts" }, "typesVersions": { "*": {