From 48f1ee90c46944b220ea3c1700613b7dbddad794 Mon Sep 17 00:00:00 2001 From: giancarlo Date: Thu, 11 Apr 2024 12:31:08 +0800 Subject: [PATCH] Update Supabase clients and refactor codebase Refactored several Supabase client functions and updated them to use generics. Also, the '@kit/supabase-config' package was removed from the project and all references were replaced accordingly. The project's dependencies were updated as well, including the Supabase package which was upgraded to the latest version. --- .../_lib/server/user-billing.service.ts | 2 +- .../_lib/server/team-billing.service.ts | 4 +- .../home/[account]/members/page.tsx | 2 +- .../home/_lib/load-user-workspace.ts | 4 +- apps/web/lib/database.types.ts | 1220 +++++++++++++++++ apps/web/package.json | 17 +- {supabase => apps/web/supabase}/.gitignore | 0 {supabase => apps/web/supabase}/config.toml | 0 .../migrations/20221215192558_schema.sql | 0 .../migrations/20240319163440_roles-seed.sql | 0 {supabase => apps/web/supabase}/seed.sql | 0 .../supabase}/tests/database/00000-dbdev.sql | 0 .../tests/database/00000-makerkit-helpers.sql | 0 .../database/account-permissions.test.sql | 0 .../tests/database/account-slug.test.sql | 0 .../create-organization-accounts.test.sql | 0 .../tests/database/personal-accounts.test.sql | 0 .../supabase}/tests/database/schema.test.sql | 0 package.json | 14 +- .../billing-gateway-provider-factory.ts | 3 +- .../supabase/src/clients/browser.client.ts | 18 +- .../src/clients/server-actions.client.ts | 12 +- .../src/clients/server-component.client.ts | 10 +- pnpm-lock.yaml | 59 +- pnpm-workspace.yaml | 3 +- supabase/package.json | 18 - tooling/eslint/apps.js | 29 + tooling/eslint/base.js | 12 + tooling/eslint/package.json | 6 +- 29 files changed, 1337 insertions(+), 96 deletions(-) create mode 100644 apps/web/lib/database.types.ts rename {supabase => apps/web/supabase}/.gitignore (100%) rename {supabase => apps/web/supabase}/config.toml (100%) rename {supabase => apps/web/supabase}/migrations/20221215192558_schema.sql (100%) rename {supabase => apps/web/supabase}/migrations/20240319163440_roles-seed.sql (100%) rename {supabase => apps/web/supabase}/seed.sql (100%) rename {supabase => apps/web/supabase}/tests/database/00000-dbdev.sql (100%) rename {supabase => apps/web/supabase}/tests/database/00000-makerkit-helpers.sql (100%) rename {supabase => apps/web/supabase}/tests/database/account-permissions.test.sql (100%) rename {supabase => apps/web/supabase}/tests/database/account-slug.test.sql (100%) rename {supabase => apps/web/supabase}/tests/database/create-organization-accounts.test.sql (100%) rename {supabase => apps/web/supabase}/tests/database/personal-accounts.test.sql (100%) rename {supabase => apps/web/supabase}/tests/database/schema.test.sql (100%) delete mode 100644 supabase/package.json create mode 100644 tooling/eslint/apps.js diff --git a/apps/web/app/(dashboard)/home/(user)/billing/_lib/server/user-billing.service.ts b/apps/web/app/(dashboard)/home/(user)/billing/_lib/server/user-billing.service.ts index 25f16f32b..de3d640e0 100644 --- a/apps/web/app/(dashboard)/home/(user)/billing/_lib/server/user-billing.service.ts +++ b/apps/web/app/(dashboard)/home/(user)/billing/_lib/server/user-billing.service.ts @@ -7,7 +7,6 @@ import { z } from 'zod'; import { getProductPlanPair } from '@kit/billing'; import { getBillingGatewayProvider } from '@kit/billing-gateway'; import { getLogger } from '@kit/shared/logger'; -import { Database } from '@kit/supabase/database'; import { requireUser } from '@kit/supabase/require-user'; import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client'; @@ -15,6 +14,7 @@ import { PersonalAccountCheckoutSchema } from '~/(dashboard)/home/(user)/billing import appConfig from '~/config/app.config'; import billingConfig from '~/config/billing.config'; import pathsConfig from '~/config/paths.config'; +import { Database } from '~/lib/database.types'; export class UserBillingService { private readonly namespace = 'billing.personal-account'; diff --git a/apps/web/app/(dashboard)/home/[account]/_lib/server/team-billing.service.ts b/apps/web/app/(dashboard)/home/[account]/_lib/server/team-billing.service.ts index ad18f54f9..33728e39d 100644 --- a/apps/web/app/(dashboard)/home/[account]/_lib/server/team-billing.service.ts +++ b/apps/web/app/(dashboard)/home/[account]/_lib/server/team-billing.service.ts @@ -7,13 +7,13 @@ import { z } from 'zod'; import { LineItemSchema } from '@kit/billing'; import { getBillingGatewayProvider } from '@kit/billing-gateway'; import { getLogger } from '@kit/shared/logger'; -import { Database } from '@kit/supabase/database'; import { requireUser } from '@kit/supabase/require-user'; import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client'; import appConfig from '~/config/app.config'; import billingConfig from '~/config/billing.config'; import pathsConfig from '~/config/paths.config'; +import { Database } from '~/lib/database.types'; import { TeamCheckoutSchema } from '../../_lib/schema/team-billing.schema'; @@ -314,7 +314,7 @@ async function getBillingPermissionsForAccountId( * customer ID for the provided account ID */ async function getCustomerIdFromAccountId( - client: ReturnType, + client: ReturnType>, accountId: string, ) { const { data, error } = await client diff --git a/apps/web/app/(dashboard)/home/[account]/members/page.tsx b/apps/web/app/(dashboard)/home/[account]/members/page.tsx index 7f892fd8b..6924624eb 100644 --- a/apps/web/app/(dashboard)/home/[account]/members/page.tsx +++ b/apps/web/app/(dashboard)/home/[account]/members/page.tsx @@ -2,7 +2,6 @@ import { SupabaseClient } from '@supabase/supabase-js'; import { PlusCircle } from 'lucide-react'; -import { Database } from '@kit/supabase/database'; import { getSupabaseServerComponentClient } from '@kit/supabase/server-component-client'; import { AccountInvitationsTable, @@ -21,6 +20,7 @@ import { If } from '@kit/ui/if'; import { PageBody, PageHeader } from '@kit/ui/page'; import { Trans } from '@kit/ui/trans'; +import { Database } from '~/lib/database.types'; import { createI18nServerInstance } from '~/lib/i18n/i18n.server'; import { withI18n } from '~/lib/i18n/with-i18n'; diff --git a/apps/web/app/(dashboard)/home/_lib/load-user-workspace.ts b/apps/web/app/(dashboard)/home/_lib/load-user-workspace.ts index 56381fc96..512730295 100644 --- a/apps/web/app/(dashboard)/home/_lib/load-user-workspace.ts +++ b/apps/web/app/(dashboard)/home/_lib/load-user-workspace.ts @@ -2,6 +2,8 @@ import { cache } from 'react'; import { getSupabaseServerComponentClient } from '@kit/supabase/server-component-client'; +import { Database } from '~/lib/database.types'; + export const loadUserWorkspace = cache(async () => { const client = getSupabaseServerComponentClient(); @@ -15,7 +17,7 @@ export const loadUserWorkspace = cache(async () => { }); async function loadUserAccounts( - client: ReturnType, + client: ReturnType>, ) { const { data: accounts, error } = await client .from('user_accounts') diff --git a/apps/web/lib/database.types.ts b/apps/web/lib/database.types.ts new file mode 100644 index 000000000..2c4c1d071 --- /dev/null +++ b/apps/web/lib/database.types.ts @@ -0,0 +1,1220 @@ +export type Json = + | string + | number + | boolean + | null + | { [key: string]: Json | undefined } + | Json[]; + +export type Database = { + graphql_public: { + Tables: { + [_ in never]: never; + }; + Views: { + [_ in never]: never; + }; + Functions: { + graphql: { + Args: { + operationName?: string; + query?: string; + variables?: Json; + extensions?: Json; + }; + Returns: Json; + }; + }; + Enums: { + [_ in never]: never; + }; + CompositeTypes: { + [_ in never]: never; + }; + }; + public: { + Tables: { + account_roles: { + Row: { + account_id: string; + id: number; + role: string; + }; + Insert: { + account_id: string; + id?: number; + role: string; + }; + Update: { + account_id?: string; + id?: number; + role?: string; + }; + Relationships: [ + { + foreignKeyName: 'account_roles_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'accounts'; + referencedColumns: ['id']; + }, + { + foreignKeyName: 'account_roles_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_account_workspace'; + referencedColumns: ['id']; + }, + { + foreignKeyName: 'account_roles_account_id_fkey'; + columns: ['account_id']; + isOneToOne: false; + referencedRelation: 'user_accounts'; + referencedColumns: ['id']; + }, + { + foreignKeyName: 'account_roles_role_fkey'; + columns: ['role']; + isOneToOne: false; + referencedRelation: 'roles'; + referencedColumns: ['name']; + }, + ]; + }; + 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; + 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; + 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; + 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_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']; + }, + ]; + }; + 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; + }; + Insert: { + 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; + }; + 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: '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_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_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']; + }, + ]; + }; + billing_customers: { + Row: { + 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']; + }; + Update: { + 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: 'user_account_workspace'; + 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; + }; + Insert: { + 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: []; + }; + 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; + }; + 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; + }; + 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; + }; + 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: 'user_account_workspace'; + 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_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; + }; + Insert: { + 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; + }; + Relationships: [ + { + 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; + }; + 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; + }; + 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; + }; + 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: 'user_account_workspace'; + 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']; + }, + ]; + }; + role_permissions: { + Row: { + id: number; + permission: Database['public']['Enums']['app_permissions']; + role: string; + }; + Insert: { + id?: number; + permission: Database['public']['Enums']['app_permissions']; + role: string; + }; + Update: { + id?: number; + permission?: Database['public']['Enums']['app_permissions']; + role?: string; + }; + Relationships: [ + { + foreignKeyName: 'role_permissions_role_fkey'; + columns: ['role']; + isOneToOne: false; + referencedRelation: 'roles'; + referencedColumns: ['name']; + }, + ]; + }; + roles: { + Row: { + account_id: string | null; + hierarchy_level: number; + name: string; + }; + Insert: { + account_id?: string | null; + hierarchy_level: number; + name: string; + }; + Update: { + 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: 'user_account_workspace'; + 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; + }; + 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; + }; + 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; + }; + Relationships: [ + { + 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; + }; + 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; + }; + 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; + }; + 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: 'user_account_workspace'; + 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']; + }, + ]; + }; + }; + Views: { + user_account_workspace: { + Row: { + id: string | null; + name: string | null; + picture_url: string | null; + subscription_status: + | 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; + }; + Relationships: [ + { + 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; + }; + add_invitations_to_account: { + Args: { + account_slug: string; + invitations: unknown[]; + }; + Returns: Database['public']['Tables']['invitations']['Row'][]; + }; + create_account: { + Args: { + 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; + slug: string | null; + updated_at: string | null; + updated_by: string | null; + }; + }; + create_invitation: { + Args: { + 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; + }; + }; + get_account_invitations: { + Args: { + 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; + }[]; + }; + get_account_members: { + Args: { + 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; + }[]; + }; + get_config: { + Args: Record; + Returns: Json; + }; + get_user_accounts: { + Args: Record; + 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; + slug: string | null; + updated_at: string | null; + updated_by: string | null; + }[]; + }; + has_more_elevated_role: { + Args: { + 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; + }; + has_role_on_account: { + Args: { + account_id: string; + account_role?: string; + }; + Returns: boolean; + }; + is_account_owner: { + Args: { + account_id: string; + }; + Returns: boolean; + }; + is_set: { + Args: { + field_name: string; + }; + Returns: boolean; + }; + is_team_member: { + Args: { + account_id: string; + user_id: string; + }; + Returns: boolean; + }; + organization_account_workspace: { + Args: { + 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'][]; + }[]; + }; + transfer_team_account_ownership: { + Args: { + target_account_id: string; + new_owner_id: string; + }; + Returns: undefined; + }; + unaccent: { + Args: { + '': string; + }; + Returns: string; + }; + unaccent_init: { + Args: { + '': 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; + }; + 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; + }; + }; + 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; + }; + 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; + }; + }; + }; + 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: 'base' | 'per_seat' | 'metered'; + subscription_status: + | 'active' + | 'trialing' + | 'past_due' + | 'canceled' + | 'unpaid' + | 'incomplete' + | 'incomplete_expired' + | 'paused'; + }; + CompositeTypes: { + [_ in never]: never; + }; + }; + 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; + }; + 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; + }; + 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: []; + }; + migrations: { + Row: { + executed_at: string | null; + hash: string; + id: number; + name: string; + }; + Insert: { + executed_at?: string | null; + hash: string; + id: number; + name: string; + }; + Update: { + 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; + }; + 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; + }; + 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; + }; + Relationships: [ + { + foreignKeyName: 'objects_bucketId_fkey'; + columns: ['bucket_id']; + isOneToOne: false; + referencedRelation: 'buckets'; + referencedColumns: ['id']; + }, + ]; + }; + }; + Views: { + [_ in never]: never; + }; + Functions: { + can_insert_object: { + Args: { + bucketid: string; + name: string; + owner: string; + metadata: Json; + }; + Returns: undefined; + }; + extension: { + Args: { + name: string; + }; + Returns: string; + }; + filename: { + Args: { + name: string; + }; + Returns: string; + }; + foldername: { + Args: { + name: string; + }; + Returns: string[]; + }; + get_size_by_bucket: { + Args: Record; + Returns: { + size: number; + bucket_id: string; + }[]; + }; + search: { + Args: { + 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; + }[]; + }; + }; + Enums: { + [_ in never]: never; + }; + CompositeTypes: { + [_ in never]: never; + }; + }; +}; + +type PublicSchema = Database[Extract]; + +export type Tables< + PublicTableNameOrOptions extends + | keyof (PublicSchema['Tables'] & PublicSchema['Views']) + | { schema: keyof Database }, + TableName extends PublicTableNameOrOptions extends { schema: keyof Database } + ? 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; + } + ? R + : never + : PublicTableNameOrOptions extends keyof (PublicSchema['Tables'] & + PublicSchema['Views']) + ? (PublicSchema['Tables'] & + PublicSchema['Views'])[PublicTableNameOrOptions] extends { + Row: infer R; + } + ? R + : never + : never; + +export type TablesInsert< + PublicTableNameOrOptions extends + | keyof PublicSchema['Tables'] + | { schema: keyof Database }, + TableName extends PublicTableNameOrOptions extends { schema: keyof Database } + ? keyof Database[PublicTableNameOrOptions['schema']]['Tables'] + : never = never, +> = PublicTableNameOrOptions extends { schema: keyof Database } + ? Database[PublicTableNameOrOptions['schema']]['Tables'][TableName] extends { + Insert: infer I; + } + ? I + : never + : PublicTableNameOrOptions extends keyof PublicSchema['Tables'] + ? PublicSchema['Tables'][PublicTableNameOrOptions] extends { + Insert: infer I; + } + ? I + : never + : never; + +export type TablesUpdate< + PublicTableNameOrOptions extends + | keyof PublicSchema['Tables'] + | { schema: keyof Database }, + TableName extends PublicTableNameOrOptions extends { schema: keyof Database } + ? keyof Database[PublicTableNameOrOptions['schema']]['Tables'] + : never = never, +> = PublicTableNameOrOptions extends { schema: keyof Database } + ? Database[PublicTableNameOrOptions['schema']]['Tables'][TableName] extends { + Update: infer U; + } + ? U + : never + : PublicTableNameOrOptions extends keyof PublicSchema['Tables'] + ? PublicSchema['Tables'][PublicTableNameOrOptions] extends { + Update: infer U; + } + ? U + : never + : never; + +export type Enums< + PublicEnumNameOrOptions extends + | keyof PublicSchema['Enums'] + | { schema: keyof Database }, + EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database } + ? 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; diff --git a/apps/web/package.json b/apps/web/package.json index 2ed40e503..77747c0ec 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -13,7 +13,17 @@ "format": "prettier --check \"**/*.{js,cjs,mjs,ts,tsx,md,json}\"", "start": "pnpm with-env next start", "typecheck": "tsc --noEmit", - "with-env": "dotenv -e ./.env.local --" + "with-env": "dotenv -e ./.env.local --", + "supabase:dev": "supabase status || supabase start", + "supabase:stop": "supabase stop", + "supabase:reset": "supabase db reset || supabase start", + "supabase:status": "supabase status", + "supabase:test": "supabase db test", + "supabase:db:lint": "supabase db lint", + "supabase:deploy": "supabase link --project-ref $SUPABASE_PROJECT_REF && supabase db push", + "supabase:typegen": "pnpm run supabase:typegen:packages && pnpm run supabase:typegen:app", + "supabase:typegen:packages": "supabase gen types typescript --local > ../../packages/supabase/src/database.types.ts", + "supabase:typegen:app": "supabase gen types typescript --local > ./lib/database.types.ts" }, "dependencies": { "@epic-web/invariant": "^1.0.0", @@ -38,7 +48,6 @@ "@makerkit/data-loader-supabase-nextjs": "^0.0.9", "@marsidev/react-turnstile": "^0.5.4", "@radix-ui/react-icons": "^1.3.0", - "@supabase/ssr": "^0.3.0", "@supabase/supabase-js": "^2.42.0", "@tanstack/react-query": "5.28.6", "@tanstack/react-query-next-experimental": "^5.29.0", @@ -73,6 +82,7 @@ "dotenv-cli": "^7.4.1", "eslint": "^8.57.0", "prettier": "^3.2.5", + "supabase": "^1.153.4", "tailwindcss": "3.4.1", "typescript": "^5.4.3" }, @@ -81,7 +91,8 @@ "extends": [ "@kit/eslint-config/base", "@kit/eslint-config/nextjs", - "@kit/eslint-config/react" + "@kit/eslint-config/react", + "@kit/eslint-config/apps" ] }, "prettier": "@kit/prettier-config" diff --git a/supabase/.gitignore b/apps/web/supabase/.gitignore similarity index 100% rename from supabase/.gitignore rename to apps/web/supabase/.gitignore diff --git a/supabase/config.toml b/apps/web/supabase/config.toml similarity index 100% rename from supabase/config.toml rename to apps/web/supabase/config.toml diff --git a/supabase/migrations/20221215192558_schema.sql b/apps/web/supabase/migrations/20221215192558_schema.sql similarity index 100% rename from supabase/migrations/20221215192558_schema.sql rename to apps/web/supabase/migrations/20221215192558_schema.sql diff --git a/supabase/migrations/20240319163440_roles-seed.sql b/apps/web/supabase/migrations/20240319163440_roles-seed.sql similarity index 100% rename from supabase/migrations/20240319163440_roles-seed.sql rename to apps/web/supabase/migrations/20240319163440_roles-seed.sql diff --git a/supabase/seed.sql b/apps/web/supabase/seed.sql similarity index 100% rename from supabase/seed.sql rename to apps/web/supabase/seed.sql diff --git a/supabase/tests/database/00000-dbdev.sql b/apps/web/supabase/tests/database/00000-dbdev.sql similarity index 100% rename from supabase/tests/database/00000-dbdev.sql rename to apps/web/supabase/tests/database/00000-dbdev.sql diff --git a/supabase/tests/database/00000-makerkit-helpers.sql b/apps/web/supabase/tests/database/00000-makerkit-helpers.sql similarity index 100% rename from supabase/tests/database/00000-makerkit-helpers.sql rename to apps/web/supabase/tests/database/00000-makerkit-helpers.sql diff --git a/supabase/tests/database/account-permissions.test.sql b/apps/web/supabase/tests/database/account-permissions.test.sql similarity index 100% rename from supabase/tests/database/account-permissions.test.sql rename to apps/web/supabase/tests/database/account-permissions.test.sql diff --git a/supabase/tests/database/account-slug.test.sql b/apps/web/supabase/tests/database/account-slug.test.sql similarity index 100% rename from supabase/tests/database/account-slug.test.sql rename to apps/web/supabase/tests/database/account-slug.test.sql diff --git a/supabase/tests/database/create-organization-accounts.test.sql b/apps/web/supabase/tests/database/create-organization-accounts.test.sql similarity index 100% rename from supabase/tests/database/create-organization-accounts.test.sql rename to apps/web/supabase/tests/database/create-organization-accounts.test.sql diff --git a/supabase/tests/database/personal-accounts.test.sql b/apps/web/supabase/tests/database/personal-accounts.test.sql similarity index 100% rename from supabase/tests/database/personal-accounts.test.sql rename to apps/web/supabase/tests/database/personal-accounts.test.sql diff --git a/supabase/tests/database/schema.test.sql b/apps/web/supabase/tests/database/schema.test.sql similarity index 100% rename from supabase/tests/database/schema.test.sql rename to apps/web/supabase/tests/database/schema.test.sql diff --git a/package.json b/package.json index 317f629e6..28f9cbb5c 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,10 @@ "engines": { "node": ">=v18.17.1" }, + "author": { + "url": "https://makerkit.dev", + "name": "MakerKit" + }, "scripts": { "build": "turbo build", "clean": "git clean -xdf node_modules dist .next", @@ -15,20 +19,14 @@ "lint": "turbo lint --continue -- --cache --cache-location 'node_modules/.cache/.eslintcache' && manypkg check", "lint:fix": "turbo lint --continue -- --fix --cache --cache-location 'node_modules/.cache/.eslintcache' && manypkg fix", "typecheck": "turbo typecheck", - "stripe:listen": "pnpm --filter '@kit/stripe' start", - "supabase:start": "turbo dev --filter @kit/supabase-config", - "supabase:stop": "pnpm --filter '@kit/supabase-config' stop", - "supabase:reset": "pnpm --filter '@kit/supabase-config' reset", - "supabase:lint": "pnpm --filter '@kit/supabase-config' lint", - "supabase:typegen": "pnpm --filter '@kit/supabase-config' typegen" + "stripe:listen": "pnpm --filter '@kit/stripe' start" }, "prettier": "@kit/prettier-config", "packageManager": "pnpm@8.15.5", "workspaces": [ "apps/*", "packages/**", - "tooling/*", - "supabase" + "tooling/*" ], "dependencies": { "@manypkg/cli": "^0.21.3", diff --git a/packages/billing/gateway/src/server/services/billing-gateway/billing-gateway-provider-factory.ts b/packages/billing/gateway/src/server/services/billing-gateway/billing-gateway-provider-factory.ts index ff3708132..65e0dd2ab 100644 --- a/packages/billing/gateway/src/server/services/billing-gateway/billing-gateway-provider-factory.ts +++ b/packages/billing/gateway/src/server/services/billing-gateway/billing-gateway-provider-factory.ts @@ -1,5 +1,6 @@ import 'server-only'; +import { Database } from '@kit/supabase/database'; import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client'; import { BillingGatewayService } from './billing-gateway.service'; @@ -18,7 +19,7 @@ export async function getBillingGatewayProvider( } async function getBillingProvider( - client: ReturnType, + client: ReturnType>, ) { const { data, error } = await client .from('config') diff --git a/packages/supabase/src/clients/browser.client.ts b/packages/supabase/src/clients/browser.client.ts index 331c0d955..8215b46f0 100644 --- a/packages/supabase/src/clients/browser.client.ts +++ b/packages/supabase/src/clients/browser.client.ts @@ -1,24 +1,18 @@ -import { SupabaseClient } from '@supabase/supabase-js'; - import { invariant } from '@epic-web/invariant'; import { createBrowserClient } from '@supabase/ssr'; import { Database } from '../database.types'; -let client: SupabaseClient; - -export function getSupabaseBrowserClient() { +/** + * @name getSupabaseBrowserClient + * @description Get a Supabase client for use in the Browser + */ +export function getSupabaseBrowserClient() { const SUPABASE_URL = process.env.NEXT_PUBLIC_SUPABASE_URL; const SUPABASE_ANON_KEY = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY; invariant(SUPABASE_URL, `Supabase URL was not provided`); invariant(SUPABASE_ANON_KEY, `Supabase Anon key was not provided`); - if (client) { - return client; - } - - client = createBrowserClient(SUPABASE_URL, SUPABASE_ANON_KEY); - - return client; + return createBrowserClient(SUPABASE_URL, SUPABASE_ANON_KEY); } diff --git a/packages/supabase/src/clients/server-actions.client.ts b/packages/supabase/src/clients/server-actions.client.ts index 737a26798..8d24749b1 100644 --- a/packages/supabase/src/clients/server-actions.client.ts +++ b/packages/supabase/src/clients/server-actions.client.ts @@ -7,15 +7,17 @@ import { createServerClient } from '@supabase/ssr'; import { Database } from '../database.types'; import { getSupabaseClientKeys } from '../get-supabase-client-keys'; -const createServerSupabaseClient = () => { +function createServerSupabaseClient() { const keys = getSupabaseClientKeys(); return createServerClient(keys.url, keys.anonKey, { cookies: getCookiesStrategy(), }); -}; +} -export const getSupabaseServerActionClient = (params?: { admin: boolean }) => { +export function getSupabaseServerActionClient< + GenericSchema = Database, +>(params?: { admin: boolean }) { const keys = getSupabaseClientKeys(); const admin = params?.admin ?? false; @@ -32,7 +34,7 @@ export const getSupabaseServerActionClient = (params?: { admin: boolean }) => { throw new Error('Supabase Service Role Key not provided'); } - return createServerClient(keys.url, serviceRoleKey, { + return createServerClient(keys.url, serviceRoleKey, { auth: { persistSession: false, }, @@ -41,7 +43,7 @@ export const getSupabaseServerActionClient = (params?: { admin: boolean }) => { } return createServerSupabaseClient(); -}; +} function getCookiesStrategy() { const cookieStore = cookies(); diff --git a/packages/supabase/src/clients/server-component.client.ts b/packages/supabase/src/clients/server-component.client.ts index 91278f905..7aa44387c 100644 --- a/packages/supabase/src/clients/server-component.client.ts +++ b/packages/supabase/src/clients/server-component.client.ts @@ -11,11 +11,11 @@ import { getSupabaseClientKeys } from '../get-supabase-client-keys'; * @name getSupabaseServerComponentClient * @description Get a Supabase client for use in the Server Components */ -export const getSupabaseServerComponentClient = ( +export function getSupabaseServerComponentClient( params = { admin: false, }, -) => { +) { const keys = getSupabaseClientKeys(); if (params.admin) { @@ -31,7 +31,7 @@ export const getSupabaseServerComponentClient = ( throw new Error('Supabase Service Role Key not provided'); } - return createServerClient(keys.url, serviceRoleKey, { + return createServerClient(keys.url, serviceRoleKey, { auth: { persistSession: false, }, @@ -39,10 +39,10 @@ export const getSupabaseServerComponentClient = ( }); } - return createServerClient(keys.url, keys.anonKey, { + return createServerClient(keys.url, keys.anonKey, { cookies: getCookiesStrategy(), }); -}; +} function getCookiesStrategy() { const cookieStore = cookies(); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 49c51746c..dbbe7ec34 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -101,9 +101,6 @@ importers: '@radix-ui/react-icons': specifier: ^1.3.0 version: 1.3.0(react@18.2.0) - '@supabase/ssr': - specifier: ^0.3.0 - version: 0.3.0(@supabase/supabase-js@2.42.0) '@supabase/supabase-js': specifier: ^2.42.0 version: 2.42.0 @@ -201,6 +198,9 @@ importers: prettier: specifier: ^3.2.5 version: 3.2.5 + supabase: + specifier: ^1.153.4 + version: 1.153.4 tailwindcss: specifier: 3.4.1 version: 3.4.1 @@ -1173,12 +1173,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 - supabase: - dependencies: - supabase: - specifier: ^1.151.1 - version: 1.151.1 - tooling/eslint: dependencies: '@next/eslint-plugin-next': @@ -6455,6 +6449,7 @@ packages: '@supabase/supabase-js': 2.42.0 cookie: 0.5.0 ramda: 0.29.1 + dev: true /@supabase/storage-js@2.5.5: resolution: {integrity: sha512-OpLoDRjFwClwc2cjTJZG8XviTiQH4Ik8sCiMK5v7et0MDu2QlXjCAW3ljxJB5+z/KazdMOTnySi+hysxWUPu3w==} @@ -7388,7 +7383,6 @@ packages: debug: 4.3.4 transitivePeerDependencies: - supports-color - dev: false /aggregate-error@3.1.0: resolution: {integrity: sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==} @@ -7686,7 +7680,7 @@ packages: npm-normalize-package-bin: 3.0.1 read-cmd-shim: 4.0.0 write-file-atomic: 5.0.1 - dev: false + dev: true /binary-extensions@2.3.0: resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} @@ -7911,7 +7905,7 @@ packages: /chownr@2.0.0: resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} engines: {node: '>=10'} - dev: false + dev: true /chrome-trace-event@1.0.3: resolution: {integrity: sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==} @@ -7985,7 +7979,7 @@ packages: /cmd-shim@6.0.2: resolution: {integrity: sha512-+FFYbB0YLaAkhkcrjkyNLYDiOsFSfRjwjY19LXk/psmMx1z00xlCv7hhQoTGXXIKi+YXHL/iiFo8NqMVQX9nOw==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - dev: false + dev: true /cmdk@1.0.0(@types/react-dom@18.2.24)(@types/react@18.2.75)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-gDzVf0a09TvoJ5jnuPvygTB77+XdOSwEmJ88L6XPFPlv7T3RxbP9jgenfylrAMD0+Le1aO0nVjQUzl2g+vjz5Q==} @@ -8231,7 +8225,7 @@ packages: /data-uri-to-buffer@4.0.1: resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==} engines: {node: '>= 12'} - dev: false + dev: true /data-uri-to-buffer@6.0.2: resolution: {integrity: sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw==} @@ -9163,7 +9157,7 @@ packages: dependencies: node-domexception: 1.0.0 web-streams-polyfill: 3.3.3 - dev: false + dev: true /figures@3.2.0: resolution: {integrity: sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==} @@ -9262,7 +9256,7 @@ packages: engines: {node: '>=12.20.0'} dependencies: fetch-blob: 3.2.0 - dev: false + dev: true /fraction.js@4.3.7: resolution: {integrity: sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==} @@ -9317,7 +9311,7 @@ packages: engines: {node: '>= 8'} dependencies: minipass: 3.3.6 - dev: false + dev: true /fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} @@ -9702,7 +9696,6 @@ packages: debug: 4.3.4 transitivePeerDependencies: - supports-color - dev: false /human-signals@2.1.0: resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} @@ -11096,12 +11089,12 @@ packages: engines: {node: '>=8'} dependencies: yallist: 4.0.0 - dev: false + dev: true /minipass@5.0.0: resolution: {integrity: sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==} engines: {node: '>=8'} - dev: false + dev: true /minipass@7.0.4: resolution: {integrity: sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==} @@ -11113,7 +11106,7 @@ packages: dependencies: minipass: 3.3.6 yallist: 4.0.0 - dev: false + dev: true /mkdirp@0.5.6: resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==} @@ -11126,7 +11119,7 @@ packages: resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==} engines: {node: '>=10'} hasBin: true - dev: false + dev: true /module-details-from-path@1.0.3: resolution: {integrity: sha512-ySViT69/76t8VhE1xXHK6Ch4NcDd26gx0MzKXLO+F7NOtnqH68d9zF94nT8ZWSxXh8ELOERsnJO/sWt1xZYw5A==} @@ -11335,7 +11328,7 @@ packages: /node-domexception@1.0.0: resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} engines: {node: '>=10.5.0'} - dev: false + dev: true /node-fetch@2.7.0: resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==} @@ -11356,7 +11349,7 @@ packages: data-uri-to-buffer: 4.0.1 fetch-blob: 3.2.0 formdata-polyfill: 4.0.10 - dev: false + dev: true /node-plop@0.26.3: resolution: {integrity: sha512-Cov028YhBZ5aB7MdMWJEmwyBig43aGL5WT4vdoB28Oitau1zZAcHUn8Sgfk9HM33TqhtLJ9PlM/O0Mv+QpV/4Q==} @@ -11407,7 +11400,7 @@ packages: /npm-normalize-package-bin@3.0.1: resolution: {integrity: sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - dev: false + dev: true /npm-run-path@4.0.1: resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} @@ -12110,6 +12103,7 @@ packages: /ramda@0.29.1: resolution: {integrity: sha512-OfxIeWzd4xdUNxlWhgFazxsA/nl3mS4/jGZI5n00uWOoSSFRhC1b6gl6xvmzUamgmqELraWp0J/qqVlXYPDPyA==} + dev: true /randombytes@2.1.0: resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==} @@ -12342,7 +12336,7 @@ packages: /read-cmd-shim@4.0.0: resolution: {integrity: sha512-yILWifhaSEEytfXI76kB9xEEiG1AiozaCJZ83A87ytjRiN+jVibXjedjCRNjoZviinhG+4UkalO3mWTd8u5O0Q==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - dev: false + dev: true /read-yaml-file@1.1.0: resolution: {integrity: sha512-VIMnQi/Z4HT2Fxuwg5KrY174U1VdUIASQVWXXyqtNRtxSr9IYkn1rsI6Tb6HsrHCmB7gVpNwX6JxPTHcH6IoTA==} @@ -13115,8 +13109,8 @@ packages: pirates: 4.0.6 ts-interface-checker: 0.1.13 - /supabase@1.151.1: - resolution: {integrity: sha512-fl4h9mgG3z+bQ7UntymT30yqvOPJ4AfiCDKvDCFAdpkDhiozSfQqh1LwytEQSqMpgt6PEAcDJdYEbvholqPKOQ==} + /supabase@1.153.4: + resolution: {integrity: sha512-dok/T9lu7ndDd7pzJOmnwlgr8mDyXNmdHBXx3Axhb1Dwy8igSHVwfLket6cp9zCAVNRhzrw+exjHxsIrPairPg==} engines: {npm: '>=8'} hasBin: true requiresBuild: true @@ -13127,7 +13121,7 @@ packages: tar: 6.2.1 transitivePeerDependencies: - supports-color - dev: false + dev: true /supports-color@5.5.0: resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} @@ -13268,7 +13262,7 @@ packages: minizlib: 2.1.2 mkdirp: 1.0.4 yallist: 4.0.0 - dev: false + dev: true /terser-webpack-plugin@5.3.10(@swc/core@1.3.101)(esbuild@0.19.11)(webpack@5.91.0): resolution: {integrity: sha512-BKFPWlPDndPs+NGGCr1U59t0XScL5317Y0UReNrHaw9/FwhPENlq6bfgs+4yPfyP51vqC1bQ4rp1EfXW5ZSH9w==} @@ -13823,7 +13817,7 @@ packages: /web-streams-polyfill@3.3.3: resolution: {integrity: sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==} engines: {node: '>= 8'} - dev: false + dev: true /webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} @@ -14013,7 +14007,7 @@ packages: dependencies: imurmurhash: 0.1.4 signal-exit: 4.1.0 - dev: false + dev: true /ws@7.5.9: resolution: {integrity: sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==} @@ -14109,7 +14103,6 @@ packages: /yallist@4.0.0: resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} - dev: false /yaml@1.10.2: resolution: {integrity: sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 433a0b816..74306e8ea 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,5 +1,4 @@ packages: - apps/* - packages/** - - tooling/* - - supabase \ No newline at end of file + - tooling/* \ No newline at end of file diff --git a/supabase/package.json b/supabase/package.json deleted file mode 100644 index 7c2b5ac9f..000000000 --- a/supabase/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "@kit/supabase-config", - "version": "0.0.0", - "private": true, - "scripts": { - "dev": "supabase status || supabase start", - "stop": "supabase stop", - "reset": "supabase db reset || supabase start", - "status": "supabase status", - "test": "supabase db test", - "db:lint": "supabase db lint", - "deploy": "supabase link --project-ref $SUPABASE_PROJECT_REF && supabase db push", - "typegen": "supabase gen types typescript --local > ../packages/supabase/src/database.types.ts" - }, - "dependencies": { - "supabase": "^1.151.1" - } -} \ No newline at end of file diff --git a/tooling/eslint/apps.js b/tooling/eslint/apps.js new file mode 100644 index 000000000..eacc2d41e --- /dev/null +++ b/tooling/eslint/apps.js @@ -0,0 +1,29 @@ +/** @type {import("eslint").Linter.Config} */ +const config = { + env: { + es2022: true, + node: true, + }, + parser: '@typescript-eslint/parser', + parserOptions: { + project: true, + }, + plugins: ['@typescript-eslint', 'import'], + rules: { + 'no-restricted-imports': [ + 'error', + { + paths: [ + { + name: '@kit/supabase/database', + importNames: ['Database'], + message: + 'Please use the application types from your app "~/lib/database.types" instead', + }, + ], + }, + ], + }, +}; + +module.exports = config; diff --git a/tooling/eslint/base.js b/tooling/eslint/base.js index f964e1a65..8fb276316 100644 --- a/tooling/eslint/base.js +++ b/tooling/eslint/base.js @@ -32,6 +32,18 @@ const config = { 2, { checksVoidReturn: { attributes: false } }, ], + 'no-restricted-imports': [ + 'error', + { + paths: [ + { + name: 'react-i18next', + importNames: ['Trans'], + message: 'Please use `@kit/ui/trans` instead', + }, + ], + }, + ], }, ignorePatterns: [ '**/.eslintrc.cjs', diff --git a/tooling/eslint/package.json b/tooling/eslint/package.json index 3d6730ffc..80fea6b2a 100644 --- a/tooling/eslint/package.json +++ b/tooling/eslint/package.json @@ -4,9 +4,7 @@ "private": true, "license": "MIT", "files": [ - "./base.js", - "./nextjs.js", - "./react.js" + "./apps.js" ], "scripts": { "clean": "rm -rf .turbo node_modules", @@ -35,7 +33,7 @@ "eslintConfig": { "root": true, "extends": [ - "./base.js" + "./apps.js" ] }, "prettier": "@kit/prettier-config"