feat: invite workspace members via link (#196)

* feat: add workspace invite links schema

* feat: update workspace invite schema

* feat: add repo funcs and share link toggle

* feat: redirect to next param on authentication

* feat: add invite page

* feat: switch to workspace on invite success

* refactor: tweak light mode styles

* feat(cloud): update subscription for cloud

* feat: only allow admin users to create links

* chore: add translations
This commit is contained in:
Henry
2025-09-26 22:25:42 +01:00
committed by GitHub
parent 7ab30acfc4
commit b159b48c35
30 changed files with 4678 additions and 506 deletions

View File

@@ -11,3 +11,4 @@ export * from "./users";
export * from "./integrations";
export * from "./workspaces";
export * from "./subscriptions";
export * from "./workspaceInviteLinks";

View File

@@ -0,0 +1,38 @@
import {
bigint,
bigserial,
pgEnum,
pgTable,
timestamp,
uuid,
varchar,
} from "drizzle-orm/pg-core";
import { users } from "./users";
import { workspaces } from "./workspaces";
export const inviteLinkStatuses = ["active", "inactive"] as const;
export type InviteLinkStatus = (typeof inviteLinkStatuses)[number];
export const inviteLinkStatusEnum = pgEnum(
"invite_link_status",
inviteLinkStatuses,
);
export const workspaceInviteLinks = pgTable("workspace_invite_links", {
id: bigserial("id", { mode: "number" }).primaryKey(),
publicId: varchar("publicId", { length: 12 }).notNull().unique(),
workspaceId: bigint("workspaceId", { mode: "number" })
.notNull()
.references(() => workspaces.id, { onDelete: "cascade" }),
code: varchar("code", { length: 12 }).notNull().unique(),
status: inviteLinkStatusEnum("status").notNull().default("active"),
expiresAt: timestamp("expiresAt"),
createdAt: timestamp("createdAt").defaultNow().notNull(),
createdBy: uuid("createdBy").references(() => users.id, {
onDelete: "set null",
}),
updatedAt: timestamp("updatedAt"),
updatedBy: uuid("updatedBy").references(() => users.id, {
onDelete: "set null",
}),
}).enableRLS();