diff --git a/.env b/.env
index 164e333..f279691 100644
--- a/.env
+++ b/.env
@@ -40,6 +40,8 @@ NEXT_PUBLIC_ENABLE_TEAM_ACCOUNTS=true
NEXT_PUBLIC_ENABLE_TEAM_ACCOUNTS_CREATION=true
NEXT_PUBLIC_LANGUAGE_PRIORITY=application
NEXT_PUBLIC_ENABLE_NOTIFICATIONS=true
+NEXT_PUBLIC_REALTIME_NOTIFICATIONS=true
+
# NEXTJS
NEXT_TELEMETRY_DISABLED=1
diff --git a/app/admin/accounts/page.tsx b/app/admin/accounts/page.tsx
index 21c1104..688987f 100644
--- a/app/admin/accounts/page.tsx
+++ b/app/admin/accounts/page.tsx
@@ -55,7 +55,7 @@ async function AccountsPage(props: AdminAccountsPageProps) {
}
if (query) {
- queryBuilder.or(`name.ilike.%${query}%,email.ilike.%${query}%`);
+ queryBuilder.or(`name.ilike.%${query}%,email.ilike.%${query}%,personal_code.ilike.%${query}%`);
}
return queryBuilder;
diff --git a/app/home/(user)/_components/home-menu-navigation.tsx b/app/home/(user)/_components/home-menu-navigation.tsx
index d91e498..bb53b77 100644
--- a/app/home/(user)/_components/home-menu-navigation.tsx
+++ b/app/home/(user)/_components/home-menu-navigation.tsx
@@ -1,13 +1,9 @@
-import {
- BorderedNavigationMenu,
- BorderedNavigationMenuItem,
-} from '@kit/ui/bordered-navigation-menu';
+
import { If } from '@kit/ui/if';
import { AppLogo } from '~/components/app-logo';
import { ProfileAccountDropdownContainer } from '~/components/personal-account-dropdown-container';
import featuresFlagConfig from '~/config/feature-flags.config';
-import { personalAccountNavigationConfig } from '~/config/personal-account-navigation.config';
// home imports
import { HomeAccountSelector } from '../_components/home-account-selector';
@@ -17,41 +13,17 @@ import { type UserWorkspace } from '../_lib/server/load-user-workspace';
export function HomeMenuNavigation(props: { workspace: UserWorkspace }) {
const { workspace, user, accounts } = props.workspace;
- const routes = personalAccountNavigationConfig.routes.reduce<
- Array<{
- path: string;
- label: string;
- Icon?: React.ReactNode;
- end?: boolean | ((path: string) => boolean);
- }>
- >((acc, item) => {
- if ('children' in item) {
- return [...acc, ...item.children];
- }
-
- if ('divider' in item) {
- return acc;
- }
-
- return [...acc, item];
- }, []);
-
return (
-
- {routes.map((route) => (
-
- ))}
-
-
+
diff --git a/app/home/(user)/_lib/server/load-user-workspace.ts b/app/home/(user)/_lib/server/load-user-workspace.ts
index b48e37d..2a9db62 100644
--- a/app/home/(user)/_lib/server/load-user-workspace.ts
+++ b/app/home/(user)/_lib/server/load-user-workspace.ts
@@ -28,15 +28,20 @@ async function workspaceLoader() {
const workspacePromise = api.getAccountWorkspace();
- const [accounts, workspace, user] = await Promise.all([
+ // TODO!: remove before deploy to prod
+ const tempAccountsPromise = () => api.loadTempUserAccounts();
+
+ const [accounts, workspace, user, tempVisibleAccounts] = await Promise.all([
accountsPromise(),
workspacePromise,
requireUserInServerComponent(),
+ tempAccountsPromise()
]);
return {
accounts,
workspace,
user,
+ tempVisibleAccounts
};
}
diff --git a/app/home/(user)/page.tsx b/app/home/(user)/page.tsx
index 3327e1f..9015e90 100644
--- a/app/home/(user)/page.tsx
+++ b/app/home/(user)/page.tsx
@@ -1,4 +1,3 @@
-import { PageBody } from '@kit/ui/page';
import { Trans } from '@kit/ui/trans';
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
@@ -6,6 +5,8 @@ import { withI18n } from '~/lib/i18n/with-i18n';
// local imports
import { HomeLayoutPageHeader } from './_components/home-page-header';
+import { use } from 'react';
+import { loadUserWorkspace } from './_lib/server/load-user-workspace';
export const generateMetadata = async () => {
const i18n = await createI18nServerInstance();
@@ -17,14 +18,21 @@ export const generateMetadata = async () => {
};
function UserHomePage() {
+ const { tempVisibleAccounts } = use(loadUserWorkspace());
return (
<>
}
description={}
/>
+ {tempVisibleAccounts.length && (
+ <>
+ Member of companies:
+ {JSON.stringify(tempVisibleAccounts, null, 2)}
+ >
+ )}
+
-
>
);
}
diff --git a/app/home/[account]/layout.tsx b/app/home/[account]/layout.tsx
index ffefb5f..f4ffec6 100644
--- a/app/home/[account]/layout.tsx
+++ b/app/home/[account]/layout.tsx
@@ -4,7 +4,7 @@ import { cookies } from 'next/headers';
import { z } from 'zod';
-import { TeamAccountWorkspaceContextProvider } from '@kit/team-accounts/components';
+import { CompanyGuard, TeamAccountWorkspaceContextProvider } from '@kit/team-accounts/components';
import { Page, PageMobileNavigation, PageNavigation } from '@kit/ui/page';
import { SidebarProvider } from '@kit/ui/shadcn-sidebar';
@@ -144,4 +144,4 @@ async function getLayoutState(account: string) {
};
}
-export default withI18n(TeamWorkspaceLayout);
+export default withI18n(CompanyGuard(TeamWorkspaceLayout));
diff --git a/app/home/[account]/page.tsx b/app/home/[account]/page.tsx
index 982f21a..4684ea3 100644
--- a/app/home/[account]/page.tsx
+++ b/app/home/[account]/page.tsx
@@ -9,6 +9,7 @@ import { withI18n } from '~/lib/i18n/with-i18n';
import { DashboardDemo } from './_components/dashboard-demo';
import { TeamAccountLayoutPageHeader } from './_components/team-account-layout-page-header';
+import { CompanyGuard } from '@/packages/features/team-accounts/src/components';
interface TeamAccountHomePageProps {
params: Promise<{ account: string }>;
@@ -41,4 +42,4 @@ function TeamAccountHomePage({ params }: TeamAccountHomePageProps) {
);
}
-export default withI18n(TeamAccountHomePage);
+export default withI18n(CompanyGuard(TeamAccountHomePage));
diff --git a/app/join/page.tsx b/app/join/page.tsx
index 6fa5c77..ffe4674 100644
--- a/app/join/page.tsx
+++ b/app/join/page.tsx
@@ -109,10 +109,7 @@ async function JoinTeamAccountPage(props: JoinTeamAccountPageProps) {
const signOutNext = `${pathsConfig.auth.signIn}?invite_token=${token}`;
// once the user accepts the invitation, we redirect them to the account home page
- const accountHome = pathsConfig.app.accountHome.replace(
- '[account]',
- invitation.account.slug,
- );
+ const accountHome = pathsConfig.app.home;
const email = auth.data.email ?? '';
diff --git a/lib/database.types.ts b/lib/database.types.ts
index 452ae7b..96430a7 100644
--- a/lib/database.types.ts
+++ b/lib/database.types.ts
@@ -4,1439 +4,1652 @@ export type Json =
| boolean
| null
| { [key: string]: Json | undefined }
- | Json[];
+ | Json[]
export type Database = {
+ audit: {
+ Tables: {
+ log_entries: {
+ Row: {
+ changed_at: string
+ changed_by: string | null
+ changed_by_role: string | null
+ changed_data: Json | null
+ id: number
+ operation: string
+ record_key: number | null
+ row_data: Json | null
+ schema_name: string
+ table_name: string
+ }
+ Insert: {
+ changed_at?: string
+ changed_by?: string | null
+ changed_by_role?: string | null
+ changed_data?: Json | null
+ id?: number
+ operation: string
+ record_key?: number | null
+ row_data?: Json | null
+ schema_name: string
+ table_name: string
+ }
+ Update: {
+ changed_at?: string
+ changed_by?: string | null
+ changed_by_role?: string | null
+ changed_data?: Json | null
+ id?: number
+ operation?: string
+ record_key?: number | null
+ row_data?: Json | null
+ schema_name?: string
+ table_name?: string
+ }
+ Relationships: []
+ }
+ sync_entries: {
+ Row: {
+ changed_by_role: string
+ comment: string | null
+ created_at: string
+ id: number
+ operation: string
+ status: string
+ }
+ Insert: {
+ changed_by_role: string
+ comment?: string | null
+ created_at?: string
+ id?: number
+ operation: string
+ status: string
+ }
+ Update: {
+ changed_by_role?: string
+ comment?: string | null
+ created_at?: string
+ id?: number
+ operation?: string
+ status?: string
+ }
+ Relationships: []
+ }
+ }
+ Views: {
+ [_ in never]: never
+ }
+ Functions: {
+ [_ in never]: never
+ }
+ Enums: {
+ sync_status: "SUCCESS" | "FAIL"
+ }
+ CompositeTypes: {
+ [_ in never]: never
+ }
+ }
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
+ personal_code: string | null
+ 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
+ personal_code?: string | null
+ 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;
- };
- Relationships: [];
- };
+ created_at?: string | null
+ created_by?: string | null
+ email?: string | null
+ id?: string
+ is_personal_account?: boolean
+ name?: string
+ personal_code?: string | null
+ picture_url?: string | null
+ primary_owner_user_id?: string
+ public_data?: Json
+ slug?: string | null
+ updated_at?: string | null
+ updated_by?: string | null
+ }
+ Relationships: []
+ }
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: "invitations_with_accounts"
+ referencedColumns: ["account_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: "invitations_with_personal_accounts"
+ referencedColumns: ["account_id"]
},
{
- foreignKeyName: 'accounts_memberships_account_role_fkey';
- columns: ['account_role'];
- isOneToOne: false;
- referencedRelation: 'roles';
- referencedColumns: ['name'];
+ 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"]
+ },
+ ]
+ }
+ analyses: {
+ Row: {
+ analysis_id_oid: string
+ analysis_id_original: string
+ analysis_name_lab: string | null
+ created_at: string
+ id: number
+ order: number
+ parent_analysis_element_id: number
+ tehik_loinc_name: string | null
+ tehik_short_loinc: string | null
+ updated_at: string | null
+ }
+ Insert: {
+ analysis_id_oid: string
+ analysis_id_original: string
+ analysis_name_lab?: string | null
+ created_at?: string
+ id?: number
+ order: number
+ parent_analysis_element_id: number
+ tehik_loinc_name?: string | null
+ tehik_short_loinc?: string | null
+ updated_at?: string | null
+ }
+ Update: {
+ analysis_id_oid?: string
+ analysis_id_original?: string
+ analysis_name_lab?: string | null
+ created_at?: string
+ id?: number
+ order?: number
+ parent_analysis_element_id?: number
+ tehik_loinc_name?: string | null
+ tehik_short_loinc?: string | null
+ updated_at?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "analyses_parent_analysis_element_id_fkey"
+ columns: ["parent_analysis_element_id"]
+ isOneToOne: false
+ referencedRelation: "analysis_elements"
+ referencedColumns: ["id"]
+ },
+ ]
+ }
+ analysis_elements: {
+ Row: {
+ analysis_id_oid: string
+ analysis_id_original: string
+ analysis_name_lab: string | null
+ created_at: string
+ id: number
+ material_groups: Json[] | null
+ order: number
+ parent_analysis_group_id: number
+ tehik_loinc_name: string
+ tehik_short_loinc: string
+ updated_at: string | null
+ }
+ Insert: {
+ analysis_id_oid: string
+ analysis_id_original: string
+ analysis_name_lab?: string | null
+ created_at?: string
+ id?: number
+ material_groups?: Json[] | null
+ order: number
+ parent_analysis_group_id: number
+ tehik_loinc_name: string
+ tehik_short_loinc: string
+ updated_at?: string | null
+ }
+ Update: {
+ analysis_id_oid?: string
+ analysis_id_original?: string
+ analysis_name_lab?: string | null
+ created_at?: string
+ id?: number
+ material_groups?: Json[] | null
+ order?: number
+ parent_analysis_group_id?: number
+ tehik_loinc_name?: string
+ tehik_short_loinc?: string
+ updated_at?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "analysis_elements_parent_analysis_group_id_fkey"
+ columns: ["parent_analysis_group_id"]
+ isOneToOne: false
+ referencedRelation: "analysis_groups"
+ referencedColumns: ["id"]
+ },
+ ]
+ }
+ analysis_groups: {
+ Row: {
+ created_at: string
+ id: number
+ name: string
+ order: number
+ original_id: string
+ updated_at: string | null
+ }
+ Insert: {
+ created_at?: string
+ id?: number
+ name: string
+ order: number
+ original_id: string
+ updated_at?: string | null
+ }
+ Update: {
+ created_at?: string
+ id?: number
+ name?: string
+ order?: number
+ original_id?: string
+ updated_at?: string | null
+ }
+ Relationships: []
+ }
+ analysis_orders: {
+ Row: {
+ analysis_element_ids: number[] | null
+ analysis_ids: number[] | null
+ created_at: string
+ id: number
+ status: Database["public"]["Enums"]["analysis_order_status"]
+ user_id: string
+ }
+ Insert: {
+ analysis_element_ids?: number[] | null
+ analysis_ids?: number[] | null
+ created_at?: string
+ id?: number
+ status: Database["public"]["Enums"]["analysis_order_status"]
+ user_id: string
+ }
+ Update: {
+ analysis_element_ids?: number[] | null
+ analysis_ids?: number[] | null
+ created_at?: string
+ id?: number
+ status?: Database["public"]["Enums"]["analysis_order_status"]
+ user_id?: string
+ }
+ Relationships: []
+ }
+ analysis_response_elements: {
+ Row: {
+ analysis_element_original_id: string
+ analysis_response_id: number
+ created_at: string
+ id: number
+ norm_lower: number | null
+ norm_lower_included: boolean | null
+ norm_status: number | null
+ norm_upper: number | null
+ norm_upper_included: boolean | null
+ original_response_element: Json
+ response_time: string
+ response_value: Json
+ unit: string | null
+ updated_at: string | null
+ }
+ Insert: {
+ analysis_element_original_id: string
+ analysis_response_id: number
+ created_at?: string
+ id?: number
+ norm_lower?: number | null
+ norm_lower_included?: boolean | null
+ norm_status?: number | null
+ norm_upper?: number | null
+ norm_upper_included?: boolean | null
+ original_response_element: Json
+ response_time: string
+ response_value: Json
+ unit?: string | null
+ updated_at?: string | null
+ }
+ Update: {
+ analysis_element_original_id?: string
+ analysis_response_id?: number
+ created_at?: string
+ id?: number
+ norm_lower?: number | null
+ norm_lower_included?: boolean | null
+ norm_status?: number | null
+ norm_upper?: number | null
+ norm_upper_included?: boolean | null
+ original_response_element?: Json
+ response_time?: string
+ response_value?: Json
+ unit?: string | null
+ updated_at?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "analysis_response_element_analysis_response_id_fkey"
+ columns: ["analysis_response_id"]
+ isOneToOne: false
+ referencedRelation: "analysis_responses"
+ referencedColumns: ["id"]
+ },
+ ]
+ }
+ analysis_responses: {
+ Row: {
+ analysis_order_id: number
+ created_at: string
+ id: number
+ order_number: string
+ order_status: Database["public"]["Enums"]["analysis_order_status"]
+ updated_at: string | null
+ user_id: string
+ }
+ Insert: {
+ analysis_order_id: number
+ created_at?: string
+ id?: number
+ order_number: string
+ order_status: Database["public"]["Enums"]["analysis_order_status"]
+ updated_at?: string | null
+ user_id: string
+ }
+ Update: {
+ analysis_order_id?: number
+ created_at?: string
+ id?: number
+ order_number?: string
+ order_status?: Database["public"]["Enums"]["analysis_order_status"]
+ updated_at?: string | null
+ user_id?: string
+ }
+ Relationships: [
+ {
+ foreignKeyName: "analysis_responses_analysis_order_id_fkey"
+ columns: ["analysis_order_id"]
+ isOneToOne: false
+ referencedRelation: "analysis_orders"
+ 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: "invitations_with_accounts"
+ referencedColumns: ["account_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: "invitations_with_personal_accounts"
+ referencedColumns: ["account_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"]
+ },
+ ]
+ }
+ codes: {
+ Row: {
+ analysis_element_id: number | null
+ analysis_group_id: number | null
+ analysis_id: number | null
+ coefficient: number
+ created_at: string
+ hk_code: string
+ hk_code_multiplier: number
+ id: number
+ price: number
+ updated_at: string | null
+ }
+ Insert: {
+ analysis_element_id?: number | null
+ analysis_group_id?: number | null
+ analysis_id?: number | null
+ coefficient: number
+ created_at?: string
+ hk_code: string
+ hk_code_multiplier: number
+ id?: number
+ price: number
+ updated_at?: string | null
+ }
+ Update: {
+ analysis_element_id?: number | null
+ analysis_group_id?: number | null
+ analysis_id?: number | null
+ coefficient?: number
+ created_at?: string
+ hk_code?: string
+ hk_code_multiplier?: number
+ id?: number
+ price?: number
+ updated_at?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "codes_analysis_element_id_fkey"
+ columns: ["analysis_element_id"]
+ isOneToOne: false
+ referencedRelation: "analysis_elements"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "codes_analysis_group_id_fkey"
+ columns: ["analysis_group_id"]
+ isOneToOne: false
+ referencedRelation: "analysis_groups"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "codes_analysis_id_fkey"
+ columns: ["analysis_id"]
+ isOneToOne: false
+ referencedRelation: "analyses"
+ 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
+ personal_code: string | null
+ 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
+ personal_code?: string | null
+ 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
+ personal_code?: string | null
+ 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: "invitations_with_accounts"
+ referencedColumns: ["account_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: "invitations_with_personal_accounts"
+ referencedColumns: ["account_id"]
},
{
- foreignKeyName: 'invitations_role_fkey';
- columns: ['role'];
- isOneToOne: false;
- referencedRelation: 'roles';
- referencedColumns: ['name'];
+ 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_role_fkey"
+ columns: ["role"]
+ isOneToOne: false
+ referencedRelation: "roles"
+ referencedColumns: ["name"]
+ },
+ ]
+ }
nonces: {
Row: {
- client_token: string;
- created_at: string;
- description: string | null;
- expires_at: string;
- id: string;
- last_verification_at: string | null;
- last_verification_ip: unknown | null;
- last_verification_user_agent: string | null;
- metadata: Json | null;
- nonce: string;
- purpose: string;
- revoked: boolean;
- revoked_reason: string | null;
- scopes: string[] | null;
- tags: string[] | null;
- used_at: string | null;
- user_id: string | null;
- verification_attempts: number;
- };
+ client_token: string
+ created_at: string
+ expires_at: string
+ id: string
+ last_verification_at: string | null
+ last_verification_ip: unknown | null
+ last_verification_user_agent: string | null
+ metadata: Json | null
+ nonce: string
+ purpose: string
+ revoked: boolean
+ revoked_reason: string | null
+ scopes: string[] | null
+ used_at: string | null
+ user_id: string | null
+ verification_attempts: number
+ }
Insert: {
- client_token: string;
- created_at?: string;
- description?: string | null;
- expires_at: string;
- id?: string;
- last_verification_at?: string | null;
- last_verification_ip?: unknown | null;
- last_verification_user_agent?: string | null;
- metadata?: Json | null;
- nonce: string;
- purpose: string;
- revoked?: boolean;
- revoked_reason?: string | null;
- scopes?: string[] | null;
- tags?: string[] | null;
- used_at?: string | null;
- user_id?: string | null;
- verification_attempts?: number;
- };
+ client_token: string
+ created_at?: string
+ expires_at: string
+ id?: string
+ last_verification_at?: string | null
+ last_verification_ip?: unknown | null
+ last_verification_user_agent?: string | null
+ metadata?: Json | null
+ nonce: string
+ purpose: string
+ revoked?: boolean
+ revoked_reason?: string | null
+ scopes?: string[] | null
+ used_at?: string | null
+ user_id?: string | null
+ verification_attempts?: number
+ }
Update: {
- client_token?: string;
- created_at?: string;
- description?: string | null;
- expires_at?: string;
- id?: string;
- last_verification_at?: string | null;
- last_verification_ip?: unknown | null;
- last_verification_user_agent?: string | null;
- metadata?: Json | null;
- nonce?: string;
- purpose?: string;
- revoked?: boolean;
- revoked_reason?: string | null;
- scopes?: string[] | null;
- tags?: string[] | null;
- used_at?: string | null;
- user_id?: string | null;
- verification_attempts?: number;
- };
- Relationships: [];
- };
+ client_token?: string
+ created_at?: string
+ expires_at?: string
+ id?: string
+ last_verification_at?: string | null
+ last_verification_ip?: unknown | null
+ last_verification_user_agent?: string | null
+ metadata?: Json | null
+ nonce?: string
+ purpose?: string
+ revoked?: boolean
+ revoked_reason?: string | null
+ scopes?: string[] | null
+ used_at?: string | null
+ user_id?: string | null
+ verification_attempts?: number
+ }
+ Relationships: []
+ }
notifications: {
Row: {
- account_id: string;
- body: string;
- channel: Database['public']['Enums']['notification_channel'];
- created_at: string;
- dismissed: boolean;
- expires_at: string | null;
- id: number;
- link: string | null;
- type: Database['public']['Enums']['notification_type'];
- };
+ account_id: string
+ body: string
+ channel: Database["public"]["Enums"]["notification_channel"]
+ created_at: string
+ dismissed: boolean
+ expires_at: string | null
+ id: number
+ link: string | null
+ type: Database["public"]["Enums"]["notification_type"]
+ }
Insert: {
- account_id: string;
- body: string;
- channel?: Database['public']['Enums']['notification_channel'];
- created_at?: string;
- dismissed?: boolean;
- expires_at?: string | null;
- id?: never;
- link?: string | null;
- type?: Database['public']['Enums']['notification_type'];
- };
+ account_id: string
+ body: string
+ channel?: Database["public"]["Enums"]["notification_channel"]
+ created_at?: string
+ dismissed?: boolean
+ expires_at?: string | null
+ id?: never
+ link?: string | null
+ type?: Database["public"]["Enums"]["notification_type"]
+ }
Update: {
- account_id?: string;
- body?: string;
- channel?: Database['public']['Enums']['notification_channel'];
- created_at?: string;
- dismissed?: boolean;
- expires_at?: string | null;
- id?: never;
- link?: string | null;
- type?: Database['public']['Enums']['notification_type'];
- };
+ account_id?: string
+ body?: string
+ channel?: Database["public"]["Enums"]["notification_channel"]
+ created_at?: string
+ dismissed?: boolean
+ expires_at?: string | null
+ id?: never
+ link?: string | null
+ type?: Database["public"]["Enums"]["notification_type"]
+ }
Relationships: [
{
- foreignKeyName: 'notifications_account_id_fkey';
- columns: ['account_id'];
- isOneToOne: false;
- referencedRelation: 'accounts';
- referencedColumns: ['id'];
+ foreignKeyName: "notifications_account_id_fkey"
+ columns: ["account_id"]
+ isOneToOne: false
+ referencedRelation: "accounts"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: 'notifications_account_id_fkey';
- columns: ['account_id'];
- isOneToOne: false;
- referencedRelation: 'user_account_workspace';
- referencedColumns: ['id'];
+ foreignKeyName: "notifications_account_id_fkey"
+ columns: ["account_id"]
+ isOneToOne: false
+ referencedRelation: "invitations_with_accounts"
+ referencedColumns: ["account_id"]
},
{
- foreignKeyName: 'notifications_account_id_fkey';
- columns: ['account_id'];
- isOneToOne: false;
- referencedRelation: 'user_accounts';
- referencedColumns: ['id'];
+ foreignKeyName: "notifications_account_id_fkey"
+ columns: ["account_id"]
+ isOneToOne: false
+ referencedRelation: "invitations_with_personal_accounts"
+ referencedColumns: ["account_id"]
},
- ];
- };
+ {
+ foreignKeyName: "notifications_account_id_fkey"
+ columns: ["account_id"]
+ isOneToOne: false
+ referencedRelation: "user_account_workspace"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "notifications_account_id_fkey"
+ columns: ["account_id"]
+ isOneToOne: false
+ referencedRelation: "user_accounts"
+ referencedColumns: ["id"]
+ },
+ ]
+ }
order_items: {
Row: {
- created_at: string;
- id: string;
- order_id: string;
- price_amount: number | null;
- product_id: string;
- quantity: number;
- updated_at: string;
- variant_id: string;
- };
+ created_at: string
+ id: string
+ order_id: string
+ price_amount: number | null
+ product_id: string
+ quantity: number
+ updated_at: string
+ variant_id: string
+ }
Insert: {
- created_at?: string;
- id: string;
- order_id: string;
- price_amount?: number | null;
- product_id: string;
- quantity?: number;
- updated_at?: string;
- variant_id: string;
- };
+ created_at?: string
+ id: string
+ order_id: string
+ price_amount?: number | null
+ product_id: string
+ quantity?: number
+ updated_at?: string
+ variant_id: string
+ }
Update: {
- created_at?: string;
- id?: string;
- order_id?: string;
- price_amount?: number | null;
- product_id?: string;
- quantity?: number;
- updated_at?: string;
- variant_id?: string;
- };
+ created_at?: string
+ id?: 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: "invitations_with_accounts"
+ referencedColumns: ["account_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: "invitations_with_personal_accounts"
+ referencedColumns: ["account_id"]
},
{
- foreignKeyName: 'orders_billing_customer_id_fkey';
- columns: ['billing_customer_id'];
- isOneToOne: false;
- referencedRelation: 'billing_customers';
- 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;
- };
+ 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: {
- hierarchy_level: number;
- name: string;
- };
+ hierarchy_level: number
+ name: string
+ }
Insert: {
- hierarchy_level: number;
- name: string;
- };
+ hierarchy_level: number
+ name: string
+ }
Update: {
- hierarchy_level?: number;
- name?: string;
- };
- Relationships: [];
- };
+ hierarchy_level?: number
+ name?: string
+ }
+ Relationships: []
+ }
subscription_items: {
Row: {
- created_at: string;
- id: 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
+ id: 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;
- id: 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
+ id: 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;
- id?: 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
+ id?: 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: "invitations_with_accounts"
+ referencedColumns: ["account_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: "invitations_with_personal_accounts"
+ referencedColumns: ["account_id"]
},
{
- foreignKeyName: 'subscriptions_billing_customer_id_fkey';
- columns: ['billing_customer_id'];
- isOneToOne: false;
- referencedRelation: 'billing_customers';
- 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: {
+ invitations_with_accounts: {
+ Row: {
+ account_id: string | null
+ invite_token: string | null
+ personal_code: string | null
+ }
+ Relationships: []
+ }
+ invitations_with_personal_accounts: {
+ Row: {
+ account_id: string | null
+ account_slug: string | null
+ invite_token: string | null
+ personal_code: string | null
+ }
+ Relationships: []
+ }
user_account_workspace: {
Row: {
- id: string | null;
- name: string | null;
- picture_url: string | null;
+ id: string | null
+ name: string | null
+ picture_url: string | 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;
- };
+ Args: { 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;
- };
+ Args: { target_team_account_id: string; target_user_id: string }
+ Returns: boolean
+ }
+ check_personal_code_exists: {
+ Args: { code: string }
+ Returns: boolean
+ }
create_invitation: {
- Args: {
- account_id: string;
- email: string;
- role: string;
- };
+ 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;
- };
- };
+ account_id: string
+ created_at: string
+ email: string
+ expires_at: string
+ id: number
+ invite_token: string
+ invited_by: string
+ personal_code: string | null
+ role: string
+ updated_at: string
+ }
+ }
create_nonce: {
Args: {
- p_user_id?: string;
- p_purpose?: string;
- p_expires_in_seconds?: number;
- p_metadata?: Json;
- p_description?: string;
- p_tags?: string[];
- p_scopes?: string[];
- p_revoke_previous?: boolean;
- };
- Returns: Json;
- };
+ p_user_id?: string
+ p_purpose?: string
+ p_expires_in_seconds?: number
+ p_metadata?: Json
+ p_scopes?: string[]
+ p_revoke_previous?: boolean
+ }
+ Returns: Json
+ }
create_team_account: {
- Args: {
- account_name: string;
- };
+ 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;
- 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
+ personal_code: string | null
+ 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;
- };
+ 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;
- }[];
- };
+ id: number
+ email: string
+ account_id: string
+ invited_by: string
+ role: string
+ created_at: string
+ updated_at: string
+ expires_at: string
+ personal_code: string
+ inviter_name: string
+ inviter_email: string
+ }[]
+ }
get_account_members: {
- Args: {
- account_slug: string;
- };
+ 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;
- }[];
- };
+ id: string
+ user_id: string
+ account_id: string
+ role: string
+ role_hierarchy_level: number
+ primary_owner_user_id: string
+ name: string
+ email: string
+ personal_code: string
+ picture_url: string
+ created_at: string
+ updated_at: string
+ }[]
+ }
get_config: {
- Args: Record;
- Returns: Json;
- };
+ Args: Record
+ Returns: Json
+ }
+ get_invitations_with_account_ids: {
+ Args: { company_id: string; personal_codes: string[] }
+ Returns: {
+ invite_token: string
+ personal_code: string
+ account_id: string
+ }[]
+ }
get_nonce_status: {
- Args: {
- p_id: string;
- };
- Returns: Json;
- };
+ Args: { p_id: string }
+ Returns: Json
+ }
get_upper_system_role: {
- Args: Record;
- Returns: string;
- };
+ Args: Record
+ Returns: string
+ }
has_active_subscription: {
- Args: {
- target_account_id: string;
- };
- Returns: boolean;
- };
+ Args: { target_account_id: string }
+ Returns: boolean
+ }
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;
- };
+ Args: { 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;
- };
- install_extensions: {
- Args: Record;
- Returns: undefined;
- };
+ target_user_id: string
+ target_account_id: string
+ role_name: string
+ }
+ Returns: boolean
+ }
is_aal2: {
- Args: Record;
- Returns: boolean;
- };
+ Args: Record
+ Returns: boolean
+ }
is_account_owner: {
- Args: {
- account_id: string;
- };
- Returns: boolean;
- };
+ Args: { account_id: string }
+ Returns: boolean
+ }
is_account_team_member: {
- Args: {
- target_account_id: string;
- };
- Returns: boolean;
- };
+ Args: { target_account_id: string }
+ Returns: boolean
+ }
+ is_company_admin: {
+ Args: { account_slug: string }
+ Returns: boolean
+ }
is_mfa_compliant: {
- Args: Record;
- Returns: boolean;
- };
+ Args: Record
+ Returns: boolean
+ }
is_set: {
- Args: {
- field_name: string;
- };
- Returns: boolean;
- };
+ Args: { field_name: string }
+ Returns: boolean
+ }
is_super_admin: {
- Args: Record;
- Returns: boolean;
- };
+ Args: Record
+ Returns: boolean
+ }
is_team_member: {
- Args: {
- account_id: string;
- user_id: string;
- };
- Returns: boolean;
- };
+ Args: { account_id: string; user_id: string }
+ Returns: boolean
+ }
revoke_nonce: {
- Args: {
- p_id: string;
- p_reason?: string;
- };
- Returns: boolean;
- };
+ Args: { p_id: string; p_reason?: string }
+ Returns: boolean
+ }
team_account_workspace: {
- Args: {
- account_slug: string;
- };
+ 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'][];
- }[];
- };
+ 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;
- };
+ Args: { target_account_id: string; new_owner_id: string }
+ Returns: undefined
+ }
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
+ }
+ }
verify_nonce: {
Args: {
- p_token: string;
- p_purpose: string;
- p_user_id?: string;
- p_required_scopes?: string[];
- p_max_verification_attempts?: number;
- p_ip?: unknown;
- p_user_agent?: string;
- };
- Returns: Json;
- };
- };
+ p_token: string
+ p_purpose: string
+ p_user_id?: string
+ p_required_scopes?: string[]
+ p_max_verification_attempts?: number
+ p_ip?: unknown
+ p_user_agent?: string
+ }
+ Returns: Json
+ }
+ }
Enums: {
+ analysis_order_status:
+ | "QUEUED"
+ | "ON_HOLD"
+ | "PROCESSING"
+ | "COMPLETED"
+ | "REJECTED"
+ | "CANCELLED"
app_permissions:
- | 'roles.manage'
- | 'billing.manage'
- | 'settings.manage'
- | 'members.manage'
- | 'invites.manage';
- billing_provider: 'stripe' | 'lemon-squeezy' | 'paddle';
- notification_channel: 'in_app' | 'email';
- notification_type: 'info' | 'warning' | 'error';
- 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"
+ notification_channel: "in_app" | "email"
+ notification_type: "info" | "warning" | "error"
+ 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;
- };
- };
- };
- 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;
- user_metadata: Json | 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;
- user_metadata?: Json | 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;
- user_metadata?: Json | null;
- version?: string | null;
- };
- Relationships: [
- {
- 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;
- user_metadata: Json | null;
- version: string;
- };
- Insert: {
- bucket_id: string;
- created_at?: string;
- id: string;
- in_progress_size?: number;
- key: string;
- owner_id?: string | null;
- upload_signature: string;
- user_metadata?: Json | null;
- version: string;
- };
- Update: {
- bucket_id?: string;
- created_at?: string;
- id?: string;
- in_progress_size?: number;
- key?: string;
- owner_id?: string | null;
- upload_signature?: string;
- user_metadata?: Json | null;
- version?: string;
- };
- Relationships: [
- {
- 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;
- };
- 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;
- };
- 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;
- };
- Relationships: [
- {
- 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'];
- },
- ];
- };
- };
- 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;
- }[];
- };
- 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;
- };
- Returns: {
- 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;
- };
- Returns: {
- name: string;
- id: string;
- metadata: Json;
- updated_at: string;
- }[];
- };
- operation: {
- Args: Record;
- Returns: 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;
- };
- };
-};
+ email: string | null
+ role: string | null
+ personal_code: string | null
+ }
+ }
+ }
+}
-type PublicSchema = Database[Extract];
+type DefaultSchema = Database[Extract]
export type Tables<
- PublicTableNameOrOptions extends
- | keyof (PublicSchema['Tables'] & PublicSchema['Views'])
+ DefaultSchemaTableNameOrOptions extends
+ | keyof (DefaultSchema["Tables"] & DefaultSchema["Views"])
| { schema: keyof Database },
- TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
- ? keyof (Database[PublicTableNameOrOptions['schema']]['Tables'] &
- Database[PublicTableNameOrOptions['schema']]['Views'])
+ TableName extends DefaultSchemaTableNameOrOptions extends {
+ schema: keyof Database
+ }
+ ? keyof (Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
+ Database[DefaultSchemaTableNameOrOptions["schema"]]["Views"])
: never = never,
-> = PublicTableNameOrOptions extends { schema: keyof Database }
- ? (Database[PublicTableNameOrOptions['schema']]['Tables'] &
- Database[PublicTableNameOrOptions['schema']]['Views'])[TableName] extends {
- Row: infer R;
+> = DefaultSchemaTableNameOrOptions extends { schema: keyof Database }
+ ? (Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
+ Database[DefaultSchemaTableNameOrOptions["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;
+ : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] &
+ DefaultSchema["Views"])
+ ? (DefaultSchema["Tables"] &
+ DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends {
+ Row: infer R
}
? R
: never
- : never;
+ : never
export type TablesInsert<
- PublicTableNameOrOptions extends
- | keyof PublicSchema['Tables']
+ DefaultSchemaTableNameOrOptions extends
+ | keyof DefaultSchema["Tables"]
| { schema: keyof Database },
- TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
- ? keyof Database[PublicTableNameOrOptions['schema']]['Tables']
+ TableName extends DefaultSchemaTableNameOrOptions extends {
+ schema: keyof Database
+ }
+ ? keyof Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
: never = never,
-> = PublicTableNameOrOptions extends { schema: keyof Database }
- ? Database[PublicTableNameOrOptions['schema']]['Tables'][TableName] extends {
- Insert: infer I;
+> = DefaultSchemaTableNameOrOptions extends { schema: keyof Database }
+ ? Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
+ Insert: infer I
}
? I
: never
- : PublicTableNameOrOptions extends keyof PublicSchema['Tables']
- ? PublicSchema['Tables'][PublicTableNameOrOptions] extends {
- Insert: infer I;
+ : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
+ ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
+ Insert: infer I
}
? I
: never
- : never;
+ : never
export type TablesUpdate<
- PublicTableNameOrOptions extends
- | keyof PublicSchema['Tables']
+ DefaultSchemaTableNameOrOptions extends
+ | keyof DefaultSchema["Tables"]
| { schema: keyof Database },
- TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
- ? keyof Database[PublicTableNameOrOptions['schema']]['Tables']
+ TableName extends DefaultSchemaTableNameOrOptions extends {
+ schema: keyof Database
+ }
+ ? keyof Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
: never = never,
-> = PublicTableNameOrOptions extends { schema: keyof Database }
- ? Database[PublicTableNameOrOptions['schema']]['Tables'][TableName] extends {
- Update: infer U;
+> = DefaultSchemaTableNameOrOptions extends { schema: keyof Database }
+ ? Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
+ Update: infer U
}
? U
: never
- : PublicTableNameOrOptions extends keyof PublicSchema['Tables']
- ? PublicSchema['Tables'][PublicTableNameOrOptions] extends {
- Update: infer U;
+ : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
+ ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
+ Update: infer U
}
? U
: never
- : never;
+ : never
export type Enums<
- PublicEnumNameOrOptions extends
- | keyof PublicSchema['Enums']
+ DefaultSchemaEnumNameOrOptions extends
+ | keyof DefaultSchema["Enums"]
| { schema: keyof Database },
- EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database }
- ? keyof Database[PublicEnumNameOrOptions['schema']]['Enums']
+ EnumName extends DefaultSchemaEnumNameOrOptions extends {
+ schema: keyof Database
+ }
+ ? keyof Database[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"]
: never = never,
-> = PublicEnumNameOrOptions extends { schema: keyof Database }
- ? Database[PublicEnumNameOrOptions['schema']]['Enums'][EnumName]
- : PublicEnumNameOrOptions extends keyof PublicSchema['Enums']
- ? PublicSchema['Enums'][PublicEnumNameOrOptions]
- : never;
+> = DefaultSchemaEnumNameOrOptions extends { schema: keyof Database }
+ ? Database[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName]
+ : DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"]
+ ? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions]
+ : never
export type CompositeTypes<
PublicCompositeTypeNameOrOptions extends
- | keyof PublicSchema['CompositeTypes']
+ | keyof DefaultSchema["CompositeTypes"]
| { schema: keyof Database },
CompositeTypeName extends PublicCompositeTypeNameOrOptions extends {
- schema: keyof Database;
+ schema: keyof Database
}
- ? keyof Database[PublicCompositeTypeNameOrOptions['schema']]['CompositeTypes']
+ ? keyof Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"]
: never = never,
> = PublicCompositeTypeNameOrOptions extends { schema: keyof Database }
- ? Database[PublicCompositeTypeNameOrOptions['schema']]['CompositeTypes'][CompositeTypeName]
- : PublicCompositeTypeNameOrOptions extends keyof PublicSchema['CompositeTypes']
- ? PublicSchema['CompositeTypes'][PublicCompositeTypeNameOrOptions]
- : never;
+ ? Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName]
+ : PublicCompositeTypeNameOrOptions extends keyof DefaultSchema["CompositeTypes"]
+ ? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions]
+ : never
+
+export const Constants = {
+ audit: {
+ Enums: {
+ sync_status: ["SUCCESS", "FAIL"],
+ },
+ },
+ graphql_public: {
+ Enums: {},
+ },
+ public: {
+ Enums: {
+ analysis_order_status: [
+ "QUEUED",
+ "ON_HOLD",
+ "PROCESSING",
+ "COMPLETED",
+ "REJECTED",
+ "CANCELLED",
+ ],
+ app_permissions: [
+ "roles.manage",
+ "billing.manage",
+ "settings.manage",
+ "members.manage",
+ "invites.manage",
+ ],
+ billing_provider: ["stripe", "lemon-squeezy", "paddle"],
+ notification_channel: ["in_app", "email"],
+ notification_type: ["info", "warning", "error"],
+ payment_status: ["pending", "succeeded", "failed"],
+ subscription_item_type: ["flat", "per_seat", "metered"],
+ subscription_status: [
+ "active",
+ "trialing",
+ "past_due",
+ "canceled",
+ "unpaid",
+ "incomplete",
+ "incomplete_expired",
+ "paused",
+ ],
+ },
+ },
+} as const
+
diff --git a/package.json b/package.json
index be13199..dfc2d5f 100644
--- a/package.json
+++ b/package.json
@@ -26,7 +26,7 @@
"supabase:db:diff": "supabase db diff",
"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:packages": "supabase gen types typescript --local > ./packages/supabase/src/database.types.ts",
"supabase:typegen:app": "supabase gen types typescript --local > ./lib/database.types.ts",
"supabase:db:dump:local": "supabase db dump --local --data-only",
"sync-data:dev": "NODE_ENV=local ts-node jobs/sync-analysis-groups.ts"
diff --git a/packages/features/accounts/src/components/personal-account-dropdown.tsx b/packages/features/accounts/src/components/personal-account-dropdown.tsx
index ea2733d..c1a7128 100644
--- a/packages/features/accounts/src/components/personal-account-dropdown.tsx
+++ b/packages/features/accounts/src/components/personal-account-dropdown.tsx
@@ -10,7 +10,7 @@ import {
ChevronsUpDown,
Home,
LogOut,
- MessageCircleQuestion,
+ UserCircle,
Shield,
} from 'lucide-react';
@@ -170,12 +170,12 @@ export function PersonalAccountDropdown({
-
+
-
+
diff --git a/packages/features/accounts/src/server/api.ts b/packages/features/accounts/src/server/api.ts
index 50b9ad4..35a4465 100644
--- a/packages/features/accounts/src/server/api.ts
+++ b/packages/features/accounts/src/server/api.ts
@@ -47,23 +47,61 @@ class AccountsApi {
}
/**
- * @name loadUserAccounts
- * Load the user accounts.
- */
+ * @name loadUserAccounts
+ * Load only user-owned accounts (not just memberships).
+ */
async loadUserAccounts() {
+ const authUser = await this.client.auth.getUser();
+
+ const {
+ data,
+ error: userError,
+ } = authUser
+
+ if (userError) {
+ throw userError;
+ }
+
+ const { user } = data;
+
const { data: accounts, error } = await this.client
- .from('user_accounts')
- .select(`name, slug, picture_url`);
+ .from('accounts_memberships')
+ .select(`
+ account_id,
+ user_accounts (
+ name,
+ slug,
+ picture_url
+ )
+ `)
+ .eq('user_id', user.id)
+ .eq('account_role', 'owner');
if (error) {
throw error;
}
- return accounts.map(({ name, slug, picture_url }) => {
+ return accounts.map(({ user_accounts }) => ({
+ label: user_accounts.name,
+ value: user_accounts.slug,
+ image: user_accounts.picture_url,
+ }));
+ }
+
+
+ async loadTempUserAccounts() {
+ const { data: accounts, error } = await this.client
+ .from('user_accounts')
+ .select(`name, slug`);
+
+ if (error) {
+ throw error;
+ }
+
+ return accounts.map(({ name, slug }) => {
return {
label: name,
value: slug,
- image: picture_url,
};
});
}
diff --git a/packages/features/admin/src/components/admin-account-page.tsx b/packages/features/admin/src/components/admin-account-page.tsx
index ea114be..0930ad2 100644
--- a/packages/features/admin/src/components/admin-account-page.tsx
+++ b/packages/features/admin/src/components/admin-account-page.tsx
@@ -28,6 +28,12 @@ import { AdminMembersTable } from './admin-members-table';
import { AdminMembershipsTable } from './admin-memberships-table';
import { AdminReactivateUserDialog } from './admin-reactivate-user-dialog';
+import {
+ AccountInvitationsTable,
+ AccountMembersTable,
+ InviteMembersDialogContainer,
+} from '@kit/team-accounts/components';
+
type Account = Tables<'accounts'>;
type Membership = Tables<'accounts_memberships'>;
@@ -146,8 +152,6 @@ async function PersonalAccountPage(props: { account: Account }) {
-
-
Companies
@@ -213,7 +217,7 @@ async function TeamAccountPage(props: {
-
Company Employees
+
Company Members
diff --git a/packages/features/admin/src/components/admin-accounts-table.tsx b/packages/features/admin/src/components/admin-accounts-table.tsx
index 06a14c7..a6ee29e 100644
--- a/packages/features/admin/src/components/admin-accounts-table.tsx
+++ b/packages/features/admin/src/components/admin-accounts-table.tsx
@@ -179,6 +179,14 @@ function getColumns(): ColumnDef
[] {
header: 'Email',
accessorKey: 'email',
},
+ {
+ id: 'personalCode',
+ header: 'Personal Code',
+ accessorKey: 'personalCode',
+ cell: ({ row }) => {
+ return row.original.personal_code ?? '-';
+ },
+ },
{
id: 'type',
header: 'Type',
diff --git a/packages/features/admin/src/components/admin-create-user-dialog.tsx b/packages/features/admin/src/components/admin-create-user-dialog.tsx
index bc21c4a..0b71f81 100644
--- a/packages/features/admin/src/components/admin-create-user-dialog.tsx
+++ b/packages/features/admin/src/components/admin-create-user-dialog.tsx
@@ -48,8 +48,9 @@ export function AdminCreateUserDialog(props: React.PropsWithChildren) {
email: '',
password: '',
emailConfirm: false,
+ personalCode: ''
},
- mode: 'onChange',
+ mode: 'onBlur',
});
const onSubmit = (data: CreateUserSchemaType) => {
@@ -98,6 +99,25 @@ export function AdminCreateUserDialog(props: React.PropsWithChildren) {
+ (
+
+ Personal code
+
+
+
+
+
+
+ )}
+ />
+
(
diff --git a/packages/features/admin/src/components/admin-members-table.tsx b/packages/features/admin/src/components/admin-members-table.tsx
index 8d256be..d970645 100644
--- a/packages/features/admin/src/components/admin-members-table.tsx
+++ b/packages/features/admin/src/components/admin-members-table.tsx
@@ -52,7 +52,7 @@ function getColumns(): ColumnDef[] {
{
header: 'Role',
cell: ({ row }) => {
- return row.original.role === 'owner' ? 'HR' : 'Employee';
+ return row.original.role === 'owner' ? 'Admin' : 'Member';
},
},
{
diff --git a/packages/features/admin/src/lib/server/admin-server-actions.ts b/packages/features/admin/src/lib/server/admin-server-actions.ts
index cac9ae9..7da94b9 100644
--- a/packages/features/admin/src/lib/server/admin-server-actions.ts
+++ b/packages/features/admin/src/lib/server/admin-server-actions.ts
@@ -160,7 +160,7 @@ export const deleteAccountAction = adminAction(
*/
export const createUserAction = adminAction(
enhanceAction(
- async ({ email, password, emailConfirm }) => {
+ async ({ email, password, emailConfirm, personalCode }) => {
const adminClient = getSupabaseServerAdminClient();
const logger = await getLogger();
@@ -182,6 +182,16 @@ export const createUserAction = adminAction(
`Super Admin has successfully created a new user`,
);
+ const { error: accountError } = await adminClient
+ .from('accounts')
+ .update({ personal_code: personalCode })
+ .eq('id', data.user.id);
+
+ if (accountError) {
+ logger.error({ accountError }, 'Error inserting personal code to accounts');
+ throw new Error(`Error saving personal code: ${accountError.message}`);
+ }
+
revalidateAdmin();
return {
diff --git a/packages/features/admin/src/lib/server/schema/create-user-profile.schema.ts b/packages/features/admin/src/lib/server/schema/create-user-profile.schema.ts
new file mode 100644
index 0000000..03e971d
--- /dev/null
+++ b/packages/features/admin/src/lib/server/schema/create-user-profile.schema.ts
@@ -0,0 +1,10 @@
+import { z } from 'zod';
+
+export const CreateUserProfileSchema = z.object({
+ personalCode: z.string().regex(/^[1-6]\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}\d$/, {
+ message: 'Invalid Estonian personal code format',
+ }),
+});
+
+export type CreateUserProfileSchemaType = z.infer;
+
diff --git a/packages/features/admin/src/lib/server/schema/create-user.schema.ts b/packages/features/admin/src/lib/server/schema/create-user.schema.ts
index 586474f..9b05b4e 100644
--- a/packages/features/admin/src/lib/server/schema/create-user.schema.ts
+++ b/packages/features/admin/src/lib/server/schema/create-user.schema.ts
@@ -1,6 +1,9 @@
import { z } from 'zod';
export const CreateUserSchema = z.object({
+ personalCode: z.string().regex(/^[1-6]\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}\d$/, {
+ message: 'Invalid Estonian personal code format',
+ }),
email: z.string().email({ message: 'Please enter a valid email address' }),
password: z
.string()
diff --git a/packages/features/auth/src/components/password-sign-up-form.tsx b/packages/features/auth/src/components/password-sign-up-form.tsx
index dbba6ea..1b29b97 100644
--- a/packages/features/auth/src/components/password-sign-up-form.tsx
+++ b/packages/features/auth/src/components/password-sign-up-form.tsx
@@ -30,6 +30,7 @@ interface PasswordSignUpFormProps {
displayTermsCheckbox?: boolean;
onSubmit: (params: {
+ personalCode: string;
email: string;
password: string;
repeatPassword: string;
@@ -48,6 +49,7 @@ export function PasswordSignUpForm({
const form = useForm({
resolver: zodResolver(PasswordSignUpSchema),
defaultValues: {
+ personalCode: '',
email: defaultValues?.email ?? '',
password: '',
repeatPassword: '',
@@ -60,6 +62,29 @@ export function PasswordSignUpForm({
className={'flex w-full flex-col gap-y-4'}
onSubmit={form.handleSubmit(onSubmit)}
>
+ (
+
+
+
+
+
+
+
+
+
+
+
+ )}
+ />
redirect(redirectUrl)}
/>
diff --git a/packages/features/auth/src/hooks/use-sign-up-flow.ts b/packages/features/auth/src/hooks/use-sign-up-flow.ts
index a6ba52e..1732b68 100644
--- a/packages/features/auth/src/hooks/use-sign-up-flow.ts
+++ b/packages/features/auth/src/hooks/use-sign-up-flow.ts
@@ -8,6 +8,7 @@ import { useAppEvents } from '@kit/shared/events';
import { useSignUpWithEmailAndPassword } from '@kit/supabase/hooks/use-sign-up-with-email-password';
type SignUpCredentials = {
+ personalCode: string;
email: string;
password: string;
};
@@ -46,7 +47,6 @@ export function usePasswordSignUpFlow({
emailRedirectTo,
captchaToken,
});
-
// emit event to track sign up
appEvents.emit({
type: 'user.signedUp',
diff --git a/packages/features/auth/src/schemas/password-sign-up.schema.ts b/packages/features/auth/src/schemas/password-sign-up.schema.ts
index 828924d..b2fcab4 100644
--- a/packages/features/auth/src/schemas/password-sign-up.schema.ts
+++ b/packages/features/auth/src/schemas/password-sign-up.schema.ts
@@ -4,6 +4,9 @@ import { RefinedPasswordSchema, refineRepeatPassword } from './password.schema';
export const PasswordSignUpSchema = z
.object({
+ personalCode: z.string().regex(/^[1-6]\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}\d$/, {
+ message: 'Invalid Estonian personal code format',
+ }),
email: z.string().email(),
password: RefinedPasswordSchema,
repeatPassword: RefinedPasswordSchema,
diff --git a/packages/features/team-accounts/package.json b/packages/features/team-accounts/package.json
index 002b1c0..2cfb254 100644
--- a/packages/features/team-accounts/package.json
+++ b/packages/features/team-accounts/package.json
@@ -9,6 +9,7 @@
"typecheck": "tsc --noEmit"
},
"exports": {
+ ".": "./src/index.ts",
"./api": "./src/server/api.ts",
"./components": "./src/components/index.ts",
"./hooks/*": "./src/hooks/*.ts",
diff --git a/packages/features/team-accounts/src/components/company-guard.tsx b/packages/features/team-accounts/src/components/company-guard.tsx
new file mode 100644
index 0000000..c146073
--- /dev/null
+++ b/packages/features/team-accounts/src/components/company-guard.tsx
@@ -0,0 +1,32 @@
+import { notFound } from 'next/navigation';
+
+import { getSupabaseServerClient } from '@kit/supabase/server-client';
+import { isCompanyAdmin } from '../server/utils/is-company-admin';
+import { isSuperAdmin } from '@kit/admin'
+
+type LayoutOrPageComponent = React.ComponentType;
+
+/**
+ * CompanyGuard is a server component wrapper that checks if the user is a company admin before rendering the component.
+ * If the user is not a company admin, we redirect to a 404.
+ * @param Component - The Page or Layout component to wrap
+ */
+export function CompanyGuard(
+ Component: LayoutOrPageComponent,
+) {
+ return async function AdminGuardServerComponentWrapper(params: Params) {
+ //@ts-ignore
+ const { account } = await params.params;
+ const client = getSupabaseServerClient();
+ const [isUserSuperAdmin, isUserCompanyAdmin] = await Promise.all(
+ [isSuperAdmin(client), isCompanyAdmin(client, account)]
+ );
+
+ console.log({ isUserSuperAdmin, isUserCompanyAdmin , params: account})
+ if (isUserSuperAdmin || isUserCompanyAdmin) {
+ return ;
+ }
+ // if the user is not a company admin, we redirect to a 404
+ notFound();
+ };
+}
diff --git a/packages/features/team-accounts/src/components/index.ts b/packages/features/team-accounts/src/components/index.ts
index 63d3ece..a3b9b09 100644
--- a/packages/features/team-accounts/src/components/index.ts
+++ b/packages/features/team-accounts/src/components/index.ts
@@ -6,3 +6,4 @@ export * from './settings/team-account-settings-container';
export * from './invitations/accept-invitation-container';
export * from './create-team-account-dialog';
export * from './team-account-workspace-context';
+export * from './company-guard';
diff --git a/packages/features/team-accounts/src/components/invitations/account-invitations-table.tsx b/packages/features/team-accounts/src/components/invitations/account-invitations-table.tsx
index a3c9c9a..45a7a2a 100644
--- a/packages/features/team-accounts/src/components/invitations/account-invitations-table.tsx
+++ b/packages/features/team-accounts/src/components/invitations/account-invitations-table.tsx
@@ -107,6 +107,14 @@ function useGetColumns(permissions: {
);
},
},
+ {
+ header: t('personalCode'),
+ cell: ({ row }) => {
+ const { personal_code } = row.original;
+
+ return personal_code;
+ },
+ },
{
header: t('roleLabel'),
cell: ({ row }) => {
diff --git a/packages/features/team-accounts/src/components/members/account-members-table.tsx b/packages/features/team-accounts/src/components/members/account-members-table.tsx
index a01155e..5473213 100644
--- a/packages/features/team-accounts/src/components/members/account-members-table.tsx
+++ b/packages/features/team-accounts/src/components/members/account-members-table.tsx
@@ -87,7 +87,8 @@ export function AccountMembersTable({
return (
displayName.includes(searchString) ||
- member.role.toLowerCase().includes(searchString)
+ member.role.toLowerCase().includes(searchString) ||
+ (member.personal_code || '').includes(searchString)
);
})
.sort((prev, next) => {
@@ -160,6 +161,13 @@ function useGetColumns(
return row.original.email ?? '-';
},
},
+ {
+ header: t('personalCode'),
+ accessorKey: 'personal_code',
+ cell: ({ row }) => {
+ return row.original.personal_code ?? '-';
+ },
+ },
{
header: t('roleLabel'),
cell: ({ row }) => {
diff --git a/packages/features/team-accounts/src/components/members/invite-members-dialog-container.tsx b/packages/features/team-accounts/src/components/members/invite-members-dialog-container.tsx
index 8d793a6..2b221e4 100644
--- a/packages/features/team-accounts/src/components/members/invite-members-dialog-container.tsx
+++ b/packages/features/team-accounts/src/components/members/invite-members-dialog-container.tsx
@@ -66,7 +66,7 @@ export function InviteMembersDialogContainer({