From 3ee0c0039ca7daf03103c04167822965cf74ccbe Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 3 Jan 2025 15:12:31 +0000 Subject: [PATCH] feat: billing portal --- apps/web/src/components/Input.tsx | 2 +- apps/web/src/components/WorkspaceMenu.tsx | 15 +- .../api/stripe/create_billing_session.ts | 73 + apps/web/src/pages/api/stripe/webhook.ts | 1 + apps/web/src/providers/workspace.tsx | 5 + .../components/UpdateWorkspaceUrlForm.tsx | 14 +- apps/web/src/views/settings/index.tsx | 146 +- packages/api/src/routers/workspace.ts | 25 + .../db/migrations/0002_bored_retro_girl.sql | 2 + .../db/migrations/meta/0002_snapshot.json | 1508 +++++++++++++++++ packages/db/migrations/meta/_journal.json | 7 + packages/db/src/repository/workspace.repo.ts | 8 +- packages/db/src/schema.ts | 6 + packages/db/src/types/database.types.ts | 1264 +++++++------- 14 files changed, 2383 insertions(+), 693 deletions(-) create mode 100644 apps/web/src/pages/api/stripe/create_billing_session.ts create mode 100644 packages/db/migrations/0002_bored_retro_girl.sql create mode 100644 packages/db/migrations/meta/0002_snapshot.json diff --git a/apps/web/src/components/Input.tsx b/apps/web/src/components/Input.tsx index 317a0011..a27220a5 100644 --- a/apps/web/src/components/Input.tsx +++ b/apps/web/src/components/Input.tsx @@ -43,7 +43,7 @@ const Input = forwardRef(
{prefix && ( -
+
{prefix}
)} diff --git a/apps/web/src/components/WorkspaceMenu.tsx b/apps/web/src/components/WorkspaceMenu.tsx index a9e887f5..0828ef2a 100644 --- a/apps/web/src/components/WorkspaceMenu.tsx +++ b/apps/web/src/components/WorkspaceMenu.tsx @@ -22,12 +22,17 @@ export default function WorkspaceMenu() { - {workspace?.name.charAt(0).toUpperCase()} + {workspace.name.charAt(0).toUpperCase()} - {workspace?.name} + {workspace.name} + {workspace.plan === "pro" && ( + + Pro + + )} )}
@@ -53,14 +58,14 @@ export default function WorkspaceMenu() {
- {availableWorkspace?.name.charAt(0).toUpperCase()} + {availableWorkspace.name.charAt(0).toUpperCase()} - {availableWorkspace?.name} + {availableWorkspace.name}
- {workspace?.name === availableWorkspace?.name && ( + {workspace.name === availableWorkspace.name && ( diff --git a/apps/web/src/pages/api/stripe/create_billing_session.ts b/apps/web/src/pages/api/stripe/create_billing_session.ts new file mode 100644 index 00000000..ad603b3a --- /dev/null +++ b/apps/web/src/pages/api/stripe/create_billing_session.ts @@ -0,0 +1,73 @@ +import type { NextRequest } from "next/server"; +import { NextResponse } from "next/server"; +import { Stripe } from "stripe"; + +import * as userRepo from "@kan/db/repository/user.repo"; +import { createNextClient } from "@kan/supabase/clients"; + +const stripeSecretKey = process.env.STRIPE_SECRET_KEY; + +if (!stripeSecretKey) { + throw new Error("STRIPE_SECRET_KEY is not defined"); +} + +const stripe = new Stripe(stripeSecretKey, { + apiVersion: "2024-12-18.acacia", +}); + +export default async function handler(req: NextRequest) { + if (req.method !== "POST") { + return new Response(JSON.stringify({ error: "Method not allowed" }), { + status: 405, + headers: { "Content-Type": "application/json" }, + }); + } + + try { + const response = NextResponse.next(); + const db = createNextClient(req, response); + const { data } = await db.auth.getUser(); + + if (!data.user) { + return new Response(JSON.stringify({ error: "Unauthorized" }), { + status: 403, + headers: { "Content-Type": "application/json" }, + }); + } + + const user = await userRepo.getById(db, data.user.id); + + if (!user?.stripeCustomerId) { + return new Response( + JSON.stringify({ error: "No billing account found" }), + { + status: 404, + headers: { "Content-Type": "application/json" }, + }, + ); + } + + const session = await stripe.billingPortal.sessions.create({ + customer: user.stripeCustomerId, + return_url: `${process.env.WEBSITE_URL}/settings`, + }); + + return new Response(JSON.stringify({ url: session.url }), { + status: 200, + headers: { "Content-Type": "application/json" }, + }); + } catch (error) { + console.error("Error:", error); + return new Response( + JSON.stringify({ error: "Error creating portal session" }), + { + status: 500, + headers: { "Content-Type": "application/json" }, + }, + ); + } +} + +export const runtime = "edge"; +export const preferredRegion = "lhr1"; +export const dynamic = "force-dynamic"; diff --git a/apps/web/src/pages/api/stripe/webhook.ts b/apps/web/src/pages/api/stripe/webhook.ts index dc39af27..279f443e 100644 --- a/apps/web/src/pages/api/stripe/webhook.ts +++ b/apps/web/src/pages/api/stripe/webhook.ts @@ -60,6 +60,7 @@ export default async function handler(req: NextRequest) { metaData.workspacePublicId, undefined, metaData.username, + "pro", ); } break; diff --git a/apps/web/src/providers/workspace.tsx b/apps/web/src/providers/workspace.tsx index 77aa2c9e..2acd5595 100644 --- a/apps/web/src/providers/workspace.tsx +++ b/apps/web/src/providers/workspace.tsx @@ -15,12 +15,14 @@ interface Workspace { name: string; publicId: string; slug: string; + plan: "free" | "pro" | "enterprise"; } const initialWorkspace: Workspace = { name: "", publicId: "", slug: "", + plan: "free", }; const initialAvailableWorkspaces: Workspace[] = []; @@ -63,6 +65,7 @@ export const WorkspaceProvider: React.FC<{ children: ReactNode }> = ({ publicId: workspace.publicId, name: workspace.name, slug: workspace.slug, + plan: workspace.plan, }; }) .filter((workspace) => workspace !== null) as Workspace[]; @@ -82,6 +85,7 @@ export const WorkspaceProvider: React.FC<{ children: ReactNode }> = ({ publicId: selectedWorkspace.workspace.publicId, name: selectedWorkspace.workspace.name, slug: selectedWorkspace.workspace.slug, + plan: selectedWorkspace.workspace.plan, }); } else { const primaryWorkspace = data[0]?.workspace; @@ -91,6 +95,7 @@ export const WorkspaceProvider: React.FC<{ children: ReactNode }> = ({ publicId: primaryWorkspace.publicId, name: primaryWorkspace.name, slug: primaryWorkspace.slug, + plan: primaryWorkspace.plan, }); } }, [data]); diff --git a/apps/web/src/views/settings/components/UpdateWorkspaceUrlForm.tsx b/apps/web/src/views/settings/components/UpdateWorkspaceUrlForm.tsx index e528094c..288871f9 100644 --- a/apps/web/src/views/settings/components/UpdateWorkspaceUrlForm.tsx +++ b/apps/web/src/views/settings/components/UpdateWorkspaceUrlForm.tsx @@ -27,9 +27,11 @@ type FormValues = z.infer; const UpdateWorkspaceUrlForm = ({ workspacePublicId, workspaceUrl, + workspacePlan, }: { workspacePublicId: string; workspaceUrl: string; + workspacePlan: "free" | "pro" | "enterprise"; }) => { const utils = api.useUtils(); const { showPopup } = usePopup(); @@ -84,7 +86,7 @@ const UpdateWorkspaceUrlForm = ({ const isWorkspaceSlugAvailable = checkWorkspaceSlugAvailability.data; const onSubmit = (data: FormValues) => { - if (isWorkspaceSlugAvailable?.isPremium) + if (isWorkspaceSlugAvailable?.isPremium && workspacePlan !== "pro") return openModal("PREMIUM_USERNAME", data.slug); updateWorkspaceSlug.mutate({ @@ -99,7 +101,10 @@ const UpdateWorkspaceUrlForm = ({ ) : isWorkspaceSlugAvailable?.isAvailable ? ( - + ) : null } /> diff --git a/apps/web/src/views/settings/index.tsx b/apps/web/src/views/settings/index.tsx index 0f5e8b64..8929ef42 100644 --- a/apps/web/src/views/settings/index.tsx +++ b/apps/web/src/views/settings/index.tsx @@ -1,5 +1,8 @@ +import { HiMiniArrowTopRightOnSquare } from "react-icons/hi2"; + import Button from "~/components/Button"; import Modal from "~/components/modal"; +import { NewWorkspaceForm } from "~/components/NewWorkspaceForm"; import { PageHead } from "~/components/PageHead"; import { useModal } from "~/providers/modal"; import { useWorkspace } from "~/providers/workspace"; @@ -12,60 +15,101 @@ export default function SettingsPage() { const { modalContentType, openModal } = useModal(); const { workspace } = useWorkspace(); + const handleOpenBillingPortal = async () => { + try { + const response = await fetch("/api/stripe/create_billing_session", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + }); + + const { url } = (await response.json()) as { url: string }; + + if (url) { + window.location.href = url; + } + } catch (error) { + console.error("Error creating billing session:", error); + } + }; + return ( <> - -
-
-

- Settings -

+
+
+ +
+
+

+ Settings +

+
+ +
+

+ Workspace name +

+ + +

+ Workspace username +

+ +
+ +
+

+ Billing +

+

+ View and manage your billing and subscription. +

+ +
+ +
+

+ Delete workspace +

+

+ Once you delete your workspace, there is no going back. Please + be certain. +

+ +
+
+ + + {modalContentType === "NEW_WORKSPACE" && } + {modalContentType === "DELETE_WORKSPACE" && ( + + )} + {modalContentType === "PREMIUM_USERNAME" && ( + + )} +
- -
-

- Workspace name -

- - -

- Workspace username -

- -
- -
-

- Delete workspace -

-

- Once you delete your workspace, there is no going back. Please be - certain. -

- -
- - - {modalContentType === "DELETE_WORKSPACE" && ( - - )} - {modalContentType === "PREMIUM_USERNAME" && ( - - )} -
); diff --git a/packages/api/src/routers/workspace.ts b/packages/api/src/routers/workspace.ts index 4feaa400..56a3e976 100644 --- a/packages/api/src/routers/workspace.ts +++ b/packages/api/src/routers/workspace.ts @@ -126,6 +126,31 @@ export const workspaceRouter = createTRPCRouter({ ) .output(z.custom>>()) .mutation(async ({ ctx, input }) => { + if (input.slug) { + const workspace = await workspaceRepo.getByPublicId( + ctx.db, + input.workspacePublicId, + ); + + const reservedOrPremiumWorkspaceSlug = + await workspaceSlugRepo.getWorkspaceSlug(ctx.db, input.slug); + + const isWorkspaceSlugAvailable = + await workspaceRepo.isWorkspaceSlugAvailable(ctx.db, input.slug); + + if ( + reservedOrPremiumWorkspaceSlug?.type === "reserved" || + (workspace?.plan !== "pro" && + reservedOrPremiumWorkspaceSlug?.type === "premium") || + !isWorkspaceSlugAvailable + ) { + throw new TRPCError({ + message: `Workspace slug already taken`, + code: "CONFLICT", + }); + } + } + const result = await workspaceRepo.update( ctx.db, input.workspacePublicId, diff --git a/packages/db/migrations/0002_bored_retro_girl.sql b/packages/db/migrations/0002_bored_retro_girl.sql new file mode 100644 index 00000000..28132261 --- /dev/null +++ b/packages/db/migrations/0002_bored_retro_girl.sql @@ -0,0 +1,2 @@ +CREATE TYPE "public"."workspace_plan" AS ENUM('free', 'pro', 'enterprise');--> statement-breakpoint +ALTER TABLE "workspace" ADD COLUMN "plan" "workspace_plan" DEFAULT 'free' NOT NULL; \ No newline at end of file diff --git a/packages/db/migrations/meta/0002_snapshot.json b/packages/db/migrations/meta/0002_snapshot.json new file mode 100644 index 00000000..a4fae557 --- /dev/null +++ b/packages/db/migrations/meta/0002_snapshot.json @@ -0,0 +1,1508 @@ +{ + "id": "772f24ff-4558-4003-9495-29ebb4f36279", + "prevId": "dbb6beb4-cd15-47c0-959a-64d161045634", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.board": { + "name": "board", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigserial", + "primaryKey": true, + "notNull": true + }, + "publicId": { + "name": "publicId", + "type": "varchar(12)", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "createdBy": { + "name": "createdBy", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "deletedAt": { + "name": "deletedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "deletedBy": { + "name": "deletedBy", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "importId": { + "name": "importId", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "workspaceId": { + "name": "workspaceId", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "board_createdBy_user_id_fk": { + "name": "board_createdBy_user_id_fk", + "tableFrom": "board", + "tableTo": "user", + "columnsFrom": [ + "createdBy" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "board_deletedBy_user_id_fk": { + "name": "board_deletedBy_user_id_fk", + "tableFrom": "board", + "tableTo": "user", + "columnsFrom": [ + "deletedBy" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "board_importId_import_id_fk": { + "name": "board_importId_import_id_fk", + "tableFrom": "board", + "tableTo": "import", + "columnsFrom": [ + "importId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "board_workspaceId_workspace_id_fk": { + "name": "board_workspaceId_workspace_id_fk", + "tableFrom": "board", + "tableTo": "workspace", + "columnsFrom": [ + "workspaceId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "board_publicId_unique": { + "name": "board_publicId_unique", + "nullsNotDistinct": false, + "columns": [ + "publicId" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.card_activity": { + "name": "card_activity", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigserial", + "primaryKey": true, + "notNull": true + }, + "publicId": { + "name": "publicId", + "type": "varchar(12)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "card_activity_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "cardId": { + "name": "cardId", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "fromIndex": { + "name": "fromIndex", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "toIndex": { + "name": "toIndex", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "fromListId": { + "name": "fromListId", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "toListId": { + "name": "toListId", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "labelId": { + "name": "labelId", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "workspaceMemberId": { + "name": "workspaceMemberId", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "fromTitle": { + "name": "fromTitle", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "toTitle": { + "name": "toTitle", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "fromDescription": { + "name": "fromDescription", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "toDescription": { + "name": "toDescription", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "createdBy": { + "name": "createdBy", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "commentId": { + "name": "commentId", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "fromComment": { + "name": "fromComment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "toComment": { + "name": "toComment", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "card_activity_cardId_card_id_fk": { + "name": "card_activity_cardId_card_id_fk", + "tableFrom": "card_activity", + "tableTo": "card", + "columnsFrom": [ + "cardId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "card_activity_fromListId_list_id_fk": { + "name": "card_activity_fromListId_list_id_fk", + "tableFrom": "card_activity", + "tableTo": "list", + "columnsFrom": [ + "fromListId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "card_activity_toListId_list_id_fk": { + "name": "card_activity_toListId_list_id_fk", + "tableFrom": "card_activity", + "tableTo": "list", + "columnsFrom": [ + "toListId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "card_activity_labelId_label_id_fk": { + "name": "card_activity_labelId_label_id_fk", + "tableFrom": "card_activity", + "tableTo": "label", + "columnsFrom": [ + "labelId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "card_activity_workspaceMemberId_workspace_members_id_fk": { + "name": "card_activity_workspaceMemberId_workspace_members_id_fk", + "tableFrom": "card_activity", + "tableTo": "workspace_members", + "columnsFrom": [ + "workspaceMemberId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "card_activity_createdBy_user_id_fk": { + "name": "card_activity_createdBy_user_id_fk", + "tableFrom": "card_activity", + "tableTo": "user", + "columnsFrom": [ + "createdBy" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "card_activity_commentId_card_comments_id_fk": { + "name": "card_activity_commentId_card_comments_id_fk", + "tableFrom": "card_activity", + "tableTo": "card_comments", + "columnsFrom": [ + "commentId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "card_activity_publicId_unique": { + "name": "card_activity_publicId_unique", + "nullsNotDistinct": false, + "columns": [ + "publicId" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public._card_workspace_members": { + "name": "_card_workspace_members", + "schema": "", + "columns": { + "cardId": { + "name": "cardId", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "workspaceMemberId": { + "name": "workspaceMemberId", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "_card_workspace_members_cardId_card_id_fk": { + "name": "_card_workspace_members_cardId_card_id_fk", + "tableFrom": "_card_workspace_members", + "tableTo": "card", + "columnsFrom": [ + "cardId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "_card_workspace_members_workspaceMemberId_workspace_members_id_fk": { + "name": "_card_workspace_members_workspaceMemberId_workspace_members_id_fk", + "tableFrom": "_card_workspace_members", + "tableTo": "workspace_members", + "columnsFrom": [ + "workspaceMemberId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "_card_workspace_members_cardId_workspaceMemberId_pk": { + "name": "_card_workspace_members_cardId_workspaceMemberId_pk", + "columns": [ + "cardId", + "workspaceMemberId" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.card": { + "name": "card", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigserial", + "primaryKey": true, + "notNull": true + }, + "publicId": { + "name": "publicId", + "type": "varchar(12)", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "index": { + "name": "index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "createdBy": { + "name": "createdBy", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "deletedAt": { + "name": "deletedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "deletedBy": { + "name": "deletedBy", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "listId": { + "name": "listId", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "importId": { + "name": "importId", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "card_createdBy_user_id_fk": { + "name": "card_createdBy_user_id_fk", + "tableFrom": "card", + "tableTo": "user", + "columnsFrom": [ + "createdBy" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "card_deletedBy_user_id_fk": { + "name": "card_deletedBy_user_id_fk", + "tableFrom": "card", + "tableTo": "user", + "columnsFrom": [ + "deletedBy" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "card_listId_list_id_fk": { + "name": "card_listId_list_id_fk", + "tableFrom": "card", + "tableTo": "list", + "columnsFrom": [ + "listId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "card_importId_import_id_fk": { + "name": "card_importId_import_id_fk", + "tableFrom": "card", + "tableTo": "import", + "columnsFrom": [ + "importId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "card_publicId_unique": { + "name": "card_publicId_unique", + "nullsNotDistinct": false, + "columns": [ + "publicId" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public._card_labels": { + "name": "_card_labels", + "schema": "", + "columns": { + "cardId": { + "name": "cardId", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "labelId": { + "name": "labelId", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "_card_labels_cardId_card_id_fk": { + "name": "_card_labels_cardId_card_id_fk", + "tableFrom": "_card_labels", + "tableTo": "card", + "columnsFrom": [ + "cardId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "_card_labels_labelId_label_id_fk": { + "name": "_card_labels_labelId_label_id_fk", + "tableFrom": "_card_labels", + "tableTo": "label", + "columnsFrom": [ + "labelId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "_card_labels_cardId_labelId_pk": { + "name": "_card_labels_cardId_labelId_pk", + "columns": [ + "cardId", + "labelId" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.card_comments": { + "name": "card_comments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigserial", + "primaryKey": true, + "notNull": true + }, + "publicId": { + "name": "publicId", + "type": "varchar(12)", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "cardId": { + "name": "cardId", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "createdBy": { + "name": "createdBy", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "deletedAt": { + "name": "deletedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "deletedBy": { + "name": "deletedBy", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "card_comments_cardId_card_id_fk": { + "name": "card_comments_cardId_card_id_fk", + "tableFrom": "card_comments", + "tableTo": "card", + "columnsFrom": [ + "cardId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "card_comments_createdBy_user_id_fk": { + "name": "card_comments_createdBy_user_id_fk", + "tableFrom": "card_comments", + "tableTo": "user", + "columnsFrom": [ + "createdBy" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "card_comments_deletedBy_user_id_fk": { + "name": "card_comments_deletedBy_user_id_fk", + "tableFrom": "card_comments", + "tableTo": "user", + "columnsFrom": [ + "deletedBy" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "card_comments_publicId_unique": { + "name": "card_comments_publicId_unique", + "nullsNotDistinct": false, + "columns": [ + "publicId" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.import": { + "name": "import", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigserial", + "primaryKey": true, + "notNull": true + }, + "publicId": { + "name": "publicId", + "type": "varchar(12)", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "source", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "createdBy": { + "name": "createdBy", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "import_createdBy_user_id_fk": { + "name": "import_createdBy_user_id_fk", + "tableFrom": "import", + "tableTo": "user", + "columnsFrom": [ + "createdBy" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "import_publicId_unique": { + "name": "import_publicId_unique", + "nullsNotDistinct": false, + "columns": [ + "publicId" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.label": { + "name": "label", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigserial", + "primaryKey": true, + "notNull": true + }, + "publicId": { + "name": "publicId", + "type": "varchar(12)", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "colourCode": { + "name": "colourCode", + "type": "varchar(12)", + "primaryKey": false, + "notNull": false + }, + "createdBy": { + "name": "createdBy", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "boardId": { + "name": "boardId", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "importId": { + "name": "importId", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "label_createdBy_user_id_fk": { + "name": "label_createdBy_user_id_fk", + "tableFrom": "label", + "tableTo": "user", + "columnsFrom": [ + "createdBy" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "label_boardId_board_id_fk": { + "name": "label_boardId_board_id_fk", + "tableFrom": "label", + "tableTo": "board", + "columnsFrom": [ + "boardId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "label_importId_import_id_fk": { + "name": "label_importId_import_id_fk", + "tableFrom": "label", + "tableTo": "import", + "columnsFrom": [ + "importId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "label_publicId_unique": { + "name": "label_publicId_unique", + "nullsNotDistinct": false, + "columns": [ + "publicId" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.list": { + "name": "list", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigserial", + "primaryKey": true, + "notNull": true + }, + "publicId": { + "name": "publicId", + "type": "varchar(12)", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "index": { + "name": "index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "createdBy": { + "name": "createdBy", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "deletedAt": { + "name": "deletedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "deletedBy": { + "name": "deletedBy", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "boardId": { + "name": "boardId", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "importId": { + "name": "importId", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "list_createdBy_user_id_fk": { + "name": "list_createdBy_user_id_fk", + "tableFrom": "list", + "tableTo": "user", + "columnsFrom": [ + "createdBy" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "list_deletedBy_user_id_fk": { + "name": "list_deletedBy_user_id_fk", + "tableFrom": "list", + "tableTo": "user", + "columnsFrom": [ + "deletedBy" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "list_boardId_board_id_fk": { + "name": "list_boardId_board_id_fk", + "tableFrom": "list", + "tableTo": "board", + "columnsFrom": [ + "boardId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "list_importId_import_id_fk": { + "name": "list_importId_import_id_fk", + "tableFrom": "list", + "tableTo": "import", + "columnsFrom": [ + "importId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "list_publicId_unique": { + "name": "list_publicId_unique", + "nullsNotDistinct": false, + "columns": [ + "publicId" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_slugs": { + "name": "workspace_slugs", + "schema": "", + "columns": { + "slug": { + "name": "slug", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "slug_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "workspace_slugs_slug_unique": { + "name": "workspace_slugs_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "emailVerified": { + "name": "emailVerified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "image": { + "name": "image", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "stripeCustomerId": { + "name": "stripeCustomerId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_members": { + "name": "workspace_members", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigserial", + "primaryKey": true, + "notNull": true + }, + "publicId": { + "name": "publicId", + "type": "varchar(12)", + "primaryKey": false, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "workspaceId": { + "name": "workspaceId", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "createdBy": { + "name": "createdBy", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "deletedAt": { + "name": "deletedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "deletedBy": { + "name": "deletedBy", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "member_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'invited'" + } + }, + "indexes": {}, + "foreignKeys": { + "workspace_members_userId_user_id_fk": { + "name": "workspace_members_userId_user_id_fk", + "tableFrom": "workspace_members", + "tableTo": "user", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "workspace_members_workspaceId_workspace_id_fk": { + "name": "workspace_members_workspaceId_workspace_id_fk", + "tableFrom": "workspace_members", + "tableTo": "workspace", + "columnsFrom": [ + "workspaceId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_members_deletedBy_user_id_fk": { + "name": "workspace_members_deletedBy_user_id_fk", + "tableFrom": "workspace_members", + "tableTo": "user", + "columnsFrom": [ + "deletedBy" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "workspace_members_publicId_unique": { + "name": "workspace_members_publicId_unique", + "nullsNotDistinct": false, + "columns": [ + "publicId" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace": { + "name": "workspace", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigserial", + "primaryKey": true, + "notNull": true + }, + "publicId": { + "name": "publicId", + "type": "varchar(12)", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "plan": { + "name": "plan", + "type": "workspace_plan", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'free'" + }, + "createdBy": { + "name": "createdBy", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "deletedAt": { + "name": "deletedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "deletedBy": { + "name": "deletedBy", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "workspace_createdBy_user_id_fk": { + "name": "workspace_createdBy_user_id_fk", + "tableFrom": "workspace", + "tableTo": "user", + "columnsFrom": [ + "createdBy" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "workspace_deletedBy_user_id_fk": { + "name": "workspace_deletedBy_user_id_fk", + "tableFrom": "workspace", + "tableTo": "user", + "columnsFrom": [ + "deletedBy" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "workspace_publicId_unique": { + "name": "workspace_publicId_unique", + "nullsNotDistinct": false, + "columns": [ + "publicId" + ] + }, + "workspace_slug_unique": { + "name": "workspace_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.card_activity_type": { + "name": "card_activity_type", + "schema": "public", + "values": [ + "card.created", + "card.updated.title", + "card.updated.description", + "card.updated.index", + "card.updated.list", + "card.updated.label.added", + "card.updated.label.removed", + "card.updated.member.added", + "card.updated.member.removed", + "card.updated.comment.added", + "card.updated.comment.updated", + "card.updated.comment.deleted", + "card.archived" + ] + }, + "public.source": { + "name": "source", + "schema": "public", + "values": [ + "trello" + ] + }, + "public.status": { + "name": "status", + "schema": "public", + "values": [ + "started", + "success", + "failed" + ] + }, + "public.role": { + "name": "role", + "schema": "public", + "values": [ + "admin", + "member", + "guest" + ] + }, + "public.member_status": { + "name": "member_status", + "schema": "public", + "values": [ + "invited", + "active", + "removed" + ] + }, + "public.slug_type": { + "name": "slug_type", + "schema": "public", + "values": [ + "reserved", + "premium" + ] + }, + "public.workspace_plan": { + "name": "workspace_plan", + "schema": "public", + "values": [ + "free", + "pro", + "enterprise" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/packages/db/migrations/meta/_journal.json b/packages/db/migrations/meta/_journal.json index b6d5f54d..e2d61d0b 100644 --- a/packages/db/migrations/meta/_journal.json +++ b/packages/db/migrations/meta/_journal.json @@ -15,6 +15,13 @@ "when": 1735821726274, "tag": "0001_little_red_hulk", "breakpoints": true + }, + { + "idx": 2, + "version": "7", + "when": 1735904544867, + "tag": "0002_bored_retro_girl", + "breakpoints": true } ] } \ No newline at end of file diff --git a/packages/db/src/repository/workspace.repo.ts b/packages/db/src/repository/workspace.repo.ts index 5b93220c..92866ce5 100644 --- a/packages/db/src/repository/workspace.repo.ts +++ b/packages/db/src/repository/workspace.repo.ts @@ -44,10 +44,11 @@ export const update = async ( workspacePublicId: string, name: string | undefined, slug: string | undefined, + plan?: "free" | "pro" | "enterprise", ) => { const { data } = await db .from("workspace") - .update({ name, slug }) + .update({ name, slug, plan }) .eq("publicId", workspacePublicId) .is("deletedAt", null); @@ -60,7 +61,7 @@ export const getByPublicId = async ( ) => { const { data } = await db .from("workspace") - .select(`id, publicId, name`) + .select(`id, publicId, name, plan`) .is("deletedAt", null) .eq("publicId", workspacePublicId) .limit(1) @@ -112,7 +113,8 @@ export const getAllByUserId = async ( workspace ( publicId, name, - slug + slug, + plan ) `, ) diff --git a/packages/db/src/schema.ts b/packages/db/src/schema.ts index b9bbbbc4..0f1fe212 100644 --- a/packages/db/src/schema.ts +++ b/packages/db/src/schema.ts @@ -40,6 +40,11 @@ export const activityTypeEnum = pgEnum("card_activity_type", [ "card.archived", ]); export const slugTypeEnum = pgEnum("slug_type", ["reserved", "premium"]); +export const workspacePlanEnum = pgEnum("workspace_plan", [ + "free", + "pro", + "enterprise", +]); export const boards = pgTable("board", { id: bigserial("id", { mode: "number" }).primaryKey(), @@ -289,6 +294,7 @@ export const workspaces = pgTable("workspace", { publicId: varchar("publicId", { length: 12 }).notNull().unique(), name: varchar("name", { length: 255 }).notNull(), slug: varchar("slug", { length: 255 }).notNull().unique(), + plan: workspacePlanEnum("plan").notNull().default("free"), createdBy: uuid("createdBy") .notNull() .references(() => users.id), diff --git a/packages/db/src/types/database.types.ts b/packages/db/src/types/database.types.ts index 0492414c..a0a70b84 100644 --- a/packages/db/src/types/database.types.ts +++ b/packages/db/src/types/database.types.ts @@ -1,764 +1,767 @@ -/* eslint-disable @typescript-eslint/no-redundant-type-constituents */ - export type Json = | string | number | boolean | null | { [key: string]: Json | undefined } - | Json[]; + | Json[] -export interface Database { +export type Database = { public: { Tables: { _card_labels: { Row: { - cardId: number; - labelId: number; - }; + cardId: number + labelId: number + } Insert: { - cardId: number; - labelId: number; - }; + cardId: number + labelId: number + } Update: { - cardId?: number; - labelId?: number; - }; + cardId?: number + labelId?: number + } Relationships: [ { - foreignKeyName: "_card_labels_cardId_card_id_fk"; - columns: ["cardId"]; - isOneToOne: false; - referencedRelation: "card"; - referencedColumns: ["id"]; + foreignKeyName: "_card_labels_cardId_card_id_fk" + columns: ["cardId"] + isOneToOne: false + referencedRelation: "card" + referencedColumns: ["id"] }, { - foreignKeyName: "_card_labels_labelId_label_id_fk"; - columns: ["labelId"]; - isOneToOne: false; - referencedRelation: "label"; - referencedColumns: ["id"]; + foreignKeyName: "_card_labels_labelId_label_id_fk" + columns: ["labelId"] + isOneToOne: false + referencedRelation: "label" + referencedColumns: ["id"] }, - ]; - }; + ] + } _card_workspace_members: { Row: { - cardId: number; - workspaceMemberId: number; - }; + cardId: number + workspaceMemberId: number + } Insert: { - cardId: number; - workspaceMemberId: number; - }; + cardId: number + workspaceMemberId: number + } Update: { - cardId?: number; - workspaceMemberId?: number; - }; + cardId?: number + workspaceMemberId?: number + } Relationships: [ { - foreignKeyName: "_card_workspace_members_cardId_card_id_fk"; - columns: ["cardId"]; - isOneToOne: false; - referencedRelation: "card"; - referencedColumns: ["id"]; + foreignKeyName: "_card_workspace_members_cardId_card_id_fk" + columns: ["cardId"] + isOneToOne: false + referencedRelation: "card" + referencedColumns: ["id"] }, { - foreignKeyName: "_card_workspace_members_workspaceMemberId_workspace_members_id_"; - columns: ["workspaceMemberId"]; - isOneToOne: false; - referencedRelation: "workspace_members"; - referencedColumns: ["id"]; + foreignKeyName: "_card_workspace_members_workspaceMemberId_workspace_members_id_" + columns: ["workspaceMemberId"] + isOneToOne: false + referencedRelation: "workspace_members" + referencedColumns: ["id"] }, - ]; - }; + ] + } board: { Row: { - createdAt: string; - createdBy: string; - deletedAt: string | null; - deletedBy: string | null; - id: number; - importId: number | null; - name: string; - publicId: string; - updatedAt: string | null; - workspaceId: number; - }; + createdAt: string + createdBy: string + deletedAt: string | null + deletedBy: string | null + id: number + importId: number | null + name: string + publicId: string + updatedAt: string | null + workspaceId: number + } Insert: { - createdAt?: string; - createdBy: string; - deletedAt?: string | null; - deletedBy?: string | null; - id?: number; - importId?: number | null; - name: string; - publicId: string; - updatedAt?: string | null; - workspaceId: number; - }; + createdAt?: string + createdBy: string + deletedAt?: string | null + deletedBy?: string | null + id?: number + importId?: number | null + name: string + publicId: string + updatedAt?: string | null + workspaceId: number + } Update: { - createdAt?: string; - createdBy?: string; - deletedAt?: string | null; - deletedBy?: string | null; - id?: number; - importId?: number | null; - name?: string; - publicId?: string; - updatedAt?: string | null; - workspaceId?: number; - }; + createdAt?: string + createdBy?: string + deletedAt?: string | null + deletedBy?: string | null + id?: number + importId?: number | null + name?: string + publicId?: string + updatedAt?: string | null + workspaceId?: number + } Relationships: [ { - foreignKeyName: "board_createdBy_user_id_fk"; - columns: ["createdBy"]; - isOneToOne: false; - referencedRelation: "user"; - referencedColumns: ["id"]; + foreignKeyName: "board_createdBy_user_id_fk" + columns: ["createdBy"] + isOneToOne: false + referencedRelation: "user" + referencedColumns: ["id"] }, { - foreignKeyName: "board_deletedBy_user_id_fk"; - columns: ["deletedBy"]; - isOneToOne: false; - referencedRelation: "user"; - referencedColumns: ["id"]; + foreignKeyName: "board_deletedBy_user_id_fk" + columns: ["deletedBy"] + isOneToOne: false + referencedRelation: "user" + referencedColumns: ["id"] }, { - foreignKeyName: "board_importId_import_id_fk"; - columns: ["importId"]; - isOneToOne: false; - referencedRelation: "import"; - referencedColumns: ["id"]; + foreignKeyName: "board_importId_import_id_fk" + columns: ["importId"] + isOneToOne: false + referencedRelation: "import" + referencedColumns: ["id"] }, { - foreignKeyName: "board_workspaceId_workspace_id_fk"; - columns: ["workspaceId"]; - isOneToOne: false; - referencedRelation: "workspace"; - referencedColumns: ["id"]; + foreignKeyName: "board_workspaceId_workspace_id_fk" + columns: ["workspaceId"] + isOneToOne: false + referencedRelation: "workspace" + referencedColumns: ["id"] }, - ]; - }; + ] + } card: { Row: { - createdAt: string; - createdBy: string; - deletedAt: string | null; - deletedBy: string | null; - description: string | null; - id: number; - importId: number | null; - index: number; - listId: number; - publicId: string; - title: string; - updatedAt: string | null; - }; + createdAt: string + createdBy: string + deletedAt: string | null + deletedBy: string | null + description: string | null + id: number + importId: number | null + index: number + listId: number + publicId: string + title: string + updatedAt: string | null + } Insert: { - createdAt?: string; - createdBy: string; - deletedAt?: string | null; - deletedBy?: string | null; - description?: string | null; - id?: number; - importId?: number | null; - index: number; - listId: number; - publicId: string; - title: string; - updatedAt?: string | null; - }; + createdAt?: string + createdBy: string + deletedAt?: string | null + deletedBy?: string | null + description?: string | null + id?: number + importId?: number | null + index: number + listId: number + publicId: string + title: string + updatedAt?: string | null + } Update: { - createdAt?: string; - createdBy?: string; - deletedAt?: string | null; - deletedBy?: string | null; - description?: string | null; - id?: number; - importId?: number | null; - index?: number; - listId?: number; - publicId?: string; - title?: string; - updatedAt?: string | null; - }; + createdAt?: string + createdBy?: string + deletedAt?: string | null + deletedBy?: string | null + description?: string | null + id?: number + importId?: number | null + index?: number + listId?: number + publicId?: string + title?: string + updatedAt?: string | null + } Relationships: [ { - foreignKeyName: "card_createdBy_user_id_fk"; - columns: ["createdBy"]; - isOneToOne: false; - referencedRelation: "user"; - referencedColumns: ["id"]; + foreignKeyName: "card_createdBy_user_id_fk" + columns: ["createdBy"] + isOneToOne: false + referencedRelation: "user" + referencedColumns: ["id"] }, { - foreignKeyName: "card_deletedBy_user_id_fk"; - columns: ["deletedBy"]; - isOneToOne: false; - referencedRelation: "user"; - referencedColumns: ["id"]; + foreignKeyName: "card_deletedBy_user_id_fk" + columns: ["deletedBy"] + isOneToOne: false + referencedRelation: "user" + referencedColumns: ["id"] }, { - foreignKeyName: "card_importId_import_id_fk"; - columns: ["importId"]; - isOneToOne: false; - referencedRelation: "import"; - referencedColumns: ["id"]; + foreignKeyName: "card_importId_import_id_fk" + columns: ["importId"] + isOneToOne: false + referencedRelation: "import" + referencedColumns: ["id"] }, { - foreignKeyName: "card_listId_list_id_fk"; - columns: ["listId"]; - isOneToOne: false; - referencedRelation: "list"; - referencedColumns: ["id"]; + foreignKeyName: "card_listId_list_id_fk" + columns: ["listId"] + isOneToOne: false + referencedRelation: "list" + referencedColumns: ["id"] }, - ]; - }; + ] + } card_activity: { Row: { - cardId: number; - commentId: number | null; - createdAt: string; - createdBy: string; - fromComment: string | null; - fromDescription: string | null; - fromIndex: number | null; - fromListId: number | null; - fromTitle: string | null; - id: number; - labelId: number | null; - publicId: string; - toComment: string | null; - toDescription: string | null; - toIndex: number | null; - toListId: number | null; - toTitle: string | null; - type: Database["public"]["Enums"]["card_activity_type"]; - workspaceMemberId: number | null; - }; + cardId: number + commentId: number | null + createdAt: string + createdBy: string + fromComment: string | null + fromDescription: string | null + fromIndex: number | null + fromListId: number | null + fromTitle: string | null + id: number + labelId: number | null + publicId: string + toComment: string | null + toDescription: string | null + toIndex: number | null + toListId: number | null + toTitle: string | null + type: Database["public"]["Enums"]["card_activity_type"] + workspaceMemberId: number | null + } Insert: { - cardId: number; - commentId?: number | null; - createdAt?: string; - createdBy: string; - fromComment?: string | null; - fromDescription?: string | null; - fromIndex?: number | null; - fromListId?: number | null; - fromTitle?: string | null; - id?: number; - labelId?: number | null; - publicId: string; - toComment?: string | null; - toDescription?: string | null; - toIndex?: number | null; - toListId?: number | null; - toTitle?: string | null; - type: Database["public"]["Enums"]["card_activity_type"]; - workspaceMemberId?: number | null; - }; + cardId: number + commentId?: number | null + createdAt?: string + createdBy: string + fromComment?: string | null + fromDescription?: string | null + fromIndex?: number | null + fromListId?: number | null + fromTitle?: string | null + id?: number + labelId?: number | null + publicId: string + toComment?: string | null + toDescription?: string | null + toIndex?: number | null + toListId?: number | null + toTitle?: string | null + type: Database["public"]["Enums"]["card_activity_type"] + workspaceMemberId?: number | null + } Update: { - cardId?: number; - commentId?: number | null; - createdAt?: string; - createdBy?: string; - fromComment?: string | null; - fromDescription?: string | null; - fromIndex?: number | null; - fromListId?: number | null; - fromTitle?: string | null; - id?: number; - labelId?: number | null; - publicId?: string; - toComment?: string | null; - toDescription?: string | null; - toIndex?: number | null; - toListId?: number | null; - toTitle?: string | null; - type?: Database["public"]["Enums"]["card_activity_type"]; - workspaceMemberId?: number | null; - }; + cardId?: number + commentId?: number | null + createdAt?: string + createdBy?: string + fromComment?: string | null + fromDescription?: string | null + fromIndex?: number | null + fromListId?: number | null + fromTitle?: string | null + id?: number + labelId?: number | null + publicId?: string + toComment?: string | null + toDescription?: string | null + toIndex?: number | null + toListId?: number | null + toTitle?: string | null + type?: Database["public"]["Enums"]["card_activity_type"] + workspaceMemberId?: number | null + } Relationships: [ { - foreignKeyName: "card_activity_cardId_card_id_fk"; - columns: ["cardId"]; - isOneToOne: false; - referencedRelation: "card"; - referencedColumns: ["id"]; + foreignKeyName: "card_activity_cardId_card_id_fk" + columns: ["cardId"] + isOneToOne: false + referencedRelation: "card" + referencedColumns: ["id"] }, { - foreignKeyName: "card_activity_commentId_card_comments_id_fk"; - columns: ["commentId"]; - isOneToOne: false; - referencedRelation: "card_comments"; - referencedColumns: ["id"]; + foreignKeyName: "card_activity_commentId_card_comments_id_fk" + columns: ["commentId"] + isOneToOne: false + referencedRelation: "card_comments" + referencedColumns: ["id"] }, { - foreignKeyName: "card_activity_createdBy_user_id_fk"; - columns: ["createdBy"]; - isOneToOne: false; - referencedRelation: "user"; - referencedColumns: ["id"]; + foreignKeyName: "card_activity_createdBy_user_id_fk" + columns: ["createdBy"] + isOneToOne: false + referencedRelation: "user" + referencedColumns: ["id"] }, { - foreignKeyName: "card_activity_fromListId_list_id_fk"; - columns: ["fromListId"]; - isOneToOne: false; - referencedRelation: "list"; - referencedColumns: ["id"]; + foreignKeyName: "card_activity_fromListId_list_id_fk" + columns: ["fromListId"] + isOneToOne: false + referencedRelation: "list" + referencedColumns: ["id"] }, { - foreignKeyName: "card_activity_labelId_label_id_fk"; - columns: ["labelId"]; - isOneToOne: false; - referencedRelation: "label"; - referencedColumns: ["id"]; + foreignKeyName: "card_activity_labelId_label_id_fk" + columns: ["labelId"] + isOneToOne: false + referencedRelation: "label" + referencedColumns: ["id"] }, { - foreignKeyName: "card_activity_toListId_list_id_fk"; - columns: ["toListId"]; - isOneToOne: false; - referencedRelation: "list"; - referencedColumns: ["id"]; + foreignKeyName: "card_activity_toListId_list_id_fk" + columns: ["toListId"] + isOneToOne: false + referencedRelation: "list" + referencedColumns: ["id"] }, { - foreignKeyName: "card_activity_workspaceMemberId_workspace_members_id_fk"; - columns: ["workspaceMemberId"]; - isOneToOne: false; - referencedRelation: "workspace_members"; - referencedColumns: ["id"]; + foreignKeyName: "card_activity_workspaceMemberId_workspace_members_id_fk" + columns: ["workspaceMemberId"] + isOneToOne: false + referencedRelation: "workspace_members" + referencedColumns: ["id"] }, - ]; - }; + ] + } card_comments: { Row: { - cardId: number; - comment: string; - createdAt: string; - createdBy: string; - deletedAt: string | null; - deletedBy: string | null; - id: number; - publicId: string; - updatedAt: string | null; - }; + cardId: number + comment: string + createdAt: string + createdBy: string + deletedAt: string | null + deletedBy: string | null + id: number + publicId: string + updatedAt: string | null + } Insert: { - cardId: number; - comment: string; - createdAt?: string; - createdBy: string; - deletedAt?: string | null; - deletedBy?: string | null; - id?: number; - publicId: string; - updatedAt?: string | null; - }; + cardId: number + comment: string + createdAt?: string + createdBy: string + deletedAt?: string | null + deletedBy?: string | null + id?: number + publicId: string + updatedAt?: string | null + } Update: { - cardId?: number; - comment?: string; - createdAt?: string; - createdBy?: string; - deletedAt?: string | null; - deletedBy?: string | null; - id?: number; - publicId?: string; - updatedAt?: string | null; - }; + cardId?: number + comment?: string + createdAt?: string + createdBy?: string + deletedAt?: string | null + deletedBy?: string | null + id?: number + publicId?: string + updatedAt?: string | null + } Relationships: [ { - foreignKeyName: "card_comments_cardId_card_id_fk"; - columns: ["cardId"]; - isOneToOne: false; - referencedRelation: "card"; - referencedColumns: ["id"]; + foreignKeyName: "card_comments_cardId_card_id_fk" + columns: ["cardId"] + isOneToOne: false + referencedRelation: "card" + referencedColumns: ["id"] }, { - foreignKeyName: "card_comments_createdBy_user_id_fk"; - columns: ["createdBy"]; - isOneToOne: false; - referencedRelation: "user"; - referencedColumns: ["id"]; + foreignKeyName: "card_comments_createdBy_user_id_fk" + columns: ["createdBy"] + isOneToOne: false + referencedRelation: "user" + referencedColumns: ["id"] }, { - foreignKeyName: "card_comments_deletedBy_user_id_fk"; - columns: ["deletedBy"]; - isOneToOne: false; - referencedRelation: "user"; - referencedColumns: ["id"]; + foreignKeyName: "card_comments_deletedBy_user_id_fk" + columns: ["deletedBy"] + isOneToOne: false + referencedRelation: "user" + referencedColumns: ["id"] }, - ]; - }; + ] + } import: { Row: { - createdAt: string; - createdBy: string; - id: number; - publicId: string; - source: Database["public"]["Enums"]["source"]; - status: Database["public"]["Enums"]["status"]; - }; + createdAt: string + createdBy: string + id: number + publicId: string + source: Database["public"]["Enums"]["source"] + status: Database["public"]["Enums"]["status"] + } Insert: { - createdAt?: string; - createdBy: string; - id?: number; - publicId: string; - source: Database["public"]["Enums"]["source"]; - status: Database["public"]["Enums"]["status"]; - }; + createdAt?: string + createdBy: string + id?: number + publicId: string + source: Database["public"]["Enums"]["source"] + status: Database["public"]["Enums"]["status"] + } Update: { - createdAt?: string; - createdBy?: string; - id?: number; - publicId?: string; - source?: Database["public"]["Enums"]["source"]; - status?: Database["public"]["Enums"]["status"]; - }; + createdAt?: string + createdBy?: string + id?: number + publicId?: string + source?: Database["public"]["Enums"]["source"] + status?: Database["public"]["Enums"]["status"] + } Relationships: [ { - foreignKeyName: "import_createdBy_user_id_fk"; - columns: ["createdBy"]; - isOneToOne: false; - referencedRelation: "user"; - referencedColumns: ["id"]; + foreignKeyName: "import_createdBy_user_id_fk" + columns: ["createdBy"] + isOneToOne: false + referencedRelation: "user" + referencedColumns: ["id"] }, - ]; - }; + ] + } label: { Row: { - boardId: number; - colourCode: string | null; - createdAt: string; - createdBy: string; - id: number; - importId: number | null; - name: string; - publicId: string; - updatedAt: string | null; - }; + boardId: number + colourCode: string | null + createdAt: string + createdBy: string + id: number + importId: number | null + name: string + publicId: string + updatedAt: string | null + } Insert: { - boardId: number; - colourCode?: string | null; - createdAt?: string; - createdBy: string; - id?: number; - importId?: number | null; - name: string; - publicId: string; - updatedAt?: string | null; - }; + boardId: number + colourCode?: string | null + createdAt?: string + createdBy: string + id?: number + importId?: number | null + name: string + publicId: string + updatedAt?: string | null + } Update: { - boardId?: number; - colourCode?: string | null; - createdAt?: string; - createdBy?: string; - id?: number; - importId?: number | null; - name?: string; - publicId?: string; - updatedAt?: string | null; - }; + boardId?: number + colourCode?: string | null + createdAt?: string + createdBy?: string + id?: number + importId?: number | null + name?: string + publicId?: string + updatedAt?: string | null + } Relationships: [ { - foreignKeyName: "label_boardId_board_id_fk"; - columns: ["boardId"]; - isOneToOne: false; - referencedRelation: "board"; - referencedColumns: ["id"]; + foreignKeyName: "label_boardId_board_id_fk" + columns: ["boardId"] + isOneToOne: false + referencedRelation: "board" + referencedColumns: ["id"] }, { - foreignKeyName: "label_createdBy_user_id_fk"; - columns: ["createdBy"]; - isOneToOne: false; - referencedRelation: "user"; - referencedColumns: ["id"]; + foreignKeyName: "label_createdBy_user_id_fk" + columns: ["createdBy"] + isOneToOne: false + referencedRelation: "user" + referencedColumns: ["id"] }, { - foreignKeyName: "label_importId_import_id_fk"; - columns: ["importId"]; - isOneToOne: false; - referencedRelation: "import"; - referencedColumns: ["id"]; + foreignKeyName: "label_importId_import_id_fk" + columns: ["importId"] + isOneToOne: false + referencedRelation: "import" + referencedColumns: ["id"] }, - ]; - }; + ] + } list: { Row: { - boardId: number; - createdAt: string; - createdBy: string; - deletedAt: string | null; - deletedBy: string | null; - id: number; - importId: number | null; - index: number; - name: string; - publicId: string; - updatedAt: string | null; - }; + boardId: number + createdAt: string + createdBy: string + deletedAt: string | null + deletedBy: string | null + id: number + importId: number | null + index: number + name: string + publicId: string + updatedAt: string | null + } Insert: { - boardId: number; - createdAt?: string; - createdBy: string; - deletedAt?: string | null; - deletedBy?: string | null; - id?: number; - importId?: number | null; - index: number; - name: string; - publicId: string; - updatedAt?: string | null; - }; + boardId: number + createdAt?: string + createdBy: string + deletedAt?: string | null + deletedBy?: string | null + id?: number + importId?: number | null + index: number + name: string + publicId: string + updatedAt?: string | null + } Update: { - boardId?: number; - createdAt?: string; - createdBy?: string; - deletedAt?: string | null; - deletedBy?: string | null; - id?: number; - importId?: number | null; - index?: number; - name?: string; - publicId?: string; - updatedAt?: string | null; - }; + boardId?: number + createdAt?: string + createdBy?: string + deletedAt?: string | null + deletedBy?: string | null + id?: number + importId?: number | null + index?: number + name?: string + publicId?: string + updatedAt?: string | null + } Relationships: [ { - foreignKeyName: "list_boardId_board_id_fk"; - columns: ["boardId"]; - isOneToOne: false; - referencedRelation: "board"; - referencedColumns: ["id"]; + foreignKeyName: "list_boardId_board_id_fk" + columns: ["boardId"] + isOneToOne: false + referencedRelation: "board" + referencedColumns: ["id"] }, { - foreignKeyName: "list_createdBy_user_id_fk"; - columns: ["createdBy"]; - isOneToOne: false; - referencedRelation: "user"; - referencedColumns: ["id"]; + foreignKeyName: "list_createdBy_user_id_fk" + columns: ["createdBy"] + isOneToOne: false + referencedRelation: "user" + referencedColumns: ["id"] }, { - foreignKeyName: "list_deletedBy_user_id_fk"; - columns: ["deletedBy"]; - isOneToOne: false; - referencedRelation: "user"; - referencedColumns: ["id"]; + foreignKeyName: "list_deletedBy_user_id_fk" + columns: ["deletedBy"] + isOneToOne: false + referencedRelation: "user" + referencedColumns: ["id"] }, { - foreignKeyName: "list_importId_import_id_fk"; - columns: ["importId"]; - isOneToOne: false; - referencedRelation: "import"; - referencedColumns: ["id"]; + foreignKeyName: "list_importId_import_id_fk" + columns: ["importId"] + isOneToOne: false + referencedRelation: "import" + referencedColumns: ["id"] }, - ]; - }; + ] + } user: { Row: { - email: string; - emailVerified: string | null; - id: string; - image: string | null; - name: string | null; - stripeCustomerId: string | null; - }; + email: string + emailVerified: string | null + id: string + image: string | null + name: string | null + stripeCustomerId: string | null + } Insert: { - email: string; - emailVerified?: string | null; - id: string; - image?: string | null; - name?: string | null; - stripeCustomerId?: string | null; - }; + email: string + emailVerified?: string | null + id: string + image?: string | null + name?: string | null + stripeCustomerId?: string | null + } Update: { - email?: string; - emailVerified?: string | null; - id?: string; - image?: string | null; - name?: string | null; - stripeCustomerId?: string | null; - }; - Relationships: []; - }; + email?: string + emailVerified?: string | null + id?: string + image?: string | null + name?: string | null + stripeCustomerId?: string | null + } + Relationships: [] + } workspace: { Row: { - createdAt: string; - createdBy: string; - deletedAt: string | null; - deletedBy: string | null; - id: number; - name: string; - publicId: string; - slug: string; - updatedAt: string | null; - }; + createdAt: string + createdBy: string + deletedAt: string | null + deletedBy: string | null + id: number + name: string + plan: Database["public"]["Enums"]["workspace_plan"] + publicId: string + slug: string + updatedAt: string | null + } Insert: { - createdAt?: string; - createdBy: string; - deletedAt?: string | null; - deletedBy?: string | null; - id?: number; - name: string; - publicId: string; - slug: string; - updatedAt?: string | null; - }; + createdAt?: string + createdBy: string + deletedAt?: string | null + deletedBy?: string | null + id?: number + name: string + plan?: Database["public"]["Enums"]["workspace_plan"] + publicId: string + slug: string + updatedAt?: string | null + } Update: { - createdAt?: string; - createdBy?: string; - deletedAt?: string | null; - deletedBy?: string | null; - id?: number; - name?: string; - publicId?: string; - slug?: string; - updatedAt?: string | null; - }; + createdAt?: string + createdBy?: string + deletedAt?: string | null + deletedBy?: string | null + id?: number + name?: string + plan?: Database["public"]["Enums"]["workspace_plan"] + publicId?: string + slug?: string + updatedAt?: string | null + } Relationships: [ { - foreignKeyName: "workspace_createdBy_user_id_fk"; - columns: ["createdBy"]; - isOneToOne: false; - referencedRelation: "user"; - referencedColumns: ["id"]; + foreignKeyName: "workspace_createdBy_user_id_fk" + columns: ["createdBy"] + isOneToOne: false + referencedRelation: "user" + referencedColumns: ["id"] }, { - foreignKeyName: "workspace_deletedBy_user_id_fk"; - columns: ["deletedBy"]; - isOneToOne: false; - referencedRelation: "user"; - referencedColumns: ["id"]; + foreignKeyName: "workspace_deletedBy_user_id_fk" + columns: ["deletedBy"] + isOneToOne: false + referencedRelation: "user" + referencedColumns: ["id"] }, - ]; - }; + ] + } workspace_members: { Row: { - createdAt: string; - createdBy: string; - deletedAt: string | null; - deletedBy: string | null; - id: number; - publicId: string; - role: Database["public"]["Enums"]["role"]; - status: Database["public"]["Enums"]["member_status"]; - updatedAt: string | null; - userId: string; - workspaceId: number; - }; + createdAt: string + createdBy: string + deletedAt: string | null + deletedBy: string | null + id: number + publicId: string + role: Database["public"]["Enums"]["role"] + status: Database["public"]["Enums"]["member_status"] + updatedAt: string | null + userId: string + workspaceId: number + } Insert: { - createdAt?: string; - createdBy: string; - deletedAt?: string | null; - deletedBy?: string | null; - id?: number; - publicId: string; - role: Database["public"]["Enums"]["role"]; - status?: Database["public"]["Enums"]["member_status"]; - updatedAt?: string | null; - userId: string; - workspaceId: number; - }; + createdAt?: string + createdBy: string + deletedAt?: string | null + deletedBy?: string | null + id?: number + publicId: string + role: Database["public"]["Enums"]["role"] + status?: Database["public"]["Enums"]["member_status"] + updatedAt?: string | null + userId: string + workspaceId: number + } Update: { - createdAt?: string; - createdBy?: string; - deletedAt?: string | null; - deletedBy?: string | null; - id?: number; - publicId?: string; - role?: Database["public"]["Enums"]["role"]; - status?: Database["public"]["Enums"]["member_status"]; - updatedAt?: string | null; - userId?: string; - workspaceId?: number; - }; + createdAt?: string + createdBy?: string + deletedAt?: string | null + deletedBy?: string | null + id?: number + publicId?: string + role?: Database["public"]["Enums"]["role"] + status?: Database["public"]["Enums"]["member_status"] + updatedAt?: string | null + userId?: string + workspaceId?: number + } Relationships: [ { - foreignKeyName: "workspace_members_deletedBy_user_id_fk"; - columns: ["deletedBy"]; - isOneToOne: false; - referencedRelation: "user"; - referencedColumns: ["id"]; + foreignKeyName: "workspace_members_deletedBy_user_id_fk" + columns: ["deletedBy"] + isOneToOne: false + referencedRelation: "user" + referencedColumns: ["id"] }, { - foreignKeyName: "workspace_members_userId_user_id_fk"; - columns: ["userId"]; - isOneToOne: false; - referencedRelation: "user"; - referencedColumns: ["id"]; + foreignKeyName: "workspace_members_userId_user_id_fk" + columns: ["userId"] + isOneToOne: false + referencedRelation: "user" + referencedColumns: ["id"] }, { - foreignKeyName: "workspace_members_workspaceId_workspace_id_fk"; - columns: ["workspaceId"]; - isOneToOne: false; - referencedRelation: "workspace"; - referencedColumns: ["id"]; + foreignKeyName: "workspace_members_workspaceId_workspace_id_fk" + columns: ["workspaceId"] + isOneToOne: false + referencedRelation: "workspace" + referencedColumns: ["id"] }, - ]; - }; + ] + } workspace_slugs: { Row: { - slug: string; - type: Database["public"]["Enums"]["slug_type"]; - }; + slug: string + type: Database["public"]["Enums"]["slug_type"] + } Insert: { - slug: string; - type: Database["public"]["Enums"]["slug_type"]; - }; + slug: string + type: Database["public"]["Enums"]["slug_type"] + } Update: { - slug?: string; - type?: Database["public"]["Enums"]["slug_type"]; - }; - Relationships: []; - }; - }; - Views: Record; + slug?: string + type?: Database["public"]["Enums"]["slug_type"] + } + Relationships: [] + } + } + Views: { + [_ in never]: never + } Functions: { is_workspace_admin: { Args: { - user_id: string; - workspace_id: number; - }; - Returns: boolean; - }; + user_id: string + workspace_id: number + } + Returns: boolean + } push_card_index: { Args: { - list_id: number; - card_index: number; - }; - Returns: undefined; - }; + list_id: number + card_index: number + } + Returns: undefined + } reorder_cards: { Args: { - card_id: number; - current_list_id: number; - new_list_id: number; - current_index: number; - new_index: number; - }; - Returns: boolean; - }; + card_id: number + current_list_id: number + new_list_id: number + current_index: number + new_index: number + } + Returns: boolean + } reorder_lists: { Args: { - board_id: number; - list_id: number; - current_index: number; - new_index: number; - }; - Returns: boolean; - }; + board_id: number + list_id: number + current_index: number + new_index: number + } + Returns: boolean + } shift_card_index: { Args: { - list_id: number; - card_index: number; - }; - Returns: undefined; - }; + list_id: number + card_index: number + } + Returns: undefined + } shift_list_index: { Args: { - board_id: number; - list_index: number; - }; - Returns: undefined; - }; - }; + board_id: number + list_index: number + } + Returns: undefined + } + } Enums: { card_activity_type: | "card.created" @@ -773,19 +776,22 @@ export interface Database { | "card.archived" | "card.updated.comment.added" | "card.updated.comment.updated" - | "card.updated.comment.deleted"; - member_status: "invited" | "active" | "removed"; - role: "admin" | "member" | "guest"; - slug_type: "reserved" | "premium"; - source: "trello"; - status: "started" | "success" | "failed"; - workspace_invite_status: "pending" | "accepted" | "cancelled"; - }; - CompositeTypes: Record; - }; + | "card.updated.comment.deleted" + member_status: "invited" | "active" | "removed" + role: "admin" | "member" | "guest" + slug_type: "reserved" | "premium" + source: "trello" + status: "started" | "success" | "failed" + workspace_invite_status: "pending" | "accepted" | "cancelled" + workspace_plan: "free" | "pro" | "enterprise" + } + CompositeTypes: { + [_ in never]: never + } + } } -type PublicSchema = Database[Extract]; +type PublicSchema = Database[Extract] export type Tables< PublicTableNameOrOptions extends @@ -798,7 +804,7 @@ export type Tables< > = PublicTableNameOrOptions extends { schema: keyof Database } ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] & Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends { - Row: infer R; + Row: infer R } ? R : never @@ -806,11 +812,11 @@ export type Tables< PublicSchema["Views"]) ? (PublicSchema["Tables"] & PublicSchema["Views"])[PublicTableNameOrOptions] extends { - Row: infer R; + Row: infer R } ? R : never - : never; + : never export type TablesInsert< PublicTableNameOrOptions extends @@ -821,17 +827,17 @@ export type TablesInsert< : never = never, > = PublicTableNameOrOptions extends { schema: keyof Database } ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Insert: infer I; + Insert: infer I } ? I : never : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { - Insert: infer I; + Insert: infer I } ? I : never - : never; + : never export type TablesUpdate< PublicTableNameOrOptions extends @@ -842,17 +848,17 @@ export type TablesUpdate< : never = never, > = PublicTableNameOrOptions extends { schema: keyof Database } ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Update: infer U; + Update: infer U } ? U : never : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { - Update: infer U; + Update: infer U } ? U : never - : never; + : never export type Enums< PublicEnumNameOrOptions extends @@ -865,14 +871,14 @@ export type Enums< ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName] : PublicEnumNameOrOptions extends keyof PublicSchema["Enums"] ? PublicSchema["Enums"][PublicEnumNameOrOptions] - : never; + : never export type CompositeTypes< PublicCompositeTypeNameOrOptions extends | keyof PublicSchema["CompositeTypes"] | { schema: keyof Database }, CompositeTypeName extends PublicCompositeTypeNameOrOptions extends { - schema: keyof Database; + schema: keyof Database } ? keyof Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"] : never = never, @@ -880,4 +886,4 @@ export type CompositeTypes< ? Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName] : PublicCompositeTypeNameOrOptions extends keyof PublicSchema["CompositeTypes"] ? PublicSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions] - : never; + : never