Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat: add organization private sharing default and viewer invites
Richie McIlroyd34acba3d760
diff --git a/apps/web/__tests__/unit/desktop-video-create.test.ts b/apps/web/__tests__/unit/desktop-video-create.test.tsindex 6dcf02ed9..b3ae99808 100644--- a/apps/web/__tests__/unit/desktop-video-create.test.ts+++ b/apps/web/__tests__/unit/desktop-video-create.test.ts@@ -12,6 +12,9 @@ const deletion = vi.hoisted(() => ({deleteVideo: vi.fn(),principal: vi.fn(),}));+const defaultSharing = vi.hoisted(() => ({+ getNewVideoPublic: vi.fn(),+}));const schema = {organizations: { table: "organizations" },@@ -42,6 +45,7 @@ const mockDb = {vi.mock("@cap/database", () => ({db: () => mockDb,}));+vi.mock("@cap/database/video-sharing-default", () => defaultSharing);vi.mock("@cap/database/auth/session", () => ({getCurrentUser: vi.fn(),@@ -400,6 +404,7 @@ describe("GET /create", () => {vi.clearAllMocks();resetMockDb();stubStorage();+ defaultSharing.getNewVideoPublic.mockResolvedValue(true);const mod = await import("@/app/api/desktop/[...route]/video");app = mod.app;});@@ -477,6 +482,31 @@ describe("GET /create", () => {});});+ it("creates a private recording when the organization default resolves to private", async () => {+ defaultSharing.getNewVideoPublic.mockResolvedValue(false);+ mockGetCurrentUser.mockResolvedValue({+ id: "user-1",+ email: "[email protected]",+ defaultOrgId: "org-1",+ activeOrganizationId: "org-1",+ });+ mockDb.where+ .mockResolvedValueOnce([+ { id: "org-1", name: "Acme", createdAt: new Date() },+ ])+ .mockResolvedValueOnce([])+ .mockResolvedValueOnce([{ count: 5 }]);++ const response = await app.request("https://cap.test/create");++ expect(response.status).toBe(200);+ expect(defaultSharing.getNewVideoPublic).toHaveBeenCalledWith("org-1");+ expect(insertedValues(schema.videos)).toMatchObject({+ orgId: "org-1",+ public: false,+ });+ });+it("heals a dangling defaultOrgId when the user has no remaining orgs", async () => {mockGetCurrentUser.mockResolvedValue({id: "user-1",diff --git a/apps/web/__tests__/unit/loom-import.test.ts b/apps/web/__tests__/unit/loom-import.test.tsindex fc1256226..a8068f6e3 100644--- a/apps/web/__tests__/unit/loom-import.test.ts+++ b/apps/web/__tests__/unit/loom-import.test.ts@@ -11,6 +11,9 @@ const headersMock = vi.hoisted(() => vi.fn());const getOrganizationAccessMock = vi.hoisted(() => vi.fn());const requireSpaceManagerMock = vi.hoisted(() => vi.fn());const requireOrganizationSettingsManagerMock = vi.hoisted(() => vi.fn());+const defaultSharing = vi.hoisted(() => ({+ getNewVideoPublic: vi.fn(),+}));const mockDb = {select: vi.fn(() => mockDb),@@ -29,6 +32,7 @@ const mockDb = {vi.mock("@cap/database", () => ({db: vi.fn(() => mockDb),}));+vi.mock("@cap/database/video-sharing-default", () => defaultSharing);vi.mock("server-only", () => ({}));@@ -214,6 +218,7 @@ function withLimit(value: unknown) {describe("importFromLoom", () => {beforeEach(() => {vi.clearAllMocks();+ defaultSharing.getNewVideoPublic.mockResolvedValue(true);whereMock.mockReset();requireSpaceManagerMock.mockReset();requireOrganizationSettingsManagerMock.mockReset();diff --git a/apps/web/__tests__/unit/share-audience.test.ts b/apps/web/__tests__/unit/share-audience.test.tsindex 4daa5816d..77aa8b74f 100644--- a/apps/web/__tests__/unit/share-audience.test.ts+++ b/apps/web/__tests__/unit/share-audience.test.ts@@ -14,6 +14,18 @@ describe("describeShareAudience", () => {expect(audience.tooltip).toContain("outside your organization");});+ it("identifies domain restricted link sharing separately from a private recording", () => {+ const audience = describeShareAudience({+ isPublic: true,+ allowedEmailDomain: "route.com",+ passwordProtected: false,+ audienceNames: [],+ });++ expect(audience.label).toBe("Restricted link access");+ expect(audience.tooltip).toContain("route.com or invited viewers");+ });+it("says a password is required when the public link is locked", () => {const audience = describeShareAudience({isPublic: true,@@ -99,4 +111,31 @@ describe("describeShareAudience", () => {expect(audience.label).toBe("Only you");expect(audience.tooltip).toContain("Click to share it");});++ it("shows invited viewers on a private recording", () => {+ const audience = describeShareAudience({+ isPublic: false,+ passwordProtected: false,+ audienceNames: [],+ viewerCount: 2,+ });++ expect(audience.kind).toBe("people");+ expect(audience.label).toBe("Shared with 2 people");+ expect(audience.tooltip).toContain("invited email address");+ });++ it("includes invited viewers alongside a shared space", () => {+ const audience = describeShareAudience({+ isPublic: false,+ passwordProtected: false,+ audienceNames: ["Design"],+ viewerCount: 1,+ });++ expect(audience.label).toBe("Shared with spaces and 1 person");+ expect(audience.tooltip).toContain(+ "members of Design and 1 invited person",+ );+ });});diff --git a/apps/web/__tests__/unit/sso-settings.test.ts b/apps/web/__tests__/unit/sso-settings.test.tsindex d216a38df..b0567b12e 100644--- a/apps/web/__tests__/unit/sso-settings.test.ts+++ b/apps/web/__tests__/unit/sso-settings.test.ts@@ -178,6 +178,7 @@ function makeFixture({metadata: null,tombstoneAt: null,allowedEmailDomain: null,+ defaultVideoVisibility: null,customDomain: null,domainVerified: null,settings: null,diff --git a/apps/web/__tests__/unit/video-sharing-default.test.ts b/apps/web/__tests__/unit/video-sharing-default.test.tsnew file mode 100644index 000000000..fac23e535--- /dev/null+++ b/apps/web/__tests__/unit/video-sharing-default.test.ts@@ -0,0 +1,57 @@+import { getNewVideoPublic } from "@cap/database/video-sharing-default";+import type { Organisation } from "@cap/web-domain";+import { beforeEach, describe, expect, it, vi } from "vitest";++const lookup = vi.hoisted(() => ({+ limit: vi.fn(),+ serverDefaultPublic: true,+}));++vi.mock("@cap/database", () => ({+ db: () => ({+ select: () => ({+ from: () => ({+ where: () => ({ limit: lookup.limit }),+ }),+ }),+ }),+}));++vi.mock("@cap/env", () => ({+ serverEnv: () => ({+ CAP_VIDEOS_DEFAULT_PUBLIC: lookup.serverDefaultPublic,+ }),+}));++const ORGANIZATION_ID = "org-1" as Organisation.OrganisationId;++describe("new recording visibility", () => {+ beforeEach(() => {+ lookup.limit.mockReset();+ lookup.serverDefaultPublic = true;+ });++ it("keeps the current server default for organizations that have not opted in", async () => {+ lookup.limit.mockResolvedValue([+ { defaultVideoVisibility: null, tombstoneAt: null },+ ]);+ expect(await getNewVideoPublic(ORGANIZATION_ID)).toBe(true);++ lookup.serverDefaultPublic = false;+ expect(await getNewVideoPublic(ORGANIZATION_ID)).toBe(false);+ });++ it("starts recordings private after the organization opts in", async () => {+ lookup.limit.mockResolvedValue([+ { defaultVideoVisibility: "private", tombstoneAt: null },+ ]);+ expect(await getNewVideoPublic(ORGANIZATION_ID)).toBe(false);+ });++ it("rejects a missing or deleted organization", async () => {+ lookup.limit.mockResolvedValue([]);+ await expect(getNewVideoPublic(ORGANIZATION_ID)).rejects.toThrow(+ "Organization not found",+ );+ });+});diff --git a/apps/web/__tests__/unit/video-viewer-invites.test.ts b/apps/web/__tests__/unit/video-viewer-invites.test.tsnew file mode 100644index 000000000..3719694de--- /dev/null+++ b/apps/web/__tests__/unit/video-viewer-invites.test.ts@@ -0,0 +1,190 @@+import type { Video } from "@cap/web-domain";+import { beforeEach, describe, expect, it, vi } from "vitest";+import {+ getVideoViewerGrants,+ inviteVideoViewer,+ revokeVideoViewer,+} from "@/actions/videos/viewer-invites";++const fixtures = vi.hoisted(() => ({+ user: vi.fn(),+ sendEmail: vi.fn(),+ revalidatePath: vi.fn(),+ video: { id: "video-1", ownerId: "owner-1", name: "Demo" },+ grants: [] as string[],+ revokedEmails: [] as string[],+ inserted: vi.fn(),+ updated: vi.fn(),+}));++const schema = vi.hoisted(() => ({+ videos: { id: "videoId", name: "videoName", ownerId: "videoOwnerId" },+ videoViewerGrants: {+ videoId: "grantVideoId",+ email: "grantEmail",+ revokedAt: "grantRevokedAt",+ },+}));++vi.mock("@cap/database", () => ({+ db: () => {+ let selectedTable: unknown;+ return {+ select: () => ({+ from: (table: unknown) => {+ selectedTable = table;+ return {+ where: () => ({+ limit: async () =>+ selectedTable === schema.videos+ ? [fixtures.video]+ : fixtures.grants.map((email) => ({+ email,+ revokedAt: fixtures.revokedEmails.includes(email)+ ? new Date(0)+ : null,+ })),+ orderBy: async () => fixtures.grants.map((email) => ({ email })),+ }),+ };+ },+ }),+ insert: () => ({+ values: (value: unknown) => ({+ onDuplicateKeyUpdate: async () => fixtures.inserted(value),+ }),+ }),+ update: () => ({+ set: (value: unknown) => ({+ where: async () => fixtures.updated(value),+ }),+ }),+ };+ },+}));++vi.mock("@cap/database/auth/session", () => ({+ getCurrentUser: fixtures.user,+}));+vi.mock("@cap/database/emails/config", () => ({+ sendEmail: fixtures.sendEmail,+}));+vi.mock("@cap/database/emails/video-viewer-invite", () => ({+ VideoViewerInvite: () => null,+}));+vi.mock("@cap/database/helpers", () => ({+ nanoId: () => "grant-1",+}));+vi.mock("@cap/database/schema", () => schema);+vi.mock("@cap/env", () => ({+ serverEnv: () => ({ WEB_URL: "https://cap.test" }),+}));+vi.mock("drizzle-orm", () => ({+ and: vi.fn((...parts: unknown[]) => parts),+ eq: vi.fn((column: unknown, value: unknown) => ({ column, value })),+ isNull: vi.fn((column: unknown) => ({ column })),+}));+vi.mock("next/cache", () => ({+ revalidatePath: fixtures.revalidatePath,+}));++const VIDEO_ID = "video-1" as Video.VideoId;++describe("recording viewer invitations", () => {+ beforeEach(() => {+ vi.clearAllMocks();+ fixtures.grants = [];+ fixtures.revokedEmails = [];+ fixtures.video.ownerId = "owner-1";+ fixtures.user.mockResolvedValue({ id: "owner-1" });+ fixtures.sendEmail.mockResolvedValue({+ data: { id: "email-1" },+ error: null,+ });+ });++ it("rejects a non-owner before writing a grant or sending email", async () => {+ fixtures.user.mockResolvedValue({ id: "other-1" });++ await expect(+ inviteVideoViewer(VIDEO_ID, "[email protected]"),+ ).rejects.toThrow("Unauthorized");+ expect(fixtures.inserted).not.toHaveBeenCalled();+ expect(fixtures.sendEmail).not.toHaveBeenCalled();+ });++ it("grants access to the normalized email and sends the recording link", async () => {+ const result = await inviteVideoViewer(VIDEO_ID, " [email protected] ");++ expect(result).toEqual({+ success: true,+ alreadyAdded: false,+ emailSent: true,+ });+ expect(fixtures.inserted).toHaveBeenCalledWith(+ expect.objectContaining({+ videoId: VIDEO_ID,+ email: "[email protected]",+ }),+ );+ expect(fixtures.sendEmail).toHaveBeenCalledWith(+ expect.objectContaining({ email: "[email protected]" }),+ );+ });++ it("keeps access when email delivery is unavailable so the owner can share the link", async () => {+ fixtures.sendEmail.mockResolvedValue(undefined);++ const result = await inviteVideoViewer(VIDEO_ID, "[email protected]");++ expect(result.emailSent).toBe(false);+ expect(fixtures.inserted).toHaveBeenCalledOnce();+ });++ it("does not resend an invitation for an active grant", async () => {+ fixtures.grants = ["[email protected]"];++ const result = await inviteVideoViewer(VIDEO_ID, "[email protected]");++ expect(result.alreadyAdded).toBe(true);+ expect(fixtures.inserted).not.toHaveBeenCalled();+ expect(fixtures.sendEmail).not.toHaveBeenCalled();+ });++ it("can invite an email again after its grant was revoked", async () => {+ fixtures.grants = ["[email protected]"];+ fixtures.revokedEmails = ["[email protected]"];++ const result = await inviteVideoViewer(VIDEO_ID, "[email protected]");++ expect(result.alreadyAdded).toBe(false);+ expect(fixtures.inserted).toHaveBeenCalledOnce();+ expect(fixtures.sendEmail).toHaveBeenCalledOnce();+ });++ it("keeps the invited viewer list and removal owner-only", async () => {+ fixtures.grants = ["[email protected]"];+ fixtures.user.mockResolvedValue({ id: "other-1" });+ await expect(getVideoViewerGrants(VIDEO_ID)).rejects.toThrow(+ "Unauthorized",+ );+ await expect(+ revokeVideoViewer(VIDEO_ID, "[email protected]"),+ ).rejects.toThrow("Unauthorized");+ expect(fixtures.updated).not.toHaveBeenCalled();+ });++ it("marks a viewer grant revoked when the owner removes it", async () => {+ fixtures.grants = ["[email protected]"];++ await expect(+ revokeVideoViewer(VIDEO_ID, "[email protected]"),+ ).resolves.toEqual({+ success: true,+ });+ expect(fixtures.updated).toHaveBeenCalledWith({+ revokedAt: expect.any(Date),+ });+ expect(fixtures.revalidatePath).toHaveBeenCalledWith(`/s/${VIDEO_ID}`);+ });+});diff --git a/apps/web/__tests__/unit/videos-policy.test.ts b/apps/web/__tests__/unit/videos-policy.test.tsindex 7c218ac46..6d1acb796 100644--- a/apps/web/__tests__/unit/videos-policy.test.ts+++ b/apps/web/__tests__/unit/videos-policy.test.ts@@ -51,6 +51,7 @@ function makeDeps(config: {orgMembership?: boolean;spaceMembership?: boolean;allowedEmailDomain?: Option.Option<string>;+ viewerGrantEmail?: string;}): VideosPolicyDeps {const {video,@@ -59,6 +60,7 @@ function makeDeps(config: {orgMembership = false,spaceMembership = false,allowedEmailDomain = Option.none<string>(),+ viewerGrantEmail,} = config;return {@@ -67,6 +69,7 @@ function makeDeps(config: {Effect.succeed(video ? Option.some([video, password] as const) : Option.none(),),+ hasViewerGrant: (_, email) => Effect.succeed(email === viewerGrantEmail),},orgsRepo: {membershipForVideo: () =>@@ -483,6 +486,42 @@ describe("VideosPolicy.canView", () => {});describe("the contractor scenario", () => {+ it("allows a named external viewer to watch a private video", async () => {+ const deps = makeDeps({+ video: makeVideo({ public: false }),+ viewerGrantEmail: "[email protected]",+ });+ expect(await runCanView(deps, makeUser("[email protected]"))).toBe(+ "allowed",+ );+ expect(await runCanView(deps, makeUser("[email protected]"))).toBe(+ "denied",+ );+ expect(await runCanView(deps, noUser)).toBe("denied");+ });++ it("lets a named viewer bypass the public link domain restriction", async () => {+ const deps = makeDeps({+ video: makeVideo({ public: true }),+ viewerGrantEmail: "[email protected]",+ allowedEmailDomain: Option.some("mycompany.com"),+ });+ expect(await runCanView(deps, makeUser("[email protected]"))).toBe(+ "allowed",+ );+ });++ it("still requires the recording password from an invited viewer", async () => {+ const deps = makeDeps({+ video: makeVideo({ public: false }),+ password: Option.some("video-hash"),+ viewerGrantEmail: "[email protected]",+ });+ expect(await runCanView(deps, makeUser("[email protected]"))).toBe(+ "password",+ );+ });+it("contractor in space can access private video despite domain restriction", async () => {const deps = makeDeps({video: makeVideo({ public: false }),@@ -653,6 +692,14 @@ describe("VideosPolicy.canViewLoaded", () => {},user: makeUser("[email protected]"),},+ {+ name: "named external viewer on a private video",+ config: {+ video: makeVideo({ public: false }),+ viewerGrantEmail: "[email protected]",+ },+ user: makeUser("[email protected]"),+ },{name: "anonymous viewer with a video password and no attachment",config: { video: makeVideo(), password: Option.some("video-hash") },@@ -722,6 +769,7 @@ describe("VideosPolicy.canViewLoaded", () => {const countingDeps: VideosPolicyDeps = {...deps,repo: {+ ...deps.repo,getById: (id) => {getByIdCalls += 1;return deps.repo.getById(id);diff --git a/apps/web/actions/loom.ts b/apps/web/actions/loom.tsindex b9e03dcec..80386e189 100644--- a/apps/web/actions/loom.ts+++ b/apps/web/actions/loom.ts@@ -16,6 +16,7 @@ import {videos,videoUploads,} from "@cap/database/schema";+import { getNewVideoPublic } from "@cap/database/video-sharing-default";import { buildEnv, NODE_ENV, serverEnv } from "@cap/env";import { dub, userIsPro } from "@cap/utils";import { Storage } from "@cap/web-backend";@@ -404,7 +405,7 @@ async function importLoomVideoForOwner({source: { type: "webMP4" as const },bucket: Option.getOrNull(writable.bucketId),storageIntegrationId: Option.getOrNull(writable.storageIntegrationId),- public: serverEnv().CAP_VIDEOS_DEFAULT_PUBLIC,+ public: await getNewVideoPublic(orgId),...(oembedMeta?.duration ? { duration: oembedMeta.duration } : {}),...(oembedMeta?.width ? { width: oembedMeta.width } : {}),...(oembedMeta?.height ? { height: oembedMeta.height } : {}),diff --git a/apps/web/actions/organization/default-video-visibility.ts b/apps/web/actions/organization/default-video-visibility.tsnew file mode 100644index 000000000..2bd8a16a4--- /dev/null+++ b/apps/web/actions/organization/default-video-visibility.ts@@ -0,0 +1,25 @@+"use server";++import { db } from "@cap/database";+import { getCurrentUser } from "@cap/database/auth/session";+import { organizations } from "@cap/database/schema";+import { eq } from "drizzle-orm";+import { revalidatePath } from "next/cache";+import { requireOrganizationSettingsManager } from "./authorization";++export async function updateDefaultVideoVisibility(privateByDefault: boolean) {+ const user = await getCurrentUser();+ if (!user?.activeOrganizationId) throw new Error("Unauthorized");++ const organizationId = user.activeOrganizationId;+ await requireOrganizationSettingsManager(user.id, organizationId);++ await db()+ .update(organizations)+ .set({ defaultVideoVisibility: privateByDefault ? "private" : null })+ .where(eq(organizations.id, organizationId));++ revalidatePath("/dashboard/settings/organization/preferences");+ revalidatePath("/dashboard/caps");+ return { success: true };+}diff --git a/apps/web/actions/video/create-for-processing.ts b/apps/web/actions/video/create-for-processing.tsindex 656d8155e..7a5660bbf 100644--- a/apps/web/actions/video/create-for-processing.ts+++ b/apps/web/actions/video/create-for-processing.ts@@ -4,7 +4,7 @@ import { db } from "@cap/database";import { getCurrentUser } from "@cap/database/auth/session";import { nanoId } from "@cap/database/helpers";import { videos, videoUploads } from "@cap/database/schema";-import { serverEnv } from "@cap/env";+import { getNewVideoPublic } from "@cap/database/video-sharing-default";import { userIsPro } from "@cap/utils";import { Storage as StorageService } from "@cap/web-backend";import {@@ -98,7 +98,7 @@ export async function createVideoForServerProcessing({source: { type: "webMP4" as const },bucket: Option.getOrNull(uploadResult.bucketId),storageIntegrationId: Option.getOrNull(uploadResult.storageIntegrationId),- public: serverEnv().CAP_VIDEOS_DEFAULT_PUBLIC,+ public: await getNewVideoPublic(orgId),...(folderId ? { folderId } : {}),});diff --git a/apps/web/actions/video/upload.ts b/apps/web/actions/video/upload.tsindex 4dbce3b51..5403fa431 100644--- a/apps/web/actions/video/upload.ts+++ b/apps/web/actions/video/upload.ts@@ -4,7 +4,7 @@ import { db } from "@cap/database";import { getCurrentUser } from "@cap/database/auth/session";import { nanoId } from "@cap/database/helpers";import { videos, videoUploads } from "@cap/database/schema";-import { serverEnv } from "@cap/env";+import { getNewVideoPublic } from "@cap/database/video-sharing-default";import { userIsPro } from "@cap/utils";import { Storage as StorageService } from "@cap/web-backend";import {@@ -228,7 +228,7 @@ export async function createVideoAndGetUploadUrl({isScreenshot,bucket: Option.getOrNull(bucketId),storageIntegrationId: Option.getOrNull(storageIntegrationId),- public: serverEnv().CAP_VIDEOS_DEFAULT_PUBLIC,+ public: await getNewVideoPublic(orgId),...(folderId ? { folderId } : {}),};diff --git a/apps/web/actions/videos/viewer-invites.ts b/apps/web/actions/videos/viewer-invites.tsnew file mode 100644index 000000000..ffa895abd--- /dev/null+++ b/apps/web/actions/videos/viewer-invites.ts@@ -0,0 +1,123 @@+"use server";++import { db } from "@cap/database";+import { getCurrentUser } from "@cap/database/auth/session";+import { sendEmail } from "@cap/database/emails/config";+import { VideoViewerInvite } from "@cap/database/emails/video-viewer-invite";+import { nanoId } from "@cap/database/helpers";+import { videos, videoViewerGrants } from "@cap/database/schema";+import { serverEnv } from "@cap/env";+import type { Video } from "@cap/web-domain";+import { and, eq, isNull } from "drizzle-orm";+import { revalidatePath } from "next/cache";++const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;++async function getOwnedVideo(videoId: Video.VideoId) {+ const user = await getCurrentUser();+ if (!user) throw new Error("Unauthorized");++ const [video] = await db()+ .select({ id: videos.id, name: videos.name, ownerId: videos.ownerId })+ .from(videos)+ .where(eq(videos.id, videoId))+ .limit(1);++ if (!video || video.ownerId !== user.id) throw new Error("Unauthorized");+ return { user, video };+}++function normalizeEmail(email: string) {+ const normalized = email.trim().toLowerCase();+ if (normalized.length > 254 || !EMAIL_PATTERN.test(normalized)) {+ throw new Error("Enter a valid email address");+ }+ return normalized;+}++export async function getVideoViewerGrants(videoId: Video.VideoId) {+ await getOwnedVideo(videoId);+ return db()+ .select({ email: videoViewerGrants.email })+ .from(videoViewerGrants)+ .where(+ and(+ eq(videoViewerGrants.videoId, videoId),+ isNull(videoViewerGrants.revokedAt),+ ),+ )+ .orderBy(videoViewerGrants.email);+}++export async function inviteVideoViewer(videoId: Video.VideoId, email: string) {+ const { user, video } = await getOwnedVideo(videoId);+ const normalizedEmail = normalizeEmail(email);++ const [existingGrant] = await db()+ .select({ revokedAt: videoViewerGrants.revokedAt })+ .from(videoViewerGrants)+ .where(+ and(+ eq(videoViewerGrants.videoId, videoId),+ eq(videoViewerGrants.email, normalizedEmail),+ ),+ )+ .limit(1);++ if (existingGrant && !existingGrant.revokedAt) {+ return { success: true, alreadyAdded: true, emailSent: false };+ }++ await db()+ .insert(videoViewerGrants)+ .values({+ id: nanoId(),+ videoId,+ email: normalizedEmail,+ invitedByUserId: user.id,+ })+ .onDuplicateKeyUpdate({+ set: { revokedAt: null, invitedByUserId: user.id },+ });++ revalidatePath(`/s/${videoId}`);++ let emailSent = false;+ try {+ const result = await sendEmail({+ email: normalizedEmail,+ subject: `Invitation to watch ${video.name} on Cap`,+ react: VideoViewerInvite({+ email: normalizedEmail,+ videoName: video.name,+ url: `${serverEnv().WEB_URL}/s/${videoId}`,+ }),+ });+ emailSent = Boolean(result?.data && !result.error);+ if (result?.error) {+ console.error("Failed to email video viewer invitation:", result.error);+ }+ } catch (error) {+ console.error("Failed to email video viewer invitation:", error);+ }++ return { success: true, alreadyAdded: false, emailSent };+}++export async function revokeVideoViewer(videoId: Video.VideoId, email: string) {+ await getOwnedVideo(videoId);+ const normalizedEmail = normalizeEmail(email);+ await db()+ .update(videoViewerGrants)+ .set({ revokedAt: new Date() })+ .where(+ and(+ eq(videoViewerGrants.videoId, videoId),+ eq(videoViewerGrants.email, normalizedEmail),+ isNull(videoViewerGrants.revokedAt),+ ),+ );++ revalidatePath(`/s/${videoId}`);+ return { success: true };+}diff --git a/apps/web/app/(org)/dashboard/caps/components/SharingDialog.tsx b/apps/web/app/(org)/dashboard/caps/components/SharingDialog.tsxindex b0ce14d42..cae466172 100644--- a/apps/web/app/(org)/dashboard/caps/components/SharingDialog.tsx+++ b/apps/web/app/(org)/dashboard/caps/components/SharingDialog.tsx@@ -12,10 +12,11 @@ import type { SpaceRuleSource, ViewerSettingKey } from "@cap/web-backend";import { type ImageUpload, Space, type Video } from "@cap/web-domain";import { faCopy, faShareNodes } from "@fortawesome/free-solid-svg-icons";import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { useMutation } from "@tanstack/react-query";+import { useMutation, useQuery } from "@tanstack/react-query";import clsx from "clsx";import { Check, Globe2, Lock, Search } from "lucide-react";import { motion } from "motion/react";+import { useRouter } from "next/navigation";import { useCallback, useEffect, useMemo, useState } from "react";import { toast } from "sonner";import { shareCap } from "@/actions/caps/share";@@ -23,6 +24,11 @@ import {removeVideoPassword,setVideoPassword,} from "@/actions/videos/password";+import {+ getVideoViewerGrants,+ inviteVideoViewer,+ revokeVideoViewer,+} from "@/actions/videos/viewer-invites";import { useDashboardContext } from "@/app/(org)/dashboard/Contexts";import type { Spaces } from "@/app/(org)/dashboard/dashboard-data";import type { CurrentUser } from "@/app/Layout/AuthContext";@@ -49,6 +55,7 @@ interface SharingDialogProps {isPublic?: boolean;spacesData?: Spaces[] | null;hasPassword?: boolean;+ allowedEmailDomain?: string | null;inheritedPasswordSources?: SpaceRuleSource[];onPasswordUpdated?: (protectedStatus: boolean) => void;user?: CurrentUser | null;@@ -65,6 +72,7 @@ export const SharingDialog: React.FC<SharingDialogProps> = ({isPublic = false,spacesData: propSpacesData = null,hasPassword = false,+ allowedEmailDomain: propAllowedEmailDomain,inheritedPasswordSources = [],onPasswordUpdated,user: propUser,@@ -80,6 +88,7 @@ export const SharingDialog: React.FC<SharingDialogProps> = ({const user = propUser ?? contextUser;const onUpgradeRequest = propOnUpgradeRequest ?? setUpgradeModalOpen;const allowedEmailDomain =+ propAllowedEmailDomain ??activeOrganization?.organization.allowedEmailDomain;const [selectedSpaces, setSelectedSpaces] = useState<Set<string>>(new Set());const [searchTerm, setSearchTerm] = useState("");@@ -94,6 +103,54 @@ export const SharingDialog: React.FC<SharingDialogProps> = ({useState(hasPassword);const tabs = ["Share", "Embed"] as const;const [activeTab, setActiveTab] = useState<(typeof tabs)[number]>("Share");+ const [viewerEmail, setViewerEmail] = useState("");+ const router = useRouter();+ const { webUrl } = usePublicEnv();+ const shareUrl = `${webUrl}/s/${capId}`;+ const viewerGrants = useQuery({+ queryKey: ["video-viewer-grants", capId],+ queryFn: () => getVideoViewerGrants(capId),+ enabled: isOpen,+ });+ const inviteViewer = useMutation({+ mutationFn: () => inviteVideoViewer(capId, viewerEmail),+ onSuccess: async (result) => {+ await viewerGrants.refetch();+ router.refresh();+ setViewerEmail("");+ if (result.alreadyAdded) {+ toast.info("This viewer already has access");+ } else if (result.emailSent) {+ toast.success("Viewer invited");+ } else {+ toast.warning(+ "Access added, but the invitation email was not sent. Copy the link to share it.",+ );+ }+ },+ onError: (error) => {+ toast.error(+ error instanceof Error ? error.message : "Failed to invite viewer",+ );+ },+ });+ const revokeViewer = useMutation({+ mutationFn: (email: string) => revokeVideoViewer(capId, email),+ onSuccess: async () => {+ await viewerGrants.refetch();+ router.refresh();+ toast.success("Viewer access removed");+ },+ onError: () => toast.error("Failed to remove viewer access"),+ });+ const copyShareUrl = async () => {+ try {+ await navigator.clipboard.writeText(shareUrl);+ toast.success("Link copied");+ } catch {+ toast.error("Failed to copy link");+ }+ };const updateSharing = useMutation({mutationFn: async ({@@ -240,6 +297,7 @@ export const SharingDialog: React.FC<SharingDialogProps> = ({setPasswordValue("");setInitialPasswordEnabled(hasPassword);setSearchTerm("");+ setViewerEmail("");setActiveTab(tabs[0]);}}, [isOpen, sharedSpaces, isPublic, hasPassword, tabs[0]]);@@ -317,7 +375,7 @@ export const SharingDialog: React.FC<SharingDialogProps> = ({return (<Dialog open={isOpen} onOpenChange={onClose}>- <DialogContent className="p-0 w-full max-w-md rounded-xl border bg-gray-2 border-gray-4">+ <DialogContent className="p-0 w-full max-w-md max-h-[90vh] overflow-y-auto rounded-xl border bg-gray-2 border-gray-4"><DialogHeadericon={<FontAwesomeIcon icon={faShareNodes} className="size-3.5" />}description={@@ -369,9 +427,11 @@ export const SharingDialog: React.FC<SharingDialogProps> = ({</div><div><p className="text-sm font-medium text-gray-12">- {allowedEmailDomain?.trim()- ? "Restricted link access"- : "Anyone with the link"}+ {!publicToggle+ ? "Private"+ : allowedEmailDomain?.trim()+ ? "Restricted link access"+ : "Anyone with the link"}</p><p className="text-xs text-gray-10">{!publicToggle@@ -388,6 +448,75 @@ export const SharingDialog: React.FC<SharingDialogProps> = ({/></div>+ <div className="p-3 mb-4 rounded-lg border bg-gray-1 border-gray-4">+ <div className="flex items-center justify-between gap-2 mb-2">+ <div>+ <p className="text-sm font-medium text-gray-12">+ People with access+ </p>+ <p className="text-xs text-gray-10">+ Invite someone by email. They can view with a Cap account+ using that address.+ </p>+ </div>+ <Button size="xs" variant="gray" onClick={copyShareUrl}>+ <FontAwesomeIcon icon={faCopy} className="size-3 mr-1" />+ Copy link+ </Button>+ </div>+ <div className="flex gap-2">+ <Input+ type="email"+ placeholder="[email protected]"+ value={viewerEmail}+ onChange={(event) => setViewerEmail(event.target.value)}+ />+ <Button+ size="sm"+ variant="dark"+ spinner={inviteViewer.isPending}+ disabled={+ inviteViewer.isPending ||+ !viewerEmail.trim() ||+ publicToggle !== initialPublicState+ }+ onClick={() => inviteViewer.mutate()}+ >+ Invite+ </Button>+ </div>+ {publicToggle !== initialPublicState && (+ <p className="mt-2 text-xs text-gray-10">+ Save the link access change before inviting viewers.+ </p>+ )}+ {viewerGrants.isError && (+ <p className="mt-2 text-xs text-red-11">+ Could not load invited viewers.+ </p>+ )}+ {viewerGrants.data && viewerGrants.data.length > 0 && (+ <div className="mt-3 space-y-1">+ {viewerGrants.data.map(({ email }) => (+ <div+ key={email}+ className="flex items-center justify-between gap-2 text-xs text-gray-11"+ >+ <span className="truncate">{email}</span>+ <Button+ size="xs"+ variant="gray"+ disabled={revokeViewer.isPending}+ onClick={() => revokeViewer.mutate(email)}+ >+ Remove+ </Button>+ </div>+ ))}+ </div>+ )}+ </div>+{inheritedPasswordLabel && (<div className="flex justify-between items-center p-3 mb-4 rounded-lg border bg-gray-1 border-gray-4"><div className="flex gap-3 items-center">diff --git a/apps/web/app/(org)/dashboard/settings/organization/components/DefaultVideoVisibility.tsx b/apps/web/app/(org)/dashboard/settings/organization/components/DefaultVideoVisibility.tsxnew file mode 100644index 000000000..b5bc84651--- /dev/null+++ b/apps/web/app/(org)/dashboard/settings/organization/components/DefaultVideoVisibility.tsx@@ -0,0 +1,69 @@+"use client";++import { Card, CardDescription, CardHeader, CardTitle, Switch } from "@cap/ui";+import { useRouter } from "next/navigation";+import { useEffect, useState } from "react";+import { toast } from "sonner";+import { updateDefaultVideoVisibility } from "@/actions/organization/default-video-visibility";+import { useDashboardContext } from "../../../Contexts";++export const DefaultVideoVisibility = () => {+ const router = useRouter();+ const { activeOrganization } = useDashboardContext();+ const savedPrivate =+ activeOrganization?.organization.defaultVideoVisibility === "private";+ const [privateByDefault, setPrivateByDefault] = useState(savedPrivate);+ const [saving, setSaving] = useState(false);++ useEffect(() => {+ setPrivateByDefault(savedPrivate);+ }, [savedPrivate]);++ const handleChange = async (checked: boolean) => {+ setPrivateByDefault(checked);+ setSaving(true);+ try {+ await updateDefaultVideoVisibility(checked);+ router.refresh();+ toast.success(+ checked+ ? "New recordings will start private"+ : "New recordings will use the current default",+ );+ } catch {+ setPrivateByDefault(!checked);+ toast.error("Failed to update the recording default");+ } finally {+ setSaving(false);+ }+ };++ return (+ <Card className="flex flex-col gap-4">+ <CardHeader>+ <CardTitle>Sharing default</CardTitle>+ <CardDescription>+ Choose how new recordings in this organization start. Owners can+ change access on each recording later.+ </CardDescription>+ </CardHeader>+ <div className="flex items-center justify-between gap-6 p-4 mx-4 mb-4 rounded-xl border bg-gray-2 border-gray-3">+ <div className="space-y-1">+ <p className="text-sm text-gray-12">Start new recordings private</p>+ <p className="text-xs text-gray-10">+ Only people given access can view them. When off, recordings follow+ the current server default.+ </p>+ <p className="text-xs text-gray-10">+ Existing recordings keep their current sharing setting.+ </p>+ </div>+ <Switch+ checked={privateByDefault}+ disabled={saving}+ onCheckedChange={handleChange}+ />+ </div>+ </Card>+ );+};diff --git a/apps/web/app/(org)/dashboard/settings/organization/preferences/page.tsx b/apps/web/app/(org)/dashboard/settings/organization/preferences/page.tsxindex 3c6b8b103..e1957201a 100644--- a/apps/web/app/(org)/dashboard/settings/organization/preferences/page.tsx+++ b/apps/web/app/(org)/dashboard/settings/organization/preferences/page.tsx@@ -1,10 +1,16 @@import type { Metadata } from "next";import CapSettingsCard from "../components/CapSettingsCard";+import { DefaultVideoVisibility } from "../components/DefaultVideoVisibility";export const metadata: Metadata = {title: "Organization Preferences — Cap",};export default function PreferencesPage() {- return <CapSettingsCard />;+ return (+ <div className="space-y-6">+ <DefaultVideoVisibility />+ <CapSettingsCard />+ </div>+ );}diff --git a/apps/web/app/api/desktop/[...route]/video.ts b/apps/web/app/api/desktop/[...route]/video.tsindex 469db105e..173c1a933 100644--- a/apps/web/app/api/desktop/[...route]/video.ts+++ b/apps/web/app/api/desktop/[...route]/video.ts@@ -10,6 +10,7 @@ import {videoUploads,} from "@cap/database/schema";import type { VideoMetadata } from "@cap/database/types";+import { getNewVideoPublic } from "@cap/database/video-sharing-default";import { serverEnv } from "@cap/env";import { userIsPro } from "@cap/utils";import { makeCurrentUserLayer, Storage, Videos } from "@cap/web-backend";@@ -321,7 +322,7 @@ app.get(isScreenshot,bucket: Option.getOrNull(writable.bucketId),storageIntegrationId: Option.getOrNull(writable.storageIntegrationId),- public: serverEnv().CAP_VIDEOS_DEFAULT_PUBLIC,+ public: await getNewVideoPublic(videoOrgId),duration: durationInSecs,width,height,diff --git a/apps/web/app/api/mobile/[...route]/route.ts b/apps/web/app/api/mobile/[...route]/route.tsindex 5159960a7..3298f890c 100644--- a/apps/web/app/api/mobile/[...route]/route.ts+++ b/apps/web/app/api/mobile/[...route]/route.ts@@ -6,6 +6,7 @@ import { sendEmail } from "@cap/database/emails/config";import { OTPEmail } from "@cap/database/emails/otp-email";import { nanoId } from "@cap/database/helpers";import * as Db from "@cap/database/schema";+import { getNewVideoPublic } from "@cap/database/video-sharing-default";import { serverEnv } from "@cap/env";import { userIsPro } from "@cap/utils";import {@@ -2390,7 +2391,7 @@ const importLoom = Effect.fn("Mobile.importLoom")(function* (source: { type: "webMP4" },bucket: Option.getOrNull(writable.bucketId),storageIntegrationId: Option.getOrNull(writable.storageIntegrationId),- public: serverEnv().CAP_VIDEOS_DEFAULT_PUBLIC,+ public: await getNewVideoPublic(user.activeOrganizationId),duration: download.durationSeconds,width: download.width,height: download.height,@@ -2477,7 +2478,7 @@ const createUpload = Effect.fn("Mobile.createUpload")(function* (ownerId: user.id,orgId: organizationId,name: getUploadTitle(input.fileName),- public: serverEnv().CAP_VIDEOS_DEFAULT_PUBLIC,+ public: yield* Effect.tryPromise(() => getNewVideoPublic(organizationId)),source: { type: "webMP4" },bucketId: writable.bucketId,storageIntegrationId: writable.storageIntegrationId,@@ -2572,7 +2573,7 @@ const createRecording = Effect.fn("Mobile.createRecording")(function* (ownerId: user.id,orgId: organizationId,name: getUploadTitle(input.fileName),- public: serverEnv().CAP_VIDEOS_DEFAULT_PUBLIC,+ public: yield* Effect.tryPromise(() => getNewVideoPublic(organizationId)),source: { type: "desktopSegments" },bucketId: writable.bucketId,storageIntegrationId: writable.storageIntegrationId,diff --git a/apps/web/app/api/v1/[...route]/route.ts b/apps/web/app/api/v1/[...route]/route.tsindex ca9726bbc..5e889e3c4 100644--- a/apps/web/app/api/v1/[...route]/route.ts+++ b/apps/web/app/api/v1/[...route]/route.ts@@ -10,6 +10,7 @@ import { sendEmail } from "@cap/database/emails/config";import { OrganizationInvite } from "@cap/database/emails/organization-invite";import { nanoId, nanoIdLong } from "@cap/database/helpers";import * as Db from "@cap/database/schema";+import { getNewVideoPublic } from "@cap/database/video-sharing-default";import { buildEnv, serverEnv } from "@cap/env";import {STRIPE_DEVELOPER_CREDITS_PRODUCT_ID,@@ -2385,7 +2386,7 @@ const queueAgentLoomImport = Effect.fn("Agent.queueLoomImport")(storageIntegrationId: Option.getOrNull(writable.storageIntegrationId,),- public: serverEnv().CAP_VIDEOS_DEFAULT_PUBLIC,+ public: await getNewVideoPublic(input.organizationId),duration: download.durationSeconds,width: download.width,height: download.height,@@ -6598,7 +6599,7 @@ const AgentManagementHandlersLive = HttpApiBuilder.group(writable.storageIntegrationId,),folderId: payload.folderId ?? null,- public: serverEnv().CAP_VIDEOS_DEFAULT_PUBLIC,+ public: await getNewVideoPublic(organizationId),duration: payload.durationSeconds,width: payload.width,height: payload.height,diff --git a/apps/web/app/s/[videoId]/_components/PrivateAccessActions.tsx b/apps/web/app/s/[videoId]/_components/PrivateAccessActions.tsxnew file mode 100644index 000000000..220997b7f--- /dev/null+++ b/apps/web/app/s/[videoId]/_components/PrivateAccessActions.tsx@@ -0,0 +1,38 @@+"use client";++import { Button } from "@cap/ui";+import type { Video } from "@cap/web-domain";+import Link from "next/link";+import { signOut } from "next-auth/react";+import { useCurrentUser } from "@/app/Layout/AuthContext";++export function PrivateAccessActions({ videoId }: { videoId: Video.VideoId }) {+ const user = useCurrentUser();+ const next = encodeURIComponent(`/s/${videoId}`);+ const loginUrl = `/login?next=${next}`;++ if (user) {+ return (+ <div className="space-y-3">+ <p>+ You're signed in as {user.email}. Use the account that was invited to+ view this recording.+ </p>+ <Button+ variant="dark"+ onClick={() => signOut({ callbackUrl: loginUrl })}+ >+ Switch account+ </Button>+ </div>+ );+ }++ return (+ <p>+ If you have access, <Link href={loginUrl}>sign in</Link> or{" "}+ <Link href={`/signup?next=${next}`}>create an account</Link> using the+ email address that was invited.+ </p>+ );+}diff --git a/apps/web/app/s/[videoId]/_components/ShareHeader.tsx b/apps/web/app/s/[videoId]/_components/ShareHeader.tsxindex 897c79f0b..37d76f03b 100644--- a/apps/web/app/s/[videoId]/_components/ShareHeader.tsx+++ b/apps/web/app/s/[videoId]/_components/ShareHeader.tsx@@ -135,8 +135,10 @@ export const ShareHeader = ({data,customDomain,domainVerified,+ allowedEmailDomain,sharedOrganizations = [],sharedSpaces = [],+ viewerCount = 0,spacesData = null,branding,canManageSharePageBranding = false,@@ -147,7 +149,9 @@ export const ShareHeader = ({data: VideoData;customDomain?: string | null;domainVerified?: boolean;+ allowedEmailDomain?: string | null;sharedOrganizations?: { id: string; name: string }[];+ viewerCount?: number;userOrganizations?: { id: string; name: string }[];sharedSpaces?: {id: string;@@ -485,11 +489,17 @@ export const ShareHeader = ({*/const audience = describeShareAudience({isPublic: Boolean(data.public),+ allowedEmailDomain,passwordProtected: effectivePasswordProtected,audienceNames: [...(sharedOrganizations ?? []).map((org) => org.name),- ...(effectiveSharedSpaces ?? []).map((space) => space.name),+ ...(effectiveSharedSpaces ?? [])+ .filter(+ (space) => !sharedOrganizations.some((org) => org.id === space.id),+ )+ .map((space) => space.name),],+ viewerCount,});const renderSharedStatus = () => {@@ -508,7 +518,7 @@ export const ShareHeader = ({const AudienceIcon =audience.kind === "public"? Globe2- : audience.kind === "spaces"+ : audience.kind === "spaces" || audience.kind === "people"? Users: Lock;@@ -748,6 +758,7 @@ export const ShareHeader = ({sharedSpaces={effectiveSharedSpaces || []}onSharingUpdated={handleSharingUpdated}isPublic={data.public}+ allowedEmailDomain={allowedEmailDomain}spacesData={spacesData}hasPassword={passwordProtected}inheritedPasswordSources={data.inheritedPasswordSources}diff --git a/apps/web/app/s/[videoId]/_components/share-audience.ts b/apps/web/app/s/[videoId]/_components/share-audience.tsindex 1cc3a05a4..879e12607 100644--- a/apps/web/app/s/[videoId]/_components/share-audience.ts+++ b/apps/web/app/s/[videoId]/_components/share-audience.ts@@ -7,7 +7,7 @@* out what that means for the link.*/-export type ShareAudienceKind = "public" | "spaces" | "private";+export type ShareAudienceKind = "public" | "spaces" | "people" | "private";export interface ShareAudience {kind: ShareAudienceKind;@@ -17,6 +17,7 @@ export interface ShareAudience {export interface ShareAudienceInput {isPublic: boolean;+ allowedEmailDomain?: string | null;/** Includes an inherited password from a space or organization. */passwordProtected: boolean;/**@@ -25,6 +26,7 @@ export interface ShareAudienceInput {* "Shared with 2 spaces" rather than printing an empty one.*/audienceNames: (string | null | undefined)[];+ viewerCount?: number;}const listNames = (names: string[], total: number): string => {@@ -40,10 +42,19 @@ const listNames = (names: string[], total: number): string => {export const describeShareAudience = ({isPublic,+ allowedEmailDomain,passwordProtected,audienceNames,+ viewerCount = 0,}: ShareAudienceInput): ShareAudience => {if (isPublic) {+ if (allowedEmailDomain?.trim()) {+ return {+ kind: "public",+ label: "Restricted link access",+ tooltip: `Only signed-in people whose email matches ${allowedEmailDomain.trim()} or invited viewers can watch this Cap.${passwordProtected ? " A password is also required." : ""}`,+ };+ }return {kind: "public",label: passwordProtected@@ -63,14 +74,26 @@ export const describeShareAudience = ({if (total > 0) {const listed = named.slice(0, 2);const remainder = total - listed.length;+ const spaceDescription = listed.length+ ? `members of ${listed.join(", ")}${remainder > 0 ? ` and ${remainder} more` : ""}`+ : "members of the spaces this is shared with";return {kind: "spaces",- label: listNames(listed, total),- tooltip: listed.length- ? `Only members of ${listed.join(", ")}${- remainder > 0 ? ` and ${remainder} more` : ""- } can watch this Cap. The link won't work for anyone else.`- : "Only members of the spaces this is shared with can watch this Cap. The link won't work for anyone else.",+ label:+ viewerCount > 0+ ? `Shared with spaces and ${viewerCount} ${viewerCount === 1 ? "person" : "people"}`+ : listNames(listed, total),+ tooltip:+ viewerCount > 0+ ? `Only ${spaceDescription} and ${viewerCount} invited ${viewerCount === 1 ? "person" : "people"} can watch this Cap.${passwordProtected ? " A password is also required." : ""}`+ : `Only ${spaceDescription} can watch this Cap. The link won't work for anyone else.`,+ };+ }+ if (viewerCount > 0) {+ return {+ kind: "people",+ label: `Shared with ${viewerCount} ${viewerCount === 1 ? "person" : "people"}`,+ tooltip: `Only invited people can watch this Cap after signing in with their invited email address.${passwordProtected ? " A password is also required." : ""}`,};}diff --git a/apps/web/app/s/[videoId]/page.tsx b/apps/web/app/s/[videoId]/page.tsxindex 7fb6192a2..886978f8d 100644--- a/apps/web/app/s/[videoId]/page.tsx+++ b/apps/web/app/s/[videoId]/page.tsx@@ -12,6 +12,7 @@ import {videoEdits,videos,videoUploads,+ videoViewerGrants,} from "@cap/database/schema";import type { VideoMetadata } from "@cap/database/types";import { buildEnv, serverEnv } from "@cap/env";@@ -76,6 +77,7 @@ import { optionFromTOrFirst } from "@/utils/effect";import { isAiGenerationEnabled } from "@/utils/flags";import { PasswordOverlay } from "./_components/PasswordOverlay";import { PendingRecordingShare } from "./_components/PendingRecordingShare";+import { PrivateAccessActions } from "./_components/PrivateAccessActions";import { ShareHeader } from "./_components/ShareHeader";import { Share } from "./Share";@@ -184,22 +186,25 @@ async function getSharedSpacesForVideo(videoId: Video.VideoId) {};}-function PolicyDeniedView({ reason }: { reason?: string }) {+function PolicyDeniedView({+ reason,+ videoId,+}: {+ reason?: string;+ videoId: Video.VideoId;+}) {let title = "This video is private";- let description: React.ReactNode = (- <>- If you own this video, please <Link href="/login">sign in</Link> to manage- sharing.- </>- );+ let description: React.ReactNode = <PrivateAccessActions videoId={videoId} />;if (reason === "email_restriction_login_required") {title = "This video requires sign-in";description = (<>The owner of this video has restricted access. Please{" "}- <Link href="/login">sign in</Link> with an authorized email address to- view.+ <Link href={`/login?next=${encodeURIComponent(`/s/${videoId}`)}`}>+ sign in+ </Link>{" "}+ with an authorized email address to view.</>);} else if (reason === "email_restriction_denied") {@@ -212,13 +217,15 @@ function PolicyDeniedView({ reason }: { reason?: string }) {<div className="flex flex-col justify-center items-center p-4 min-h-screen text-center"><Logo className="size-32" /><h1 className="mb-2 text-2xl font-semibold">{title}</h1>- <p className="text-gray-400">{description}</p>+ <div className="text-gray-400">{description}</div></div>);}const renderPolicyDenied = (videoId: Video.VideoId, reason?: string) =>- Effect.succeed(<PolicyDeniedView key={videoId} reason={reason} />);+ Effect.succeed(+ <PolicyDeniedView key={videoId} videoId={videoId} reason={reason} />,+ );const renderNoSuchElement = (awaitRecording: boolean) =>awaitRecording@@ -366,6 +373,7 @@ export default async function ShareVideoPage(props: PageProps<"/s/[videoId]">) {organizationId: sharedVideos.organizationId,},orgSettings: organizations.settings,+ allowedEmailDomain: organizations.allowedEmailDomain,organizationName: organizations.name,organizationIconUrl: organizations.iconUrl,shareableLinkIconUrl: organizations.shareableLinkIconUrl,@@ -438,6 +446,7 @@ async function AuthorizedContent({hasActiveUpload: boolean;activeUploadRawFileKey: string | null;orgSettings?: OrganizationSettings | null;+ allowedEmailDomain?: string | null;videoSettings?: OrganizationSettings | null;organizationName?: string | null;organizationIconUrl?: ImageUpload.ImageUrlOrKey | null;@@ -511,6 +520,19 @@ async function AuthorizedContent({: Promise.resolve(null);const sharedSpacesPromise = getSharedSpacesForVideo(videoId);+ const viewerCountPromise =+ user?.id === video.owner.id+ ? db()+ .select({ count: sql<number>`count(*)`.mapWith(Number) })+ .from(videoViewerGrants)+ .where(+ and(+ eq(videoViewerGrants.videoId, videoId),+ isNull(videoViewerGrants.revokedAt),+ ),+ )+ .then(([row]) => row?.count ?? 0)+ : Promise.resolve(0);const ownerIsPro = userIsPro(video.owner);@@ -769,6 +791,7 @@ async function AuthorizedContent({const [spacesData,{ sharedSpaces, sharedOrganizations },+ viewerCount,aiGenerationEnabled,screenshotImageUrl,membersList,@@ -782,6 +805,7 @@ async function AuthorizedContent({] = await Promise.all([spacesDataPromise,sharedSpacesPromise,+ viewerCountPromise,aiGenerationEnabledPromise,screenshotImageUrlPromise,membersListPromise,@@ -902,10 +926,12 @@ async function AuthorizedContent({}}customDomain={customDomain}domainVerified={domainVerified}+ allowedEmailDomain={video.allowedEmailDomain}sharedOrganizations={videoWithOrganizationInfo.sharedOrganizations || []}sharedSpaces={sharedSpaces}+ viewerCount={viewerCount}userOrganizations={userOrganizations}spacesData={spacesData}branding={getSharePageBranding(videoWithOrganizationInfo)}diff --git a/apps/web/content/docs/sharing/share-a-cap.mdx b/apps/web/content/docs/sharing/share-a-cap.mdxindex d0809766b..272c7eb10 100644--- a/apps/web/content/docs/sharing/share-a-cap.mdx+++ b/apps/web/content/docs/sharing/share-a-cap.mdx@@ -23,11 +23,15 @@ After Cap finishes the required upload and processing, copy the returned link frCap supports different access states:- **Public:** anyone with the link can watch in a browser without an account.-- **Private:** the viewer must sign in and have access through the owner, organization, space, or folder rules.+- **Private:** the viewer must sign in and have access through the owner, organization, space, folder, or a recording-specific email invitation.- **Password protected:** the viewer must enter the recording or effective space password before playback.Sharing a link does not bypass private, organization, space, or password rules. If a Cap belongs to several containers, Cap resolves the effective viewer settings for those locations.+The recording owner can open **Manage access** and invite a viewer by email. The viewer opens the usual Cap link and signs in with a Cap account using the invited address. An external viewer does not need to join the owner's organization or use a Pro seat. The owner can remove that invitation later. Access through a public link or a shared organization or space still applies independently.++Owners and admins can turn on **Start new recordings private** under **Dashboard → Settings → Organization → Preferences**. This changes how new recordings start in that organization. Existing recordings keep their current access setting, and the allowed email domain setting continues to govern link access separately. Review existing public recordings before removing an allowed domain restriction.+## What appears on the share pageThe share page provides video playback, scrubbing, fullscreen, volume, and Cap's configured playback speeds. Depending on the recording's processing state and effective settings, it can also show:diff --git a/apps/web/content/docs/teams.mdx b/apps/web/content/docs/teams.mdxindex 6bcf65bb0..cf6390891 100644--- a/apps/web/content/docs/teams.mdx+++ b/apps/web/content/docs/teams.mdx@@ -38,6 +38,8 @@ Signed-in viewers can add timestamped comments, replies, and emoji reactions wheOrganization settings can disable comments, reactions, transcripts, captions, summaries, or chapters for the whole organization. They can also set branding, a custom domain, an allowed email domain, a default playback speed, and an AI language.+Owners and admins can also choose to start new recordings Private in organization preferences. The setting is opt-in and leaves existing recordings unchanged. A recording owner can invite an external viewer by email from **Manage access** without adding that viewer as an organization member.+## Understand engagementOrganization analytics can be viewed over 24 hours, 7 days, 30 days, or the lifetime of the organization. The dashboard includes Cap, view, comment, and reaction totals plus time-series and breakdown views for geography, browser, operating system, device, and top Caps. Results can be narrowed to a space or an individual Cap.diff --git a/packages/database/emails/video-viewer-invite.tsx b/packages/database/emails/video-viewer-invite.tsxnew file mode 100644index 000000000..44d1b4183--- /dev/null+++ b/packages/database/emails/video-viewer-invite.tsx@@ -0,0 +1,69 @@+import { CAP_LOGO_URL } from "@cap/utils";+import {+ Body,+ Container,+ Head,+ Heading,+ Html,+ Img,+ Link,+ Preview,+ Section,+ Tailwind,+ Text,+} from "@react-email/components";+import Footer from "./components/Footer";++export function VideoViewerInvite({+ email,+ videoName,+ url,+}: {+ email: string;+ videoName: string;+ url: string;+}) {+ return (+ <Html>+ <Head />+ <Preview>You've been invited to watch {videoName} on Cap</Preview>+ <Tailwind>+ <Body className="mx-auto my-auto bg-gray-1 font-sans">+ <Container className="mx-auto my-10 max-w-[500px] rounded border border-solid border-gray-200 px-10 py-5">+ <Section className="mt-8">+ <Img+ src={CAP_LOGO_URL}+ width="40"+ height="40"+ alt="Cap"+ className="mx-auto my-0"+ />+ </Section>+ <Heading className="mx-0 my-7 p-0 text-center text-xl font-semibold text-black">+ You're invited to watch {videoName}+ </Heading>+ <Text className="text-sm leading-6 text-black">+ Open the recording using a Cap account with this email address:+ {` ${email}`}. You can sign up if you don't have an account yet.+ </Text>+ <Section className="my-8 text-center">+ <Link+ className="rounded-full bg-black px-6 py-3 text-center text-[12px] font-semibold text-white no-underline"+ href={url}+ >+ Watch recording+ </Link>+ </Section>+ <Text className="text-sm leading-6 text-black">+ You don't need to join the owner's organization to watch it.+ </Text>+ <Text className="max-w-sm flex-wrap break-words font-medium text-purple-600 no-underline">+ {url.replace(/^https?:\/\//, "")}+ </Text>+ <Footer email={email} />+ </Container>+ </Body>+ </Tailwind>+ </Html>+ );+}diff --git a/packages/database/migrations/0046_complex_gateway.sql b/packages/database/migrations/0046_complex_gateway.sqlnew file mode 100644index 000000000..6ed1cc234--- /dev/null+++ b/packages/database/migrations/0046_complex_gateway.sql@@ -0,0 +1,13 @@+CREATE TABLE `video_viewer_grants` (+ `id` varchar(15) NOT NULL,+ `videoId` varchar(15) NOT NULL,+ `email` varchar(255) NOT NULL,+ `invitedByUserId` varchar(15) NOT NULL,+ `createdAt` timestamp NOT NULL DEFAULT (now()),+ `revokedAt` timestamp,+ CONSTRAINT `video_viewer_grants_id` PRIMARY KEY(`id`),+ CONSTRAINT `video_email_idx` UNIQUE(`videoId`,`email`)+);+--> statement-breakpoint+ALTER TABLE `organizations` ADD `defaultVideoVisibility` varchar(7);--> statement-breakpoint+ALTER TABLE `video_viewer_grants` ADD CONSTRAINT `video_viewer_grants_videoId_videos_id_fk` FOREIGN KEY (`videoId`) REFERENCES `videos`(`id`) ON DELETE cascade ON UPDATE no action;\ No newline at end of filediff --git a/packages/database/migrations/meta/0046_snapshot.json b/packages/database/migrations/meta/0046_snapshot.jsonnew file mode 100644index 000000000..1f0d70342--- /dev/null+++ b/packages/database/migrations/meta/0046_snapshot.json@@ -0,0 +1,4656 @@+{+ "version": "5",+ "dialect": "mysql",+ "id": "9024abc5-1605-4676-b403-f08872068860",+ "prevId": "0d80e4e5-6d93-4d28-b235-bf1231baa7a9",+ "tables": {+ "accounts": {+ "name": "accounts",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "userId": {+ "name": "userId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "providerAccountId": {+ "name": "providerAccountId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "expires_in": {+ "name": "expires_in",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "id_token": {+ "name": "id_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "refresh_token_expires_in": {+ "name": "refresh_token_expires_in",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "scope": {+ "name": "scope",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "token_type": {+ "name": "token_type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ },+ "tempColumn": {+ "name": "tempColumn",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "user_id_idx": {+ "name": "user_id_idx",+ "columns": ["userId"],+ "isUnique": false+ },+ "provider_account_id_idx": {+ "name": "provider_account_id_idx",+ "columns": ["providerAccountId"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "accounts_id": {+ "name": "accounts_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "agent_api_authorization_codes": {+ "name": "agent_api_authorization_codes",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "userId": {+ "name": "userId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "codeHash": {+ "name": "codeHash",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "codeChallenge": {+ "name": "codeChallenge",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "redirectUri": {+ "name": "redirectUri",+ "type": "varchar(512)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "scopes": {+ "name": "scopes",+ "type": "json",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expiresAt": {+ "name": "expiresAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "consumedAt": {+ "name": "consumedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ }+ },+ "indexes": {+ "code_hash_idx": {+ "name": "code_hash_idx",+ "columns": ["codeHash"],+ "isUnique": true+ },+ "expires_at_idx": {+ "name": "expires_at_idx",+ "columns": ["expiresAt"],+ "isUnique": false+ },+ "user_created_at_idx": {+ "name": "user_created_at_idx",+ "columns": ["userId", "createdAt"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "agent_api_authorization_codes_id": {+ "name": "agent_api_authorization_codes_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "agent_api_idempotency": {+ "name": "agent_api_idempotency",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "userId": {+ "name": "userId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "operation": {+ "name": "operation",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "keyHash": {+ "name": "keyHash",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "requestHash": {+ "name": "requestHash",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "state": {+ "name": "state",+ "type": "varchar(16)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'pending'"+ },+ "statusCode": {+ "name": "statusCode",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "response": {+ "name": "response",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "expiresAt": {+ "name": "expiresAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ }+ },+ "indexes": {+ "user_operation_key_idx": {+ "name": "user_operation_key_idx",+ "columns": ["userId", "operation", "keyHash"],+ "isUnique": true+ },+ "expires_at_idx": {+ "name": "expires_at_idx",+ "columns": ["expiresAt"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "agent_api_idempotency_id": {+ "name": "agent_api_idempotency_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "agent_api_keys": {+ "name": "agent_api_keys",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "userId": {+ "name": "userId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "tokenHash": {+ "name": "tokenHash",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(100)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'Cap CLI'"+ },+ "scopes": {+ "name": "scopes",+ "type": "json",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expiresAt": {+ "name": "expiresAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "revokedAt": {+ "name": "revokedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "lastUsedAt": {+ "name": "lastUsedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "token_hash_idx": {+ "name": "token_hash_idx",+ "columns": ["tokenHash"],+ "isUnique": true+ },+ "user_created_at_idx": {+ "name": "user_created_at_idx",+ "columns": ["userId", "createdAt"],+ "isUnique": false+ },+ "expires_at_idx": {+ "name": "expires_at_idx",+ "columns": ["expiresAt"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "agent_api_keys_id": {+ "name": "agent_api_keys_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "agent_api_operations": {+ "name": "agent_api_operations",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "userId": {+ "name": "userId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "kind": {+ "name": "kind",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "resourceId": {+ "name": "resourceId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "resultResourceId": {+ "name": "resultResourceId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "state": {+ "name": "state",+ "type": "varchar(16)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'queued'"+ },+ "payload": {+ "name": "payload",+ "type": "json",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "result": {+ "name": "result",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "errorCode": {+ "name": "errorCode",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "errorMessage": {+ "name": "errorMessage",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ },+ "completedAt": {+ "name": "completedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "user_created_at_idx": {+ "name": "user_created_at_idx",+ "columns": ["userId", "createdAt"],+ "isUnique": false+ },+ "state_updated_at_idx": {+ "name": "state_updated_at_idx",+ "columns": ["state", "updatedAt"],+ "isUnique": false+ },+ "resource_id_idx": {+ "name": "resource_id_idx",+ "columns": ["resourceId"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "agent_api_operations_id": {+ "name": "agent_api_operations_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "auth_api_keys": {+ "name": "auth_api_keys",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(36)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "userId": {+ "name": "userId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "source": {+ "name": "source",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'unknown'"+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ }+ },+ "indexes": {+ "user_id_created_at_idx": {+ "name": "user_id_created_at_idx",+ "columns": ["userId", "createdAt"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "auth_api_keys_id": {+ "name": "auth_api_keys_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "comments": {+ "name": "comments",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "varchar(6)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "timestamp": {+ "name": "timestamp",+ "type": "float",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "authorId": {+ "name": "authorId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "videoId": {+ "name": "videoId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ },+ "parentCommentId": {+ "name": "parentCommentId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "mediaKey": {+ "name": "mediaKey",+ "type": "varchar(512)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "mediaDuration": {+ "name": "mediaDuration",+ "type": "float",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "mediaMeta": {+ "name": "mediaMeta",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "video_type_created_idx": {+ "name": "video_type_created_idx",+ "columns": ["videoId", "type", "createdAt", "id"],+ "isUnique": false+ },+ "author_id_idx": {+ "name": "author_id_idx",+ "columns": ["authorId"],+ "isUnique": false+ },+ "parent_comment_id_idx": {+ "name": "parent_comment_id_idx",+ "columns": ["parentCommentId"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "comments_id": {+ "name": "comments_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "developer_api_keys": {+ "name": "developer_api_keys",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "appId": {+ "name": "appId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "keyType": {+ "name": "keyType",+ "type": "varchar(8)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "keyPrefix": {+ "name": "keyPrefix",+ "type": "varchar(12)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "keyHash": {+ "name": "keyHash",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "encryptedKey": {+ "name": "encryptedKey",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "lastUsedAt": {+ "name": "lastUsedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "revokedAt": {+ "name": "revokedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ }+ },+ "indexes": {+ "key_hash_idx": {+ "name": "key_hash_idx",+ "columns": ["keyHash"],+ "isUnique": true+ },+ "app_key_type_idx": {+ "name": "app_key_type_idx",+ "columns": ["appId", "keyType"],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "developer_api_keys_appId_developer_apps_id_fk": {+ "name": "developer_api_keys_appId_developer_apps_id_fk",+ "tableFrom": "developer_api_keys",+ "tableTo": "developer_apps",+ "columnsFrom": ["appId"],+ "columnsTo": ["id"],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "developer_api_keys_id": {+ "name": "developer_api_keys_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "developer_app_domains": {+ "name": "developer_app_domains",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "appId": {+ "name": "appId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "domain": {+ "name": "domain",+ "type": "varchar(253)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "developer_app_domains_appId_developer_apps_id_fk": {+ "name": "developer_app_domains_appId_developer_apps_id_fk",+ "tableFrom": "developer_app_domains",+ "tableTo": "developer_apps",+ "columnsFrom": ["appId"],+ "columnsTo": ["id"],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "developer_app_domains_id": {+ "name": "developer_app_domains_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {+ "app_domain_unique": {+ "name": "app_domain_unique",+ "columns": ["appId", "domain"]+ }+ },+ "checkConstraint": {}+ },+ "developer_apps": {+ "name": "developer_apps",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "ownerId": {+ "name": "ownerId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "environment": {+ "name": "environment",+ "type": "varchar(16)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "logoUrl": {+ "name": "logoUrl",+ "type": "varchar(1024)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "deletedAt": {+ "name": "deletedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ }+ },+ "indexes": {+ "owner_deleted_idx": {+ "name": "owner_deleted_idx",+ "columns": ["ownerId", "deletedAt"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "developer_apps_id": {+ "name": "developer_apps_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "developer_credit_accounts": {+ "name": "developer_credit_accounts",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "appId": {+ "name": "appId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "ownerId": {+ "name": "ownerId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "balanceMicroCredits": {+ "name": "balanceMicroCredits",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "stripeCustomerId": {+ "name": "stripeCustomerId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "stripePaymentMethodId": {+ "name": "stripePaymentMethodId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "autoTopUpEnabled": {+ "name": "autoTopUpEnabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "autoTopUpThresholdMicroCredits": {+ "name": "autoTopUpThresholdMicroCredits",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "autoTopUpAmountCents": {+ "name": "autoTopUpAmountCents",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ }+ },+ "indexes": {+ "app_id_unique": {+ "name": "app_id_unique",+ "columns": ["appId"],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "developer_credit_accounts_appId_developer_apps_id_fk": {+ "name": "developer_credit_accounts_appId_developer_apps_id_fk",+ "tableFrom": "developer_credit_accounts",+ "tableTo": "developer_apps",+ "columnsFrom": ["appId"],+ "columnsTo": ["id"],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "developer_credit_accounts_id": {+ "name": "developer_credit_accounts_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "developer_credit_transactions": {+ "name": "developer_credit_transactions",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "accountId": {+ "name": "accountId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "varchar(16)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "amountMicroCredits": {+ "name": "amountMicroCredits",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "balanceAfterMicroCredits": {+ "name": "balanceAfterMicroCredits",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "referenceId": {+ "name": "referenceId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "referenceType": {+ "name": "referenceType",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "metadata": {+ "name": "metadata",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ }+ },+ "indexes": {+ "account_type_created_idx": {+ "name": "account_type_created_idx",+ "columns": ["accountId", "type", "createdAt"],+ "isUnique": false+ },+ "account_ref_dedup_idx": {+ "name": "account_ref_dedup_idx",+ "columns": ["accountId", "referenceId", "referenceType"],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "dev_credit_txn_account_fk": {+ "name": "dev_credit_txn_account_fk",+ "tableFrom": "developer_credit_transactions",+ "tableTo": "developer_credit_accounts",+ "columnsFrom": ["accountId"],+ "columnsTo": ["id"],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "developer_credit_transactions_id": {+ "name": "developer_credit_transactions_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "developer_daily_storage_snapshots": {+ "name": "developer_daily_storage_snapshots",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "appId": {+ "name": "appId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "snapshotDate": {+ "name": "snapshotDate",+ "type": "varchar(10)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "totalDurationMinutes": {+ "name": "totalDurationMinutes",+ "type": "float",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "videoCount": {+ "name": "videoCount",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "microCreditsCharged": {+ "name": "microCreditsCharged",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "processedAt": {+ "name": "processedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "developer_daily_storage_snapshots_appId_developer_apps_id_fk": {+ "name": "developer_daily_storage_snapshots_appId_developer_apps_id_fk",+ "tableFrom": "developer_daily_storage_snapshots",+ "tableTo": "developer_apps",+ "columnsFrom": ["appId"],+ "columnsTo": ["id"],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "developer_daily_storage_snapshots_id": {+ "name": "developer_daily_storage_snapshots_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {+ "app_date_unique": {+ "name": "app_date_unique",+ "columns": ["appId", "snapshotDate"]+ }+ },+ "checkConstraint": {}+ },+ "developer_videos": {+ "name": "developer_videos",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "appId": {+ "name": "appId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "externalUserId": {+ "name": "externalUserId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'Untitled'"+ },+ "duration": {+ "name": "duration",+ "type": "float",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "width": {+ "name": "width",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "height": {+ "name": "height",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "fps": {+ "name": "fps",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "s3Key": {+ "name": "s3Key",+ "type": "varchar(512)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "transcriptionStatus": {+ "name": "transcriptionStatus",+ "type": "varchar(16)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "metadata": {+ "name": "metadata",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "deletedAt": {+ "name": "deletedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ }+ },+ "indexes": {+ "app_created_idx": {+ "name": "app_created_idx",+ "columns": ["appId", "createdAt"],+ "isUnique": false+ },+ "app_user_idx": {+ "name": "app_user_idx",+ "columns": ["appId", "externalUserId"],+ "isUnique": false+ },+ "app_deleted_idx": {+ "name": "app_deleted_idx",+ "columns": ["appId", "deletedAt"],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "developer_videos_appId_developer_apps_id_fk": {+ "name": "developer_videos_appId_developer_apps_id_fk",+ "tableFrom": "developer_videos",+ "tableTo": "developer_apps",+ "columnsFrom": ["appId"],+ "columnsTo": ["id"],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "developer_videos_id": {+ "name": "developer_videos_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "folders": {+ "name": "folders",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "color": {+ "name": "color",+ "type": "varchar(16)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'normal'"+ },+ "public": {+ "name": "public",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "settings": {+ "name": "settings",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "organizationId": {+ "name": "organizationId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "createdById": {+ "name": "createdById",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "parentId": {+ "name": "parentId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "spaceId": {+ "name": "spaceId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ }+ },+ "indexes": {+ "organization_id_idx": {+ "name": "organization_id_idx",+ "columns": ["organizationId"],+ "isUnique": false+ },+ "created_by_id_idx": {+ "name": "created_by_id_idx",+ "columns": ["createdById"],+ "isUnique": false+ },+ "parent_id_idx": {+ "name": "parent_id_idx",+ "columns": ["parentId"],+ "isUnique": false+ },+ "space_id_idx": {+ "name": "space_id_idx",+ "columns": ["spaceId"],+ "isUnique": false+ },+ "public_parent_id_idx": {+ "name": "public_parent_id_idx",+ "columns": ["public", "parentId"],+ "isUnique": false+ },+ "public_space_parent_id_idx": {+ "name": "public_space_parent_id_idx",+ "columns": ["public", "spaceId", "parentId"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "folders_id": {+ "name": "folders_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "imported_videos": {+ "name": "imported_videos",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "orgId": {+ "name": "orgId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "source": {+ "name": "source",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "source_id": {+ "name": "source_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "id_idx": {+ "name": "id_idx",+ "columns": ["id"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "imported_videos_orgId_source_source_id_pk": {+ "name": "imported_videos_orgId_source_source_id_pk",+ "columns": ["orgId", "source", "source_id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "integration_installations": {+ "name": "integration_installations",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "externalId": {+ "name": "externalId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "displayName": {+ "name": "displayName",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "organizationId": {+ "name": "organizationId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "installedByUserId": {+ "name": "installedByUserId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "encryptedCredentials": {+ "name": "encryptedCredentials",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "metadata": {+ "name": "metadata",+ "type": "json",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ }+ },+ "indexes": {+ "provider_external_id_idx": {+ "name": "provider_external_id_idx",+ "columns": ["provider", "externalId"],+ "isUnique": true+ },+ "organization_provider_display_name_idx": {+ "name": "organization_provider_display_name_idx",+ "columns": ["organizationId", "provider", "displayName"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "integration_installations_id": {+ "name": "integration_installations_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "loops_sync_jobs": {+ "name": "loops_sync_jobs",+ "columns": {+ "userId": {+ "name": "userId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "revision": {+ "name": "revision",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 1+ },+ "nextAttemptAt": {+ "name": "nextAttemptAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "leaseToken": {+ "name": "leaseToken",+ "type": "varchar(36)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "leaseUntil": {+ "name": "leaseUntil",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "failures": {+ "name": "failures",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "lastError": {+ "name": "lastError",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "profileHash": {+ "name": "profileHash",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "teammateJoinedAt": {+ "name": "teammateJoinedAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "syncedEmail": {+ "name": "syncedEmail",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "lastSyncedAt": {+ "name": "lastSyncedAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "loops_sync_due_idx": {+ "name": "loops_sync_due_idx",+ "columns": ["nextAttemptAt"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "loops_sync_jobs_userId": {+ "name": "loops_sync_jobs_userId",+ "columns": ["userId"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "media_processing_budgets": {+ "name": "media_processing_budgets",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "reserved_bytes": {+ "name": "reserved_bytes",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "limit_bytes": {+ "name": "limit_bytes",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "datetime(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "media_budget_expiry_idx": {+ "name": "media_budget_expiry_idx",+ "columns": ["expires_at"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "media_processing_budgets_id": {+ "name": "media_processing_budgets_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "messenger_conversations": {+ "name": "messenger_conversations",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "agent": {+ "name": "agent",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "mode": {+ "name": "mode",+ "type": "varchar(16)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'agent'"+ },+ "userId": {+ "name": "userId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "anonymousId": {+ "name": "anonymousId",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "takeoverByUserId": {+ "name": "takeoverByUserId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "takeoverAt": {+ "name": "takeoverAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ },+ "lastMessageAt": {+ "name": "lastMessageAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ }+ },+ "indexes": {+ "user_last_message_idx": {+ "name": "user_last_message_idx",+ "columns": ["userId", "lastMessageAt"],+ "isUnique": false+ },+ "anonymous_last_message_idx": {+ "name": "anonymous_last_message_idx",+ "columns": ["anonymousId", "lastMessageAt"],+ "isUnique": false+ },+ "mode_last_message_idx": {+ "name": "mode_last_message_idx",+ "columns": ["mode", "lastMessageAt"],+ "isUnique": false+ },+ "updated_at_idx": {+ "name": "updated_at_idx",+ "columns": ["updatedAt"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "messenger_conversations_id": {+ "name": "messenger_conversations_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "messenger_messages": {+ "name": "messenger_messages",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "conversationId": {+ "name": "conversationId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "role": {+ "name": "role",+ "type": "varchar(16)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "userId": {+ "name": "userId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "anonymousId": {+ "name": "anonymousId",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ }+ },+ "indexes": {+ "conversation_created_at_idx": {+ "name": "conversation_created_at_idx",+ "columns": ["conversationId", "createdAt"],+ "isUnique": false+ },+ "role_created_at_idx": {+ "name": "role_created_at_idx",+ "columns": ["role", "createdAt"],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "messenger_messages_conversationId_messenger_conversations_id_fk": {+ "name": "messenger_messages_conversationId_messenger_conversations_id_fk",+ "tableFrom": "messenger_messages",+ "tableTo": "messenger_conversations",+ "columnsFrom": ["conversationId"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "messenger_messages_id": {+ "name": "messenger_messages_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "messenger_support_emails": {+ "name": "messenger_support_emails",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "conversationId": {+ "name": "conversationId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "userId": {+ "name": "userId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "userEmail": {+ "name": "userEmail",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "subject": {+ "name": "subject",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "message": {+ "name": "message",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ }+ },+ "indexes": {+ "support_email_user_created_at_idx": {+ "name": "support_email_user_created_at_idx",+ "columns": ["userId", "createdAt"],+ "isUnique": false+ },+ "support_email_conversation_created_at_idx": {+ "name": "support_email_conversation_created_at_idx",+ "columns": ["conversationId", "createdAt"],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "support_email_conversation_fk": {+ "name": "support_email_conversation_fk",+ "tableFrom": "messenger_support_emails",+ "tableTo": "messenger_conversations",+ "columnsFrom": ["conversationId"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "messenger_support_emails_id": {+ "name": "messenger_support_emails_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "notifications": {+ "name": "notifications",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "orgId": {+ "name": "orgId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "recipientId": {+ "name": "recipientId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "varchar(16)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "data": {+ "name": "data",+ "type": "json",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "videoId": {+ "name": "videoId",+ "type": "varchar(50)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "dedupKey": {+ "name": "dedupKey",+ "type": "varchar(128)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "readAt": {+ "name": "readAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ }+ },+ "indexes": {+ "org_id_idx": {+ "name": "org_id_idx",+ "columns": ["orgId"],+ "isUnique": false+ },+ "type_idx": {+ "name": "type_idx",+ "columns": ["type"],+ "isUnique": false+ },+ "read_at_idx": {+ "name": "read_at_idx",+ "columns": ["readAt"],+ "isUnique": false+ },+ "created_at_idx": {+ "name": "created_at_idx",+ "columns": ["createdAt"],+ "isUnique": false+ },+ "recipient_read_idx": {+ "name": "recipient_read_idx",+ "columns": ["recipientId", "readAt"],+ "isUnique": false+ },+ "recipient_created_idx": {+ "name": "recipient_created_idx",+ "columns": ["recipientId", "createdAt"],+ "isUnique": false+ },+ "dedup_key_idx": {+ "name": "dedup_key_idx",+ "columns": ["dedupKey"],+ "isUnique": true+ },+ "type_recipient_created_idx": {+ "name": "type_recipient_created_idx",+ "columns": ["type", "recipientId", "createdAt"],+ "isUnique": false+ },+ "type_recipient_video_created_idx": {+ "name": "type_recipient_video_created_idx",+ "columns": ["type", "recipientId", "videoId", "createdAt"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "notifications_id": {+ "name": "notifications_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "organization_invites": {+ "name": "organization_invites",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "organizationId": {+ "name": "organizationId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "invitedEmail": {+ "name": "invitedEmail",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "invitedByUserId": {+ "name": "invitedByUserId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "role": {+ "name": "role",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "status": {+ "name": "status",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'pending'"+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ },+ "expiresAt": {+ "name": "expiresAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "organization_id_idx": {+ "name": "organization_id_idx",+ "columns": ["organizationId"],+ "isUnique": false+ },+ "invited_email_idx": {+ "name": "invited_email_idx",+ "columns": ["invitedEmail"],+ "isUnique": false+ },+ "invited_by_user_id_idx": {+ "name": "invited_by_user_id_idx",+ "columns": ["invitedByUserId"],+ "isUnique": false+ },+ "status_idx": {+ "name": "status_idx",+ "columns": ["status"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "organization_invites_id": {+ "name": "organization_invites_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "organization_members": {+ "name": "organization_members",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "userId": {+ "name": "userId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "organizationId": {+ "name": "organizationId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "role": {+ "name": "role",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "hasProSeat": {+ "name": "hasProSeat",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ }+ },+ "indexes": {+ "organization_id_idx": {+ "name": "organization_id_idx",+ "columns": ["organizationId"],+ "isUnique": false+ },+ "user_id_organization_id_idx": {+ "name": "user_id_organization_id_idx",+ "columns": ["userId", "organizationId"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "organization_members_id": {+ "name": "organization_members_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "organization_sso": {+ "name": "organization_sso",+ "columns": {+ "organizationId": {+ "name": "organizationId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "purchasedByUserId": {+ "name": "purchasedByUserId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "stripeCustomerId": {+ "name": "stripeCustomerId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "stripeSubscriptionId": {+ "name": "stripeSubscriptionId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "stripePriceId": {+ "name": "stripePriceId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "status": {+ "name": "status",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'unpaid'"+ },+ "paidThrough": {+ "name": "paidThrough",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "currentPeriodEnd": {+ "name": "currentPeriodEnd",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "cancelAtPeriodEnd": {+ "name": "cancelAtPeriodEnd",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "checkoutAttemptId": {+ "name": "checkoutAttemptId",+ "type": "varchar(36)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "checkoutCurrency": {+ "name": "checkoutCurrency",+ "type": "varchar(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "checkoutPriceId": {+ "name": "checkoutPriceId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "checkoutSessionId": {+ "name": "checkoutSessionId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "checkoutStartedAt": {+ "name": "checkoutStartedAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ }+ },+ "indexes": {+ "sso_stripe_subscription_id_idx": {+ "name": "sso_stripe_subscription_id_idx",+ "columns": ["stripeSubscriptionId"],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "organization_sso_organizationId": {+ "name": "organization_sso_organizationId",+ "columns": ["organizationId"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "organizations": {+ "name": "organizations",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "ownerId": {+ "name": "ownerId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "metadata": {+ "name": "metadata",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "tombstoneAt": {+ "name": "tombstoneAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "allowedEmailDomain": {+ "name": "allowedEmailDomain",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "defaultVideoVisibility": {+ "name": "defaultVideoVisibility",+ "type": "varchar(7)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "customDomain": {+ "name": "customDomain",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "domainVerified": {+ "name": "domainVerified",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "settings": {+ "name": "settings",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "iconUrl": {+ "name": "iconUrl",+ "type": "varchar(1024)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "shareableLinkIconUrl": {+ "name": "shareableLinkIconUrl",+ "type": "varchar(1024)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ },+ "workosOrganizationId": {+ "name": "workosOrganizationId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "workosConnectionId": {+ "name": "workosConnectionId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "owner_id_tombstone_idx": {+ "name": "owner_id_tombstone_idx",+ "columns": ["ownerId", "tombstoneAt"],+ "isUnique": false+ },+ "custom_domain_idx": {+ "name": "custom_domain_idx",+ "columns": ["customDomain"],+ "isUnique": false+ },+ "workos_organization_id_idx": {+ "name": "workos_organization_id_idx",+ "columns": ["workosOrganizationId"],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "organizations_id": {+ "name": "organizations_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "s3_buckets": {+ "name": "s3_buckets",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "ownerId": {+ "name": "ownerId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "organizationId": {+ "name": "organizationId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "region": {+ "name": "region",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "endpoint": {+ "name": "endpoint",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "bucketName": {+ "name": "bucketName",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "accessKeyId": {+ "name": "accessKeyId",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "secretAccessKey": {+ "name": "secretAccessKey",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('aws')"+ },+ "active": {+ "name": "active",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ }+ },+ "indexes": {+ "owner_organization_idx": {+ "name": "owner_organization_idx",+ "columns": ["ownerId", "organizationId"],+ "isUnique": false+ },+ "organization_id_idx": {+ "name": "organization_id_idx",+ "columns": ["organizationId"],+ "isUnique": false+ },+ "organization_active_idx": {+ "name": "organization_active_idx",+ "columns": ["organizationId", "active", "updatedAt"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "s3_buckets_id": {+ "name": "s3_buckets_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "sessions": {+ "name": "sessions",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "sessionToken": {+ "name": "sessionToken",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "userId": {+ "name": "userId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires": {+ "name": "expires",+ "type": "datetime",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ }+ },+ "indexes": {+ "session_token_idx": {+ "name": "session_token_idx",+ "columns": ["sessionToken"],+ "isUnique": true+ },+ "user_id_idx": {+ "name": "user_id_idx",+ "columns": ["userId"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "sessions_id": {+ "name": "sessions_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "shared_videos": {+ "name": "shared_videos",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "videoId": {+ "name": "videoId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "folderId": {+ "name": "folderId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "organizationId": {+ "name": "organizationId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "sharedByUserId": {+ "name": "sharedByUserId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "sharedAt": {+ "name": "sharedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ }+ },+ "indexes": {+ "folder_id_idx": {+ "name": "folder_id_idx",+ "columns": ["folderId"],+ "isUnique": false+ },+ "organization_id_idx": {+ "name": "organization_id_idx",+ "columns": ["organizationId"],+ "isUnique": false+ },+ "shared_by_user_id_idx": {+ "name": "shared_by_user_id_idx",+ "columns": ["sharedByUserId"],+ "isUnique": false+ },+ "video_id_organization_id_idx": {+ "name": "video_id_organization_id_idx",+ "columns": ["videoId", "organizationId"],+ "isUnique": false+ },+ "video_id_folder_id_idx": {+ "name": "video_id_folder_id_idx",+ "columns": ["videoId", "folderId"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "shared_videos_id": {+ "name": "shared_videos_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "signed_baas": {+ "name": "signed_baas",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "organizationId": {+ "name": "organizationId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "userId": {+ "name": "userId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "status": {+ "name": "status",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'pending'"+ },+ "stripeSubscriptionId": {+ "name": "stripeSubscriptionId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "entityName": {+ "name": "entityName",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "entityType": {+ "name": "entityType",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "entityAddress": {+ "name": "entityAddress",+ "type": "varchar(500)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "signerName": {+ "name": "signerName",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "signerTitle": {+ "name": "signerTitle",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "noticesEmail": {+ "name": "noticesEmail",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "signatureData": {+ "name": "signatureData",+ "type": "longtext",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "signedAt": {+ "name": "signedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "emailSentAt": {+ "name": "emailSentAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ }+ },+ "indexes": {+ "signed_baa_organization_id_idx": {+ "name": "signed_baa_organization_id_idx",+ "columns": ["organizationId"],+ "isUnique": true+ },+ "signed_baa_stripe_subscription_idx": {+ "name": "signed_baa_stripe_subscription_idx",+ "columns": ["stripeSubscriptionId"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "signed_baas_id": {+ "name": "signed_baas_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "space_members": {+ "name": "space_members",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "spaceId": {+ "name": "spaceId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "userId": {+ "name": "userId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "role": {+ "name": "role",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'member'"+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ }+ },+ "indexes": {+ "user_id_idx": {+ "name": "user_id_idx",+ "columns": ["userId"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "space_members_id": {+ "name": "space_members_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {+ "space_id_user_id_unique": {+ "name": "space_id_user_id_unique",+ "columns": ["spaceId", "userId"]+ }+ },+ "checkConstraint": {}+ },+ "space_videos": {+ "name": "space_videos",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "spaceId": {+ "name": "spaceId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "folderId": {+ "name": "folderId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "videoId": {+ "name": "videoId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "addedById": {+ "name": "addedById",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "addedAt": {+ "name": "addedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ }+ },+ "indexes": {+ "folder_id_idx": {+ "name": "folder_id_idx",+ "columns": ["folderId"],+ "isUnique": false+ },+ "video_id_idx": {+ "name": "video_id_idx",+ "columns": ["videoId"],+ "isUnique": false+ },+ "added_by_id_idx": {+ "name": "added_by_id_idx",+ "columns": ["addedById"],+ "isUnique": false+ },+ "space_id_video_id_idx": {+ "name": "space_id_video_id_idx",+ "columns": ["spaceId", "videoId"],+ "isUnique": false+ },+ "space_id_folder_id_idx": {+ "name": "space_id_folder_id_idx",+ "columns": ["spaceId", "folderId"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "space_videos_id": {+ "name": "space_videos_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "spaces": {+ "name": "spaces",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "primary": {+ "name": "primary",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "organizationId": {+ "name": "organizationId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "createdById": {+ "name": "createdById",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "iconUrl": {+ "name": "iconUrl",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "description": {+ "name": "description",+ "type": "varchar(1000)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "settings": {+ "name": "settings",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "password": {+ "name": "password",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ },+ "privacy": {+ "name": "privacy",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'Private'"+ },+ "public": {+ "name": "public",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ }+ },+ "indexes": {+ "organization_id_idx": {+ "name": "organization_id_idx",+ "columns": ["organizationId"],+ "isUnique": false+ },+ "created_by_id_idx": {+ "name": "created_by_id_idx",+ "columns": ["createdById"],+ "isUnique": false+ },+ "public_organization_id_idx": {+ "name": "public_organization_id_idx",+ "columns": ["public", "organizationId"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "spaces_id": {+ "name": "spaces_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "storage_integrations": {+ "name": "storage_integrations",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "ownerId": {+ "name": "ownerId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "organizationId": {+ "name": "organizationId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "displayName": {+ "name": "displayName",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "status": {+ "name": "status",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'active'"+ },+ "active": {+ "name": "active",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "encryptedConfig": {+ "name": "encryptedConfig",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "googleDriveAccessToken": {+ "name": "googleDriveAccessToken",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "googleDriveAccessTokenExpiresAt": {+ "name": "googleDriveAccessTokenExpiresAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "googleDriveTokenRefreshLeaseId": {+ "name": "googleDriveTokenRefreshLeaseId",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "googleDriveTokenRefreshLeaseExpiresAt": {+ "name": "googleDriveTokenRefreshLeaseExpiresAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "googleDriveStorageQuotaCache": {+ "name": "googleDriveStorageQuotaCache",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ }+ },+ "indexes": {+ "owner_provider_idx": {+ "name": "owner_provider_idx",+ "columns": ["ownerId", "provider"],+ "isUnique": false+ },+ "owner_active_idx": {+ "name": "owner_active_idx",+ "columns": ["ownerId", "active"],+ "isUnique": false+ },+ "organization_provider_idx": {+ "name": "organization_provider_idx",+ "columns": ["organizationId", "provider"],+ "isUnique": false+ },+ "organization_active_idx": {+ "name": "organization_active_idx",+ "columns": ["organizationId", "active", "status"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "storage_integrations_id": {+ "name": "storage_integrations_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "storage_objects": {+ "name": "storage_objects",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "integrationId": {+ "name": "integrationId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "ownerId": {+ "name": "ownerId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "videoId": {+ "name": "videoId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "objectKey": {+ "name": "objectKey",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "objectKeyHash": {+ "name": "objectKeyHash",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "providerObjectId": {+ "name": "providerObjectId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "uploadSessionUrl": {+ "name": "uploadSessionUrl",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "uploadStatus": {+ "name": "uploadStatus",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'pending'"+ },+ "contentType": {+ "name": "contentType",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "contentLength": {+ "name": "contentLength",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "metadata": {+ "name": "metadata",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ }+ },+ "indexes": {+ "integration_key_hash_idx": {+ "name": "integration_key_hash_idx",+ "columns": ["integrationId", "objectKeyHash"],+ "isUnique": true+ },+ "integration_status_idx": {+ "name": "integration_status_idx",+ "columns": ["integrationId", "uploadStatus"],+ "isUnique": false+ },+ "integration_object_key_prefix_idx": {+ "name": "integration_object_key_prefix_idx",+ "columns": ["integrationId", "`objectKey`(191)"],+ "isUnique": false+ },+ "video_id_idx": {+ "name": "video_id_idx",+ "columns": ["videoId"],+ "isUnique": false+ },+ "owner_id_idx": {+ "name": "owner_id_idx",+ "columns": ["ownerId"],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "storage_objects_integrationId_storage_integrations_id_fk": {+ "name": "storage_objects_integrationId_storage_integrations_id_fk",+ "tableFrom": "storage_objects",+ "tableTo": "storage_integrations",+ "columnsFrom": ["integrationId"],+ "columnsTo": ["id"],+ "onDelete": "restrict",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "storage_objects_id": {+ "name": "storage_objects_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "users": {+ "name": "users",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "lastName": {+ "name": "lastName",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "emailVerified": {+ "name": "emailVerified",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "image": {+ "name": "image",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "stripeCustomerId": {+ "name": "stripeCustomerId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "stripeSubscriptionId": {+ "name": "stripeSubscriptionId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "thirdPartyStripeSubscriptionId": {+ "name": "thirdPartyStripeSubscriptionId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "stripeSubscriptionStatus": {+ "name": "stripeSubscriptionStatus",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "stripeSubscriptionPriceId": {+ "name": "stripeSubscriptionPriceId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "preferences": {+ "name": "preferences",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "('null')"+ },+ "activeOrganizationId": {+ "name": "activeOrganizationId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ },+ "onboardingSteps": {+ "name": "onboardingSteps",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "onboarding_completed_at": {+ "name": "onboarding_completed_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "customBucket": {+ "name": "customBucket",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "inviteQuota": {+ "name": "inviteQuota",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 1+ },+ "defaultOrgId": {+ "name": "defaultOrgId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "authSessionVersion": {+ "name": "authSessionVersion",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "marketingOrigin": {+ "name": "marketingOrigin",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'unknown'"+ }+ },+ "indexes": {+ "email_idx": {+ "name": "email_idx",+ "columns": ["email"],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "users_id": {+ "name": "users_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "verification_tokens": {+ "name": "verification_tokens",+ "columns": {+ "identifier": {+ "name": "identifier",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires": {+ "name": "expires",+ "type": "datetime",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "verification_tokens_identifier": {+ "name": "verification_tokens_identifier",+ "columns": ["identifier"]+ }+ },+ "uniqueConstraints": {+ "verification_tokens_token_unique": {+ "name": "verification_tokens_token_unique",+ "columns": ["token"]+ }+ },+ "checkConstraint": {}+ },+ "video_edits": {+ "name": "video_edits",+ "columns": {+ "videoId": {+ "name": "videoId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "sourceKey": {+ "name": "sourceKey",+ "type": "varchar(512)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "editSpec": {+ "name": "editSpec",+ "type": "json",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "video_edits_videoId_videos_id_fk": {+ "name": "video_edits_videoId_videos_id_fk",+ "tableFrom": "video_edits",+ "tableTo": "videos",+ "columnsFrom": ["videoId"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "video_edits_videoId": {+ "name": "video_edits_videoId",+ "columns": ["videoId"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "video_processing_jobs": {+ "name": "video_processing_jobs",+ "columns": {+ "video_id": {+ "name": "video_id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "owner_id": {+ "name": "owner_id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "generation": {+ "name": "generation",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "manifest_sha256": {+ "name": "manifest_sha256",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "state": {+ "name": "state",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'committing'"+ },+ "attempt_id": {+ "name": "attempt_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "attempt_count": {+ "name": "attempt_count",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "lease_expires_at": {+ "name": "lease_expires_at",+ "type": "datetime(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "next_retry_at": {+ "name": "next_retry_at",+ "type": "datetime(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workflow_run_id": {+ "name": "workflow_run_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "remote_job_id": {+ "name": "remote_job_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "source": {+ "name": "source",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "verification": {+ "name": "verification",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "output": {+ "name": "output",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "error_code": {+ "name": "error_code",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "error_message": {+ "name": "error_message",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "datetime(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "datetime(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "processing_state_retry_video_idx": {+ "name": "processing_state_retry_video_idx",+ "columns": ["state", "next_retry_at", "video_id"],+ "isUnique": false+ },+ "processing_state_lease_video_idx": {+ "name": "processing_state_lease_video_idx",+ "columns": ["state", "lease_expires_at", "video_id"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "video_processing_jobs_video_id": {+ "name": "video_processing_jobs_video_id",+ "columns": ["video_id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "video_uploads": {+ "name": "video_uploads",+ "columns": {+ "video_id": {+ "name": "video_id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "uploaded": {+ "name": "uploaded",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "total": {+ "name": "total",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "mode": {+ "name": "mode",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "phase": {+ "name": "phase",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'uploading'"+ },+ "processing_progress": {+ "name": "processing_progress",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "processing_message": {+ "name": "processing_message",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "processing_error": {+ "name": "processing_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "raw_file_key": {+ "name": "raw_file_key",+ "type": "varchar(512)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "phase_updated_at_video_id_idx": {+ "name": "phase_updated_at_video_id_idx",+ "columns": ["phase", "updated_at", "video_id"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "video_uploads_video_id": {+ "name": "video_uploads_video_id",+ "columns": ["video_id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "video_viewer_grants": {+ "name": "video_viewer_grants",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "videoId": {+ "name": "videoId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "invitedByUserId": {+ "name": "invitedByUserId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "revokedAt": {+ "name": "revokedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "video_email_idx": {+ "name": "video_email_idx",+ "columns": ["videoId", "email"],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "video_viewer_grants_videoId_videos_id_fk": {+ "name": "video_viewer_grants_videoId_videos_id_fk",+ "tableFrom": "video_viewer_grants",+ "tableTo": "videos",+ "columnsFrom": ["videoId"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "video_viewer_grants_id": {+ "name": "video_viewer_grants_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "videos": {+ "name": "videos",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "ownerId": {+ "name": "ownerId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "orgId": {+ "name": "orgId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'My Video'"+ },+ "bucket": {+ "name": "bucket",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "storageIntegrationId": {+ "name": "storageIntegrationId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "duration": {+ "name": "duration",+ "type": "float",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "width": {+ "name": "width",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "height": {+ "name": "height",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "fps": {+ "name": "fps",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "metadata": {+ "name": "metadata",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "public": {+ "name": "public",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "settings": {+ "name": "settings",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "transcriptionStatus": {+ "name": "transcriptionStatus",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "source": {+ "name": "source",+ "type": "json",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('{\"type\":\"MediaConvert\"}')"+ },+ "folderId": {+ "name": "folderId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "effectiveCreatedAt": {+ "name": "effectiveCreatedAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "generated": {+ "as": "COALESCE(\n STR_TO_DATE(JSON_UNQUOTE(JSON_EXTRACT(`metadata`, '$.customCreatedAt')), '%Y-%m-%dT%H:%i:%s.%fZ'),\n STR_TO_DATE(JSON_UNQUOTE(JSON_EXTRACT(`metadata`, '$.customCreatedAt')), '%Y-%m-%dT%H:%i:%sZ'),\n `createdAt`\n )",+ "type": "stored"+ }+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ },+ "password": {+ "name": "password",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "xStreamInfo": {+ "name": "xStreamInfo",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "firstViewEmailSentAt": {+ "name": "firstViewEmailSentAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "isScreenshot": {+ "name": "isScreenshot",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "awsRegion": {+ "name": "awsRegion",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "awsBucket": {+ "name": "awsBucket",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "videoStartTime": {+ "name": "videoStartTime",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "audioStartTime": {+ "name": "audioStartTime",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "jobId": {+ "name": "jobId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "jobStatus": {+ "name": "jobStatus",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "skipProcessing": {+ "name": "skipProcessing",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ }+ },+ "indexes": {+ "owner_id_idx": {+ "name": "owner_id_idx",+ "columns": ["ownerId"],+ "isUnique": false+ },+ "is_public_idx": {+ "name": "is_public_idx",+ "columns": ["public"],+ "isUnique": false+ },+ "folder_id_idx": {+ "name": "folder_id_idx",+ "columns": ["folderId"],+ "isUnique": false+ },+ "storage_integration_id_idx": {+ "name": "storage_integration_id_idx",+ "columns": ["storageIntegrationId"],+ "isUnique": false+ },+ "org_owner_folder_idx": {+ "name": "org_owner_folder_idx",+ "columns": ["orgId", "ownerId", "folderId"],+ "isUnique": false+ },+ "org_effective_created_idx": {+ "name": "org_effective_created_idx",+ "columns": ["orgId", "effectiveCreatedAt"],+ "isUnique": false+ },+ "screenshot_transcription_created_idx": {+ "name": "screenshot_transcription_created_idx",+ "columns": ["isScreenshot", "transcriptionStatus", "createdAt"],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "videos_storageIntegrationId_storage_integrations_id_fk": {+ "name": "videos_storageIntegrationId_storage_integrations_id_fk",+ "tableFrom": "videos",+ "tableTo": "storage_integrations",+ "columnsFrom": ["storageIntegrationId"],+ "columnsTo": ["id"],+ "onDelete": "restrict",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "videos_id": {+ "name": "videos_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ }+ },+ "views": {},+ "_meta": {+ "schemas": {},+ "tables": {},+ "columns": {}+ },+ "internal": {+ "tables": {},+ "indexes": {+ "integration_object_key_prefix_idx": {+ "columns": {+ "`objectKey`(191)": {+ "isExpression": true+ }+ }+ }+ }+ }+}diff --git a/packages/database/migrations/meta/_journal.json b/packages/database/migrations/meta/_journal.jsonindex 014bc42ce..cf387faeb 100644--- a/packages/database/migrations/meta/_journal.json+++ b/packages/database/migrations/meta/_journal.json@@ -323,6 +323,13 @@"when": 1789136779085,"tag": "0045_steep_forge","breakpoints": true+ },+ {+ "idx": 46,+ "version": "5",+ "when": 1789664835831,+ "tag": "0046_complex_gateway",+ "breakpoints": true}]}diff --git a/packages/database/package.json b/packages/database/package.jsonindex 878d989c5..ae6d39b6c 100644--- a/packages/database/package.json+++ b/packages/database/package.json@@ -64,6 +64,7 @@"./auth/sso": "./auth/sso.ts","./auth/sso-state": "./auth/sso-state.ts","./schema": "./schema.ts",+ "./video-sharing-default": "./video-sharing-default.ts","./loops/*": "./loops/*.ts","./crypto": "./crypto.ts","./helpers": "./helpers.ts",diff --git a/packages/database/schema.ts b/packages/database/schema.tsindex 7df0825ed..3d4739cb6 100644--- a/packages/database/schema.ts+++ b/packages/database/schema.ts@@ -221,6 +221,9 @@ export const organizations = mysqlTable(metadata: json("metadata"),tombstoneAt: timestamp("tombstoneAt"),allowedEmailDomain: varchar("allowedEmailDomain", { length: 255 }),+ defaultVideoVisibility: varchar("defaultVideoVisibility", {+ length: 7,+ }).$type<"private">(),customDomain: varchar("customDomain", { length: 255 }),domainVerified: timestamp("domainVerified"),settings: json("settings").$type<{@@ -554,6 +557,27 @@ export const sharedVideos = mysqlTable(}),);+export const videoViewerGrants = mysqlTable(+ "video_viewer_grants",+ {+ id: nanoId("id").notNull().primaryKey(),+ videoId: nanoId("videoId")+ .notNull()+ .$type<Video.VideoId>()+ .references(() => videos.id, { onDelete: "cascade" }),+ email: varchar("email", { length: 255 }).notNull(),+ invitedByUserId: nanoId("invitedByUserId").notNull().$type<User.UserId>(),+ createdAt: timestamp("createdAt").notNull().defaultNow(),+ revokedAt: timestamp("revokedAt"),+ },+ (table) => ({+ videoEmailUnique: uniqueIndex("video_email_idx").on(+ table.videoId,+ table.email,+ ),+ }),+);+export const comments = mysqlTable("comments",{diff --git a/packages/database/video-sharing-default.ts b/packages/database/video-sharing-default.tsnew file mode 100644index 000000000..127c997bc--- /dev/null+++ b/packages/database/video-sharing-default.ts@@ -0,0 +1,25 @@+import { serverEnv } from "@cap/env";+import type { Organisation } from "@cap/web-domain";+import { eq } from "drizzle-orm";+import { db } from "./index.ts";+import { organizations } from "./schema.ts";++export async function getNewVideoPublic(+ organizationId: Organisation.OrganisationId,+): Promise<boolean> {+ const [organization] = await db()+ .select({+ defaultVideoVisibility: organizations.defaultVideoVisibility,+ tombstoneAt: organizations.tombstoneAt,+ })+ .from(organizations)+ .where(eq(organizations.id, organizationId))+ .limit(1);++ if (!organization || organization.tombstoneAt) {+ throw new Error("Organization not found");+ }++ if (organization.defaultVideoVisibility === "private") return false;+ return serverEnv().CAP_VIDEOS_DEFAULT_PUBLIC;+}diff --git a/packages/web-backend/src/Videos/VideosPolicy.ts b/packages/web-backend/src/Videos/VideosPolicy.tsindex d99f0c741..95df93ec2 100644--- a/packages/web-backend/src/Videos/VideosPolicy.ts+++ b/packages/web-backend/src/Videos/VideosPolicy.ts@@ -27,6 +27,10 @@ export type VideosPolicyDeps = {getById: (id: Video.VideoId,) => Effect.Effect<Option.Option<LoadedVideo>, DatabaseError>;+ hasViewerGrant: (+ id: Video.VideoId,+ email: string,+ ) => Effect.Effect<boolean, DatabaseError>;};orgsRepo: {membershipForVideo: (@@ -50,11 +54,11 @@ export type VideosPolicyDeps = {export type ViewDecisionDeps = Pick<VideosPolicyDeps,- "orgsRepo" | "spacesRepo"+ "repo" | "orgsRepo" | "spacesRepo">;const decideCanView = (- { orgsRepo, spacesRepo }: ViewDecisionDeps,+ { repo, orgsRepo, spacesRepo }: ViewDecisionDeps,user: Option.Option<CurrentUser["Type"]>,video: ViewableVideo,password: Option.Option<string>,@@ -97,10 +101,17 @@ const decideCanView = (}if (!video.public) {- yield* Effect.log(- "Video is private and user has no explicit access. Access denied.",- );- return false;+ if (+ Option.isNone(user) ||+ !(yield* repo.hasViewerGrant(video.id, user.value.email))+ ) {+ yield* Effect.log(+ "Video is private and user has no explicit access. Access denied.",+ );+ return false;+ }+ yield* Video.verifyPasswordCandidates(video, passwordHashes);+ return true;}const allowedEmails = yield* orgsRepo.allowedEmailDomain(video.orgId);@@ -121,7 +132,8 @@ const decideCanView = (}if (Option.isSome(user) &&- !isEmailAllowedByRestriction(user.value.email, restriction)+ !isEmailAllowedByRestriction(user.value.email, restriction) &&+ !(yield* repo.hasViewerGrant(video.id, user.value.email))) {yield* Effect.log("Email access restriction active. Access denied.");yield* Effect.fail(diff --git a/packages/web-backend/src/Videos/VideosRepo.ts b/packages/web-backend/src/Videos/VideosRepo.tsindex 82fb453b8..c7facabba 100644--- a/packages/web-backend/src/Videos/VideosRepo.ts+++ b/packages/web-backend/src/Videos/VideosRepo.ts@@ -46,6 +46,22 @@ export class VideosRepo extends Effect.Service<VideosRepo>()("VideosRepo", {);});+ const hasViewerGrant = (id: Video.VideoId, email: string) =>+ db.use(async (database) => {+ const [grant] = await database+ .select({ id: Db.videoViewerGrants.id })+ .from(Db.videoViewerGrants)+ .where(+ Dz.and(+ Dz.eq(Db.videoViewerGrants.videoId, id),+ Dz.eq(Db.videoViewerGrants.email, email.trim().toLowerCase()),+ Dz.isNull(Db.videoViewerGrants.revokedAt),+ ),+ )+ .limit(1);+ return Boolean(grant);+ });+const prepareDelete = (id: Video.VideoId, ownerId: User.UserId) =>db.use((database) =>database.transaction(async (tx) => {@@ -150,7 +166,7 @@ export class VideosRepo extends Effect.Service<VideosRepo>()("VideosRepo", {return id;});- return { getById, prepareDelete, delete: delete_, create };+ return { getById, hasViewerGrant, prepareDelete, delete: delete_, create };}),dependencies: [Database.Default],}) {}diff --git a/packages/web-backend/src/Videos/index.ts b/packages/web-backend/src/Videos/index.tsindex d308f5e7a..1b15fa49e 100644--- a/packages/web-backend/src/Videos/index.ts+++ b/packages/web-backend/src/Videos/index.ts@@ -1,9 +1,11 @@import { nanoId } from "@cap/database/helpers";import * as Db from "@cap/database/schema";+import { getNewVideoPublic } from "@cap/database/video-sharing-default";import { buildEnv, NODE_ENV, serverEnv } from "@cap/env";import { dub } from "@cap/utils";import {CurrentUser,+ DatabaseError,type Folder,Policy,Storage as StorageDomain,@@ -612,7 +614,10 @@ export class Videos extends Effect.Service<Videos>()("Videos", {ownerId: user.id,orgId: input.orgId,name: `Cap Recording - ${formattedDate}`,- public: serverEnv().CAP_VIDEOS_DEFAULT_PUBLIC,+ public: yield* Effect.tryPromise({+ try: () => getNewVideoPublic(input.orgId),+ catch: (cause) => new DatabaseError({ cause }),+ }),source: { type: "webMP4" },bucketId,storageIntegrationId,