diff --git a/.github/workflows/infra-database.yml b/.github/workflows/infra-database.yml index 4642ea73b44..d3843acfe0b 100644 --- a/.github/workflows/infra-database.yml +++ b/.github/workflows/infra-database.yml @@ -14,6 +14,7 @@ on: - "apps/web/app/api/cron/developer-storage/**" - "apps/web/lib/user-preferences-sql.ts" - "apps/web/lib/meetings/trial.ts" + - "apps/web/lib/meetings/share.ts" - "apps/web/lib/meetings/audio-usage.ts" - "apps/web/lib/media-input-policy-strikes.ts" - "apps/web/lib/organization-member-removal.ts" @@ -52,6 +53,7 @@ on: - "apps/web/app/api/cron/developer-storage/**" - "apps/web/lib/user-preferences-sql.ts" - "apps/web/lib/meetings/trial.ts" + - "apps/web/lib/meetings/share.ts" - "apps/web/lib/meetings/audio-usage.ts" - "apps/web/lib/media-input-policy-strikes.ts" - "apps/web/lib/organization-member-removal.ts" @@ -155,4 +157,4 @@ jobs: CAP_INFRA_TEST_DATABASE_URL: mysql://root@127.0.0.1:3306/cap_infra_tests CAP_INFRA_ROUND_TRIPS_DATABASE_URL: mysql://root@127.0.0.1:3306/cap_infra_tests CAP_PASSKEYS_TEST_DATABASE_URL: mysql://root@127.0.0.1:3306/cap_infra_tests - run: bun run vitest run __tests__/integration/infra-*-database.test.ts __tests__/integration/user-preferences-database.test.ts __tests__/integration/space-creator-membership-database.test.ts __tests__/integration/organization-pointer-database.test.ts __tests__/integration/dashboard-library-database.test.ts __tests__/integration/messenger-poll-database.test.ts __tests__/integration/passkeys-database.test.ts __tests__/integration/email-change-database.test.ts __tests__/integration/meetings-trial-database.test.ts __tests__/integration/meetings-audio-usage-database.test.ts + run: bun run vitest run __tests__/integration/infra-*-database.test.ts __tests__/integration/user-preferences-database.test.ts __tests__/integration/space-creator-membership-database.test.ts __tests__/integration/organization-pointer-database.test.ts __tests__/integration/dashboard-library-database.test.ts __tests__/integration/messenger-poll-database.test.ts __tests__/integration/passkeys-database.test.ts __tests__/integration/email-change-database.test.ts __tests__/integration/meetings-trial-database.test.ts __tests__/integration/meetings-audio-usage-database.test.ts __tests__/integration/meetings-share-database.test.ts diff --git a/apps/web/__tests__/integration/dashboard-library-database.test.ts b/apps/web/__tests__/integration/dashboard-library-database.test.ts index 4e44d876961..c3b96ea9a6a 100644 --- a/apps/web/__tests__/integration/dashboard-library-database.test.ts +++ b/apps/web/__tests__/integration/dashboard-library-database.test.ts @@ -233,6 +233,71 @@ describe.runIf(Boolean(databaseUrl))( ).toEqual({ [unshared]: [], [shared]: [orgId] }); }); + it("lists and counts each kind of Cap on its own, newest first", async () => { + const { CapsPageView } = await import( + "@/app/(org)/dashboard/caps/caps-page-data" + ); + const { listCapIdsInView } = await import("@/actions/caps/list-view-ids"); + const { orgId, ownerId } = await createOrg(); + const otherId = await addMember(orgId); + const at = (minute: number) => ({ + createdAt: new Date(Date.UTC(2026, 0, 1, 0, minute)), + }); + const videoIds = [ + await createVideo(ownerId, orgId, at(1)), + await createVideo(ownerId, orgId, at(4)), + ]; + const imageIds = [ + await createVideo(ownerId, orgId, { ...at(2), isScreenshot: true }), + ]; + const noteIds = [ + await createVideo(ownerId, orgId, { ...at(3), isNote: true }), + await createVideo(ownerId, orgId, { ...at(5), isNote: true }), + ]; + await createVideo(ownerId, orgId, { + ...at(6), + archivedAt: new Date(), + }); + await createVideo(ownerId, orgId, { + ...at(7), + isNote: true, + folderId: id() as never, + }); + await createVideo(otherId, orgId, { ...at(8), isNote: true }); + fixture.sessionUserId = ownerId; + const expected = { + videos: videoIds.toReversed(), + images: imageIds, + notes: noteIds.toReversed(), + }; + + for (const kind of ["videos", "images", "notes"] as const) { + const page = await CapsPageView({ + searchParams: {}, + view: "library", + kind, + }); + expect( + page.props.data.map((cap: { id: string }) => cap.id), + kind, + ).toEqual(expected[kind]); + expect(page.props.count, kind).toBe(expected[kind].length); + expect( + (await listCapIdsInView({ type: "personal", kind })).ids, + ).toEqual(expected[kind]); + } + + const overview = await CapsPageView({ + searchParams: {}, + view: "library", + }); + expect( + overview.props.data.map((cap: { id: string }) => cap.id).sort(), + ).toEqual([...videoIds, ...imageIds, ...noteIds].sort()); + expect(overview.props.counts).toEqual({ videos: 2, images: 1, notes: 2 }); + expect(overview.props.archivedCount).toBe(1); + }); + it("counts comments and lists each shared organization once on My Caps", async () => { const { CapsPageView } = await import( "@/app/(org)/dashboard/caps/caps-page-data" diff --git a/apps/web/__tests__/integration/meetings-share-database.test.ts b/apps/web/__tests__/integration/meetings-share-database.test.ts new file mode 100644 index 00000000000..f09757568ab --- /dev/null +++ b/apps/web/__tests__/integration/meetings-share-database.test.ts @@ -0,0 +1,337 @@ +import { randomUUID } from "node:crypto"; +import * as Db from "@cap/database/schema"; +import { eq, inArray } from "drizzle-orm"; +import { drizzle, type MySql2Database } from "drizzle-orm/mysql2"; +import type { Effect } from "effect"; +import { createPool, type Pool } from "mysql2/promise"; +import { afterAll, beforeAll, describe, expect, it, vi } from "vitest"; + +const fixture = vi.hoisted(() => ({ + database: undefined as unknown, + storageListed: [] as string[], +})); + +vi.mock("server-only", () => ({})); +vi.mock("@cap/database", async (importOriginal) => ({ + ...(await importOriginal()), + db: () => { + if (!fixture.database) throw new Error("Test database is not connected."); + return fixture.database; + }, +})); +vi.mock("@cap/database/video-sharing-default", () => ({ + getNewVideoPublic: async (orgId: string) => !orgId.startsWith("private"), +})); +vi.mock("@cap/web-backend/src/Storage/index", async () => { + const { Effect } = await import("effect"); + class Storage extends Effect.Service()("Storage", { + sync: () => ({ + getAccessForVideo: () => + Effect.succeed([ + { + listObjects: ({ prefix }: { prefix: string }) => { + fixture.storageListed.push(prefix); + return Effect.succeed({ Contents: [] }); + }, + deleteObjects: () => Effect.void, + }, + ]), + }), + }) {} + return { Storage }; +}); +vi.mock("@cap/web-backend/src/Tinybird/index", async () => { + const { Effect } = await import("effect"); + class Tinybird extends Effect.Service()("Tinybird", { + sync: () => ({}), + }) {} + return { Tinybird }; +}); +vi.mock("@/lib/server", async () => { + const { Effect } = await import("effect"); + const { Videos } = await import("@cap/web-backend"); + return { + runPromise: (effect: Effect.Effect) => + Effect.runPromise( + effect.pipe(Effect.provide(Videos.Default)) as Effect.Effect< + A, + E, + never + >, + ), + }; +}); + +const share = await import("@/lib/meetings/share"); +const { meetingShareRequestSchema } = await import("@/lib/meetings/schemas"); + +const databaseUrl = process.env.CAP_INFRA_TEST_DATABASE_URL; +const database = () => fixture.database as MySql2Database; +const id = () => randomUUID().replaceAll("-", "").slice(0, 15); + +type ShareUser = Parameters[0]; + +const createOrg = async (ownerId: string, prefix = "") => { + const orgId = `${prefix}${id()}`.slice(0, 15); + await database() + .insert(Db.organizations) + .values({ + id: orgId as never, + name: "Team", + ownerId: ownerId as never, + }); + return orgId; +}; + +const createUser = async (prefix = "") => { + const userId = id(); + const orgId = await createOrg(userId, prefix); + await database() + .insert(Db.users) + .values({ + id: userId as never, + email: `${userId}@example.com`, + name: "Alex Morgan", + activeOrganizationId: orgId as never, + defaultOrgId: orgId as never, + }); + const [user] = await database() + .select() + .from(Db.users) + .where(eq(Db.users.id, userId as never)); + return { user: user as unknown as ShareUser, orgId }; +}; + +const note = (overrides: Record = {}) => + meetingShareRequestSchema.parse({ + documentId: `doc-${id()}`, + title: "Weekly sync", + summaryMarkdown: "## Summary\n\nShip the export fix on **Monday**.", + notesMarkdown: "- [ ] Email the list", + transcript: [{ speaker: " Sam ", startMs: 1_000, text: " Morning. " }], + participants: ["Sam", " Sam ", "Priya", ""], + startedAt: "2026-11-27T09:00:00Z", + durationSeconds: 1_934, + ...overrides, + }); + +const capRow = async (videoId: string) => { + const [row] = await database() + .select() + .from(Db.videos) + .where(eq(Db.videos.id, videoId as never)); + return row; +}; + +const noteRow = async (videoId: string) => { + const [row] = await database() + .select() + .from(Db.videoNotes) + .where(eq(Db.videoNotes.videoId, videoId as never)); + return row; +}; + +const saved = async (user: ShareUser, input: ReturnType) => { + const result = await share.upsertSharedNote(user, input); + if (typeof result === "string") throw new Error(result); + return result; +}; + +describe.runIf(Boolean(databaseUrl))("shared notes in MySQL", () => { + let pool: Pool; + + beforeAll(async () => { + pool = createPool({ uri: databaseUrl, connectionLimit: 12 }); + fixture.database = drizzle(pool); + }); + + afterAll(async () => { + await pool?.end(); + }); + + it("creates a note cap with the organization's default access", async () => { + const { user, orgId } = await createUser(); + const input = note(); + + const result = await saved(user, input); + + expect(result).toMatchObject({ orgId, created: true }); + expect(await capRow(result.id)).toMatchObject({ + ownerId: user.id, + orgId, + name: "Weekly sync", + isNote: true, + isScreenshot: false, + public: true, + password: null, + duration: 1_934, + source: { type: "local" }, + transcriptionStatus: "SKIPPED", + bucket: null, + }); + expect(await noteRow(result.id)).toMatchObject({ + ownerId: user.id, + documentId: input.documentId, + excerpt: "Ship the export fix on Monday.", + summaryMarkdown: "## Summary\n\nShip the export fix on **Monday**.", + notesMarkdown: "- [ ] Email the list", + transcript: [{ speaker: "Sam", startMs: 1_000, text: "Morning." }], + participants: ["Sam", "Priya"], + meetingStartedAt: new Date("2026-11-27T09:00:00Z"), + }); + }); + + it("follows an organization that keeps new caps private", async () => { + const { user } = await createUser("private"); + + const result = await saved(user, note()); + + expect(await capRow(result.id)).toMatchObject({ public: false }); + }); + + it("shares into the requested organization only when the user belongs to it", async () => { + const { user, orgId } = await createUser(); + const second = await createOrg(user.id); + const { orgId: foreign } = await createUser(); + + expect(await saved(user, note({ orgId: second }))).toMatchObject({ + orgId: second, + }); + expect(await saved(user, note({ orgId: foreign }))).toMatchObject({ + orgId, + }); + }); + + it("updates the same link when the document is shared again", async () => { + const { user } = await createUser(); + const input = note(); + const first = await saved(user, input); + await database() + .update(Db.videos) + .set({ public: false, folderId: "folder-1" as never }) + .where(eq(Db.videos.id, first.id)); + + const second = await saved(user, { + ...input, + title: "Weekly sync, edited", + summaryMarkdown: "Moved to Tuesday.", + notesMarkdown: "", + transcript: undefined, + participants: [], + startedAt: undefined, + durationSeconds: undefined, + }); + + expect(second).toMatchObject({ id: first.id, created: false }); + expect(await capRow(first.id)).toMatchObject({ + name: "Weekly sync, edited", + duration: null, + public: false, + folderId: "folder-1", + }); + expect(await noteRow(first.id)).toMatchObject({ + excerpt: "Moved to Tuesday.", + summaryMarkdown: "Moved to Tuesday.", + notesMarkdown: null, + transcript: null, + participants: [], + meetingStartedAt: null, + }); + }); + + it("keeps one link when the same document is shared at the same moment", async () => { + const { user } = await createUser(); + const input = note(); + + const results = await Promise.all( + Array.from({ length: 6 }, () => saved(user, input)), + ); + + expect(new Set(results.map((result) => result.id)).size).toBe(1); + expect(results.filter((result) => result.created)).toHaveLength(1); + const caps = await database() + .select({ id: Db.videos.id }) + .from(Db.videos) + .where(eq(Db.videos.ownerId, user.id)); + expect(caps).toHaveLength(1); + }); + + it("gives two people their own link for the same document id", async () => { + const [first, second] = await Promise.all([createUser(), createUser()]); + const input = note(); + + const mine = await saved(first.user, input); + const theirs = await saved(second.user, input); + + expect(mine.id).not.toBe(theirs.id); + expect([mine.created, theirs.created]).toEqual([true, true]); + }); + + it("stops sharing by removing the cap and its content", async () => { + const { user } = await createUser(); + const input = note(); + const { id: videoId } = await saved(user, input); + + expect(await share.deleteSharedNote(user, input.documentId)).toBe(true); + + expect(await capRow(videoId)).toBeUndefined(); + expect(await noteRow(videoId)).toBeUndefined(); + expect(fixture.storageListed).toContain(`${user.id}/${videoId}/`); + expect(await share.deleteSharedNote(user, input.documentId)).toBe(false); + expect(await saved(user, input)).toMatchObject({ created: true }); + }); + + it("does not let one person stop another's share of the same document id", async () => { + const [owner, other] = await Promise.all([createUser(), createUser()]); + const input = note(); + const { id: videoId } = await saved(owner.user, input); + + expect(await share.deleteSharedNote(other.user, input.documentId)).toBe( + false, + ); + + expect(await noteRow(videoId)).toBeDefined(); + }); + + it("leaves a transferred cap to its new owner", async () => { + const [owner, other] = await Promise.all([createUser(), createUser()]); + const input = note(); + const { id: videoId } = await saved(owner.user, input); + await database() + .update(Db.videos) + .set({ ownerId: other.user.id }) + .where(eq(Db.videos.id, videoId)); + + expect(await share.upsertSharedNote(owner.user, input)).toBe("conflict"); + expect(await share.deleteSharedNote(owner.user, input.documentId)).toBe( + false, + ); + expect(await noteRow(videoId)).toMatchObject({ + summaryMarkdown: input.summaryMarkdown, + }); + }); + + it("replaces content left behind without its cap", async () => { + const { user } = await createUser(); + const input = note(); + const first = await saved(user, input); + const connection = await pool.getConnection(); + try { + await connection.query("SET FOREIGN_KEY_CHECKS = 0"); + await connection.query("DELETE FROM videos WHERE id = ?", [first.id]); + } finally { + await connection.query("SET FOREIGN_KEY_CHECKS = 1"); + connection.release(); + } + + const second = await saved(user, input); + + expect(second.created).toBe(true); + expect(second.id).not.toBe(first.id); + const rows = await database() + .select({ videoId: Db.videoNotes.videoId }) + .from(Db.videoNotes) + .where(inArray(Db.videoNotes.videoId, [first.id, second.id])); + expect(rows).toEqual([{ videoId: second.id }]); + }); +}); diff --git a/apps/web/__tests__/unit/cap-kind-query.test.ts b/apps/web/__tests__/unit/cap-kind-query.test.ts new file mode 100644 index 00000000000..b7686b495bc --- /dev/null +++ b/apps/web/__tests__/unit/cap-kind-query.test.ts @@ -0,0 +1,52 @@ +import { VIDEOS_KIND_LIST_INDEX, videos } from "@cap/database/schema"; +import { and, eq } from "drizzle-orm"; +import { getTableConfig, QueryBuilder } from "drizzle-orm/mysql-core"; +import { describe, expect, it } from "vitest"; +import { CAP_KINDS } from "@/lib/cap-kind"; +import { capKindCondition, capKindIndexHint } from "@/lib/cap-kind-query"; + +const listQuery = (kind: (typeof CAP_KINDS)[number]) => + new QueryBuilder() + .select({ id: videos.id }) + .from(videos, capKindIndexHint) + .where(and(eq(videos.ownerId, "user-1" as never), capKindCondition(kind))) + .toSQL(); + +describe("cap kind queries", () => { + it("pins a kind list to an index the videos table defines", () => { + const index = getTableConfig(videos).indexes.find( + (each) => each.config.name === VIDEOS_KIND_LIST_INDEX, + ); + + expect( + index?.config.columns.map((column) => "name" in column && column.name), + ).toEqual([ + "orgId", + "ownerId", + "folderId", + "archivedAt", + "isNote", + "isScreenshot", + "effectiveCreatedAt", + ]); + expect(listQuery("videos").sql).toContain( + `from \`videos\` FORCE INDEX (${VIDEOS_KIND_LIST_INDEX})`, + ); + }); + + it("filters every kind on both flags so each kind is one index range", () => { + expect( + Object.fromEntries( + CAP_KINDS.map((kind) => [kind, listQuery(kind).params.slice(1)]), + ), + ).toEqual({ + videos: [false, false], + images: [false, true], + notes: [true, false], + }); + for (const kind of CAP_KINDS) + expect(listQuery(kind).sql).toContain( + "`videos`.`isNote` = ? and `videos`.`isScreenshot` = ?", + ); + }); +}); diff --git a/apps/web/__tests__/unit/cap-kind.test.ts b/apps/web/__tests__/unit/cap-kind.test.ts new file mode 100644 index 00000000000..f32752be759 --- /dev/null +++ b/apps/web/__tests__/unit/cap-kind.test.ts @@ -0,0 +1,89 @@ +import { describe, expect, it } from "vitest"; +import { + capCountLabel, + capIdsInKindOrder, + capKindCountsFromTotals, + capKindOf, + groupCapsByKind, + visibleNoteExcerpt, +} from "@/lib/cap-kind"; +import { toggleSelection } from "@/lib/cap-selection"; + +describe("cap kinds", () => { + it("reads a note before a screenshot, and a video otherwise", () => { + expect(capKindOf({ isNote: true, isScreenshot: true })).toBe("notes"); + expect(capKindOf({ isScreenshot: true })).toBe("images"); + expect(capKindOf({ isNote: null, isScreenshot: null })).toBe("videos"); + }); + + it("groups in section order and leaves empty kinds out", () => { + const caps = [ + { id: "n", isNote: true }, + { id: "v", isNote: false }, + { id: "v2" }, + ]; + + expect(groupCapsByKind(caps)).toEqual([ + { kind: "videos", caps: [caps[1], caps[2]] }, + { kind: "notes", caps: [caps[0]] }, + ]); + }); + + it("lists ids in the order the kind sections show them", () => { + const caps = [ + { id: "video-1" }, + { id: "note-1", isNote: true }, + { id: "video-2" }, + { id: "image-1", isScreenshot: true }, + ]; + const orderedIds = capIdsInKindOrder(caps); + + expect(orderedIds).toEqual(["video-1", "video-2", "image-1", "note-1"]); + expect( + toggleSelection({ + orderedIds, + selected: ["video-1"], + anchorId: "video-1", + targetId: "video-2", + shiftKey: true, + }).selected, + ).toEqual(["video-1", "video-2"]); + }); + + it("counts a folder's contents as Caps", () => { + expect([0, 1, 5].map(capCountLabel)).toEqual(["0 Caps", "1 Cap", "5 Caps"]); + }); + + it("derives video counts from the totals", () => { + expect(capKindCountsFromTotals({ count: 10, images: 3, notes: 2 })).toEqual( + { videos: 5, images: 3, notes: 2 }, + ); + expect(capKindCountsFromTotals(undefined)).toEqual({ + videos: 0, + images: 0, + notes: 0, + }); + }); +}); + +describe("note excerpt on a card", () => { + const note = { ownerId: "owner", noteExcerpt: "Ship on Monday" }; + + it("shows an open note to anyone who can list it", () => { + expect(visibleNoteExcerpt(note, "member", false)).toBe("Ship on Monday"); + }); + + it.each([ + [{ ...note, hasPassword: true }, false], + [note, true], + ])( + "hides a password-protected note from other people %#", + (cap, inherited) => { + expect(visibleNoteExcerpt(cap, "member", inherited)).toBeNull(); + expect(visibleNoteExcerpt(cap, null, inherited)).toBeNull(); + expect(visibleNoteExcerpt(cap, "owner", inherited)).toBe( + "Ship on Monday", + ); + }, + ); +}); diff --git a/apps/web/__tests__/unit/caps-keyboard.test.ts b/apps/web/__tests__/unit/caps-keyboard.test.ts index 83f5bbec193..6bb4c27044d 100644 --- a/apps/web/__tests__/unit/caps-keyboard.test.ts +++ b/apps/web/__tests__/unit/caps-keyboard.test.ts @@ -123,6 +123,12 @@ let selection: HTMLButtonElement; beforeEach(async () => { vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true); + vi.stubGlobal("matchMedia", (media: string) => ({ + media, + matches: true, + addEventListener: () => {}, + removeEventListener: () => {}, + })); mocks.mutate.mockClear(); mocks.mutations.length = 0; mocks.pending = false; diff --git a/apps/web/__tests__/unit/caps-overview-grid.test.ts b/apps/web/__tests__/unit/caps-overview-grid.test.ts new file mode 100644 index 00000000000..5eedd51f36d --- /dev/null +++ b/apps/web/__tests__/unit/caps-overview-grid.test.ts @@ -0,0 +1,64 @@ +import { describe, expect, it } from "vitest"; +import { + gridColumns, + overviewItemClass, + overviewShows, +} from "@/app/(org)/dashboard/caps/overview-grid"; + +const SHOWN_FROM: Record = { + "sm:block": 2, + "lg:block": 3, + "xl:block": 4, + "2xl:block": 5, +}; + +const shownByClass = (index: number, rows: number, columns: number) => { + const className = overviewItemClass(index, rows); + if (className === undefined) return true; + const show = className.replace("hidden", "").trim(); + return show !== "" && columns >= (SHOWN_FROM[show] ?? Infinity); +}; + +describe("My Caps overview grid", () => { + it("counts a card as shown exactly when its classes show it", () => { + for (const rows of [1, 2]) + for (let columns = 1; columns <= 5; columns++) + for (let index = 0; index < 12; index++) + expect([ + rows, + columns, + index, + overviewShows(index, rows, columns), + ]).toEqual([ + rows, + columns, + index, + shownByClass(index, rows, columns), + ]); + }); + + it("shows whole rows on wide screens and a short stack on a phone", () => { + const shown = (rows: number, columns: number) => + Array.from({ length: 10 }, (_, index) => index).filter((index) => + overviewShows(index, rows, columns), + ).length; + + expect([ + shown(2, 5), + shown(2, 4), + shown(2, 3), + shown(2, 2), + shown(2, 1), + ]).toEqual([10, 8, 6, 4, 3]); + expect([shown(1, 5), shown(1, 3), shown(1, 1)]).toEqual([5, 3, 2]); + }); + + it("reads the column count from the widest matching breakpoint", () => { + const at = (width: number) => + gridColumns((query) => width >= Number(/\d+/.exec(query)?.[0])); + + expect([at(390), at(640), at(1023), at(1024), at(1280), at(1536)]).toEqual([ + 1, 2, 2, 3, 4, 5, + ]); + }); +}); diff --git a/apps/web/__tests__/unit/caps-page-redirect.test.ts b/apps/web/__tests__/unit/caps-page-redirect.test.ts new file mode 100644 index 00000000000..ed2de89b6ff --- /dev/null +++ b/apps/web/__tests__/unit/caps-page-redirect.test.ts @@ -0,0 +1,54 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; + +const mocks = vi.hoisted(() => ({ + redirect: vi.fn((url: string) => { + throw new Error(`redirect:${url}`); + }), + view: vi.fn(async (_props: unknown) => null), +})); + +vi.mock("next/navigation", () => ({ redirect: mocks.redirect })); +vi.mock("@/app/(org)/dashboard/caps/caps-page-data", () => ({ + CapsPageView: mocks.view, +})); + +const { default: CapsPage } = await import("@/app/(org)/dashboard/caps/page"); + +const open = (searchParams: Record) => + CapsPage({ + params: Promise.resolve({}), + searchParams: Promise.resolve(searchParams), + } as never); + +beforeEach(() => { + mocks.redirect.mockClear(); + mocks.view.mockClear(); +}); + +describe("My Caps page links", () => { + it.each([ + [{ page: "3" }, 3], + [{ page: "1" }, 1], + [{ page: ["2", "9"] }, 2], + [{ page: "not-a-page" }, 1], + [{ page: "-4" }, 1], + ])( + "sends the old list link %j to that page of Videos", + async (params, page) => { + await expect(open(params)).rejects.toThrow( + `redirect:/dashboard/caps/videos?page=${page}`, + ); + expect(mocks.view).not.toHaveBeenCalled(); + }, + ); + + it("shows the overview when no page is asked for", async () => { + await open({ upgrade: "true" }); + + expect(mocks.redirect).not.toHaveBeenCalled(); + expect(mocks.view).toHaveBeenCalledWith({ + searchParams: { upgrade: "true" }, + view: "library", + }); + }); +}); diff --git a/apps/web/__tests__/unit/comment-composer-composition.test.ts b/apps/web/__tests__/unit/comment-composer-composition.test.ts index c90630fe24b..42c9e640b8c 100644 --- a/apps/web/__tests__/unit/comment-composer-composition.test.ts +++ b/apps/web/__tests__/unit/comment-composer-composition.test.ts @@ -63,6 +63,7 @@ const video = { xStreamInfo: null, firstViewEmailSentAt: null, isScreenshot: true, + isNote: false, awsRegion: null, awsBucket: null, videoStartTime: null, diff --git a/apps/web/__tests__/unit/dashboard-search-item-values.test.ts b/apps/web/__tests__/unit/dashboard-search-item-values.test.ts index cb0be0e4119..f0ca0c3aff8 100644 --- a/apps/web/__tests__/unit/dashboard-search-item-values.test.ts +++ b/apps/web/__tests__/unit/dashboard-search-item-values.test.ts @@ -53,6 +53,7 @@ const video = (id: string, name: string, ownerName = "Sam") => createdAt: "2026-01-01T00:00:00.000Z", duration: 65, isScreenshot: false, + isNote: false, }) as DashboardVideoSearchResult; const space = (id: string, name: string) => ({ diff --git a/apps/web/__tests__/unit/embed-video-playback-chrome.test.ts b/apps/web/__tests__/unit/embed-video-playback-chrome.test.ts index 52020b5e13d..dee8d82f812 100644 --- a/apps/web/__tests__/unit/embed-video-playback-chrome.test.ts +++ b/apps/web/__tests__/unit/embed-video-playback-chrome.test.ts @@ -219,6 +219,7 @@ const createProps = ( xStreamInfo: null, firstViewEmailSentAt: null, isScreenshot: false, + isNote: false, awsRegion: null, awsBucket: null, videoStartTime: null, diff --git a/apps/web/__tests__/unit/folder-videos.test.ts b/apps/web/__tests__/unit/folder-videos.test.ts index ed0647b86a9..285fa0d827a 100644 --- a/apps/web/__tests__/unit/folder-videos.test.ts +++ b/apps/web/__tests__/unit/folder-videos.test.ts @@ -1,11 +1,12 @@ import { Database, ImageUploads } from "@cap/web-backend"; -import { Folder, Organisation, Space } from "@cap/web-domain"; +import { CurrentUser, Folder, Organisation, Space } from "@cap/web-domain"; import { Effect } from "effect"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { getVideosByFolderId } from "@/lib/folder"; import { readDistinctVideoIds } from "../fixtures/distinct-video-ids"; const mocks = vi.hoisted(() => ({ query: vi.fn() })); +const viewer = { id: "viewer" } as CurrentUser["Type"]; vi.mock("server-only", () => ({})); vi.mock("@cap/web-backend", async () => { @@ -65,6 +66,8 @@ describe.each([ "2026-10-23 12:00:00", false, false, + false, + null, ], ], }); @@ -74,6 +77,7 @@ describe.each([ ).pipe( Effect.provide(Database.Default), Effect.provide(ImageUploads.Default), + Effect.provideService(CurrentUser, viewer), Effect.runPromise, ); @@ -101,6 +105,7 @@ describe.each([ await getVideosByFolderId(Folder.FolderId.make("folder-1"), root).pipe( Effect.provide(Database.Default), Effect.provide(ImageUploads.Default), + Effect.provideService(CurrentUser, viewer), Effect.runPromise, ); const queries = mocks.query.mock.calls.map(([query]) => String(query)); diff --git a/apps/web/__tests__/unit/meetings-route.test.ts b/apps/web/__tests__/unit/meetings-route.test.ts index 49979d5b52c..84e67691fad 100644 --- a/apps/web/__tests__/unit/meetings-route.test.ts +++ b/apps/web/__tests__/unit/meetings-route.test.ts @@ -30,6 +30,16 @@ const mocks = vi.hoisted(() => ({ { completed: boolean; runs: number; asks: number } >(), daily: vi.fn(), + shareUpsert: vi.fn(), + shareDelete: vi.fn(), +})); + +vi.mock("@/lib/meetings/share", () => ({ + upsertSharedNote: mocks.shareUpsert, + deleteSharedNote: mocks.shareDelete, +})); +vi.mock("@/lib/desktop-share-url", () => ({ + getDesktopShareUrl: async () => undefined, })); vi.mock("@/lib/meetings/audio-usage", () => ({ @@ -300,6 +310,7 @@ beforeEach(() => { ASSEMBLY_API_KEY: "test-key", ASSEMBLY_BASE_URL: "https://speech.example/asr", NEXTAUTH_SECRET: "test-secret", + WEB_URL: "https://cap.so", }; mocks.aiConfigured = true; mocks.after = []; @@ -314,6 +325,8 @@ beforeEach(() => { mocks.remove, mocks.streamText, mocks.generateText, + mocks.shareUpsert, + mocks.shareDelete, ]) fn.mockReset(); mocks.daily.mockReset(); @@ -1553,3 +1566,207 @@ describe("remote control", () => { expect(capabilities.notes).toBe(true); }); }); + +describe("note share links", () => { + const note = { + documentId: "doc_weekly-sync", + title: "Weekly sync", + summaryMarkdown: `## Summary\n\n${SECRET}`, + transcript: [{ speaker: "Sam", startMs: 1_000, text: SECRET }], + participants: ["Sam", "Priya"], + startedAt: "2026-11-27T10:00:00+01:00", + durationSeconds: 1_934, + }; + const saved = { id: "0123456789abcde", orgId: "org-1", created: true }; + + it("needs a sign-in to share or stop sharing", async () => { + const share = await call("/share", { + auth: false, + body: JSON.stringify(note), + headers: { "content-type": "application/json" }, + }); + const stop = await call("/share/doc_weekly-sync", { + auth: false, + method: "DELETE", + }); + + expect([share.status, stop.status]).toEqual([401, 401]); + expect(mocks.shareUpsert).not.toHaveBeenCalled(); + expect(mocks.shareDelete).not.toHaveBeenCalled(); + }); + + it("creates a link for a free account and returns it uncached", async () => { + const user = signIn(null); + mocks.shareUpsert.mockResolvedValue(saved); + + const response = await postJson("/share", note); + + expect(response.status).toBe(200); + expect(response.headers.get("cache-control")).toBe("no-store"); + expect(await response.json()).toEqual({ + id: saved.id, + shareUrl: `https://cap.so/s/${saved.id}`, + created: true, + }); + expect(mocks.shareUpsert).toHaveBeenCalledWith( + expect.objectContaining({ id: user.id }), + expect.objectContaining({ + documentId: note.documentId, + title: note.title, + notesMarkdown: "", + transcript: note.transcript, + }), + ); + }); + + it("reports an update of the same document as not created", async () => { + signIn(); + mocks.shareUpsert.mockResolvedValue({ ...saved, created: false }); + + const response = await postJson("/share", note); + + expect(await response.json()).toMatchObject({ + id: saved.id, + created: false, + }); + }); + + it.each([ + ["text/plain", JSON.stringify(note), "content-type"], + ["application/json", "{", "body"], + ])("rejects a %s body it cannot read", async (type, body, field) => { + signIn(); + + const response = await call("/share", { + body, + headers: { "content-type": type }, + }); + + expect(response.status).toBe(400); + expect((await response.json()).detail).toContain(field); + expect(mocks.shareUpsert).not.toHaveBeenCalled(); + }); + + it("names the invalid field without repeating the note", async () => { + signIn(); + + const response = await postJson("/share", { + ...note, + documentId: "../other", + }); + const body = await response.text(); + + expect(response.status).toBe(400); + expect(body).toContain("documentId"); + expect(body).not.toContain(SECRET); + expect(mocks.shareUpsert).not.toHaveBeenCalled(); + }); + + it("refuses a body over the size limit", async () => { + signIn(); + + const response = await postJson("/share", { + ...note, + summaryMarkdown: "a".repeat(4_000_001), + }); + + expect(response.status).toBe(413); + expect(mocks.shareUpsert).not.toHaveBeenCalled(); + }); + + it.each([ + ["no_organization", 403, "no_valid_org"], + ["conflict", 409, "conflict"], + ])("answers %s without a link", async (result, status, error) => { + signIn(); + mocks.shareUpsert.mockResolvedValue(result); + + const response = await postJson("/share", note); + + expect(response.status).toBe(status); + expect(await response.json()).toEqual({ error }); + }); + + it("keeps note text out of the response and the logs when saving fails", async () => { + signIn(); + mocks.shareUpsert.mockRejectedValue(new Error(`insert failed: ${SECRET}`)); + + const response = await postJson("/share", note); + + expect(response.status).toBe(500); + expect(await response.text()).not.toContain(SECRET); + const logged = JSON.stringify( + [console.log, console.error, console.warn].flatMap( + (log) => vi.mocked(log).mock.calls, + ), + ); + expect(logged).not.toContain(SECRET); + }); + + it("limits how often one account can share", async () => { + signIn(); + mocks.shareUpsert.mockResolvedValue(saved); + for (let index = 0; index < 120; index++) + expect((await postJson("/share", note)).status).toBe(200); + + const limited = await postJson("/share", note); + + expect(limited.status).toBe(429); + expect(limited.headers.get("retry-after")).not.toBeNull(); + expect(mocks.shareUpsert).toHaveBeenCalledTimes(120); + }); + + it("charges a large note more of the same allowance", async () => { + signIn(); + mocks.shareUpsert.mockResolvedValue(saved); + const large = { + ...note, + transcript: Array.from({ length: 47 }, () => ({ + speaker: "Sam", + startMs: 0, + text: "a".repeat(20_000), + })), + }; + for (let index = 0; index < 12; index++) + expect((await postJson("/share", large)).status).toBe(200); + + expect((await postJson("/share", large)).status).toBe(429); + }); + + it("stops sharing a document", async () => { + const user = signIn(); + mocks.shareDelete.mockResolvedValue(true); + + const response = await call("/share/doc_weekly-sync", { + method: "DELETE", + }); + + expect(response.status).toBe(200); + expect(await response.json()).toEqual({ deleted: true }); + expect(mocks.shareDelete).toHaveBeenCalledWith( + expect.objectContaining({ id: user.id }), + "doc_weekly-sync", + ); + }); + + it("answers a document that is not shared without an error", async () => { + signIn(); + mocks.shareDelete.mockResolvedValue(false); + + const response = await call("/share/doc_unknown", { method: "DELETE" }); + + expect(response.status).toBe(200); + expect(await response.json()).toEqual({ deleted: false }); + }); + + it("rejects a document id it cannot have issued", async () => { + signIn(); + + const response = await call(`/share/${"a".repeat(65)}`, { + method: "DELETE", + }); + + expect(response.status).toBe(400); + expect(mocks.shareDelete).not.toHaveBeenCalled(); + }); +}); diff --git a/apps/web/__tests__/unit/meetings-share-content.test.ts b/apps/web/__tests__/unit/meetings-share-content.test.ts new file mode 100644 index 00000000000..944e31ce57c --- /dev/null +++ b/apps/web/__tests__/unit/meetings-share-content.test.ts @@ -0,0 +1,75 @@ +import { describe, expect, it } from "vitest"; +import { meetingShareDocumentIdSchema } from "@/lib/meetings/schemas"; +import { + NOTE_EXCERPT_CHARS, + NOTE_TITLE_COLUMN_CHARS, + noteExcerpt, + noteTitle, + transferredNoteDocumentId, +} from "@/lib/meetings/share-content"; + +describe("note title", () => { + it("keeps a title as written, on one line", () => { + expect(noteTitle(" Weekly\n sync ")).toBe("Weekly sync"); + }); + + it("names a note that has no title", () => { + expect(noteTitle(" \n ")).toBe("Untitled note"); + }); + + it("fits the title column without splitting a character", () => { + const title = noteTitle("🎥".repeat(300)); + + expect(Array.from(title)).toHaveLength(NOTE_TITLE_COLUMN_CHARS); + expect(title.endsWith("🎥")).toBe(true); + }); +}); + +describe("note excerpt", () => { + it("reads as plain text", () => { + const markdown = [ + "## Summary", + "", + "We ship **export** on _Monday_.", + "", + "---", + "- [ ] Email the [list](https://example.com/list)", + "- [x] Fix `scrub` bug", + "1. Call Juno", + "> Agreed by all", + "![chart](https://example.com/chart.png)", + ].join("\n"); + + expect(noteExcerpt(markdown)).toBe( + "We ship export on Monday. Email the list Fix scrub bug Call Juno Agreed by all chart", + ); + }); + + it("leaves out code blocks and markup", () => { + expect( + noteExcerpt( + 'Before\n```ts\nconst key = "value";\n```\nAfter bold', + ), + ).toBe("Before After alert(1)bold"); + }); + + it("is empty for a note with only headings", () => { + expect(noteExcerpt("# Title\n\n## Section")).toBe(""); + }); + + it("stops at the card length without splitting a character", () => { + const excerpt = noteExcerpt("🙂".repeat(500)); + + expect(Array.from(excerpt)).toHaveLength(NOTE_EXCERPT_CHARS); + }); +}); + +describe("note document id after a transfer", () => { + it("is a valid document id that belongs to that cap alone", () => { + const id = transferredNoteDocumentId("0123456789abcde"); + + expect(id).toBe("transferred-0123456789abcde"); + expect(meetingShareDocumentIdSchema.safeParse(id).success).toBe(true); + expect(transferredNoteDocumentId("edcba9876543210")).not.toBe(id); + }); +}); diff --git a/apps/web/__tests__/unit/meetings-share-schemas.test.ts b/apps/web/__tests__/unit/meetings-share-schemas.test.ts new file mode 100644 index 00000000000..44bd4e0b020 --- /dev/null +++ b/apps/web/__tests__/unit/meetings-share-schemas.test.ts @@ -0,0 +1,177 @@ +import { describe, expect, it } from "vitest"; +import { + MEETING_NOTES_TRANSCRIPT_MAX_CHARS, + MEETING_SHARE_MAX_DURATION_SECONDS, + MEETING_SHARE_NOTES_MAX_CHARS, + MEETING_SHARE_SUMMARY_MAX_CHARS, + MEETING_SHARE_TITLE_MAX_CHARS, + MEETING_SHARE_TRANSCRIPT_MAX_TURNS, + MEETING_SHARE_TURN_MAX_CHARS, + meetingShareDocumentIdSchema, + meetingShareRequestSchema, + parseMeetingBody, +} from "@/lib/meetings/schemas"; + +const note = { + documentId: "doc_weekly-sync", + title: "Weekly sync", + summaryMarkdown: "## Summary\n\nShip on Monday.", +}; + +const parse = (body: unknown) => + parseMeetingBody(meetingShareRequestSchema, body); + +const rejected = (body: unknown) => { + const result = parse(body); + return result.ok ? null : result.detail; +}; + +describe("note share request", () => { + it("accepts the smallest note and fills the optional fields", () => { + const result = parse(note); + + expect(result).toEqual({ + ok: true, + data: { ...note, notesMarkdown: "", participants: [] }, + }); + }); + + it("accepts a full note", () => { + const full = { + ...note, + orgId: "0123456789abcde", + notesMarkdown: "- [ ] Email the list", + transcript: [{ speaker: "Sam", startMs: 0, text: "Morning." }], + participants: ["Sam", "Priya"], + startedAt: "2026-11-27T10:00:00+01:00", + durationSeconds: 1_934.5, + }; + + expect(parse(full)).toEqual({ ok: true, data: full }); + }); + + it("accepts a note that is only the owner's own notes", () => { + expect( + parse({ documentId: "d1", notesMarkdown: "Call back Friday" }).ok, + ).toBe(true); + }); + + it.each([ + [{ ...note, summaryMarkdown: " ", notesMarkdown: "\n" }, "required"], + [{ ...note, documentId: "" }, "documentId"], + [{ ...note, documentId: "a".repeat(65) }, "documentId"], + [{ ...note, documentId: "../etc" }, "documentId"], + [{ ...note, documentId: 7 }, "documentId"], + [{ ...note, orgId: "org id" }, "orgId"], + [ + { ...note, title: "a".repeat(MEETING_SHARE_TITLE_MAX_CHARS + 1) }, + "title", + ], + [ + { + ...note, + summaryMarkdown: "a".repeat(MEETING_SHARE_SUMMARY_MAX_CHARS + 1), + }, + "summaryMarkdown", + ], + [ + { ...note, notesMarkdown: "a".repeat(MEETING_SHARE_NOTES_MAX_CHARS + 1) }, + "notesMarkdown", + ], + [{ ...note, summaryMarkdown: "a\u0000b" }, "summaryMarkdown"], + [{ ...note, participants: Array(101).fill("Sam") }, "participants"], + [{ ...note, participants: ["a".repeat(201)] }, "participants.0"], + [{ ...note, participants: "Sam" }, "participants"], + [{ ...note, startedAt: "yesterday" }, "startedAt"], + [{ ...note, startedAt: "2026-11-27T10:00:00" }, "startedAt"], + [{ ...note, durationSeconds: -1 }, "durationSeconds"], + [ + { ...note, durationSeconds: MEETING_SHARE_MAX_DURATION_SECONDS + 1 }, + "durationSeconds", + ], + [{ ...note, durationSeconds: "90" }, "durationSeconds"], + [{ ...note, transcript: "Sam: hello" }, "transcript"], + [ + { ...note, transcript: [{ speaker: "Sam", startMs: -1, text: "a" }] }, + "transcript.0.startMs", + ], + [ + { ...note, transcript: [{ speaker: "Sam", startMs: 1.5, text: "a" }] }, + "transcript.0.startMs", + ], + [ + { ...note, transcript: [{ speaker: "Sam", startMs: 0 }] }, + "transcript.0.text", + ], + [ + { + ...note, + transcript: [{ speaker: "a".repeat(201), startMs: 0, text: "hello" }], + }, + "transcript.0.speaker", + ], + [ + { + ...note, + transcript: [ + { + speaker: "Sam", + startMs: 0, + text: "a".repeat(MEETING_SHARE_TURN_MAX_CHARS + 1), + }, + ], + }, + "transcript.0.text", + ], + [ + { + ...note, + transcript: Array(MEETING_SHARE_TRANSCRIPT_MAX_TURNS + 1).fill({ + speaker: "Sam", + startMs: 0, + text: "a", + }), + }, + "transcript", + ], + ])("rejects an out of bounds field %#", (body, field) => { + expect(rejected(body)).toContain(field); + }); + + it("bounds the transcript as a whole", () => { + const turn = { + speaker: "Sam", + startMs: 0, + text: "a".repeat(MEETING_SHARE_TURN_MAX_CHARS), + }; + const turns = MEETING_NOTES_TRANSCRIPT_MAX_CHARS / turn.text.length; + + expect(parse({ ...note, transcript: Array(turns).fill(turn) }).ok).toBe( + true, + ); + expect( + rejected({ ...note, transcript: Array(turns + 1).fill(turn) }), + ).toContain("transcript"); + }); + + it("counts title characters, not UTF-16 units", () => { + expect( + parse({ ...note, title: "🎥".repeat(MEETING_SHARE_TITLE_MAX_CHARS) }).ok, + ).toBe(true); + }); + + it("never repeats a submitted value in the error", () => { + const secret = "SECRET-roadmap"; + + expect( + rejected({ ...note, summaryMarkdown: secret, startedAt: secret }), + ).not.toContain(secret); + }); + + it.each(["doc-1", "DOC_1", "a".repeat(64)])( + "accepts the document id %s", + (id) => { + expect(meetingShareDocumentIdSchema.safeParse(id).success).toBe(true); + }, + ); +}); diff --git a/apps/web/__tests__/unit/note-content-readers.test.ts b/apps/web/__tests__/unit/note-content-readers.test.ts new file mode 100644 index 00000000000..d07b742afe4 --- /dev/null +++ b/apps/web/__tests__/unit/note-content-readers.test.ts @@ -0,0 +1,75 @@ +import { readdirSync, readFileSync } from "node:fs"; +import { join, relative } from "node:path"; +import { describe, expect, it } from "vitest"; + +const repo = join(__dirname, "../../../.."); +const roots = ["apps/web", "packages"]; +const skipped = new Set([ + "node_modules", + ".next", + ".turbo", + "dist", + "__tests__", + "migrations", +]); + +const sources = (directory: string): string[] => + readdirSync(directory, { withFileTypes: true }).flatMap((entry) => { + if (skipped.has(entry.name)) return []; + const path = join(directory, entry.name); + if (entry.isDirectory()) return sources(path); + return /\.tsx?$/.test(entry.name) && !/\.test\.tsx?$/.test(entry.name) + ? [path] + : []; + }); + +const readers = roots + .flatMap((root) => sources(join(repo, root))) + .filter((path) => + /\bvideoNotes\b|\bvideo_notes\b/.test(readFileSync(path, "utf8")), + ) + .map((path) => relative(repo, path)) + .sort(); + +const readsText = (path: string) => + /videoNotes\.(summaryMarkdown|notesMarkdown|transcript|participants|excerpt)\b/.test( + readFileSync(join(repo, path), "utf8"), + ); + +describe("who reads shared note content", () => { + it("is only the share page, signed-in library lists and the note's own lifecycle", () => { + expect(readers).toEqual([ + "apps/web/actions/spaces/get-user-videos.ts", + "apps/web/app/(org)/dashboard/caps/caps-page-data.tsx", + "apps/web/app/(org)/dashboard/spaces/[spaceId]/page.tsx", + "apps/web/app/s/[videoId]/page.tsx", + "apps/web/lib/folder.ts", + "apps/web/lib/meetings/share.ts", + "apps/web/workflows/agent-cap-operation.ts", + "apps/web/workflows/transfer-organization-content.ts", + "packages/database/schema.ts", + "packages/web-backend/src/Organisations/index.ts", + "packages/web-backend/src/Videos/VideosRepo.ts", + ]); + }); + + it("returns the full note from the share page alone", () => { + expect( + readers.filter((path) => + /videoNotes\.(summaryMarkdown|notesMarkdown|transcript|participants)\b/.test( + readFileSync(join(repo, path), "utf8"), + ), + ), + ).toEqual(["apps/web/app/s/[videoId]/page.tsx"]); + }); + + it("lists an excerpt only on signed-in library pages", () => { + expect(readers.filter(readsText)).toEqual([ + "apps/web/actions/spaces/get-user-videos.ts", + "apps/web/app/(org)/dashboard/caps/caps-page-data.tsx", + "apps/web/app/(org)/dashboard/spaces/[spaceId]/page.tsx", + "apps/web/app/s/[videoId]/page.tsx", + "apps/web/lib/folder.ts", + ]); + }); +}); diff --git a/apps/web/__tests__/unit/note-document-markdown.test.ts b/apps/web/__tests__/unit/note-document-markdown.test.ts new file mode 100644 index 00000000000..3e626e1713d --- /dev/null +++ b/apps/web/__tests__/unit/note-document-markdown.test.ts @@ -0,0 +1,64 @@ +import { createElement } from "react"; +import { renderToStaticMarkup } from "react-dom/server"; +import { describe, expect, it } from "vitest"; +import { NoteDocument } from "@/app/s/[videoId]/_components/note/NoteDocument"; + +const render = (summaryMarkdown: string, notesMarkdown: string | null = null) => + renderToStaticMarkup( + createElement(NoteDocument, { + summaryMarkdown, + notesMarkdown, + participants: [""], + meetingStartedAt: null, + duration: 120, + ownerName: "", + }), + ); + +describe("shared note markdown", () => { + it("shows markup in a note as text, never as elements", () => { + const html = render( + [ + "", + '', + '', + 'raw', + "", + ].join("\n\n"), + "", + ); + + expect(html).not.toMatch(/<(script|img|iframe|style|svg)\b/i); + expect(html.replace(/"[^"]*"/g, '""')).not.toMatch( + /<[a-z][^>]*\son[a-z]+=/i, + ); + expect(html).not.toMatch(/ { + const html = render( + [ + "![pixel](https://example.com/track.png)", + "[run](javascript:alert(1))", + "[data](data:text/html;base64,PHNjcmlwdD4=)", + "[vb](vbscript:msgbox(1))", + "[site](https://example.com/page)", + ].join("\n\n"), + ); + + expect(html).not.toMatch(/ { + const html = render("- [x] Done\n- [ ] Next"); + + expect(html).not.toMatch(/ ({ + row: null as Record | null, + access: "allowed" as "allowed" | "private" | "password", + renderVideoOg: vi.fn(async (_variant: unknown) => new Response("card")), + renderVideoOgStatus: vi.fn(async (_kind: unknown) => new Response("status")), + storage: vi.fn(), + posterFrame: vi.fn(), + tables: [] as string[], +})); + +vi.mock("server-only", () => ({})); +vi.mock("@cap/database", () => ({ + db: () => ({ + select: () => ({ + from: (table: { [key: symbol]: unknown }) => { + mocks.tables.push( + String( + Object.getOwnPropertySymbols(table) + .map((symbol) => table[symbol]) + .find((value) => typeof value === "string"), + ), + ); + return { + leftJoin: () => ({ + where: async () => (mocks.row ? [mocks.row] : []), + }), + }; + }, + }), + }), +})); +vi.mock("@cap/web-backend", () => ({ + findScreenshotObjectKey: () => null, + Storage: { getAccessForVideo: mocks.storage }, + VideosPolicy: Context.GenericTag("NoteOgPolicy"), +})); +vi.mock("@/lib/og/poster-frame", () => ({ + extractPosterFrameDataUri: mocks.posterFrame, +})); +vi.mock("@/lib/og/video-og", () => ({ + renderVideoOg: mocks.renderVideoOg, + renderVideoOgStatus: mocks.renderVideoOgStatus, +})); +vi.mock("@/lib/video-storage", () => ({ decodeStorageVideo: vi.fn() })); +vi.mock("@/lib/server", () => { + const policy = { + canViewLoaded: () => + mocks.access === "allowed" + ? Effect.void + : Effect.fail({ + _tag: + mocks.access === "private" + ? "PolicyDenied" + : "VerifyVideoPasswordError", + }), + }; + const provide = (effect: Effect.Effect) => + effect.pipe( + Effect.provideService(Context.GenericTag("NoteOgPolicy"), policy), + ) as Effect.Effect; + return { + runPromise: (effect: Effect.Effect) => + Effect.runPromise(provide(effect)), + runPromiseExit: (effect: Effect.Effect) => + Effect.runPromiseExit(provide(effect)), + }; +}); + +const { generateVideoOgImage } = await import("@/actions/videos/get-og-image"); + +const note = (overrides: Record = {}) => ({ + video: { + id: "note-1", + ownerId: "owner", + orgId: "org-1", + name: "Weekly sync", + public: true, + password: null, + isNote: true, + isScreenshot: false, + metadata: null, + source: { type: "local" }, + duration: 1_934, + ...overrides, + }, + ownerName: "Alex Morgan", +}); + +beforeEach(() => { + mocks.access = "allowed"; + mocks.tables = []; + for (const fn of [ + mocks.renderVideoOg, + mocks.renderVideoOgStatus, + mocks.storage, + mocks.posterFrame, + ]) + fn.mockClear(); +}); + +describe("link preview image for a note", () => { + it("shows the title and owner of a note anyone can open", async () => { + mocks.row = note(); + + await generateVideoOgImage("note-1" as never); + + expect(mocks.renderVideoOg.mock.calls).toEqual([ + [ + { + kind: "note", + note: { title: "Weekly sync", ownerName: "Alex Morgan" }, + }, + ], + ]); + expect(mocks.storage).not.toHaveBeenCalled(); + expect(mocks.posterFrame).not.toHaveBeenCalled(); + }); + + it.each([ + ["password-protected", { password: "hash" }, "allowed", "password"], + ["private", { public: false }, "allowed", "locked"], + ["restricted", {}, "private", "locked"], + ["space password", {}, "password", "password"], + ] as const)( + "shows nothing about a %s note", + async (_name, overrides, access, status) => { + mocks.row = note({ name: NOTE_TEXT, ...overrides }); + mocks.access = access; + + await generateVideoOgImage("note-1" as never); + + expect(mocks.renderVideoOgStatus.mock.calls).toEqual([[status]]); + expect(mocks.renderVideoOg).not.toHaveBeenCalled(); + }, + ); + + it("never reads note content", async () => { + mocks.row = note(); + + await generateVideoOgImage("note-1" as never); + + expect(mocks.tables).toEqual(["videos"]); + }); +}); diff --git a/apps/web/__tests__/unit/public-share-video.test.ts b/apps/web/__tests__/unit/public-share-video.test.ts index 717a1c647a6..e696474c287 100644 --- a/apps/web/__tests__/unit/public-share-video.test.ts +++ b/apps/web/__tests__/unit/public-share-video.test.ts @@ -16,6 +16,7 @@ const candidate = ( allowedEmailDomain: null, linkOpenToAnyone: false, isScreenshot: false, + isNote: false, hasActiveUpload: false, sourceType: "desktopMP4", jobStatus: "COMPLETE", @@ -37,6 +38,7 @@ describe("public share video eligibility", () => { { hasInheritedPassword: true }, { allowedEmailDomain: "@cap.so" }, { isScreenshot: true }, + { isNote: true }, { hasActiveUpload: true }, ])("rejects restricted or non-video candidates", (override) => { expect(isPublicShareVideoCandidateEligible(candidate(override))).toBe( diff --git a/apps/web/__tests__/unit/share-page-loading.test.ts b/apps/web/__tests__/unit/share-page-loading.test.ts index f4305b19227..b3aa2c832b1 100644 --- a/apps/web/__tests__/unit/share-page-loading.test.ts +++ b/apps/web/__tests__/unit/share-page-loading.test.ts @@ -136,6 +136,7 @@ vi.mock("@/app/s/[videoId]/_components/ShareHeader", () => ({ ShareHeader: () => null, })); vi.mock("@/app/s/[videoId]/Share", () => ({ Share: () => null })); +vi.mock("@/app/s/[videoId]/NoteShare", () => ({ NoteShare: () => null })); import { PasswordGate } from "@/app/s/[videoId]/_components/PasswordGate"; import ShareVideoPage from "@/app/s/[videoId]/page"; diff --git a/apps/web/__tests__/unit/share-page-round-trips.test.ts b/apps/web/__tests__/unit/share-page-round-trips.test.ts index f0cb30d748f..1035d0243ef 100644 --- a/apps/web/__tests__/unit/share-page-round-trips.test.ts +++ b/apps/web/__tests__/unit/share-page-round-trips.test.ts @@ -5,7 +5,14 @@ import { Context, Effect } from "effect"; import { type ComponentProps, isValidElement, type ReactElement } from "react"; import { beforeEach, describe, expect, it, vi } from "vitest"; -const mocks = vi.hoisted(() => ({ query: vi.fn(), userId: "viewer" })); +const mocks = vi.hoisted(() => ({ + query: vi.fn(), + userId: "viewer", + note: false, + access: "allowed" as "allowed" | "private" | "password", + ownerIsPro: true, + overLinkLimit: false, +})); vi.mock("server-only", () => ({})); vi.mock("@cap/database", async () => { @@ -24,7 +31,10 @@ vi.mock("@cap/env", () => ({ serverEnv: () => ({}), })); vi.mock("@cap/ui", () => ({ Logo: () => null })); -vi.mock("@cap/utils", () => ({ userIsPro: () => true })); +vi.mock("@cap/utils", () => ({ userIsPro: () => mocks.ownerIsPro })); +vi.mock("@/lib/shareable-link-quota", () => ({ + isVideoOverShareableLinkLimit: async () => mocks.overLinkLimit, +})); vi.mock("@cap/web-backend", async () => { const { Context, Effect } = await import("effect"); const { resolveEffectiveVideoRules } = await import( @@ -48,7 +58,15 @@ vi.mock("@/lib/server", async () => { runPromise: (effect: Effect.Effect) => effect.pipe( Effect.provideService(Context.GenericTag("SharePerfPolicy"), { - canViewLoaded: () => Effect.void, + canViewLoaded: () => + mocks.access === "allowed" + ? Effect.void + : Effect.fail({ + _tag: + mocks.access === "private" + ? "PolicyDenied" + : "VerifyVideoPasswordError", + }), }), Effect.provideService(Context.GenericTag("SharePerfDatabase"), { use: (callback: (client: ReturnType) => Promise) => @@ -87,6 +105,7 @@ vi.mock("@/lib/share-playback", () => ({ vi.mock("@/lib/share-web-url", () => ({ resolveShareWebUrl: vi.fn(), resolveForeignShareRedirect: async () => null, + resolveRestrictedShareRedirect: async () => null, })); vi.mock("@/lib/transcribe", () => ({ transcribeVideo: vi.fn() })); vi.mock("@/utils/flags", () => ({ isAiGenerationEnabled: async () => true })); @@ -100,6 +119,7 @@ vi.mock("@/app/s/[videoId]/_components/ShareHeader", () => ({ ShareHeader: () => null, })); vi.mock("@/app/s/[videoId]/Share", () => ({ Share: () => null })); +vi.mock("@/app/s/[videoId]/NoteShare", () => ({ NoteShare: () => null })); import type { ShareHeader } from "@/app/s/[videoId]/_components/ShareHeader"; import ShareVideoPage from "@/app/s/[videoId]/page"; @@ -128,6 +148,22 @@ const recording = { transcriptionStatus: "COMPLETE", }; +const NOTE_TEXT = "NOTE-TEXT-acquisition-of-initech"; +const sharedNote = { + ...recording, + isNote: 1, + source: { type: "local" }, + metadata: null, + transcriptionStatus: "SKIPPED", +}; +const noteContent = { + summaryMarkdown: `## Summary\n\n${NOTE_TEXT}`, + notesMarkdown: NOTE_TEXT, + transcript: [{ speaker: "Sam", startMs: 0, text: NOTE_TEXT }], + participants: ["Sam"], + meetingStartedAt: createdAt, +}; + function project( query: string, tables: Record>, @@ -150,7 +186,7 @@ function rowsFor(query: string) { ) { return [ project(query, { - videos: recording, + videos: mocks.note ? sharedNote : recording, users: { id: "owner", name: "Owner", email: "owner@example.com" }, organizations: organization, shared_videos: { organizationId: "shared-org" }, @@ -230,6 +266,16 @@ function rowsFor(query: string) { } if (query.includes("from `space_members`")) return [["space-member"]]; if (query.includes("from `video_edits`")) return []; + if (query.includes("from `video_notes`")) + return [ + [ + noteContent.summaryMarkdown, + noteContent.notesMarkdown, + noteContent.transcript, + noteContent.participants, + noteContent.meetingStartedAt, + ], + ]; if (query.includes("from `video_viewer_grants`")) return [[0]]; throw new Error(`Unexpected query: ${query}`); } @@ -267,6 +313,10 @@ async function loadPage() { beforeEach(() => { mocks.query.mockReset(); mocks.userId = "viewer"; + mocks.note = false; + mocks.access = "allowed"; + mocks.ownerIsPro = true; + mocks.overLinkLimit = false; }); describe("share page database round trips", () => { @@ -345,3 +395,67 @@ describe("share page database round trips", () => { }, ); }); + +describe("share page note content", () => { + const noteQueries = () => + mocks.query.mock.calls + .map(([query]) => String(query)) + .filter((query) => query.includes("`video_notes`")); + + const openNote = (access: typeof mocks.access) => { + mocks.note = true; + mocks.access = access; + mocks.query.mockImplementation(async (query: string) => { + try { + return { rows: rowsFor(query) }; + } catch { + return { rows: [] }; + } + }); + return ShareVideoPage({ + params: Promise.resolve({ videoId: recording.id }), + searchParams: Promise.resolve({}), + }) as Promise>>; + }; + + it.each(["private", "password"] as const)( + "never reads the text of a %s note the viewer cannot open", + async (access) => { + const page = await openNote(access); + + expect(noteQueries()).toEqual([]); + expect(JSON.stringify(page)).not.toContain(NOTE_TEXT); + expect(page.props).toMatchObject({ isNote: true }); + }, + ); + + const renderNote = async () => { + const page = await openNote("allowed"); + const authorized = page.props.children as ReactElement; + const content = (await ( + authorized.type as (props: unknown) => Promise + )(authorized.props)) as ReactElement<{ + children: ReactElement<{ document: ReactElement; transcript: unknown }>; + }>; + return content.props.children.props; + }; + + it("reads the note only for a viewer the policy lets in", async () => { + const shell = await renderNote(); + + expect(noteQueries()).toHaveLength(1); + expect(JSON.stringify(shell.document.props)).toContain(NOTE_TEXT); + expect(shell.transcript).not.toBeNull(); + }); + + it("holds back a note that is over the owner's free link allowance", async () => { + mocks.ownerIsPro = false; + mocks.overLinkLimit = true; + + const shell = await renderNote(); + + expect(shell.document.props).toEqual({ isOwner: false }); + expect(shell.transcript).toBeNull(); + expect(JSON.stringify(shell)).not.toContain(NOTE_TEXT); + }); +}); diff --git a/apps/web/__tests__/unit/share-transcript-rendering.test.ts b/apps/web/__tests__/unit/share-transcript-rendering.test.ts index a53f19d8f62..df40226c96c 100644 --- a/apps/web/__tests__/unit/share-transcript-rendering.test.ts +++ b/apps/web/__tests__/unit/share-transcript-rendering.test.ts @@ -70,6 +70,7 @@ const video: VideoData = { fps: 30, public: true, isScreenshot: false, + isNote: false, skipProcessing: false, createdAt: new Date("2026-01-01"), updatedAt: new Date("2026-01-01"), diff --git a/apps/web/__tests__/unit/space-page-round-trips.test.ts b/apps/web/__tests__/unit/space-page-round-trips.test.ts index 014c82d7529..6dad6821a4f 100644 --- a/apps/web/__tests__/unit/space-page-round-trips.test.ts +++ b/apps/web/__tests__/unit/space-page-round-trips.test.ts @@ -260,6 +260,12 @@ describe("space and folder page round trips", () => { }).pipe( Effect.provide(Database.Default), Effect.provide(ImageUploads.Default), + Effect.provideService(CurrentUser, { + id: User.UserId.make("user-1"), + email: "user@example.com", + activeOrganizationId: Organisation.OrganisationId.make("org-1"), + iconUrlOrKey: Option.none(), + }), Effect.runPromise, ), LIST_COLUMNS.folder, diff --git a/apps/web/__tests__/unit/space-video-order.test.ts b/apps/web/__tests__/unit/space-video-order.test.ts index 0f1486a24b2..354d98ededf 100644 --- a/apps/web/__tests__/unit/space-video-order.test.ts +++ b/apps/web/__tests__/unit/space-video-order.test.ts @@ -3,6 +3,7 @@ import { nextInOrder, positionChanges, reorderIds, + reorderIdsWithinGroups, spaceVideoOrderFromSettings, } from "@/lib/space-video-order"; @@ -126,3 +127,73 @@ describe("space order helpers", () => { expect(nextInOrder(ids, "zz")).toBeNull(); }); }); + +describe("reorderIdsWithinGroups", () => { + const mixed = [ + { id: "v1", group: "videos" }, + { id: "n1", group: "notes" }, + { id: "v2", group: "videos" }, + { id: "i1", group: "images" }, + { id: "v3", group: "videos" }, + { id: "n2", group: "notes" }, + ]; + + it("steps past caps of other kinds so every move shows in its section", () => { + expect(reorderIdsWithinGroups(mixed, ["v3"], { type: "earlier" })).toEqual([ + "v1", + "n1", + "v3", + "i1", + "v2", + "n2", + ]); + expect(reorderIdsWithinGroups(mixed, ["n1"], { type: "later" })).toEqual([ + "v1", + "n2", + "v2", + "i1", + "v3", + "n1", + ]); + }); + + it("moves to the start of its own kind and leaves the others in place", () => { + expect(reorderIdsWithinGroups(mixed, ["n2"], { type: "start" })).toEqual([ + "v1", + "n2", + "v2", + "i1", + "v3", + "n1", + ]); + }); + + it("ignores a drop on a cap of another kind", () => { + expect( + reorderIdsWithinGroups(mixed, ["v1"], { type: "after", targetId: "n2" }), + ).toEqual(mixed.map((row) => row.id)); + }); + + it("moves only the caps that share the target's kind", () => { + expect( + reorderIdsWithinGroups(mixed, ["v1", "n1"], { + type: "after", + targetId: "v3", + }), + ).toEqual(["v2", "n1", "v3", "i1", "v1", "n2"]); + }); + + it("matches reorderIds when every cap is the same kind", () => { + const videos = ids.map((id) => ({ id, group: "videos" })); + for (const placement of [ + { type: "earlier" }, + { type: "later" }, + { type: "start" }, + { type: "end" }, + { type: "before", targetId: "a" }, + ] as const) + expect(reorderIdsWithinGroups(videos, ["c"], placement)).toEqual( + reorderIds(ids, ["c"], placement), + ); + }); +}); diff --git a/apps/web/__tests__/unit/video-edit-processing.test.ts b/apps/web/__tests__/unit/video-edit-processing.test.ts index 4dbc1fe3b79..e43b27ad671 100644 --- a/apps/web/__tests__/unit/video-edit-processing.test.ts +++ b/apps/web/__tests__/unit/video-edit-processing.test.ts @@ -118,6 +118,7 @@ vi.mock("@/app/s/[videoId]/_components/PasswordGate", () => ({ vi.mock("@/app/s/[videoId]/_components/PendingRecordingShare", () => ({})); vi.mock("@/app/s/[videoId]/_components/ShareHeader", () => ({})); vi.mock("@/app/s/[videoId]/Share", () => ({})); +vi.mock("@/app/s/[videoId]/NoteShare", () => ({})); vi.mock("@/app/s/[videoId]/edit/EditUpgradeGate", () => ({})); vi.mock("@/app/s/[videoId]/edit/EditVideoClient", () => ({ EditVideoClient: () => null, diff --git a/apps/web/actions/admin/replace-video.ts b/apps/web/actions/admin/replace-video.ts index 0a6879c9ca9..decd9b5d248 100644 --- a/apps/web/actions/admin/replace-video.ts +++ b/apps/web/actions/admin/replace-video.ts @@ -32,7 +32,7 @@ async function getVideoOrThrow(videoId: string) { .from(videos) .where(eq(videos.id, Video.VideoId.make(videoId))); - if (!video) { + if (!video || video.isNote) { throw new Error("Video not found"); } return video; diff --git a/apps/web/actions/admin/reprocess-video.ts b/apps/web/actions/admin/reprocess-video.ts index cfd2cd98e39..46d95091f2b 100644 --- a/apps/web/actions/admin/reprocess-video.ts +++ b/apps/web/actions/admin/reprocess-video.ts @@ -17,11 +17,12 @@ export async function adminReprocessVideo(input: string) { id: videos.id, ownerId: videos.ownerId, name: videos.name, + isNote: videos.isNote, }) .from(videos) .where(eq(videos.id, videoId)); - if (!video) { + if (!video || video.isNote) { throw new Error("Video not found"); } diff --git a/apps/web/actions/caps/list-view-ids.ts b/apps/web/actions/caps/list-view-ids.ts index c0e7611653b..b7a02da1f85 100644 --- a/apps/web/actions/caps/list-view-ids.ts +++ b/apps/web/actions/caps/list-view-ids.ts @@ -12,6 +12,8 @@ import type { Organisation, Space, Video } from "@cap/web-domain"; import { and, desc, eq, isNotNull, isNull } from "drizzle-orm"; import { getOrganizationAccess } from "@/actions/organization/authorization"; import { getSpaceAccess } from "@/actions/organization/space-authorization"; +import { CAP_KINDS } from "@/lib/cap-kind"; +import { capKindCondition, capKindIndexHint } from "@/lib/cap-kind-query"; import { canManageOrganizationMembers } from "@/lib/permissions/roles"; import { MAX_SELECT_ALL_ITEMS, @@ -33,10 +35,17 @@ export async function listCapIdsInView( if (view.type === "personal" || view.type === "archived") { if (!user.activeOrganizationId) return { ids: [], truncated: false }; + if ( + view.type === "personal" && + view.kind !== undefined && + !CAP_KINDS.includes(view.kind) + ) + throw new Error("Invalid view"); const isArchivedView = view.type === "archived"; + const kind = view.type === "personal" ? view.kind : undefined; const rows = await db() .select({ id: videos.id }) - .from(videos) + .from(videos, kind ? capKindIndexHint : undefined) .innerJoin(organizations, eq(videos.orgId, organizations.id)) .where( and( @@ -46,6 +55,7 @@ export async function listCapIdsInView( isArchivedView ? isNotNull(videos.archivedAt) : and(isNull(videos.folderId), isNull(videos.archivedAt)), + kind ? capKindCondition(kind) : undefined, ), ) .orderBy( diff --git a/apps/web/actions/spaces/get-user-videos.ts b/apps/web/actions/spaces/get-user-videos.ts index 372fb45cefd..b0628c62237 100644 --- a/apps/web/actions/spaces/get-user-videos.ts +++ b/apps/web/actions/spaces/get-user-videos.ts @@ -10,6 +10,7 @@ import { spaces, spaceVideos, users, + videoNotes, videos, videoUploads, } from "@cap/database/schema"; @@ -34,6 +35,8 @@ export async function getUserVideos(spaceId: Space.SpaceIdOrOrganisationId) { createdAt: videos.createdAt, metadata: videos.metadata, isScreenshot: videos.isScreenshot, + isNote: videos.isNote, + noteExcerpt: videoNotes.excerpt, totalComments: sql`COUNT(DISTINCT CASE WHEN ${comments.type} = 'text' THEN ${comments.id} END)`, totalReactions: sql`COUNT(DISTINCT CASE WHEN ${comments.type} = 'emoji' THEN ${comments.id} END)`, ownerName: users.name, @@ -53,6 +56,7 @@ export async function getUserVideos(spaceId: Space.SpaceIdOrOrganisationId) { .leftJoin(comments, eq(videos.id, comments.videoId)) .leftJoin(users, eq(videos.ownerId, users.id)) .leftJoin(videoUploads, eq(videos.id, videoUploads.videoId)) + .leftJoin(videoNotes, eq(videos.id, videoNotes.videoId)) .leftJoin( sharedVideos, and( @@ -73,6 +77,8 @@ export async function getUserVideos(spaceId: Space.SpaceIdOrOrganisationId) { videos.createdAt, videos.metadata, videos.isScreenshot, + videos.isNote, + videoNotes.excerpt, users.name, folders.name, folders.color, @@ -86,6 +92,7 @@ export async function getUserVideos(spaceId: Space.SpaceIdOrOrganisationId) { .leftJoin(comments, eq(videos.id, comments.videoId)) .leftJoin(users, eq(videos.ownerId, users.id)) .leftJoin(videoUploads, eq(videos.id, videoUploads.videoId)) + .leftJoin(videoNotes, eq(videos.id, videoNotes.videoId)) .leftJoin( spaceVideos, and( @@ -106,6 +113,8 @@ export async function getUserVideos(spaceId: Space.SpaceIdOrOrganisationId) { videos.createdAt, videos.metadata, videos.isScreenshot, + videos.isNote, + videoNotes.excerpt, users.name, folders.name, folders.color, diff --git a/apps/web/actions/spaces/video-order.ts b/apps/web/actions/spaces/video-order.ts index 20489b4b8bd..fbda68623e7 100644 --- a/apps/web/actions/spaces/video-order.ts +++ b/apps/web/actions/spaces/video-order.ts @@ -7,12 +7,13 @@ import { Space, type Video } from "@cap/web-domain"; import { and, eq, inArray, isNull, sql } from "drizzle-orm"; import { revalidatePath } from "next/cache"; import { getSpaceAccess } from "@/actions/organization/space-authorization"; +import { capKindOf } from "@/lib/cap-kind"; import { isSpaceVideoOrder, MAX_REORDER_ITEMS, positionChanges, type ReorderPlacement, - reorderIds, + reorderIdsWithinGroups, type SpaceVideoOrder, } from "@/lib/space-video-order"; import { getSpaceRootVideoOrder } from "@/lib/space-video-order-query"; @@ -91,8 +92,8 @@ export async function reorderSpaceVideos(input: { const current = await getSpaceRootVideoOrder(id, "custom", { executor: tx, }); - const nextOrder = reorderIds( - current.map((row) => row.id as string), + const nextOrder = reorderIdsWithinGroups( + current.map((row) => ({ id: row.id, group: capKindOf(row) })), videoIds, placement, ); diff --git a/apps/web/actions/video/trigger-instant-recording-processing.ts b/apps/web/actions/video/trigger-instant-recording-processing.ts index ce117d11a40..bff1ad81fa1 100644 --- a/apps/web/actions/video/trigger-instant-recording-processing.ts +++ b/apps/web/actions/video/trigger-instant-recording-processing.ts @@ -20,7 +20,7 @@ export async function triggerInstantRecordingProcessing({ .from(videos) .where(eq(videos.id, videoId)); - if (!video) throw new Error("Video not found"); + if (!video || video.isNote) throw new Error("Video not found"); if (video.ownerId !== user.id) throw new Error("Unauthorized"); const rawFileKey = `${user.id}/${videoId}/result.mp4`; diff --git a/apps/web/actions/video/trigger-processing.ts b/apps/web/actions/video/trigger-processing.ts index ca48badff8c..cb0dce34d53 100644 --- a/apps/web/actions/video/trigger-processing.ts +++ b/apps/web/actions/video/trigger-processing.ts @@ -48,7 +48,7 @@ export async function triggerVideoProcessing({ .from(videos) .where(eq(videos.id, videoId)); - if (!video) throw new Error("Video not found"); + if (!video || video.isNote) throw new Error("Video not found"); if (video.ownerId !== user.id) throw new Error("Unauthorized"); if (!isVideoStorageKey(video, rawFileKey)) { throw new Error("Upload file does not belong to this video"); diff --git a/apps/web/actions/video/upload.ts b/apps/web/actions/video/upload.ts index 325ef11674e..4205c89e3e1 100644 --- a/apps/web/actions/video/upload.ts +++ b/apps/web/actions/video/upload.ts @@ -166,6 +166,7 @@ export async function createVideoAndGetUploadUrl({ if (existingVideo) { if (existingVideo.ownerId !== user.id) throw new Error("Forbidden"); + if (existingVideo.isNote) throw new Error("Video not found"); const existingVideoDomain = Video.Video.decodeSync({ ...existingVideo, diff --git a/apps/web/actions/videos/custom-thumbnail.ts b/apps/web/actions/videos/custom-thumbnail.ts index 6ad29595b35..5bd7072c4e8 100644 --- a/apps/web/actions/videos/custom-thumbnail.ts +++ b/apps/web/actions/videos/custom-thumbnail.ts @@ -50,6 +50,9 @@ async function loadOwnedVideo( if (video.isScreenshot) { return "Screenshots already use the image as their thumbnail"; } + if (video.isNote) { + return "Notes do not have a thumbnail"; + } return video; } diff --git a/apps/web/actions/videos/download.ts b/apps/web/actions/videos/download.ts index ca48735fa1c..966e36eba2d 100644 --- a/apps/web/actions/videos/download.ts +++ b/apps/web/actions/videos/download.ts @@ -41,7 +41,7 @@ export async function downloadVideo(videoId: Video.VideoId) { } const video = query[0]; - if (!video) { + if (!video || video.isNote) { throw new Error("Video not found"); } @@ -87,7 +87,7 @@ export async function getVideoDownloadInfo( .from(videos) .where(eq(videos.id, videoId)); - if (!video) { + if (!video || video.isNote) { throw new Error( user ? "Video not found" : "Missing required data for downloading video", ); diff --git a/apps/web/actions/videos/get-og-image.tsx b/apps/web/actions/videos/get-og-image.tsx index 980e3475624..ddf9ad6439f 100644 --- a/apps/web/actions/videos/get-og-image.tsx +++ b/apps/web/actions/videos/get-og-image.tsx @@ -33,6 +33,12 @@ export async function generateVideoOgImage( const access = await anonymousViewAccess(video); if (access !== "allowed") return renderVideoOgStatus(access); + if (video.isNote) + return renderVideoOg({ + kind: "note", + note: { title: video.name, ownerName: ownerName ?? undefined }, + }); + // A version only names an image that exists. Anything else goes to the // current URL, so made-up versions cannot each cost a fresh render. const currentVersion = getCustomThumbnailVersion(video.metadata); diff --git a/apps/web/app/(org)/dashboard/Contexts.tsx b/apps/web/app/(org)/dashboard/Contexts.tsx index f8b6409980d..beed6725268 100644 --- a/apps/web/app/(org)/dashboard/Contexts.tsx +++ b/apps/web/app/(org)/dashboard/Contexts.tsx @@ -27,6 +27,7 @@ export function DashboardContexts({ activeOrganization, spacesData, userCapsCount, + userCapKindCounts = null, organizationSettings, userPreferences, anyNewNotifications, @@ -40,6 +41,7 @@ export function DashboardContexts({ activeOrganization: SharedContext["activeOrganization"]; spacesData: SharedContext["spacesData"]; userCapsCount: SharedContext["userCapsCount"]; + userCapKindCounts?: SharedContext["userCapKindCounts"]; organizationSettings: SharedContext["organizationSettings"]; userPreferences: SharedContext["userPreferences"]; anyNewNotifications: boolean; @@ -143,6 +145,7 @@ export function DashboardContexts({ activeOrganization, spacesData, userCapsCount, + userCapKindCounts, anyNewNotifications, userPreferences, organizationSettings, diff --git a/apps/web/app/(org)/dashboard/DashboardContext.ts b/apps/web/app/(org)/dashboard/DashboardContext.ts index 142d3d027dd..19adf0c5908 100644 --- a/apps/web/app/(org)/dashboard/DashboardContext.ts +++ b/apps/web/app/(org)/dashboard/DashboardContext.ts @@ -2,6 +2,7 @@ import { createContext, useContext } from "react"; import type { CurrentUser } from "@/app/Layout/AuthContext"; +import type { CapKindCounts } from "@/lib/cap-kind"; import type { Organization, OrganizationSettings, @@ -26,6 +27,7 @@ export type SharedContext = { activeSpace: Spaces | null; user: CurrentUser; userCapsCount: number | null; + userCapKindCounts: CapKindCounts | null; toggleSidebarCollapsed: () => void; anyNewNotifications: boolean; userPreferences: UserPreferences; diff --git a/apps/web/app/(org)/dashboard/_components/Navbar/DashboardSearch.tsx b/apps/web/app/(org)/dashboard/_components/Navbar/DashboardSearch.tsx index 52717ffa7f9..5c6f05eb1af 100644 --- a/apps/web/app/(org)/dashboard/_components/Navbar/DashboardSearch.tsx +++ b/apps/web/app/(org)/dashboard/_components/Navbar/DashboardSearch.tsx @@ -16,6 +16,7 @@ import { Bell, Building2, CreditCard, + FileText, FileVideo, FolderSearch, Image, @@ -31,7 +32,15 @@ import { UsersRound, } from "lucide-react"; import { usePathname, useRouter } from "next/navigation"; -import { type ReactNode, useEffect, useMemo, useRef, useState } from "react"; +import { + Fragment, + type ReactNode, + useEffect, + useMemo, + useRef, + useState, +} from "react"; +import { CAP_KIND_LABEL, groupCapsByKind } from "@/lib/cap-kind"; import { loomImportDestinationFromPathname, loomImportPageHref, @@ -99,7 +108,7 @@ const formatDuration = (duration: number | null) => { const formatVideoSubtitle = (video: DashboardVideoSearchResult) => { const parts = [ - video.isScreenshot ? "Screenshot" : "Video", + video.isNote ? "Note" : video.isScreenshot ? "Screenshot" : "Video", video.ownerName ? `by ${video.ownerName}` : null, videoDateFormatter.format(new Date(video.createdAt)), formatDuration(video.duration), @@ -403,26 +412,41 @@ export function DashboardSearch({ {canSearchVideos && ( <> - Videos and screenshots + {!hasVideoResults || videoLoading ? ( + Videos, images and notes + ) : null} {videoLoading ? (
- Searching videos… + Searching your caps…
) : hasVideoResults ? ( - videoResults.map((video) => ( - navigateTo(`/s/${video.id}`)} - /> + groupCapsByKind(videoResults).map((group) => ( + + + {CAP_KIND_LABEL[group.kind]} + + {group.caps.map((video) => ( + navigateTo(`/s/${video.id}`)} + /> + ))} + )) ) : (

- No videos or screenshots match{" "} + No videos, images or notes match{" "} “{query.trim()}” diff --git a/apps/web/app/(org)/dashboard/_components/Navbar/Items.tsx b/apps/web/app/(org)/dashboard/_components/Navbar/Items.tsx index 6b6ea844e82..cf119819864 100644 --- a/apps/web/app/(org)/dashboard/_components/Navbar/Items.tsx +++ b/apps/web/app/(org)/dashboard/_components/Navbar/Items.tsx @@ -29,6 +29,7 @@ import Link from "next/link"; import { usePathname, useRouter } from "next/navigation"; import { cloneElement, + Fragment, type RefObject, useCallback, useEffect, @@ -41,6 +42,7 @@ import { NewOrganization } from "@/components/forms/NewOrganization"; import { SignedImageUrl } from "@/components/SignedImageUrl"; import { Tooltip } from "@/components/Tooltip"; import { UsageButton } from "@/components/UsageButton"; +import { CAP_KIND_LABEL, CAP_KINDS, capKindHref } from "@/lib/cap-kind"; import { canUseInfra } from "@/lib/infra-access"; import { INFRA_BASE_PATH } from "@/lib/infra-routes"; import { @@ -73,7 +75,8 @@ interface Props { const AdminNavItems = ({ toggleMobileNav }: Props) => { const pathname = usePathname(); const [open, setOpen] = useState(false); - const { user, sidebarCollapsed, userCapsCount } = useDashboardContext(); + const { user, sidebarCollapsed, userCapsCount, userCapKindCounts } = + useDashboardContext(); const showDeveloperDashboard = buildEnv.NEXT_PUBLIC_IS_CAP === "true" && canUseInfra(user.email); @@ -81,33 +84,38 @@ const AdminNavItems = ({ toggleMobileNav }: Props) => { buildEnv.NEXT_PUBLIC_IS_CAP && user.email.toLowerCase() === MESSENGER_ADMIN_EMAIL; + const noSubNav: { name: string; href: string; count?: number }[] = []; const manageNavigation = [ { name: "My Caps", href: `/dashboard/caps`, extraText: userCapsCount, icon: , - subNav: [], + subNav: CAP_KINDS.map((kind) => ({ + name: CAP_KIND_LABEL[kind], + href: capKindHref(kind), + count: userCapKindCounts?.[kind], + })), }, { name: "Analytics", href: `/dashboard/analytics`, matchChildren: true, icon: , - subNav: [], + subNav: noSubNav, }, { name: "Record a Cap", href: `/dashboard/caps/record`, icon: , - subNav: [], + subNav: noSubNav, }, { name: "Import Media", href: loomImportPageHref(loomImportDestinationFromPathname(pathname)), matchChildren: true, icon: , - subNav: [], + subNav: noSubNav, }, { name: "Organization Settings", @@ -115,7 +123,7 @@ const AdminNavItems = ({ toggleMobileNav }: Props) => { adminOnly: true, matchChildren: true, icon: , - subNav: [], + subNav: noSubNav, }, ...(showDeveloperDashboard ? [ @@ -125,7 +133,7 @@ const AdminNavItems = ({ toggleMobileNav }: Props) => { ownerOnly: true, matchChildren: true, icon: , - subNav: [] as { name: string; href: string }[], + subNav: noSubNav, }, ] : []), @@ -135,7 +143,7 @@ const AdminNavItems = ({ toggleMobileNav }: Props) => { name: "Migration Queue", href: "/dashboard/admin/loom-migrations", icon: , - subNav: [], + subNav: noSubNav, }, ] : []), @@ -432,41 +440,78 @@ const AdminNavItems = ({ toggleMobileNav }: Props) => { .filter((item) => !item.ownerOnly || isOwner) .filter((item) => !item.adminOnly || canViewSettings) .map((item) => ( -

- {isPathActive(item.href, item.matchChildren ?? false) && ( - - )} + +
+ {isPathActive(item.href, item.matchChildren ?? false) && ( + + )} - -
+ +
+ {!sidebarCollapsed && + item.subNav.map((subItem) => { + const active = isPathActive(subItem.href); + return ( +
+ {active && ( + + )} + toggleMobileNav?.()} + aria-current={active ? "page" : undefined} + className={clsx( + "flex relative items-center pr-3 w-full h-8 text-[13px] rounded-lg border border-transparent outline-none transition pl-[38px] z-3 focus-visible:ring-2 focus-visible:ring-gray-6", + active + ? "font-medium pointer-events-none text-gray-12" + : "text-gray-11 dashboard-nav-hover", + )} + > + {subItem.name} + {subItem.count ? ( + + {subItem.count} + + ) : null} + +
+ ); + })} + ))} toggleMobileNav?.()} /> diff --git a/apps/web/app/(org)/dashboard/_components/Navbar/search.ts b/apps/web/app/(org)/dashboard/_components/Navbar/search.ts index 2b4479f135e..5aca3bc5bf8 100644 --- a/apps/web/app/(org)/dashboard/_components/Navbar/search.ts +++ b/apps/web/app/(org)/dashboard/_components/Navbar/search.ts @@ -27,6 +27,7 @@ export type DashboardVideoSearchResult = { createdAt: string; duration: number | null; isScreenshot: boolean; + isNote: boolean; }; const normalizeSearchQuery = (query: string) => @@ -90,6 +91,7 @@ export async function searchDashboardVideos( createdAt: videos.createdAt, duration: videos.duration, isScreenshot: videos.isScreenshot, + isNote: videos.isNote, }) .from(videos) .innerJoin(organizations, eq(videos.orgId, organizations.id)) diff --git a/apps/web/app/(org)/dashboard/_components/dashboard-titles.ts b/apps/web/app/(org)/dashboard/_components/dashboard-titles.ts index 77857a75ad0..b92ec9d17cd 100644 --- a/apps/web/app/(org)/dashboard/_components/dashboard-titles.ts +++ b/apps/web/app/(org)/dashboard/_components/dashboard-titles.ts @@ -6,6 +6,18 @@ const exact: Record = { { label: "My Caps", href: "/dashboard/caps" }, { label: "Archived" }, ], + "/dashboard/caps/videos": [ + { label: "My Caps", href: "/dashboard/caps" }, + { label: "Videos" }, + ], + "/dashboard/caps/images": [ + { label: "My Caps", href: "/dashboard/caps" }, + { label: "Images" }, + ], + "/dashboard/caps/notes": [ + { label: "My Caps", href: "/dashboard/caps" }, + { label: "Notes" }, + ], "/dashboard/caps/record": [{ label: "Record a Cap" }], "/dashboard/analytics": [{ label: "Analytics" }], "/dashboard/import": [{ label: "Import Media" }], diff --git a/apps/web/app/(org)/dashboard/_components/library-doodles.tsx b/apps/web/app/(org)/dashboard/_components/library-doodles.tsx index 76146cac4f1..795884d352e 100644 --- a/apps/web/app/(org)/dashboard/_components/library-doodles.tsx +++ b/apps/web/app/(org)/dashboard/_components/library-doodles.tsx @@ -387,3 +387,61 @@ export function ArchiveDoodle({ size = 88 }: { size?: number }) { ); } + +export function NotesDoodle({ size = 88 }: { size?: number }) { + return ( + + + + + + + + + + + + ); +} diff --git a/apps/web/app/(org)/dashboard/caps/Caps.tsx b/apps/web/app/(org)/dashboard/caps/Caps.tsx index a39199e93ce..1e31ab47814 100644 --- a/apps/web/app/(org)/dashboard/caps/Caps.tsx +++ b/apps/web/app/(org)/dashboard/caps/Caps.tsx @@ -5,18 +5,27 @@ import type { VideoMetadata } from "@cap/database/types"; import type { SpaceRuleSource, ViewerSettingKey } from "@cap/web-backend"; import type { ImageUpload, Video } from "@cap/web-domain"; import { faBoxArchive } from "@fortawesome/free-solid-svg-icons/faBoxArchive"; +import { faChevronRight } from "@fortawesome/free-solid-svg-icons/faChevronRight"; import clsx from "clsx"; import { Effect, Exit } from "effect"; import { AnimatePresence } from "framer-motion"; import Link from "next/link"; import { useRouter, useSearchParams } from "next/navigation"; -import { useEffect, useMemo, useState } from "react"; +import { useEffect, useMemo, useState, useSyncExternalStore } from "react"; import { toast } from "sonner"; import { FontAwesomeIcon } from "@/components/FontAwesomeIcon"; import { type SeededThumbnails, SeededThumbnailsProvider, } from "@/components/VideoThumbnail"; +import { + CAP_KIND_LABEL, + CAP_KINDS, + type CapKind, + type CapKindCounts, + capKindHref, + capKindOf, +} from "@/lib/cap-kind"; import { DEFAULT_DASHBOARD_PAGE_SIZE } from "@/lib/dashboard-page-size"; import { useEffectMutation, useRpcClient } from "@/lib/EffectRuntime"; import { parsePageParam } from "@/lib/page-param"; @@ -43,10 +52,17 @@ import { DragHint } from "./components/DragHint"; import { EmptyCapState } from "./components/EmptyCapState"; import type { FolderDataType } from "./components/Folder"; import { FoldersSection } from "./components/FoldersSection"; +import { NotesEmptyState } from "./components/NotesEmptyState"; import { QuickActions } from "./components/QuickActions"; import { useArchiveCaps, useLeavingCaps } from "./components/useArchiveCaps"; import { useCapSelection } from "./components/useCapSelection"; import { useCapsMoved } from "./components/useCapsMoved"; +import { + gridColumns, + OVERVIEW_ROWS, + overviewItemClass, + overviewShows, +} from "./overview-grid"; import { useUploadingStatus } from "./UploadingContext"; export type VideoData = { @@ -76,6 +92,8 @@ export type VideoData = { metadata?: VideoMetadata; source: typeof videosSchema.$inferSelect.source; isScreenshot: boolean; + isNote?: boolean; + noteExcerpt?: string | null; hasPassword: boolean; hasInheritedPassword?: boolean; inheritedPasswordSources?: SpaceRuleSource[]; @@ -85,9 +103,28 @@ export type VideoData = { archivedAt?: Date | null; }[]; +const GRID_CLASS = + "grid relative grid-cols-1 gap-x-5 gap-y-6 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5"; + +const subscribeToResize = (notify: () => void) => { + window.addEventListener("resize", notify); + return () => window.removeEventListener("resize", notify); +}; + +const useGridColumns = () => + useSyncExternalStore( + subscribeToResize, + () => gridColumns((query) => window.matchMedia(query).matches), + () => 1, + ); + +const NO_COUNTS: CapKindCounts = { videos: 0, images: 0, notes: 0 }; + export const Caps = ({ data, count, + counts = NO_COUNTS, + kind, analyticsEnabled, folders, thumbnails, @@ -97,6 +134,8 @@ export const Caps = ({ }: { data: VideoData; count: number; + counts?: CapKindCounts; + kind?: CapKind; folders: FolderDataType[]; analyticsEnabled: boolean; thumbnails?: SeededThumbnails; @@ -109,6 +148,7 @@ export const Caps = ({ const page = parsePageParam(params.get("page")); const { user } = useDashboardContext(); const isArchivedView = view === "archived"; + const isOverview = !isArchivedView && kind === undefined; const [openNewFolderDialog, setOpenNewFolderDialog] = useState(false); const totalPages = Math.ceil(count / pageSize); const moveLocation = { type: "personal" } as const; @@ -123,21 +163,43 @@ export const Caps = ({ ); const leavingCaps = useLeavingCaps(listedVideos); const visibleVideos = leavingCaps.present; - const pageIds = useMemo( - () => visibleVideos.map((video) => video.id), + const sections = useMemo( + () => + CAP_KINDS.map((sectionKind) => ({ + kind: sectionKind, + caps: visibleVideos.filter((video) => capKindOf(video) === sectionKind), + })), [visibleVideos], ); + const gridColumnCount = useGridColumns(); + const pageIds = useMemo( + () => + isOverview + ? sections.flatMap((section) => + section.caps + .filter((_, index) => + overviewShows( + index, + OVERVIEW_ROWS[section.kind], + gridColumnCount, + ), + ) + .map((video) => video.id), + ) + : visibleVideos.map((video) => video.id), + [isOverview, sections, gridColumnCount, visibleVideos], + ); const selectAllView = useMemo( () => isArchivedView ? ({ type: "archived" } as const) - : ({ type: "personal" } as const), - [isArchivedView], + : ({ type: "personal", kind } as const), + [isArchivedView, kind], ); const selection = useCapSelection({ pageIds, - totalCount: count, - view: selectAllView, + totalCount: isOverview ? undefined : count, + view: isOverview ? undefined : selectAllView, }); const selectedCaps = selection.selected; const setSelectedCaps = selection.setSelected; @@ -153,6 +215,12 @@ export const Caps = ({ onReturn: leavingCaps.restore, }); const shownCount = count - leavingCaps.leavingCount; + const shownKindCounts = useMemo(() => { + const shown = { ...counts }; + for (const video of listedVideos) + if (leavingCaps.leaving.has(video.id)) shown[capKindOf(video)] -= 1; + return shown; + }, [counts, listedVideos, leavingCaps.leaving]); const shownArchivedCount = archivedCount + (isArchivedView ? 0 : leavingCaps.leavingCount); @@ -286,13 +354,11 @@ export const Caps = ({ }; }, [selectedCaps, deleteCaps, isDeletingCaps, pageIds]); - if ( + const libraryIsEmpty = !isArchivedView && shownCount === 0 && folders.length === 0 && - shownArchivedCount === 0 - ) - return ; + shownArchivedCount === 0; const archivedLink = !isArchivedView && shownArchivedCount > 0 ? ( @@ -308,6 +374,66 @@ export const Caps = ({ ) : null; + const renderCap = (video: VideoData[number], className?: string) => ( + + { + if (selectedCaps.length > 0) { + deleteCaps(selectedCaps); + } else { + deleteCap(video.id); + } + }} + userId={user?.id} + isLoadingAnalytics={isLoadingAnalytics} + isSelected={selectedCaps.includes(video.id)} + anyCapSelected={anyCapSelected} + onSelectToggle={(options) => selection.toggle(video.id, options)} + selectedIds={selectedCaps} + canMove={!isArchivedView} + moveLocation={moveLocation} + moveRootLabel="My Caps" + isArchived={isArchivedView} + onArchiveToggle={() => + void archiveCaps.mutate({ + ids: [video.id], + archived: !isArchivedView, + }) + } + /> + + ); + + const showUploadPlaceholder = + !isArchivedView && isUploading && (isOverview || kind === "videos"); + + const overviewSections = sections.filter( + (section) => + section.kind === "notes" || + section.caps.length > 0 || + (section.kind === "videos" && showUploadPlaceholder), + ); + + if (libraryIsEmpty && isOverview && !showUploadPlaceholder) + return ( +
+
+ +
+ + +
+ ); + return (
{isArchivedView ? ( @@ -323,7 +449,9 @@ export const Caps = ({ open={openNewFolderDialog} onOpenChange={setOpenNewFolderDialog} /> - setOpenNewFolderDialog(true)} /> + {isOverview && ( + setOpenNewFolderDialog(true)} /> + )}
)} - {visibleVideos.length === 0 && archivedLink && ( -
{archivedLink}
- )} - {visibleVideos.length > 0 && ( - <> - + {isOverview ? ( +
+ {overviewSections.map((section, sectionIndex) => { + const sectionCount = shownKindCounts[section.kind]; + const hasCaps = + section.caps.length > 0 || + (section.kind === "videos" && showUploadPlaceholder); + return ( +
+ 0 ? sectionCount : undefined} + actions={ + (sectionIndex === 0 && archivedLink) || hasCaps ? ( + <> + {sectionIndex === 0 && archivedLink} + {hasCaps && ( + + See all + + + )} + + ) : undefined + } + /> + {hasCaps ? ( +
+ {section.kind === "videos" && showUploadPlaceholder && ( + + )} + + {section.caps.map((video, index) => + renderCap( + video, + overviewItemClass( + index, + OVERVIEW_ROWS[section.kind], + ), + ), + )} + +
+ ) : ( + + )} +
+ ); + })} +
+ ) : ( + <> + {visibleVideos.length === 0 && archivedLink && ( +
{archivedLink}
+ )} + {(visibleVideos.length > 0 || showUploadPlaceholder) && ( <> - {archivedLink} - + + {archivedLink} + + + } + /> +
+ {showUploadPlaceholder && ( + + )} + + {visibleVideos.map((video) => renderCap(video))} + +
- } - /> - - -
- {!isArchivedView && isUploading && ( - + )} + {kind && + visibleVideos.length === 0 && + !showUploadPlaceholder && + page === 1 && ( + <> + + {kind === "notes" ? ( + + ) : ( +
+
+

+ {kind === "videos" + ? "No videos yet" + : "No images yet"} +

+

+ {kind === "videos" + ? "Record or upload a video and it shows up here." + : "Screenshots you take with Cap show up here."} +

+
+ + Back to My Caps + +
+ )} + )} - - {visibleVideos.map((video) => { - const videoAnalytics = analytics[video.id]; - return ( - - { - if (selectedCaps.length > 0) { - deleteCaps(selectedCaps); - } else { - deleteCap(video.id); - } - }} - userId={user?.id} - isLoadingAnalytics={isLoadingAnalytics} - isSelected={selectedCaps.includes(video.id)} - anyCapSelected={anyCapSelected} - onSelectToggle={(options) => - selection.toggle(video.id, options) - } - selectedIds={selectedCaps} - canMove={!isArchivedView} - moveLocation={moveLocation} - moveRootLabel="My Caps" - isArchived={isArchivedView} - onArchiveToggle={() => - void archiveCaps.mutate({ - ids: [video.id], - archived: !isArchivedView, - }) - } - /> - - ); - })} - -
-
- - )} - {(data.length >= pageSize || page !== 1) && ( + + )} + + {!isOverview && (data.length >= pageSize || page !== 1) && (
`/dashboard/caps/archived?page=${target}` - : undefined + hrefForPage={(target) => + `${isArchivedView ? "/dashboard/caps/archived" : capKindHref(kind ?? "videos")}?page=${target}` } />
diff --git a/apps/web/app/(org)/dashboard/caps/caps-page-data.tsx b/apps/web/app/(org)/dashboard/caps/caps-page-data.tsx index 3f7f500b88c..9377e6b39f3 100644 --- a/apps/web/app/(org)/dashboard/caps/caps-page-data.tsx +++ b/apps/web/app/(org)/dashboard/caps/caps-page-data.tsx @@ -8,6 +8,7 @@ import { spaces, spaceVideos, users, + videoNotes, videos, videoUploads, } from "@cap/database/schema"; @@ -26,10 +27,14 @@ import { isNotNull, isNull, or, + type SQL, sql, } from "drizzle-orm"; +import { unionAll } from "drizzle-orm/mysql-core"; import { type Array, Effect } from "effect"; import { redirect } from "next/navigation"; +import { CAP_KINDS, type CapKind } from "@/lib/cap-kind"; +import { capKindCondition, capKindIndexHint } from "@/lib/cap-kind-query"; import { resolveDashboardPageSize } from "@/lib/dashboard-page-size"; import { parsePageParam } from "@/lib/page-param"; import { seedThumbnailUrls } from "@/lib/seeded-thumbnails"; @@ -131,12 +136,20 @@ const getSharedSpacesForVideos = Effect.fn(function* ( return sharedSpacesMap; }); +const OVERVIEW_SECTION_SIZE: Record = { + videos: 10, + images: 5, + notes: 5, +}; + export async function CapsPageView({ searchParams, view, + kind, }: { searchParams: Record; view: "library" | "archived"; + kind?: CapKind; }) { const user = await getCurrentUser(); @@ -150,6 +163,7 @@ export async function CapsPageView({ preferences: user.preferences, }); const isArchivedView = view === "archived"; + const isOverview = !isArchivedView && kind === undefined; const userId = user.id; const offset = (page - 1) * limit; @@ -157,18 +171,21 @@ export async function CapsPageView({ // One pass gives both the library count and the archived count, so the // Archived entry costs no extra round trip. The OR keeps the library rows // (root, not archived) and every archived row, wherever it is filed. + const libraryKindCount = (kind: CapKind) => + sql`count(case when ${videos.archivedAt} is null and ${capKindCondition(kind) as SQL} then 1 end)`.mapWith( + Number, + ); const totalCountPromise = db() .select({ - count: - sql`count(case when ${videos.archivedAt} is null then 1 end)`.mapWith( - Number, - ), + videos: libraryKindCount("videos"), + images: libraryKindCount("images"), + notes: libraryKindCount("notes"), archivedCount: sql`count(case when ${videos.archivedAt} is not null then 1 end)`.mapWith( Number, ), }) - .from(videos) + .from(videos, capKindIndexHint) .leftJoin(organizations, eq(videos.orgId, organizations.id)) .where( and( @@ -180,28 +197,37 @@ export async function CapsPageView({ ), ); - const capsPage = db() - .select({ id: videos.id }) - .from(videos) - .leftJoin(organizations, eq(videos.orgId, organizations.id)) - .where( - and( - eq(videos.ownerId, userId), - eq(videos.orgId, user.activeOrganizationId), - isArchivedView - ? isNotNull(videos.archivedAt) - : and(isNull(videos.folderId), isNull(videos.archivedAt)), - isNull(organizations.tombstoneAt), - ), - ) - .orderBy( - ...(isArchivedView - ? [desc(videos.archivedAt), desc(videos.id)] - : [desc(videos.effectiveCreatedAt), desc(videos.id)]), - ) - .limit(limit) - .offset(offset) - .as("caps_page"); + const pageIds = (pageKind: CapKind | undefined, take: number, skip: number) => + db() + .select({ id: videos.id }) + .from(videos, pageKind && !isArchivedView ? capKindIndexHint : undefined) + .leftJoin(organizations, eq(videos.orgId, organizations.id)) + .where( + and( + eq(videos.ownerId, userId), + eq(videos.orgId, user.activeOrganizationId), + isArchivedView + ? isNotNull(videos.archivedAt) + : and(isNull(videos.folderId), isNull(videos.archivedAt)), + pageKind ? capKindCondition(pageKind) : undefined, + isNull(organizations.tombstoneAt), + ), + ) + .orderBy( + ...(isArchivedView + ? [desc(videos.archivedAt), desc(videos.id)] + : [desc(videos.effectiveCreatedAt), desc(videos.id)]), + ) + .limit(take) + .offset(skip); + + const capsPage = isOverview + ? unionAll( + pageIds("videos", OVERVIEW_SECTION_SIZE.videos, 0), + pageIds("images", OVERVIEW_SECTION_SIZE.images, 0), + pageIds("notes", OVERVIEW_SECTION_SIZE.notes, 0), + ).as("caps_page") + : pageIds(kind, limit, offset).as("caps_page"); const videoDataPromise = db() .select({ @@ -243,6 +269,8 @@ export async function CapsPageView({ ), settings: videos.settings, archivedAt: videos.archivedAt, + isNote: videos.isNote, + noteExcerpt: videoNotes.excerpt, }) .from(videos) .innerJoin(capsPage, eq(videos.id, capsPage.id)) @@ -250,6 +278,7 @@ export async function CapsPageView({ .leftJoin(organizations, eq(sharedVideos.organizationId, organizations.id)) .leftJoin(users, eq(videos.ownerId, users.id)) .leftJoin(videoUploads, eq(videos.id, videoUploads.videoId)) + .leftJoin(videoNotes, eq(videos.id, videoNotes.videoId)) .groupBy( videos.id, videos.ownerId, @@ -258,6 +287,8 @@ export async function CapsPageView({ videos.metadata, videos.source, videos.isScreenshot, + videos.isNote, + videoNotes.excerpt, videos.duration, videos.public, videos.password, @@ -311,17 +342,24 @@ export async function CapsPageView({ foldersDataPromise, organizationSettingsPromise, ]); - const totalCount = isArchivedView - ? (totalCountResult[0]?.archivedCount ?? 0) - : (totalCountResult[0]?.count ?? 0); + const counts = { + videos: totalCountResult[0]?.videos ?? 0, + images: totalCountResult[0]?.images ?? 0, + notes: totalCountResult[0]?.notes ?? 0, + }; const archivedCount = totalCountResult[0]?.archivedCount ?? 0; + const totalCount = isArchivedView + ? archivedCount + : kind + ? counts[kind] + : CAP_KINDS.reduce((total, each) => total + counts[each], 0); const organizationSettings = organizationSettingsRow?.settings ?? null; const videoIds = videoData.map((video) => video.id); const thumbnails = seedThumbnailUrls( user, videoData - .filter((video) => !video.hasActiveUpload) + .filter((video) => !video.hasActiveUpload && !video.isNote) .map((video) => Video.VideoId.make(video.id)), ); const sharedSpacesMap = @@ -392,6 +430,8 @@ export async function CapsPageView({ data={processedVideoData} folders={foldersData} count={totalCount} + counts={counts} + kind={kind} thumbnails={thumbnails} pageSize={limit} archivedCount={archivedCount} diff --git a/apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx b/apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx index 2cf2dd5a54a..1e0f0aa2a4c 100644 --- a/apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx +++ b/apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx @@ -72,6 +72,7 @@ import { SharingDialog } from "../SharingDialog"; import { CapCardAnalytics, capAnalyticsHref } from "./CapCardAnalytics"; import { CapCardButton } from "./CapCardButton"; import { CapCardContent } from "./CapCardContent"; +import { NoteThumbnail } from "./NoteThumbnail"; const CustomThumbnailDialog = dynamic( () => import("@/components/custom-thumbnail/CustomThumbnailDialog"), @@ -125,6 +126,8 @@ export interface CapCardProps extends PropsWithChildren { metadata?: VideoMetadata; source?: typeof videosSchema.$inferSelect.source; isScreenshot?: boolean; + isNote?: boolean; + noteExcerpt?: string | null; hasPassword?: boolean; hasInheritedPassword?: boolean; inheritedPasswordSources?: SpaceRuleSource[]; @@ -265,6 +268,7 @@ export const CapCard = ({ }; const isOwner = userId === cap.ownerId; + const isNote = cap.isNote === true; const customThumbnail = getCustomThumbnailMetadata(cap.metadata); const moveEnabled = Boolean(canMove && moveLocation && moveRootLabel); // A drag carries at most MAX_MOVE_ITEMS ids; larger selections ("Select @@ -339,11 +343,13 @@ export const CapCard = ({ const handleCopy = async (text: string) => { try { - await copyRichVideoLink({ - url: text, - title: cap.name || "Cap Recording", - previewImageUrl: videoPreviewImageUrl(webUrl, cap.id), - }); + if (isNote) await navigator.clipboard.writeText(text); + else + await copyRichVideoLink({ + url: text, + title: cap.name || "Cap Recording", + previewImageUrl: videoPreviewImageUrl(webUrl, cap.id), + }); } catch (error) { console.error("Failed to copy link:", error); toast.error("Couldn't copy the link. Please try again."); @@ -388,6 +394,7 @@ export const CapCard = ({ isOwner && !sharedCapCard && cap.isScreenshot !== true && + !isNote && !cap.hasActiveUpload && (cap.source?.type === "desktopMP4" || cap.source?.type === "webMP4") && Boolean(cap.duration && cap.duration > 0); @@ -418,6 +425,7 @@ export const CapCard = ({ hasPassword={passwordProtected} inheritedPasswordSources={cap.inheritedPasswordSources} onPasswordUpdated={handlePasswordUpdated} + isNote={isNote} /> setIsSettingsDialogOpen(false)} onSaved={() => router.refresh()} + isNote={isNote} /> )} - { - e.stopPropagation(); - handleDownload(); - }} - className="flex gap-2 items-center rounded-lg" - > - -

Download

-
+ {!isNote && ( + { + e.stopPropagation(); + handleDownload(); + }} + className="flex gap-2 items-center rounded-lg" + > + +

Download

+
+ )} { e.stopPropagation(); @@ -643,25 +654,27 @@ export const CapCard = ({ )} {isOwner && ( <> - { - toast.promise( - duplicateMutation.mutateAsync().then(rejectOnFailure), - { - loading: "Duplicating cap...", - success: "Cap duplicated successfully", - error: "Failed to duplicate cap", - }, - ); - }} - disabled={ - duplicateMutation.isPending || cap.hasActiveUpload - } - className="flex gap-2 items-center rounded-lg" - > - -

Duplicate

-
+ {!isNote && ( + { + toast.promise( + duplicateMutation.mutateAsync().then(rejectOnFailure), + { + loading: "Duplicating cap...", + success: "Cap duplicated successfully", + error: "Failed to duplicate cap", + }, + ); + }} + disabled={ + duplicateMutation.isPending || cap.hasActiveUpload + } + className="flex gap-2 items-center rounded-lg" + > + +

Duplicate

+
+ )} {canEditVideo && ( { @@ -674,7 +687,7 @@ export const CapCard = ({

Edit video

)} - {cap.isScreenshot !== true && ( + {cap.isScreenshot !== true && !isNote && ( { e.stopPropagation(); @@ -905,37 +918,50 @@ export const CapCard = ({ )} - -
+ {isNote ? ( + + ) : ( + <> + +
+ + )} {cap.isScreenshot === true && !hasVisibleUploadProgress && ( = ({ try { await editTitle(cap.id, next); setSavedTitle(next); - toast.success("Video title updated"); + toast.success(cap.isNote ? "Title updated" : "Video title updated"); if (!editingRef.current || draftRef.current.trim() === next) { setDraft(next); setEditing(false); @@ -139,7 +139,7 @@ export const CapCardContent: React.FC = ({ try { await editDate(cap.id, selectedDate.toISOString()); - toast.success("Video date updated"); + toast.success(cap.isNote ? "Date updated" : "Video date updated"); setIsDateEditing(false); router.refresh(); } catch (error) { diff --git a/apps/web/app/(org)/dashboard/caps/components/CapCard/NoteThumbnail.tsx b/apps/web/app/(org)/dashboard/caps/components/CapCard/NoteThumbnail.tsx new file mode 100644 index 00000000000..dae4910782c --- /dev/null +++ b/apps/web/app/(org)/dashboard/caps/components/CapCard/NoteThumbnail.tsx @@ -0,0 +1,39 @@ +import clsx from "clsx"; +import { formatDuration } from "@/components/VideoThumbnail"; + +export function NoteThumbnail({ + excerpt, + duration, + dimmed, + controlsShown, +}: { + excerpt?: string | null; + duration?: number | null; + dimmed?: boolean; + controlsShown?: boolean; +}) { + return ( +
+

+ {excerpt} +

+
+ {duration ? ( +

+ {formatDuration(duration)} +

+ ) : null} +
+ ); +} diff --git a/apps/web/app/(org)/dashboard/caps/components/CapGridItem.tsx b/apps/web/app/(org)/dashboard/caps/components/CapGridItem.tsx index 2fc2b2a299e..5075dba5451 100644 --- a/apps/web/app/(org)/dashboard/caps/components/CapGridItem.tsx +++ b/apps/web/app/(org)/dashboard/caps/components/CapGridItem.tsx @@ -23,11 +23,13 @@ export function CapGridItem({ children, layoutDependency, returning, + className, }: { id: string; children: ReactNode; layoutDependency: unknown; returning: boolean; + className?: string; }) { const reduceMotion = useReducedMotion(); return ( @@ -50,7 +52,7 @@ export function CapGridItem({ opacity: { duration: 0.2, ease: "easeOut" }, scale: { duration: 0.2, ease: "easeOut" }, }} - className="min-w-0" + className={className ? `min-w-0 ${className}` : "min-w-0"} > {children} diff --git a/apps/web/app/(org)/dashboard/caps/components/CapPagination.tsx b/apps/web/app/(org)/dashboard/caps/components/CapPagination.tsx index 0d7dba6436b..79de3d842dd 100644 --- a/apps/web/app/(org)/dashboard/caps/components/CapPagination.tsx +++ b/apps/web/app/(org)/dashboard/caps/components/CapPagination.tsx @@ -12,13 +12,13 @@ import { getPaginationItems } from "./pagination-items"; interface CapPaginationProps { currentPage: number; totalPages: number; - hrefForPage?: (page: number) => string; + hrefForPage: (page: number) => string; } export const CapPagination: React.FC = ({ currentPage, totalPages, - hrefForPage = (page) => `/dashboard/caps?page=${page}`, + hrefForPage, }) => { return ( diff --git a/apps/web/app/(org)/dashboard/caps/components/Folder.tsx b/apps/web/app/(org)/dashboard/caps/components/Folder.tsx index 48cad77e480..c3506e5452d 100644 --- a/apps/web/app/(org)/dashboard/caps/components/Folder.tsx +++ b/apps/web/app/(org)/dashboard/caps/components/Folder.tsx @@ -13,6 +13,7 @@ import { moveVideoToFolder, } from "@/actions/folders/moveVideoToFolder"; import { FontAwesomeIcon } from "@/components/FontAwesomeIcon"; +import { capCountLabel } from "@/lib/cap-kind"; import { useEffectMutation, useRpcClient } from "@/lib/EffectRuntime"; import { CAP_DRAG_TYPE, @@ -555,7 +556,9 @@ const FolderCard = ({ "text-sm truncate text-gray-10 w-fit", isList && "tabular-nums", )} - >{`${videoCount} ${videoCount === 1 ? "video" : "videos"}`}

+ > + {capCountLabel(videoCount)} +

{publicEnabled && !isList && ( diff --git a/apps/web/app/(org)/dashboard/caps/components/NotesEmptyState.tsx b/apps/web/app/(org)/dashboard/caps/components/NotesEmptyState.tsx new file mode 100644 index 00000000000..af32c42a6da --- /dev/null +++ b/apps/web/app/(org)/dashboard/caps/components/NotesEmptyState.tsx @@ -0,0 +1,42 @@ +import { Button } from "@cap/ui"; +import { faDownload } from "@fortawesome/free-solid-svg-icons/faDownload"; +import clsx from "clsx"; +import { FontAwesomeIcon } from "@/components/FontAwesomeIcon"; +import { + libraryDoodleHost, + NotesDoodle, +} from "../../_components/library-doodles"; + +export function NotesEmptyState({ + secondary = false, +}: { + secondary?: boolean; +}) { + return ( +
+ +
+

+ Record your meetings in the Cap desktop app +

+

+ Cap takes the notes. Share one and it shows up here. +

+
+ +
+ ); +} diff --git a/apps/web/app/(org)/dashboard/caps/components/SettingsDialog.tsx b/apps/web/app/(org)/dashboard/caps/components/SettingsDialog.tsx index 0a9ee107167..383a6ffe611 100644 --- a/apps/web/app/(org)/dashboard/caps/components/SettingsDialog.tsx +++ b/apps/web/app/(org)/dashboard/caps/components/SettingsDialog.tsx @@ -29,11 +29,12 @@ interface SettingsDialogProps { user?: CurrentUser | null; organizationSettings?: OrganizationSettings | null; onSaved?: () => void; + isNote?: boolean; } type SettingKey = ViewerSettingKey | "disableDownloads"; -const options: { +const allOptions: { label: string; value: SettingKey; description: string; @@ -79,6 +80,23 @@ const options: { }, ]; +const NOTE_SETTINGS: SettingKey[] = [ + "disableComments", + "disableReactions", + "disableTranscript", +]; + +const noteOptions = allOptions + .filter((option) => NOTE_SETTINGS.includes(option.value)) + .map((option) => + option.value === "disableTranscript" + ? { + ...option, + description: "Show the meeting transcript beside this note", + } + : option, + ); + export const SettingsDialog = ({ isOpen, onClose, @@ -88,7 +106,9 @@ export const SettingsDialog = ({ user: propUser, organizationSettings: propOrganizationSettings, onSaved, + isNote = false, }: SettingsDialogProps) => { + const options = isNote ? noteOptions : allOptions; const contextData = useDashboardContext(); const user = propUser ?? contextData.user; const organizationSettings = @@ -260,7 +280,7 @@ export const SettingsDialog = ({ ); })}
-
+
diff --git a/apps/web/app/(org)/dashboard/caps/components/SharingDialog.tsx b/apps/web/app/(org)/dashboard/caps/components/SharingDialog.tsx index 8482342b843..0c0f8300899 100644 --- a/apps/web/app/(org)/dashboard/caps/components/SharingDialog.tsx +++ b/apps/web/app/(org)/dashboard/caps/components/SharingDialog.tsx @@ -72,6 +72,7 @@ interface SharingDialogProps { user?: CurrentUser | null; onUpgradeRequest?: (open: boolean) => void; shareUrl?: string; + isNote?: boolean; } export const SharingDialog: React.FC = ({ @@ -92,6 +93,7 @@ export const SharingDialog: React.FC = ({ user: propUser, onUpgradeRequest: propOnUpgradeRequest, shareUrl: propShareUrl, + isNote = false, }) => { const { spacesData: contextSpacesData, @@ -427,8 +429,9 @@ export const SharingDialog: React.FC = ({ return ( - + } description={ activeTab === "Share" @@ -441,7 +444,12 @@ export const SharingDialog: React.FC = ({ -
+
{tabs.map((tab) => (
-
+
{activeTab === "Share" ? ( <> {/* Public sharing toggle */} @@ -688,8 +696,9 @@ export const SharingDialog: React.FC = ({

Spaces

- Members of a space can watch it there. It also stays in My - Caps. To file it in a folder, use Move. + Members of a space can {isNote ? "read" : "watch"} it + there. It also stays in My Caps. To file it in a folder, + use Move.

@@ -750,7 +759,7 @@ export const SharingDialog: React.FC = ({ )}
- + {activeTab === "Share" ? ( <> + )} +
+ )} +
+
+
+ {showRail && ( + + )} +
+ + ); +} diff --git a/apps/web/app/s/[videoId]/Share.tsx b/apps/web/app/s/[videoId]/Share.tsx index 27d4c3bcef1..9dfde0f3167 100644 --- a/apps/web/app/s/[videoId]/Share.tsx +++ b/apps/web/app/s/[videoId]/Share.tsx @@ -41,6 +41,7 @@ import { Toolbar } from "./_components/Toolbar"; import { formatTimeAgo } from "./_components/tabs/Activity/utils"; import { TimelineSkeleton } from "./_components/timeline/TimelineSkeleton"; import type { FilmstripSource } from "./_components/timeline/useFilmstripFrames"; +import { trackVideoView } from "./_components/track-video-view"; import type { VideoData } from "./types"; const importTimelineView = () => import("./_components/timeline/TimelineView"); @@ -75,102 +76,6 @@ export type CommentType = typeof commentsSchema.$inferSelect & { clientKey?: string; }; -const SESSION_STORAGE_KEY = "cap_tb_session_id"; -const SESSION_TTL_MS = 30 * 60 * 1000; // 30 minutes - -const ensureAnalyticsSessionId = () => { - if (typeof window === "undefined") return "anonymous"; - try { - const raw = window.localStorage.getItem(SESSION_STORAGE_KEY); - const now = Date.now(); - if (raw) { - const parsed = JSON.parse(raw) as { value: string; expiry: number }; - if (parsed?.value && parsed.expiry > now) return parsed.value; - } - const newId = - typeof crypto !== "undefined" && "randomUUID" in crypto - ? crypto.randomUUID() - : Math.random().toString(36).slice(2); - window.localStorage.setItem( - SESSION_STORAGE_KEY, - JSON.stringify({ value: newId, expiry: now + SESSION_TTL_MS }), - ); - return newId; - } catch (error) { - console.warn("Failed to persist analytics session id", error); - return "anonymous"; - } -}; - -const trackVideoView = (payload: { - videoId: string; - orgId?: string | null; - ownerId?: string | null; -}) => { - if (typeof window === "undefined") return; - const sessionId = ensureAnalyticsSessionId(); - const screen = window.screen; - const body = { - videoId: payload.videoId, - orgId: payload.orgId, - ownerId: payload.ownerId, - sessionId, - pathname: window.location.pathname, - href: window.location.href, - referrer: document.referrer, - hostname: window.location.hostname, - timezone: Intl.DateTimeFormat().resolvedOptions().timeZone, - language: typeof navigator !== "undefined" ? navigator.language : undefined, - locale: - typeof navigator !== "undefined" && navigator.languages?.length - ? navigator.languages[0] - : undefined, - screen: screen - ? { - width: screen.width, - height: screen.height, - colorDepth: screen.colorDepth, - } - : undefined, - userAgent: - typeof navigator !== "undefined" ? navigator.userAgent : undefined, - occurredAt: new Date().toISOString(), - }; - - const serializedBody = JSON.stringify(body); - - if ( - typeof navigator !== "undefined" && - typeof navigator.sendBeacon === "function" - ) { - try { - const beaconPayload = new Blob([serializedBody], { - type: "application/json", - }); - const queued = navigator.sendBeacon( - "/api/analytics/track", - beaconPayload, - ); - if (queued) { - return; - } - } catch (error) { - console.warn("Falling back to fetch for analytics tracking", error); - } - } - - void fetch("/api/analytics/track", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: serializedBody, - keepalive: true, - }).catch((error) => { - if (error?.name !== "AbortError") { - console.warn("Failed to track analytics event", error); - } - }); -}; - type AiGenerationStatus = | "QUEUED" | "PROCESSING" diff --git a/apps/web/app/s/[videoId]/ShareLoader.tsx b/apps/web/app/s/[videoId]/ShareLoader.tsx new file mode 100644 index 00000000000..afedab00d13 --- /dev/null +++ b/apps/web/app/s/[videoId]/ShareLoader.tsx @@ -0,0 +1,17 @@ +"use client"; + +import dynamic from "next/dynamic"; + +export const ShareLoader = dynamic(() => + import("./Share").then((module) => module.Share), +); + +export const NoteShareLoader = dynamic(() => + import("./NoteShare").then((module) => module.NoteShare), +); + +export const NoteLinkLimitLoader = dynamic(() => + import("./_components/note/NoteLinkLimit").then( + (module) => module.NoteLinkLimit, + ), +); diff --git a/apps/web/app/s/[videoId]/_components/AccessStates.tsx b/apps/web/app/s/[videoId]/_components/AccessStates.tsx index 05eb9df3e20..3bd15e04e26 100644 --- a/apps/web/app/s/[videoId]/_components/AccessStates.tsx +++ b/apps/web/app/s/[videoId]/_components/AccessStates.tsx @@ -35,7 +35,12 @@ function SwitchAccountButton({ loginUrl }: { loginUrl: string }) { ); } -export function PrivateVideoState({ videoId }: { videoId: Video.VideoId }) { +type AccessStateProps = { videoId: Video.VideoId; isNote?: boolean }; + +export function PrivateVideoState({ + videoId, + isNote = false, +}: AccessStateProps) { const user = useCurrentUser(); const urls = accessUrls(videoId); @@ -44,7 +49,7 @@ export function PrivateVideoState({ videoId }: { videoId: Video.VideoId }) { } - title="This video is private" + title={isNote ? "This note is private" : "This video is private"} lede={ <> You're signed in as {user.email}, which doesn't @@ -70,8 +75,12 @@ export function PrivateVideoState({ videoId }: { videoId: Video.VideoId }) { } - title="This video is private" - lede="Only people the owner invited can watch it. If that's you, sign in with the email address that was invited." + title={isNote ? "This note is private" : "This video is private"} + lede={ + isNote + ? "Only people the owner invited can read it. If that's you, sign in with the email address that was invited." + : "Only people the owner invited can watch it. If that's you, sign in with the email address that was invited." + } > @@ -85,13 +94,20 @@ export function PrivateVideoState({ videoId }: { videoId: Video.VideoId }) { ); } -export function SignInRequiredState({ videoId }: { videoId: Video.VideoId }) { +export function SignInRequiredState({ + videoId, + isNote = false, +}: AccessStateProps) { return ( } - title="Sign in to watch" - lede="The owner only shares this video with approved email addresses. Sign in with yours to start watching." + title={isNote ? "Sign in to read" : "Sign in to watch"} + lede={ + isNote + ? "The owner only shares this note with approved email addresses. Sign in with yours to read it." + : "The owner only shares this video with approved email addresses. Sign in with yours to start watching." + } > @@ -102,14 +118,17 @@ export function SignInRequiredState({ videoId }: { videoId: Video.VideoId }) { ); } -export function AccessRestrictedState({ videoId }: { videoId: Video.VideoId }) { +export function AccessRestrictedState({ + videoId, + isNote = false, +}: AccessStateProps) { const user = useCurrentUser(); return ( } - title="This video is restricted" + title={isNote ? "This note is restricted" : "This video is restricted"} lede={ user ? ( <> diff --git a/apps/web/app/s/[videoId]/_components/DeleteCapDialog.tsx b/apps/web/app/s/[videoId]/_components/DeleteCapDialog.tsx index 24ecb767ce8..42e51a30e94 100644 --- a/apps/web/app/s/[videoId]/_components/DeleteCapDialog.tsx +++ b/apps/web/app/s/[videoId]/_components/DeleteCapDialog.tsx @@ -31,7 +31,7 @@ export default function DeleteCapDialog({ mutationFn: () => rpc.VideoDelete(videoId), onSuccess: () => { toast.success("Cap deleted successfully"); - push("/dashboard/caps?page=1"); + push("/dashboard/caps"); }, onError: () => { toast.error("Failed to delete Cap"); diff --git a/apps/web/app/s/[videoId]/_components/PasswordGate.tsx b/apps/web/app/s/[videoId]/_components/PasswordGate.tsx index f1c2b413208..382525ef37a 100644 --- a/apps/web/app/s/[videoId]/_components/PasswordGate.tsx +++ b/apps/web/app/s/[videoId]/_components/PasswordGate.tsx @@ -13,7 +13,13 @@ import { } from "@/components/paper-state/PaperState"; import { TOO_MANY_PASSWORD_ATTEMPTS } from "@/lib/password-attempts"; -export function PasswordGate({ videoId }: { videoId: Video.VideoId }) { +export function PasswordGate({ + videoId, + isNote = false, +}: { + videoId: Video.VideoId; + isNote?: boolean; +}) { const [password, setPassword] = useState(""); const router = useRouter(); @@ -33,8 +39,16 @@ export function PasswordGate({ videoId }: { videoId: Video.VideoId }) { } - title="This video is password protected" - lede="Enter the password the owner gave you to start watching." + title={ + isNote + ? "This note is password protected" + : "This video is password protected" + } + lede={ + isNote + ? "Enter the password the owner gave you to read it." + : "Enter the password the owner gave you to start watching." + } >
- {busy ? "Checking…" : "Watch video"} + {busy ? "Checking…" : isNote ? "Open note" : "Watch video"} {failed && (

diff --git a/apps/web/app/s/[videoId]/_components/ShareHeader.tsx b/apps/web/app/s/[videoId]/_components/ShareHeader.tsx index 06808b01f76..878d076f75e 100644 --- a/apps/web/app/s/[videoId]/_components/ShareHeader.tsx +++ b/apps/web/app/s/[videoId]/_components/ShareHeader.tsx @@ -488,11 +488,13 @@ export const ShareHeader = ({ }; const copyShareLink = (url: string) => - copyRichVideoLink({ - url, - title: displayTitle || "Cap Recording", - previewImageUrl: videoPreviewImageUrl(webUrl, data.id), - }); + data.isNote + ? navigator.clipboard.writeText(url) + : copyRichVideoLink({ + url, + title: displayTitle || "Cap Recording", + previewImageUrl: videoPreviewImageUrl(webUrl, data.id), + }); const handleCopyClick = () => { const video = document.querySelector("video"); @@ -683,6 +685,7 @@ export const ShareHeader = ({ const canEditVideo = isOwner && !data.isScreenshot && + !data.isNote && !data.hasActiveUpload && (data.source.type === "desktopMP4" || data.source.type === "webMP4"); const customThumbnail = getCustomThumbnailMetadata(data.metadata); @@ -850,7 +853,7 @@ export const ShareHeader = ({ return ( <> - {userIsOwnerAndNotPro && ( + {userIsOwnerAndNotPro && !data.isNote && (

Shareable links are limited to 5 mins on the free plan. @@ -884,6 +887,7 @@ export const ShareHeader = ({ user={user} onUpgradeRequest={setUpgradeModalOpen} shareUrl={getVideoLink()} + isNote={data.isNote} /> )} {shareLinkDialogMounted && ( @@ -900,6 +904,7 @@ export const ShareHeader = ({ setIsSharingDialogOpen(true); }} ownerIsPro={data.owner.isPro} + isNote={data.isNote} /> )} {isOwner && ( @@ -928,6 +933,7 @@ export const ShareHeader = ({ user={user} organizationSettings={data.orgSettings} onSaved={refresh} + isNote={data.isNote} /> )} {passwordDialogMounted && ( @@ -1133,7 +1139,7 @@ export const ShareHeader = ({

{data.name && (

- Video settings + {data.isNote ? "Note settings" : "Video settings"}

@@ -1330,7 +1339,7 @@ export const ShareHeader = ({ ) : null} - {!data.isScreenshot && ( + {!data.isScreenshot && !data.isNote && ( setIsThumbnailDialogOpen(true)} className="flex items-center gap-2 rounded-lg" @@ -1363,10 +1372,12 @@ export const ShareHeader = ({ : "Add password"}

- + {!data.isNote && ( + + )} {/* Downloads used to live behind a second dots button next to the link. There is one "everything else about this Cap" menu, and this is it. */} diff --git a/apps/web/app/s/[videoId]/_components/ShareLinkDialog.tsx b/apps/web/app/s/[videoId]/_components/ShareLinkDialog.tsx index 3b074467d39..246294f059f 100644 --- a/apps/web/app/s/[videoId]/_components/ShareLinkDialog.tsx +++ b/apps/web/app/s/[videoId]/_components/ShareLinkDialog.tsx @@ -96,6 +96,7 @@ export const ShareLinkDialog = ({ canManageAccess = false, onManageAccess, ownerIsPro = false, + isNote = false, }: { open: boolean; onOpenChange: (open: boolean) => void; @@ -107,6 +108,7 @@ export const ShareLinkDialog = ({ canManageAccess?: boolean; onManageAccess?: () => void; ownerIsPro?: boolean; + isNote?: boolean; }) => { const { webUrl } = usePublicEnv(); const playback = useOptionalPlayback(); @@ -159,6 +161,8 @@ export const ShareLinkDialog = ({ try { if (tab === "embed") { await navigator.clipboard.writeText(embedCode); + } else if (isNote) { + await navigator.clipboard.writeText(targetUrl); } else { await copyRichVideoLink({ url: targetUrl, @@ -172,7 +176,7 @@ export const ShareLinkDialog = ({ tab === "embed" ? "Failed to copy embed code" : "Failed to copy link", ); } - }, [tab, embedCode, targetUrl, videoTitle, webUrl, videoId]); + }, [tab, embedCode, targetUrl, videoTitle, webUrl, videoId, isNote]); return ( @@ -185,7 +189,7 @@ export const ShareLinkDialog = ({ Share -
+
{TABS.map(({ id, label, Icon }) => { const active = tab === id; return ( @@ -303,7 +307,12 @@ export const ShareLinkDialog = ({ : "Copy link"} - + ), + input: ({ node: _node, ...props }) => + props.type === "checkbox" ? ( + + ) : null, +}; + +function NoteMarkdown({ children }: { children: string }) { + return ( +
+ + {children} + +
+ ); +} + +export function NoteDocument({ + summaryMarkdown, + notesMarkdown, + participants, + meetingStartedAt, + duration, + ownerName, +}: { + summaryMarkdown: string | null; + notesMarkdown: string | null; + participants: string[]; + meetingStartedAt: Date | null; + duration: number | null; + ownerName: string | null; +}) { + const summary = summaryMarkdown?.trim() ?? ""; + const ownNotes = notesMarkdown?.trim() ?? ""; + const shownParticipants = participants.slice(0, SHOWN_PARTICIPANTS); + const moreParticipants = participants.length - shownParticipants.length; + const people = + shownParticipants.length > 0 + ? `${shownParticipants.join(", ")}${moreParticipants > 0 ? ` +${moreParticipants}` : ""}` + : null; + const hasDetails = Boolean(meetingStartedAt || duration || people); + + return ( +
+
+ {hasDetails && ( +

+ {meetingStartedAt && ( + + )} + {meetingStartedAt && duration ? ( + + · + + ) : null} + {duration ? {formatMeetingLength(duration)} : null} + {people && (meetingStartedAt || duration) ? ( + + · + + ) : null} + {people && ( + + {people} + + )} +

+ )} + {summary && {summary}} + {ownNotes && ( +
+

+ {ownerName ? `Notes from ${ownerName}` : "Notes"} +

+ {ownNotes} +
+ )} + {!summary && !ownNotes && ( +

This note is empty.

+ )} +
+
+ ); +} diff --git a/apps/web/app/s/[videoId]/_components/note/NoteLinkLimit.tsx b/apps/web/app/s/[videoId]/_components/note/NoteLinkLimit.tsx new file mode 100644 index 00000000000..74c939ebbf6 --- /dev/null +++ b/apps/web/app/s/[videoId]/_components/note/NoteLinkLimit.tsx @@ -0,0 +1,34 @@ +"use client"; + +import dynamic from "next/dynamic"; +import { useState } from "react"; +import { ShareableLinkLimitOverlay } from "../ShareableLinkLimitOverlay"; + +const importUpgradeModal = () => + import("@/components/UpgradeModal").then((module) => module.UpgradeModal); +const UpgradeModal = dynamic(importUpgradeModal, { ssr: false }); + +export function NoteLinkLimit({ isOwner }: { isOwner: boolean }) { + const [upgradeOpen, setUpgradeOpen] = useState(false); + const [upgradeMounted, setUpgradeMounted] = useState(false); + + return ( + <> + { + setUpgradeMounted(true); + setUpgradeOpen(true); + }} + onUpgradeHover={() => { + void importUpgradeModal(); + }} + className="min-h-[28rem]" + /> + {upgradeMounted && ( + + )} + + ); +} diff --git a/apps/web/app/s/[videoId]/_components/note/NoteMeetingTime.tsx b/apps/web/app/s/[videoId]/_components/note/NoteMeetingTime.tsx new file mode 100644 index 00000000000..6833e37f270 --- /dev/null +++ b/apps/web/app/s/[videoId]/_components/note/NoteMeetingTime.tsx @@ -0,0 +1,39 @@ +"use client"; + +import { useSyncExternalStore } from "react"; + +const utcDay = new Intl.DateTimeFormat("en-US", { + weekday: "short", + month: "short", + day: "numeric", + timeZone: "UTC", +}); + +const localDay = new Intl.DateTimeFormat("en-US", { + weekday: "short", + month: "short", + day: "numeric", +}); + +const localTime = new Intl.DateTimeFormat("en-US", { + hour: "numeric", + minute: "2-digit", +}); + +const subscribeToNothing = () => () => {}; + +export function NoteMeetingTime({ iso }: { iso: string }) { + const hydrated = useSyncExternalStore( + subscribeToNothing, + () => true, + () => false, + ); + const date = new Date(iso); + return ( + + ); +} diff --git a/apps/web/app/s/[videoId]/_components/note/NoteTranscript.tsx b/apps/web/app/s/[videoId]/_components/note/NoteTranscript.tsx new file mode 100644 index 00000000000..10014b063e6 --- /dev/null +++ b/apps/web/app/s/[videoId]/_components/note/NoteTranscript.tsx @@ -0,0 +1,43 @@ +import type { VideoNoteTranscriptTurn } from "@cap/database/schema"; + +const formatTurnTime = (startMs: number) => { + const total = Math.max(0, Math.floor(startMs / 1000)); + const hours = Math.floor(total / 3600); + const minutes = Math.floor((total % 3600) / 60); + const seconds = total % 60; + const pad = (value: number) => String(value).padStart(2, "0"); + return hours > 0 + ? `${hours}:${pad(minutes)}:${pad(seconds)}` + : `${pad(minutes)}:${pad(seconds)}`; +}; + +export function NoteTranscript({ + turns, +}: { + turns: VideoNoteTranscriptTurn[]; +}) { + const rows = turns.map((turn, position) => ({ + ...turn, + id: `${turn.startMs}:${position}`, + })); + + return ( +
    + {rows.map((row) => ( +
  1. +

    + + {row.speaker} + + + {formatTurnTime(row.startMs)} + +

    +

    + {row.text} +

    +
  2. + ))} +
+ ); +} diff --git a/apps/web/app/s/[videoId]/_components/tabs/Activity/Comment.tsx b/apps/web/app/s/[videoId]/_components/tabs/Activity/Comment.tsx index a98b4df6424..47291a33f08 100644 --- a/apps/web/app/s/[videoId]/_components/tabs/Activity/Comment.tsx +++ b/apps/web/app/s/[videoId]/_components/tabs/Activity/Comment.tsx @@ -34,6 +34,7 @@ const CommentComponent: React.FC<{ ) => void; level?: number; onSeek?: (time: number) => void; + hideTimestamps?: boolean; }> = ({ comment, replies, @@ -44,6 +45,7 @@ const CommentComponent: React.FC<{ onDelete, level = 0, onSeek, + hideTimestamps = false, }) => { const user = useCurrentUser(); const isReplying = replyingToId === comment.id; @@ -115,7 +117,7 @@ const CommentComponent: React.FC<{

- {comment.timestamp !== null && ( + {comment.timestamp !== null && !hideTimestamps && (
diff --git a/apps/web/app/s/[videoId]/_components/tabs/Activity/Comments.tsx b/apps/web/app/s/[videoId]/_components/tabs/Activity/Comments.tsx index 6184ecd55f7..5fe326ddeca 100644 --- a/apps/web/app/s/[videoId]/_components/tabs/Activity/Comments.tsx +++ b/apps/web/app/s/[videoId]/_components/tabs/Activity/Comments.tsx @@ -38,6 +38,7 @@ export const Comments = Object.assign( setOptimisticComments: (newComment: CommentType) => void; handleCommentSuccess: (comment: CommentType) => void; onSeek?: (time: number) => void; + hideTimestamps?: boolean; setShowAuthOverlay: (v: boolean) => void; commentsDisabled: boolean; ownerName?: string | null; @@ -294,6 +295,7 @@ export const Comments = Object.assign( onCancelReply={handleCancelReply} onDelete={handleDeleteComment} onSeek={onSeek} + hideTimestamps={props.hideTimestamps} /> ); })} diff --git a/apps/web/app/s/[videoId]/_components/tabs/Activity/index.tsx b/apps/web/app/s/[videoId]/_components/tabs/Activity/index.tsx index eeda00ea991..7e7e4959ce4 100644 --- a/apps/web/app/s/[videoId]/_components/tabs/Activity/index.tsx +++ b/apps/web/app/s/[videoId]/_components/tabs/Activity/index.tsx @@ -15,6 +15,7 @@ interface ActivityProps { comments: CommentType[]; setComments: React.Dispatch>; onSeek?: (time: number) => void; + hideTimestamps?: boolean; handleCommentSuccess: (comment: CommentType) => void; videoId: Video.VideoId; optimisticComments: CommentType[]; @@ -72,6 +73,7 @@ export const Activity = Object.assign( videoId={videoId} setShowAuthOverlay={setShowAuthOverlay} onSeek={props.onSeek} + hideTimestamps={props.hideTimestamps} commentsDisabled={commentsDisabled} ownerName={ownerName} canRecordMedia={canRecordMedia} @@ -96,7 +98,7 @@ export const Activity = Object.assign(
{user && props.isOwnerOrMember && (
- {props.analytics} +
{props.analytics}
)} diff --git a/apps/web/app/s/[videoId]/_components/track-video-view.ts b/apps/web/app/s/[videoId]/_components/track-video-view.ts new file mode 100644 index 00000000000..f9d27808583 --- /dev/null +++ b/apps/web/app/s/[videoId]/_components/track-video-view.ts @@ -0,0 +1,97 @@ +const SESSION_STORAGE_KEY = "cap_tb_session_id"; +const SESSION_TTL_MS = 30 * 60 * 1000; + +const ensureAnalyticsSessionId = () => { + if (typeof window === "undefined") return "anonymous"; + try { + const raw = window.localStorage.getItem(SESSION_STORAGE_KEY); + const now = Date.now(); + if (raw) { + const parsed = JSON.parse(raw) as { value: string; expiry: number }; + if (parsed?.value && parsed.expiry > now) return parsed.value; + } + const newId = + typeof crypto.randomUUID === "function" + ? crypto.randomUUID() + : Array.from(crypto.getRandomValues(new Uint8Array(16)), (byte) => + byte.toString(16).padStart(2, "0"), + ).join(""); + window.localStorage.setItem( + SESSION_STORAGE_KEY, + JSON.stringify({ value: newId, expiry: now + SESSION_TTL_MS }), + ); + return newId; + } catch (error) { + console.warn("Failed to persist analytics session id", error); + return "anonymous"; + } +}; + +export const trackVideoView = (payload: { + videoId: string; + orgId?: string | null; + ownerId?: string | null; +}) => { + if (typeof window === "undefined") return; + const sessionId = ensureAnalyticsSessionId(); + const screen = window.screen; + const body = { + videoId: payload.videoId, + orgId: payload.orgId, + ownerId: payload.ownerId, + sessionId, + pathname: window.location.pathname, + href: window.location.href, + referrer: document.referrer, + hostname: window.location.hostname, + timezone: Intl.DateTimeFormat().resolvedOptions().timeZone, + language: typeof navigator !== "undefined" ? navigator.language : undefined, + locale: + typeof navigator !== "undefined" && navigator.languages?.length + ? navigator.languages[0] + : undefined, + screen: screen + ? { + width: screen.width, + height: screen.height, + colorDepth: screen.colorDepth, + } + : undefined, + userAgent: + typeof navigator !== "undefined" ? navigator.userAgent : undefined, + occurredAt: new Date().toISOString(), + }; + + const serializedBody = JSON.stringify(body); + + if ( + typeof navigator !== "undefined" && + typeof navigator.sendBeacon === "function" + ) { + try { + const beaconPayload = new Blob([serializedBody], { + type: "application/json", + }); + const queued = navigator.sendBeacon( + "/api/analytics/track", + beaconPayload, + ); + if (queued) { + return; + } + } catch (error) { + console.warn("Falling back to fetch for analytics tracking", error); + } + } + + void fetch("/api/analytics/track", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: serializedBody, + keepalive: true, + }).catch((error) => { + if (error?.name !== "AbortError") { + console.warn("Failed to track analytics event", error); + } + }); +}; diff --git a/apps/web/app/s/[videoId]/page.tsx b/apps/web/app/s/[videoId]/page.tsx index fdb9885081b..8c7f8a16be3 100644 --- a/apps/web/app/s/[videoId]/page.tsx +++ b/apps/web/app/s/[videoId]/page.tsx @@ -9,6 +9,7 @@ import { spaceVideos, users, videoEdits, + videoNotes, videos, videoUploads, videoViewerGrants, @@ -76,7 +77,10 @@ import { getCustomThumbnailUrl, getSharePlaybackSource, } from "@/lib/share-playback"; -import { buildShareVideoMetadata } from "@/lib/share-video-metadata"; +import { + buildShareNoteMetadata, + buildShareVideoMetadata, +} from "@/lib/share-video-metadata"; import { resolveForeignShareRedirect, resolveRestrictedShareRedirect, @@ -108,10 +112,16 @@ import { PrivateVideoState, SignInRequiredState, } from "./_components/AccessStates"; +import { NoteDocument } from "./_components/note/NoteDocument"; +import { NoteTranscript } from "./_components/note/NoteTranscript"; import { PasswordGate } from "./_components/PasswordGate"; import { PendingRecordingShare } from "./_components/PendingRecordingShare"; import { ShareHeader } from "./_components/ShareHeader"; -import { Share } from "./Share"; +import { + NoteLinkLimitLoader, + NoteShareLoader, + ShareLoader, +} from "./ShareLoader"; const VIEW_NOTIFICATION_DELAY_MS = 2 * 60 * 1000; const VIDEO_ID_PATTERN = /^[0-9abcdefghjkmnpqrstvwxyz]+$/; @@ -242,23 +252,36 @@ const getSharedSpacesForVideo = cache(async function getSharedSpacesForVideo( function PolicyDeniedView({ reason, videoId, + isNote, }: { reason?: string; videoId: Video.VideoId; + isNote: boolean; }) { if (reason === "email_restriction_login_required") { - return ; + return ; } if (reason === "email_restriction_denied") { - return ; + return ; } - return ; + return ; } -const renderPolicyDenied = (videoId: Video.VideoId, reason?: string) => - Effect.succeed( - , - ); +type LoadedKind = { isNote: boolean }; + +const renderPolicyDenied = ( + videoId: Video.VideoId, + reason: string | undefined, + loadedKind: LoadedKind, +) => + Effect.sync(() => ( + + )); const renderNoSuchElement = (awaitRecording: boolean) => awaitRecording @@ -271,6 +294,7 @@ const getShareVideoPageCatchers = ( videoId: Video.VideoId, awaitRecording: boolean, searchParams: ShareVideoSearchParams, + loadedKind: LoadedKind, ) => ({ PolicyDenied: (e: Policy.PolicyDeniedError) => Effect.promise(async () => @@ -280,7 +304,7 @@ const getShareVideoPageCatchers = ( (redirectTo): Effect.Effect => redirectTo ? Effect.succeed({ redirectTo }) - : renderPolicyDenied(videoId, e.reason), + : renderPolicyDenied(videoId, e.reason, loadedKind), ), ), NoSuchElementException: () => renderNoSuchElement(awaitRecording), @@ -327,6 +351,15 @@ export async function generateMetadata( } : notFound(), onSome: ([video]) => { + if (video.isNote) + return { + ...buildShareNoteMetadata({ + videoId, + name: video.name, + webUrl, + }), + robots: "noindex, nofollow", + }; return { ...buildShareVideoMetadata({ videoId, @@ -404,6 +437,7 @@ export default async function ShareVideoPage(props: PageProps<"/s/[videoId]">) { ); if (foreignShareRedirect) redirect(foreignShareRedirect); + const loadedKind: LoadedKind = { isNote: false }; const page = await Effect.gen(function* () { const videosPolicy = yield* VideosPolicy; const loadVideo = () => @@ -428,6 +462,7 @@ export default async function ShareVideoPage(props: PageProps<"/s/[videoId]">) { jobId: videos.jobId, jobStatus: videos.jobStatus, isScreenshot: videos.isScreenshot, + isNote: videos.isNote, skipProcessing: videos.skipProcessing, transcriptionStatus: videos.transcriptionStatus, source: videos.source, @@ -462,6 +497,7 @@ export default async function ShareVideoPage(props: PageProps<"/s/[videoId]">) { const [row] = yield* Effect.promise(loadVideo); if (row) { + loadedKind.isNote = row.isNote; yield* videosPolicy.canViewLoaded(row, Option.fromNullable(row.password)); } @@ -478,7 +514,11 @@ export default async function ShareVideoPage(props: PageProps<"/s/[videoId]">) { ), Effect.map((data) => data.needsPassword ? ( - + ) : ( // overflow-x-clip: the timeline view's theater strip breaks out to // 100vw, which overshoots by the scrollbar width on OSes with classic @@ -502,7 +542,12 @@ export default async function ShareVideoPage(props: PageProps<"/s/[videoId]">) { ), ), Effect.catchTags( - getShareVideoPageCatchers(videoId, awaitRecording, searchParams), + getShareVideoPageCatchers( + videoId, + awaitRecording, + searchParams, + loadedKind, + ), ), provideOptionalAuth, EffectRuntime.runPromise, @@ -641,6 +686,7 @@ async function AuthorizedContent({ const firstViewKey = user?.id !== video.owner.id && !video.isScreenshot && + !video.isNote && !hasActiveUpload && (video.source.type === "desktopMP4" || video.source.type === "webMP4") ? (Video.getRetainedRecordingOutputKey( @@ -660,28 +706,29 @@ async function AuthorizedContent({ }, firstViewKey, ); - const overDurationLimitPromise = ownerIsPro - ? Promise.resolve(false) - : Promise.all([ - isVideoOverFreePlanDuration({ - id: videoId, - ownerId: video.owner.id, - orgId: video.orgId, - metadata: video.metadata, - }), - firstViewPromise, - ]) - .then( - ([overDurationLimit, firstView]) => - overDurationLimit || firstView === "held", - ) - .catch((error) => { - console.error( - `[ShareVideoPage] Free plan duration check failed for ${videoId}:`, - error, - ); - return false; - }); + const overDurationLimitPromise = + ownerIsPro || video.isNote + ? Promise.resolve(false) + : Promise.all([ + isVideoOverFreePlanDuration({ + id: videoId, + ownerId: video.owner.id, + orgId: video.orgId, + metadata: video.metadata, + }), + firstViewPromise, + ]) + .then( + ([overDurationLimit, firstView]) => + overDurationLimit || firstView === "held", + ) + .catch((error) => { + console.error( + `[ShareVideoPage] Free plan duration check failed for ${videoId}:`, + error, + ); + return false; + }); const playbackPendingPromise = firstViewPromise.then( (firstView) => firstView === "pending", ); @@ -702,6 +749,7 @@ async function AuthorizedContent({ ); const initialPlaybackSourcePromise = !video.isScreenshot && + !video.isNote && !hasActiveUpload && (video.source.type === "desktopMP4" || video.source.type === "webMP4") ? playbackLockedPromise.then(async (locked) => { @@ -737,13 +785,14 @@ async function AuthorizedContent({ ? resolveWithin(initialPlaybackSourcePromise, SERVER_PLAYBACK_WAIT_MS) : Promise.resolve(null); - const customThumbnailKey = video.isScreenshot - ? undefined - : getCustomThumbnailKey({ - id: videoId, - ownerId: video.owner.id, - metadata: video.metadata, - }); + const customThumbnailKey = + video.isScreenshot || video.isNote + ? undefined + : getCustomThumbnailKey({ + id: videoId, + ownerId: video.owner.id, + metadata: video.metadata, + }); const posterUrlPromise = customThumbnailKey ? getCustomThumbnailUrl(video, customThumbnailKey) : Promise.resolve(null); @@ -898,7 +947,9 @@ async function AuthorizedContent({ })(); const isVideoDownloadReady = - !hasActiveUpload && video.source?.type !== "desktopSegments"; + !video.isNote && + !hasActiveUpload && + video.source?.type !== "desktopSegments"; const memberCanDownloadPromise = userId && isVideoDownloadReady @@ -944,7 +995,7 @@ async function AuthorizedContent({ }); const upNextPromise = - user && searchParams.space && !video.isScreenshot + user && searchParams.space && !video.isScreenshot && !video.isNote ? getSpaceUpNext({ spaceParam: searchParams.space, videoId }).catch( (error) => { console.error( @@ -957,7 +1008,7 @@ async function AuthorizedContent({ : null; const videoHasEditsPromise = memberCanDownloadPromise.then((canDownload) => { - if (!canDownload || video.isScreenshot) return false; + if (!canDownload || video.isScreenshot || video.isNote) return false; return db() .select({ editSpec: videoEdits.editSpec }) .from(videoEdits) @@ -972,6 +1023,21 @@ async function AuthorizedContent({ ); }); + const notePromise = video.isNote + ? db() + .select({ + summaryMarkdown: videoNotes.summaryMarkdown, + notesMarkdown: videoNotes.notesMarkdown, + transcript: videoNotes.transcript, + participants: videoNotes.participants, + meetingStartedAt: videoNotes.meetingStartedAt, + }) + .from(videoNotes) + .where(eq(videoNotes.videoId, videoId)) + .limit(1) + .then(([row]) => row ?? null) + : Promise.resolve(null); + const [ spacesData, { sharedSpaces, sharedOrganizations }, @@ -989,6 +1055,7 @@ async function AuthorizedContent({ dashboardDestination, serverPlaybackSource, posterUrl, + note, ] = await Promise.all([ spacesDataPromise, sharedSpacesPromise, @@ -1006,6 +1073,7 @@ async function AuthorizedContent({ dashboardDestinationPromise, serverPlaybackSourcePromise, posterUrlPromise, + notePromise, viewNotificationPromise, ]); @@ -1017,6 +1085,7 @@ async function AuthorizedContent({ const env = serverEnv(); const transcriptionGenerationAvailable = !video.isScreenshot && + !video.isNote && Boolean(env.ASSEMBLY_API_KEY) && !rules.settings.disableTranscript; const aiProviderAvailable = isAiConfigured(); @@ -1115,7 +1184,9 @@ async function AuthorizedContent({ ownerId: video.owner.id, videoId, rawFileKey: video.activeUploadRawFileKey, - }) && !video.isScreenshot; + }) && + !video.isScreenshot && + !video.isNote; const defaultPlaybackSpeed = resolveDefaultPlaybackSpeed( video.videoSettings?.defaultPlaybackSpeed, @@ -1138,52 +1209,90 @@ async function AuthorizedContent({ // knows which view is active. Gutters moved into Share too — the comments // rail is flush to the viewport edge, so only the video column is centred // in a container. + const header = ( + null)} + dashboardDestination={dashboardDestination} + /> + ); + + if (video.isNote) { + const noteTurns = + !ownerIsOverShareLimit && + !rules.settings.disableTranscript && + Array.isArray(note?.transcript) + ? note.transcript + : []; + return ( +
+ + ) : ( + + ) + } + transcript={ + noteTurns.length > 0 ? : null + } + videoSettings={videoWithOrganizationInfo.settings} + comments={commentsPromise} + views={viewsPromise} + viewerId={user?.id ?? null} + /> +
+ ); + } + return (
- null)} - dashboardDestination={dashboardDestination} - /> - } + + and( + eq(videos.isNote, kind === "notes"), + eq(videos.isScreenshot, kind === "images"), + ); + +// Left to the optimizer, a kind list can be served from an index that is not +// in date order for that kind, which sorts or walks far more rows than a page. +export const capKindIndexHint = { forceIndex: VIDEOS_KIND_LIST_INDEX }; diff --git a/apps/web/lib/cap-kind.ts b/apps/web/lib/cap-kind.ts new file mode 100644 index 00000000000..dd32461c82a --- /dev/null +++ b/apps/web/lib/cap-kind.ts @@ -0,0 +1,57 @@ +export const CAP_KINDS = ["videos", "images", "notes"] as const; + +export type CapKind = (typeof CAP_KINDS)[number]; + +export type CapKindCounts = Record; + +export const CAP_KIND_LABEL: Record = { + videos: "Videos", + images: "Images", + notes: "Notes", +}; + +export const capCountLabel = (count: number) => + `${count} ${count === 1 ? "Cap" : "Caps"}`; + +export const capKindHref = (kind: CapKind) => `/dashboard/caps/${kind}`; + +type KindFlags = { isScreenshot?: boolean | null; isNote?: boolean | null }; + +export const capKindOf = (cap: KindFlags): CapKind => + cap.isNote ? "notes" : cap.isScreenshot ? "images" : "videos"; + +export function groupCapsByKind( + caps: readonly T[], +): { kind: CapKind; caps: T[] }[] { + const groups: Record = { videos: [], images: [], notes: [] }; + for (const cap of caps) groups[capKindOf(cap)].push(cap); + return CAP_KINDS.map((kind) => ({ kind, caps: groups[kind] })).filter( + (group) => group.caps.length > 0, + ); +} + +export const capIdsInKindOrder = ( + caps: readonly T[], +): T["id"][] => + groupCapsByKind(caps).flatMap((group) => group.caps.map((cap) => cap.id)); + +export const capKindCountsFromTotals = ( + totals: { count: number; images: number; notes: number } | undefined, +): CapKindCounts => ({ + videos: (totals?.count ?? 0) - (totals?.images ?? 0) - (totals?.notes ?? 0), + images: totals?.images ?? 0, + notes: totals?.notes ?? 0, +}); + +export const visibleNoteExcerpt = ( + cap: { + ownerId: string; + noteExcerpt?: string | null; + hasPassword?: boolean; + }, + viewerId: string | null | undefined, + hasInheritedPassword: boolean, +) => + cap.ownerId === viewerId || !(cap.hasPassword || hasInheritedPassword) + ? (cap.noteExcerpt ?? null) + : null; diff --git a/apps/web/lib/folder.ts b/apps/web/lib/folder.ts index 171d445add9..b6a30a76483 100644 --- a/apps/web/lib/folder.ts +++ b/apps/web/lib/folder.ts @@ -8,6 +8,7 @@ import { spaces, spaceVideos, users, + videoNotes, videos, videoUploads, } from "@cap/database/schema"; @@ -21,6 +22,7 @@ import { CurrentUser, Folder } from "@cap/web-domain"; import { and, desc, eq, inArray, isNull } from "drizzle-orm"; import { sql } from "drizzle-orm/sql"; import { Effect } from "effect"; +import { visibleNoteExcerpt } from "./cap-kind"; export const getFolderById = Effect.fn(function* (folderId: string) { if (!folderId) throw new Error("Folder ID is required"); @@ -178,6 +180,7 @@ export const getVideosByFolderId = Effect.fn(function* ( if (!folderId) throw new Error("Folder ID is required"); const db = yield* Database; const imageUploads = yield* ImageUploads; + const viewer = yield* CurrentUser; const videoData = yield* db.use((db) => { const folderVideosPage = @@ -268,6 +271,8 @@ export const getVideosByFolderId = Effect.fn(function* ( sql`${videoUploads.videoId} IS NOT NULL AND ${videos.isScreenshot} = false`.mapWith( Boolean, ), + isNote: videos.isNote, + noteExcerpt: videoNotes.excerpt, }) .from(videos) .innerJoin(folderVideosPage, eq(videos.id, folderVideosPage.id)) @@ -278,6 +283,7 @@ export const getVideosByFolderId = Effect.fn(function* ( ) .leftJoin(users, eq(videos.ownerId, users.id)) .leftJoin(videoUploads, eq(videos.id, videoUploads.videoId)) + .leftJoin(videoNotes, eq(videos.id, videoNotes.videoId)) .groupBy( videos.id, videos.ownerId, @@ -287,6 +293,8 @@ export const getVideosByFolderId = Effect.fn(function* ( videos.metadata, videos.source, videos.isScreenshot, + videos.isNote, + videoNotes.excerpt, videos.duration, videos.settings, videos.orgId, @@ -378,6 +386,12 @@ export const getVideosByFolderId = Effect.fn(function* ( source: video.source, duration: video.duration ?? undefined, isScreenshot: video.isScreenshot, + isNote: video.isNote, + noteExcerpt: visibleNoteExcerpt( + video, + viewer.id, + rules.hasInheritedPassword, + ), hasPassword: video.hasPassword, hasInheritedPassword: rules.hasInheritedPassword, inheritedPasswordSources: rules.inheritedPasswordSources, diff --git a/apps/web/lib/meetings/budgets.ts b/apps/web/lib/meetings/budgets.ts index 899f0e5fa3f..b521543a336 100644 --- a/apps/web/lib/meetings/budgets.ts +++ b/apps/web/lib/meetings/budgets.ts @@ -9,12 +9,13 @@ import { import { consumeDailyAudioUnits } from "./audio-usage"; import { MEETING_CLIP_SAMPLE_RATE } from "./wav"; -export type MeetingEndpoint = "transcribe" | "notes" | "ask"; +export type MeetingEndpoint = "transcribe" | "notes" | "ask" | "share"; export const MEETING_REQUEST_RULE_IDS = { transcribe: RATE_LIMIT_IDS.MEETINGS_TRANSCRIBE, notes: RATE_LIMIT_IDS.MEETINGS_NOTES, ask: RATE_LIMIT_IDS.MEETINGS_ASK, + share: RATE_LIMIT_IDS.MEETINGS_SHARE, } as const satisfies Record; export const MEETING_AUDIO_UNIT_SECONDS = 10; @@ -69,7 +70,7 @@ export async function consumeMeetingRequestBudget( return { limited: false }; } -// Notes and Ask send the meeting with every request. On top of the unit paid +// Notes, Ask and Share send the meeting with every request. On top of the unit paid // on arrival, a request is charged one more unit per started // MEETING_BODY_UNIT_BYTES of body past the first, against the same rule. A // model never reads more tokens than the UTF-8 bytes it is sent. @@ -80,7 +81,7 @@ export function meetingBodyUnits(bytes: number): number { } export async function consumeMeetingBodyBudget( - endpoint: "notes" | "ask", + endpoint: "notes" | "ask" | "share", userId: string, bodyBytes: number, headers: Headers, diff --git a/apps/web/lib/meetings/schemas.ts b/apps/web/lib/meetings/schemas.ts index 1ce61e2186a..b4261f68f31 100644 --- a/apps/web/lib/meetings/schemas.ts +++ b/apps/web/lib/meetings/schemas.ts @@ -159,6 +159,82 @@ export const meetingAskRequestSchema = z export type MeetingAskRequest = z.infer; +export const MEETING_SHARE_TITLE_MAX_CHARS = 300; +export const MEETING_SHARE_SUMMARY_MAX_CHARS = 100_000; +export const MEETING_SHARE_NOTES_MAX_CHARS = 50_000; +export const MEETING_SHARE_TRANSCRIPT_MAX_TURNS = 20_000; +export const MEETING_SHARE_TURN_MAX_CHARS = 20_000; +export const MEETING_SHARE_MAX_DURATION_SECONDS = 48 * 60 * 60; + +export const meetingShareDocumentIdSchema = z + .string() + .min(1) + .max(64) + .regex(/^[A-Za-z0-9_-]+$/); + +const shareText = (max: number) => + text(max).refine( + (value) => !value.includes("\u0000"), + "must not contain null characters", + ); + +export const meetingShareRequestSchema = z + .object({ + documentId: meetingShareDocumentIdSchema, + orgId: z + .string() + .min(1) + .max(64) + .regex(/^[A-Za-z0-9_-]+$/) + .optional(), + title: shareText(MEETING_SHARE_TITLE_MAX_CHARS).default(""), + summaryMarkdown: shareText(MEETING_SHARE_SUMMARY_MAX_CHARS).default(""), + notesMarkdown: shareText(MEETING_SHARE_NOTES_MAX_CHARS).default(""), + transcript: z + .array( + z.object({ + speaker: shareText(200), + startMs: z + .number() + .int() + .min(0) + .max(MEETING_SHARE_MAX_DURATION_SECONDS * 1000), + text: shareText(MEETING_SHARE_TURN_MAX_CHARS), + }), + ) + .max(MEETING_SHARE_TRANSCRIPT_MAX_TURNS) + .optional(), + participants: z.array(shareText(200)).max(100).default([]), + startedAt: z.iso.datetime({ offset: true }).optional(), + durationSeconds: z + .number() + .min(0) + .max(MEETING_SHARE_MAX_DURATION_SECONDS) + .optional(), + }) + .refine( + (value) => + value.summaryMarkdown.trim().length > 0 || + value.notesMarkdown.trim().length > 0, + { message: "summaryMarkdown or notesMarkdown is required" }, + ) + .refine( + (value) => { + let total = 0; + for (const turn of value.transcript ?? []) { + total += turn.text.length; + if (total > MEETING_NOTES_TRANSCRIPT_MAX_CHARS) return false; + } + return true; + }, + { + path: ["transcript"], + message: `must be at most ${MEETING_NOTES_TRANSCRIPT_MAX_CHARS} characters in total`, + }, + ); + +export type MeetingShareRequest = z.infer; + export type ParseResult = | { ok: true; data: T } | { ok: false; detail: string }; diff --git a/apps/web/lib/meetings/share-content.ts b/apps/web/lib/meetings/share-content.ts new file mode 100644 index 00000000000..c6670c7b11f --- /dev/null +++ b/apps/web/lib/meetings/share-content.ts @@ -0,0 +1,45 @@ +export const NOTE_TITLE_COLUMN_CHARS = 255; +export const NOTE_EXCERPT_CHARS = 360; +const UNTITLED_NOTE = "Untitled note"; + +export const transferredNoteDocumentId = (videoId: string) => + `transferred-${videoId}`; + +const firstCharacters = (value: string, max: number) => + Array.from(value).slice(0, max).join(""); + +export function noteTitle(title: string): string { + const trimmed = title.replace(/\s+/g, " ").trim(); + return firstCharacters(trimmed || UNTITLED_NOTE, NOTE_TITLE_COLUMN_CHARS); +} + +function withoutTags(value: string): string { + let current = value; + for (;;) { + const next = current.replace(/<[^>]*>/g, ""); + if (next === current) return next.replace(/[<>]/g, ""); + current = next; + } +} + +export function noteExcerpt(markdown: string): string { + const text = markdown + .replace(/```[\s\S]*?```/g, " ") + .split("\n") + .map((line) => line.trim()) + .filter( + (line) => line && !/^#{1,6}\s/.test(line) && !/^[-*_]{3,}$/.test(line), + ) + .map((line) => + line + .replace(/^>+\s*/, "") + .replace(/^([-*+]|\d+[.)])\s+(\[[ xX]\]\s+)?/, "") + .replace(/!?\[([^\]]*)\]\([^)]*\)/g, "$1") + .replace(/[*_~`]+/g, ""), + ) + .map(withoutTags) + .join(" ") + .replace(/\s+/g, " ") + .trim(); + return firstCharacters(text, NOTE_EXCERPT_CHARS); +} diff --git a/apps/web/lib/meetings/share.ts b/apps/web/lib/meetings/share.ts new file mode 100644 index 00000000000..47df38488b1 --- /dev/null +++ b/apps/web/lib/meetings/share.ts @@ -0,0 +1,228 @@ +import { db } from "@cap/database"; +import { nanoId } from "@cap/database/helpers"; +import { ensurePersonalOrganization } from "@cap/database/organization-pointer"; +import { + organizationMembers, + organizations, + videoNotes, + videos, +} from "@cap/database/schema"; +import { getNewVideoPublic } from "@cap/database/video-sharing-default"; +import { makeCurrentUserLayer, Videos } from "@cap/web-backend"; +import { type Organisation, type User, Video } from "@cap/web-domain"; +import { and, eq, isNull } from "drizzle-orm"; +import { Effect } from "effect"; +import { runPromise } from "@/lib/server"; +import type { MeetingShareRequest } from "./schemas"; +import { noteExcerpt, noteTitle } from "./share-content"; + +type ShareUser = Parameters[0] & { + id: User.UserId; + defaultOrgId?: Organisation.OrganisationId | null; +}; + +export type SharedNote = { + id: Video.VideoId; + orgId: Organisation.OrganisationId; + created: boolean; +}; + +export type ShareNoteResult = SharedNote | "no_organization" | "conflict"; + +const isDuplicateKey = (error: unknown): boolean => { + const value = error as { code?: string; errno?: number; cause?: unknown }; + if (value?.code === "ER_DUP_ENTRY" || value?.errno === 1062) return true; + return value?.cause !== undefined && isDuplicateKey(value.cause); +}; + +function noteContent(input: MeetingShareRequest) { + const summaryMarkdown = input.summaryMarkdown.trim(); + const notesMarkdown = input.notesMarkdown.trim(); + const participants = Array.from( + new Set( + input.participants + .map((name) => name.replace(/\s+/g, " ").trim()) + .filter((name) => name.length > 0), + ), + ); + const transcript = (input.transcript ?? []) + .map((turn) => ({ + speaker: turn.speaker.replace(/\s+/g, " ").trim(), + startMs: turn.startMs, + text: turn.text.trim(), + })) + .filter((turn) => turn.text.length > 0); + return { + excerpt: noteExcerpt(summaryMarkdown || notesMarkdown), + summaryMarkdown: summaryMarkdown || null, + notesMarkdown: notesMarkdown || null, + transcript: transcript.length > 0 ? transcript : null, + participants, + meetingStartedAt: input.startedAt ? new Date(input.startedAt) : null, + }; +} + +async function resolveShareOrganization( + user: ShareUser, + requested: string | undefined, +): Promise { + const columns = { id: organizations.id, createdAt: organizations.createdAt }; + const [owned, joined] = await Promise.all([ + db() + .select(columns) + .from(organizations) + .where( + and( + eq(organizations.ownerId, user.id), + isNull(organizations.tombstoneAt), + ), + ), + db() + .select(columns) + .from(organizationMembers) + .innerJoin( + organizations, + eq(organizations.id, organizationMembers.organizationId), + ) + .where( + and( + eq(organizationMembers.userId, user.id), + isNull(organizations.tombstoneAt), + ), + ), + ]); + const ids = Array.from( + new Map([...owned, ...joined].map((row) => [row.id, row])).values(), + ) + .sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime()) + .map((row) => row.id); + if (ids.length === 0) { + const created = await ensurePersonalOrganization(db(), user.id); + if (created) ids.push(created.id); + } + + const requestedId = ids.find((id) => id === requested); + if (requestedId) return requestedId; + if (user.defaultOrgId && ids.includes(user.defaultOrgId)) + return user.defaultOrgId; + return ids[0] ?? null; +} + +async function updateSharedNote( + userId: User.UserId, + input: MeetingShareRequest, +): Promise | "conflict" | null> { + return db().transaction(async (tx) => { + const [row] = await tx + .select({ + videoId: videoNotes.videoId, + capOwnerId: videos.ownerId, + orgId: videos.orgId, + }) + .from(videoNotes) + .leftJoin(videos, eq(videos.id, videoNotes.videoId)) + .where( + and( + eq(videoNotes.ownerId, userId), + eq(videoNotes.documentId, input.documentId), + ), + ) + .for("update"); + if (!row) return null; + if (!row.capOwnerId || !row.orgId) { + await tx.delete(videoNotes).where(eq(videoNotes.videoId, row.videoId)); + return null; + } + if (row.capOwnerId !== userId) return "conflict"; + + await tx + .update(videos) + .set({ + name: noteTitle(input.title), + duration: input.durationSeconds ?? null, + }) + .where(eq(videos.id, row.videoId)); + await tx + .update(videoNotes) + .set(noteContent(input)) + .where(eq(videoNotes.videoId, row.videoId)); + return { id: row.videoId, orgId: row.orgId }; + }); +} + +export async function upsertSharedNote( + user: ShareUser, + input: MeetingShareRequest, +): Promise { + for (let attempt = 0; attempt < 2; attempt++) { + const existing = await updateSharedNote(user.id, input); + if (existing === "conflict") return "conflict"; + if (existing) return { ...existing, created: false }; + + const orgId = await resolveShareOrganization(user, input.orgId); + if (!orgId) return "no_organization"; + const isPublic = await getNewVideoPublic(orgId); + const id = Video.VideoId.make(nanoId()); + try { + await db().transaction(async (tx) => { + await tx.insert(videos).values({ + id, + ownerId: user.id, + orgId, + name: noteTitle(input.title), + isNote: true, + source: { type: "local" }, + transcriptionStatus: "SKIPPED", + public: isPublic, + duration: input.durationSeconds ?? null, + }); + await tx.insert(videoNotes).values({ + videoId: id, + ownerId: user.id, + documentId: input.documentId, + ...noteContent(input), + }); + }); + return { id, orgId, created: true }; + } catch (error) { + if (!isDuplicateKey(error)) throw error; + } + } + throw new Error("Note share could not be saved"); +} + +export async function deleteSharedNote( + user: ShareUser, + documentId: string, +): Promise { + const [row] = await db() + .select({ videoId: videoNotes.videoId, capOwnerId: videos.ownerId }) + .from(videoNotes) + .leftJoin(videos, eq(videos.id, videoNotes.videoId)) + .where( + and( + eq(videoNotes.ownerId, user.id), + eq(videoNotes.documentId, documentId), + ), + ) + .limit(1); + if (!row) return false; + if (!row.capOwnerId) { + await db().delete(videoNotes).where(eq(videoNotes.videoId, row.videoId)); + return true; + } + if (row.capOwnerId !== user.id) return false; + + return Effect.gen(function* () { + const service = yield* Videos; + yield* service.delete(row.videoId); + return true; + }).pipe( + Effect.provide(makeCurrentUserLayer(user)), + Effect.catchTags({ + VideoNotFoundError: () => Effect.succeed(false), + PolicyDenied: () => Effect.succeed(false), + }), + runPromise, + ); +} diff --git a/apps/web/lib/og/video-og.tsx b/apps/web/lib/og/video-og.tsx index 86e64c57554..c802924ebd8 100644 --- a/apps/web/lib/og/video-og.tsx +++ b/apps/web/lib/og/video-og.tsx @@ -25,8 +25,14 @@ export type VideoOgData = { screenshotUrl?: string; }; +export type NoteOgData = { + title: string; + ownerName?: string; +}; + export type VideoOgVariant = | { kind: "video"; video: VideoOgData } + | { kind: "note"; note: NoteOgData } | { kind: "locked" } | { kind: "password" } | { kind: "not-found" }; @@ -298,6 +304,60 @@ const videoLayout = ( ); }; +const noteLayout = ( + note: NoteOgData, + assets: Awaited>, +) => ( + +
+ +
+ + {note.title} + + {note.ownerName && ( +
+ + + {note.ownerName} + +
+ )} +
+
+
+ +); + const statusLayout = ( { heading, @@ -374,6 +434,8 @@ export async function renderVideoOg(variant: VideoOgVariant) { switch (variant.kind) { case "video": return videoLayout(variant.video, thumbnail, assets); + case "note": + return noteLayout(variant.note, assets); case "locked": return statusLayout( { @@ -413,7 +475,7 @@ export async function renderVideoOg(variant: VideoOgVariant) { }); } -export type VideoOgStatus = Exclude; +export type VideoOgStatus = Exclude; const statusImages = new Map>(); diff --git a/apps/web/lib/public-collections.ts b/apps/web/lib/public-collections.ts index bdced970dbf..8b80f10550d 100644 --- a/apps/web/lib/public-collections.ts +++ b/apps/web/lib/public-collections.ts @@ -490,6 +490,7 @@ async function getPublicSpaceVideos( eq(spaceVideos.spaceId, collection.id as Space.SpaceIdOrOrganisationId), isNull(spaceVideos.folderId), eq(videos.public, true), + eq(videos.isNote, false), isNull(organizations.tombstoneAt), videoPasswordPredicate( sql`${videos.id}`, @@ -535,6 +536,7 @@ async function getPublicSpaceFolderVideos( const where = and( eq(spaceVideos.folderId, collection.id as Folder.FolderId), eq(videos.public, true), + eq(videos.isNote, false), isNull(organizations.tombstoneAt), videoPasswordPredicate( sql`${videos.id}`, @@ -580,6 +582,7 @@ async function getPublicOrgFolderVideos( const where = and( eq(sharedVideos.folderId, collection.id as Folder.FolderId), eq(videos.public, true), + eq(videos.isNote, false), isNull(organizations.tombstoneAt), videoPasswordPredicate( sql`${videos.id}`, @@ -625,6 +628,7 @@ async function getPublicUserFolderVideos( const where = and( eq(videos.folderId, collection.id as Folder.FolderId), eq(videos.public, true), + eq(videos.isNote, false), isNull(organizations.tombstoneAt), videoPasswordPredicate( sql`${videos.id}`, @@ -727,6 +731,7 @@ async function getPublicSpaceFolderVideoCounts( and( inArray(spaceVideos.folderId, folderIds), eq(videos.public, true), + eq(videos.isNote, false), isNull(organizations.tombstoneAt), videoPasswordPredicate( sql`${videos.id}`, @@ -754,6 +759,7 @@ async function getPublicOrgFolderVideoCounts( and( inArray(sharedVideos.folderId, folderIds), eq(videos.public, true), + eq(videos.isNote, false), isNull(organizations.tombstoneAt), videoPasswordPredicate( sql`${videos.id}`, @@ -780,6 +786,7 @@ async function getPublicUserFolderVideoCounts( and( inArray(videos.folderId, folderIds), eq(videos.public, true), + eq(videos.isNote, false), isNull(organizations.tombstoneAt), videoPasswordPredicate( sql`${videos.id}`, diff --git a/apps/web/lib/public-share-video.ts b/apps/web/lib/public-share-video.ts index c4104a5cb79..88cfd70fecd 100644 --- a/apps/web/lib/public-share-video.ts +++ b/apps/web/lib/public-share-video.ts @@ -22,6 +22,7 @@ export type PublicShareVideoCandidate = { allowedEmailDomain: string | null; linkOpenToAnyone: boolean; isScreenshot: boolean; + isNote: boolean; hasActiveUpload: boolean; sourceType: | "MediaConvert" @@ -45,6 +46,7 @@ export type PublicShareVideo = Omit< | "allowedEmailDomain" | "linkOpenToAnyone" | "isScreenshot" + | "isNote" | "hasActiveUpload" | "jobStatus" | "skipProcessing" @@ -59,6 +61,7 @@ export const isPublicShareVideoCandidateEligible = ( ((video.allowedEmailDomain?.trim().length ?? 0) === 0 || video.linkOpenToAnyone) && !video.isScreenshot && + !video.isNote && !video.hasActiveUpload && (video.sourceType !== "MediaConvert" || video.jobStatus === "COMPLETE" || @@ -81,6 +84,7 @@ export async function getPublicShareVideo( videoSettings: videos.settings, organizationSettings: organizations.settings, isScreenshot: videos.isScreenshot, + isNote: videos.isNote, hasActiveUpload: sql`${videoUploads.videoId} IS NOT NULL AND ${videoUploads.phase} <> 'complete'`.mapWith( Boolean, diff --git a/apps/web/lib/queue-video-transcription.ts b/apps/web/lib/queue-video-transcription.ts index 3b78a446605..016ae25e658 100644 --- a/apps/web/lib/queue-video-transcription.ts +++ b/apps/web/lib/queue-video-transcription.ts @@ -46,6 +46,7 @@ export async function queueVideoTranscription( .select({ id: videos.ownerId, isScreenshot: videos.isScreenshot, + isNote: videos.isNote, stripeSubscriptionStatus: users.stripeSubscriptionStatus, thirdPartyStripeSubscriptionId: users.thirdPartyStripeSubscriptionId, }) @@ -59,6 +60,9 @@ export async function queueVideoTranscription( if (owner.isScreenshot) { return { success: true, message: "Screenshot does not need transcription" }; } + if (owner.isNote) { + return { success: true, message: "Note does not need transcription" }; + } return transcribeVideo( videoId, diff --git a/apps/web/lib/rate-limit.ts b/apps/web/lib/rate-limit.ts index 223aa08c67a..8113aba206e 100644 --- a/apps/web/lib/rate-limit.ts +++ b/apps/web/lib/rate-limit.ts @@ -276,6 +276,8 @@ export const RATE_LIMIT_IDS = { MEETINGS_NOTES: "rl_meetings_notes", /** Desktop meeting questions (LLM cost): one unit per request plus one per started 100 KB of body past the first. Suggested: 120 / 1h per key (user). */ MEETINGS_ASK: "rl_meetings_ask", + /** Desktop note share links: one unit per request plus one per started 100 KB of body past the first. Suggested: 120 / 1h per key (user). */ + MEETINGS_SHARE: "rl_meetings_share", /** Desktop meeting audio, charged one unit per started 10 s of audio (see `checkFirewallRateLimitUnits`). Suggested: 720 / 1h per key (user). Firewall windows stop at one hour; the daily cap is kept in the database (lib/meetings/audio-usage.ts). */ MEETINGS_AUDIO: "rl_meetings_audio", /** Desktop meeting requests whose sign-in was not accepted. Suggested: 60 / 1m per IP. */ @@ -355,6 +357,7 @@ const FALLBACK_RATE_LIMITS: Record = { }, [RATE_LIMIT_IDS.MEETINGS_NOTES]: { limit: 60, windowMs: 60 * MINUTE_MS }, [RATE_LIMIT_IDS.MEETINGS_ASK]: { limit: 120, windowMs: 60 * MINUTE_MS }, + [RATE_LIMIT_IDS.MEETINGS_SHARE]: { limit: 120, windowMs: 60 * MINUTE_MS }, [RATE_LIMIT_IDS.MEETINGS_AUDIO]: { limit: 5_760, windowMs: 24 * 60 * MINUTE_MS, diff --git a/apps/web/lib/select-all-view.ts b/apps/web/lib/select-all-view.ts index 72866017bbe..3b6c01328f5 100644 --- a/apps/web/lib/select-all-view.ts +++ b/apps/web/lib/select-all-view.ts @@ -1,7 +1,9 @@ +import type { CapKind } from "./cap-kind"; + export const MAX_SELECT_ALL_ITEMS = 5000; export type SelectAllView = - | { type: "personal" } + | { type: "personal"; kind?: CapKind } | { type: "archived" } | { type: "space"; spaceId: string } | { type: "organization"; organizationId: string }; diff --git a/apps/web/lib/share-video-metadata.ts b/apps/web/lib/share-video-metadata.ts index b782e22d10e..570ee2b1253 100644 --- a/apps/web/lib/share-video-metadata.ts +++ b/apps/web/lib/share-video-metadata.ts @@ -200,3 +200,38 @@ export const buildShareVideoMetadata = ({ }, }; }; + +export const buildShareNoteMetadata = ({ + videoId, + name, + webUrl, +}: Pick): Metadata => { + const shareUrl = new URL(`/s/${videoId}`, webUrl).toString(); + const ogImage = { + url: buildVideoOgImageUrl({ videoId, webUrl }), + width: 1200, + height: 630, + type: "image/png", + }; + const title = `${name} | Cap`; + const description = "Read this note on Cap"; + + return { + title, + description, + alternates: { canonical: shareUrl }, + openGraph: { + title, + description, + url: shareUrl, + type: "article", + images: [ogImage], + }, + twitter: { + card: "summary_large_image", + title, + description, + images: [ogImage.url], + }, + }; +}; diff --git a/apps/web/lib/space-video-order-query.ts b/apps/web/lib/space-video-order-query.ts index 6e150fa3978..487f0a29dea 100644 --- a/apps/web/lib/space-video-order-query.ts +++ b/apps/web/lib/space-video-order-query.ts @@ -45,6 +45,7 @@ export async function getSpaceRootVideoOrder( .select({ id: videos.id, isScreenshot: videos.isScreenshot, + isNote: videos.isNote, position: spaceVideoPositionSql, }) .from(spaceVideos) @@ -57,7 +58,12 @@ export async function getSpaceRootVideoOrder( isNull(organizations.tombstoneAt), ), ) - .groupBy(videos.id, videos.isScreenshot, videos.effectiveCreatedAt) + .groupBy( + videos.id, + videos.isScreenshot, + videos.isNote, + videos.effectiveCreatedAt, + ) .orderBy( ...spaceVideoOrderBy(order, { position: spaceVideoPositionSql, @@ -71,6 +77,6 @@ export async function getSpaceRootVideoOrder( : query.limit(options.limit)); return options.includeScreenshots === false - ? rows.filter((row) => !row.isScreenshot) + ? rows.filter((row) => !row.isScreenshot && !row.isNote) : rows; } diff --git a/apps/web/lib/space-video-order.ts b/apps/web/lib/space-video-order.ts index b4f8f572746..c00531abfce 100644 --- a/apps/web/lib/space-video-order.ts +++ b/apps/web/lib/space-video-order.ts @@ -68,6 +68,40 @@ export function reorderIds( return [...rest.slice(0, insertAt), ...block, ...rest.slice(insertAt)]; } +export function reorderIdsWithinGroups( + ordered: ReadonlyArray<{ id: string; group: string }>, + movedIds: readonly string[], + placement: ReorderPlacement, +): string[] { + const groupOf = new Map(ordered.map((row) => [row.id, row.group])); + const targetGroup = + placement.type === "before" || placement.type === "after" + ? groupOf.get(placement.targetId) + : undefined; + const reordered = new Map(); + for (const id of movedIds) { + const group = groupOf.get(id); + if (group === undefined || reordered.has(group)) continue; + if (targetGroup !== undefined && targetGroup !== group) continue; + reordered.set( + group, + reorderIds( + ordered.filter((row) => row.group === group).map((row) => row.id), + movedIds, + placement, + ), + ); + } + const taken = new Map(); + return ordered.map((row) => { + const next = reordered.get(row.group); + if (!next) return row.id; + const index = taken.get(row.group) ?? 0; + taken.set(row.group, index + 1); + return next[index] ?? row.id; + }); +} + // Positions are dense (0..n-1) in the new order. Only rows whose stored value // differs are returned, so a move near the top of a large space rewrites a // short range instead of the whole list. diff --git a/apps/web/lib/transcribe.ts b/apps/web/lib/transcribe.ts index abf35326711..2aab554d80f 100644 --- a/apps/web/lib/transcribe.ts +++ b/apps/web/lib/transcribe.ts @@ -93,6 +93,10 @@ export async function transcribeVideo( return { success: false, message: "Video information is missing" }; } + if (video.isNote) { + return { success: true, message: "Note does not need transcription" }; + } + if ( video.settings?.disableTranscript ?? result.orgSettings?.disableTranscript diff --git a/apps/web/lib/video-download-access.ts b/apps/web/lib/video-download-access.ts index 867ce034369..18e9933cdc7 100644 --- a/apps/web/lib/video-download-access.ts +++ b/apps/web/lib/video-download-access.ts @@ -89,7 +89,8 @@ export async function resolveVideoDownloadAccess({ return "member"; } - if (variant !== "current" || video.isScreenshot) return "denied"; + if (variant !== "current" || video.isScreenshot || video.isNote) + return "denied"; if (await isRateLimited(RATE_LIMIT_IDS.VIEWER_DOWNLOAD)) { return "rate_limited"; } diff --git a/apps/web/lib/video-pipeline-recovery.ts b/apps/web/lib/video-pipeline-recovery.ts index 217e995dc29..ea928c0f851 100644 --- a/apps/web/lib/video-pipeline-recovery.ts +++ b/apps/web/lib/video-pipeline-recovery.ts @@ -395,6 +395,7 @@ export async function recoverStalledVideoPipeline({ and( isNull(videoUploads.videoId), eq(videos.isScreenshot, false), + eq(videos.isNote, false), gte(videos.createdAt, recentBefore), lte(videos.updatedAt, staleBefore), or( @@ -426,6 +427,7 @@ export async function recoverStalledVideoPipeline({ and( isNull(videoUploads.videoId), eq(videos.isScreenshot, false), + eq(videos.isNote, false), eq(videos.transcriptionStatus, "COMPLETE"), gte(videos.createdAt, recentBefore), lte(videos.updatedAt, staleBefore), diff --git a/apps/web/workflows/agent-cap-operation.ts b/apps/web/workflows/agent-cap-operation.ts index 202dc811536..8fe21313958 100644 --- a/apps/web/workflows/agent-cap-operation.ts +++ b/apps/web/workflows/agent-cap-operation.ts @@ -300,6 +300,7 @@ async function deleteCapDatabase( .where(eq(Db.sharedVideos.videoId, videoId)); await tx.delete(Db.spaceVideos).where(eq(Db.spaceVideos.videoId, videoId)); await tx.delete(Db.videoEdits).where(eq(Db.videoEdits.videoId, videoId)); + await tx.delete(Db.videoNotes).where(eq(Db.videoNotes.videoId, videoId)); await tx.delete(Db.videos).where(eq(Db.videos.id, videoId)); const now = new Date(); await tx diff --git a/apps/web/workflows/transfer-organization-content.ts b/apps/web/workflows/transfer-organization-content.ts index 63006f408d0..14f5018c3c9 100644 --- a/apps/web/workflows/transfer-organization-content.ts +++ b/apps/web/workflows/transfer-organization-content.ts @@ -25,6 +25,7 @@ import { MAX_CONTENT_TRANSFER_VIDEOS, moveContentTransferSourceKeys, } from "@/lib/content-transfer"; +import { transferredNoteDocumentId } from "@/lib/meetings/share-content"; import { enqueueVideoStorageNameSync } from "@/lib/sync-video-storage-names"; import { runWorkflowPromise } from "@/lib/workflow-runtime"; @@ -806,6 +807,13 @@ export async function transferOneVideo( .where(eq(Db.videos.id, videoId)); if (item.sourceOwnerId !== payload.targetUserId) { + await tx + .update(Db.videoNotes) + .set({ + ownerId: targetUserId, + documentId: transferredNoteDocumentId(videoId), + }) + .where(eq(Db.videoNotes.videoId, videoId)); await tx .update(Db.videoUploads) .set({ diff --git a/packages/database/loops/activation.ts b/packages/database/loops/activation.ts index ebe3f04fb2a..21dbab91cd6 100644 --- a/packages/database/loops/activation.ts +++ b/packages/database/loops/activation.ts @@ -38,11 +38,11 @@ const activationSignals = ` export const activationQuery = ` SELECT ${activationSignals} - WHERE v.ownerId = ? AND v.isScreenshot = 0 + WHERE v.ownerId = ? AND v.isScreenshot = 0 AND v.isNote = 0 `; export const batchActivationQuery = (users: number) => ` SELECT v.ownerId AS userId, ${activationSignals} - WHERE v.ownerId IN (${placeholders(users)}) AND v.isScreenshot = 0 + WHERE v.ownerId IN (${placeholders(users)}) AND v.isScreenshot = 0 AND v.isNote = 0 GROUP BY v.ownerId `; diff --git a/packages/database/migrations/0068_concerned_blue_marvel.sql b/packages/database/migrations/0068_concerned_blue_marvel.sql new file mode 100644 index 00000000000..657458ef760 --- /dev/null +++ b/packages/database/migrations/0068_concerned_blue_marvel.sql @@ -0,0 +1,19 @@ +CREATE TABLE `video_notes` ( + `videoId` varchar(15) NOT NULL, + `ownerId` varchar(15) NOT NULL, + `documentId` varchar(64) NOT NULL, + `excerpt` varchar(512) NOT NULL DEFAULT '', + `summaryMarkdown` mediumtext, + `notesMarkdown` mediumtext, + `transcript` json, + `participants` json, + `meetingStartedAt` timestamp, + `createdAt` timestamp NOT NULL DEFAULT (now()), + `updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP, + CONSTRAINT `video_notes_videoId` PRIMARY KEY(`videoId`), + CONSTRAINT `owner_document_idx` UNIQUE(`ownerId`,`documentId`) +); +--> statement-breakpoint +ALTER TABLE `videos` ADD `isNote` boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE `video_notes` ADD CONSTRAINT `video_notes_videoId_videos_id_fk` FOREIGN KEY (`videoId`) REFERENCES `videos`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +CREATE INDEX `org_owner_folder_archived_kind_effective_idx` ON `videos` (`orgId`,`ownerId`,`folderId`,`archivedAt`,`isNote`,`isScreenshot`,`effectiveCreatedAt`); \ No newline at end of file diff --git a/packages/database/migrations/meta/0068_snapshot.json b/packages/database/migrations/meta/0068_snapshot.json new file mode 100644 index 00000000000..4501dd676e3 --- /dev/null +++ b/packages/database/migrations/meta/0068_snapshot.json @@ -0,0 +1,6909 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "6cdb1751-a6e6-47b8-89d8-f8a9628a174c", + "prevId": "6b499e71-fe96-4123-8a0a-6efafb6c93ac", + "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": {} + }, + "auth_challenges": { + "name": "auth_challenges", + "columns": { + "id": { + "name": "id", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "userId": { + "name": "userId", + "type": "varchar(15)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "purpose": { + "name": "purpose", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "secretHash": { + "name": "secretHash", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "attempts": { + "name": "attempts", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "expiresAt": { + "name": "expiresAt", + "type": "datetime", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "secret_hash_idx": { + "name": "secret_hash_idx", + "columns": ["secretHash"], + "isUnique": true + }, + "user_purpose_idx": { + "name": "user_purpose_idx", + "columns": ["userId", "purpose"], + "isUnique": false + }, + "expires_at_idx": { + "name": "expires_at_idx", + "columns": ["expiresAt"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "auth_challenges_id": { + "name": "auth_challenges_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 + }, + "owner_idx": { + "name": "owner_idx", + "columns": ["ownerId"], + "isUnique": false + }, + "auto_top_up_idx": { + "name": "auto_top_up_idx", + "columns": ["autoTopUpEnabled"], + "isUnique": false + } + }, + "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_created_idx": { + "name": "account_created_idx", + "columns": ["accountId", "createdAt"], + "isUnique": false + }, + "account_ref_dedup_idx": { + "name": "account_ref_dedup_idx", + "columns": ["accountId", "referenceId", "referenceType"], + "isUnique": false + }, + "reference_type_id_idx": { + "name": "reference_type_id_idx", + "columns": ["referenceType", "referenceId"], + "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_delivery_daily": { + "name": "developer_delivery_daily", + "columns": { + "appId": { + "name": "appId", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tier": { + "name": "tier", + "type": "varchar(8)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "seconds": { + "name": "seconds", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "bytes": { + "name": "bytes", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "requests": { + "name": "requests", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "abandonedBytes": { + "name": "abandonedBytes", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "final": { + "name": "final", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "finalizedAt": { + "name": "finalizedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "day_idx": { + "name": "day_idx", + "columns": ["day"], + "isUnique": false + } + }, + "foreignKeys": { + "developer_delivery_daily_appId_developer_apps_id_fk": { + "name": "developer_delivery_daily_appId_developer_apps_id_fk", + "tableFrom": "developer_delivery_daily", + "tableTo": "developer_apps", + "columnsFrom": ["appId"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "developer_delivery_daily_appId_day_tier_pk": { + "name": "developer_delivery_daily_appId_day_tier_pk", + "columns": ["appId", "day", "tier"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "developer_delivery_log_files": { + "name": "developer_delivery_log_files", + "columns": { + "logFile": { + "name": "logFile", + "type": "varchar(191)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "etag": { + "name": "etag", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "logHour": { + "name": "logHour", + "type": "datetime", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "parts": { + "name": "parts", + "type": "json", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "processedAt": { + "name": "processedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "log_hour_idx": { + "name": "log_hour_idx", + "columns": ["logHour"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "developer_delivery_log_files_logFile": { + "name": "developer_delivery_log_files_logFile", + "columns": ["logFile"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "developer_transcripts": { + "name": "developer_transcripts", + "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'" + }, + "status": { + "name": "status", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sourceType": { + "name": "sourceType", + "type": "varchar(8)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sourceUrl": { + "name": "sourceUrl", + "type": "varchar(2048)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "videoId": { + "name": "videoId", + "type": "varchar(15)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "requestedAt": { + "name": "requestedAt", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "s3Key": { + "name": "s3Key", + "type": "varchar(512)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "resultKey": { + "name": "resultKey", + "type": "varchar(512)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "sourceBytes": { + "name": "sourceBytes", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "durationSeconds": { + "name": "durationSeconds", + "type": "float", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "requestedLanguage": { + "name": "requestedLanguage", + "type": "varchar(16)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "language": { + "name": "language", + "type": "varchar(16)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "text": { + "name": "text", + "type": "mediumtext", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "wordCount": { + "name": "wordCount", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reservedMicroCredits": { + "name": "reservedMicroCredits", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "billedMicroCredits": { + "name": "billedMicroCredits", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "errorCode": { + "name": "errorCode", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "errorMessage": { + "name": "errorMessage", + "type": "varchar(512)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "runId": { + "name": "runId", + "type": "varchar(32)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "queuedAt": { + "name": "queuedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "startedAt": { + "name": "startedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "completedAt": { + "name": "completedAt", + "type": "timestamp", + "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": { + "dev_transcripts_app_list_idx": { + "name": "dev_transcripts_app_list_idx", + "columns": ["appId", "deletedAt", "createdAt", "id"], + "isUnique": false + }, + "dev_transcripts_app_user_idx": { + "name": "dev_transcripts_app_user_idx", + "columns": ["appId", "externalUserId", "createdAt"], + "isUnique": false + }, + "dev_transcripts_app_status_idx": { + "name": "dev_transcripts_app_status_idx", + "columns": ["appId", "status", "createdAt"], + "isUnique": false + }, + "dev_transcripts_status_updated_idx": { + "name": "dev_transcripts_status_updated_idx", + "columns": ["status", "updatedAt"], + "isUnique": false + }, + "dev_transcripts_app_completed_idx": { + "name": "dev_transcripts_app_completed_idx", + "columns": [ + "appId", + "status", + "completedAt", + "durationSeconds", + "billedMicroCredits" + ], + "isUnique": false + }, + "dev_transcripts_app_status_held_idx": { + "name": "dev_transcripts_app_status_held_idx", + "columns": [ + "appId", + "status", + "createdAt", + "deletedAt", + "reservedMicroCredits" + ], + "isUnique": false + }, + "dev_transcripts_app_video_idx": { + "name": "dev_transcripts_app_video_idx", + "columns": ["appId", "videoId", "requestedAt", "id"], + "isUnique": false + } + }, + "foreignKeys": { + "developer_transcripts_appId_developer_apps_id_fk": { + "name": "developer_transcripts_appId_developer_apps_id_fk", + "tableFrom": "developer_transcripts", + "tableTo": "developer_apps", + "columnsFrom": ["appId"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "developer_transcripts_id": { + "name": "developer_transcripts_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "developer_video_imports": { + "name": "developer_video_imports", + "columns": { + "videoId": { + "name": "videoId", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "appId": { + "name": "appId", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "keyId": { + "name": "keyId", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sourceUrl": { + "name": "sourceUrl", + "type": "varchar(2048)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'downloading'" + }, + "bytes": { + "name": "bytes", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "errorCode": { + "name": "errorCode", + "type": "varchar(32)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "startedAt": { + "name": "startedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "finishedAt": { + "name": "finishedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "dev_imports_app_state_idx": { + "name": "dev_imports_app_state_idx", + "columns": ["appId", "state"], + "isUnique": false + }, + "dev_imports_key_created_idx": { + "name": "dev_imports_key_created_idx", + "columns": ["keyId", "createdAt"], + "isUnique": false + } + }, + "foreignKeys": { + "developer_video_imports_appId_developer_apps_id_fk": { + "name": "developer_video_imports_appId_developer_apps_id_fk", + "tableFrom": "developer_video_imports", + "tableTo": "developer_apps", + "columnsFrom": ["appId"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "developer_video_imports_videoId": { + "name": "developer_video_imports_videoId", + "columns": ["videoId"] + } + }, + "uniqueConstraints": {}, + "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 + }, + "status": { + "name": "status", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'uploading'" + }, + "playbackId": { + "name": "playbackId", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "maxResolutionTier": { + "name": "maxResolutionTier", + "type": "varchar(8)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'1080p'" + }, + "renditions": { + "name": "renditions", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "storedBytes": { + "name": "storedBytes", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "errorReason": { + "name": "errorReason", + "type": "varchar(512)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "processing": { + "name": "processing", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "storagePaidUntil": { + "name": "storagePaidUntil", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "deletedAt": { + "name": "deletedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "filesDeletedAt": { + "name": "filesDeletedAt", + "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 + }, + "playback_id_idx": { + "name": "playback_id_idx", + "columns": ["playbackId"], + "isUnique": true + }, + "files_pending_idx": { + "name": "files_pending_idx", + "columns": ["filesDeletedAt", "deletedAt"], + "isUnique": false + }, + "app_storage_idx": { + "name": "app_storage_idx", + "columns": [ + "appId", + "deletedAt", + "status", + "maxResolutionTier", + "width", + "height", + "storagePaidUntil", + "duration", + "createdAt" + ], + "isUnique": false + }, + "first_month_due_idx": { + "name": "first_month_due_idx", + "columns": ["storagePaidUntil", "status", "createdAt"], + "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": {} + }, + "developer_webhook_endpoints": { + "name": "developer_webhook_endpoints", + "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 + }, + "url": { + "name": "url", + "type": "varchar(2048)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "secretPrefix": { + "name": "secretPrefix", + "type": "varchar(12)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "encryptedSecret": { + "name": "encryptedSecret", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "events": { + "name": "events", + "type": "json", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "disabledReason": { + "name": "disabledReason", + "type": "varchar(32)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "lastDeliveryAt": { + "name": "lastDeliveryAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "lastDeliveryStatus": { + "name": "lastDeliveryStatus", + "type": "varchar(16)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "lastResponseStatus": { + "name": "lastResponseStatus", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "lastErrorCode": { + "name": "lastErrorCode", + "type": "varchar(32)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "consecutiveFailures": { + "name": "consecutiveFailures", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "failingSince": { + "name": "failingSince", + "type": "timestamp", + "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": { + "dev_webhooks_app_list_idx": { + "name": "dev_webhooks_app_list_idx", + "columns": ["appId", "deletedAt", "createdAt", "id"], + "isUnique": false + } + }, + "foreignKeys": { + "developer_webhook_endpoints_appId_developer_apps_id_fk": { + "name": "developer_webhook_endpoints_appId_developer_apps_id_fk", + "tableFrom": "developer_webhook_endpoints", + "tableTo": "developer_apps", + "columnsFrom": ["appId"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "developer_webhook_endpoints_id": { + "name": "developer_webhook_endpoints_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "directory_users": { + "name": "directory_users", + "columns": { + "id": { + "name": "id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organizationId": { + "name": "organizationId", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "directoryId": { + "name": "directoryId", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "userId": { + "name": "userId", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "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": { + "directory_users_organization_id_idx": { + "name": "directory_users_organization_id_idx", + "columns": ["organizationId"], + "isUnique": false + }, + "directory_users_user_org_idx": { + "name": "directory_users_user_org_idx", + "columns": ["userId", "organizationId"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "directory_users_id": { + "name": "directory_users_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "email_change_requests": { + "name": "email_change_requests", + "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 + }, + "newEmail": { + "name": "newEmail", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "codeHash": { + "name": "codeHash", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "attempts": { + "name": "attempts", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "expiresAt": { + "name": "expiresAt", + "type": "datetime", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "user_id_idx": { + "name": "user_id_idx", + "columns": ["userId"], + "isUnique": false + }, + "expires_at_idx": { + "name": "expires_at_idx", + "columns": ["expiresAt"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "email_change_requests_id": { + "name": "email_change_requests_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": {} + }, + "loom_migration_imports": { + "name": "loom_migration_imports", + "columns": { + "videoId": { + "name": "videoId", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "requestId": { + "name": "requestId", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "datetime", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "loom_migration_imports_request_idx": { + "name": "loom_migration_imports_request_idx", + "columns": ["requestId"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "loom_migration_imports_videoId": { + "name": "loom_migration_imports_videoId", + "columns": ["videoId"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "loom_migration_requests": { + "name": "loom_migration_requests", + "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 + }, + "activeOrganizationId": { + "name": "activeOrganizationId", + "type": "varchar(15)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "requestedByUserId": { + "name": "requestedByUserId", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspaceName": { + "name": "workspaceName", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customerNote": { + "name": "customerNote", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customerReply": { + "name": "customerReply", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "invitedAt": { + "name": "invitedAt", + "type": "datetime", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "capMessage": { + "name": "capMessage", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expectedVideoCount": { + "name": "expectedVideoCount", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "importedVideoCount": { + "name": "importedVideoCount", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "queuedVideoCount": { + "name": "queuedVideoCount", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "activeImportCount": { + "name": "activeImportCount", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "activeImportLeaseToken": { + "name": "activeImportLeaseToken", + "type": "varchar(36)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "activeImportLeaseUntil": { + "name": "activeImportLeaseUntil", + "type": "datetime", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "lastOperatorUserId": { + "name": "lastOperatorUserId", + "type": "varchar(15)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "lastOperatorAt": { + "name": "lastOperatorAt", + "type": "datetime", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "completedAt": { + "name": "completedAt", + "type": "datetime", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "datetime", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "datetime", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "loom_migration_active_org_idx": { + "name": "loom_migration_active_org_idx", + "columns": ["activeOrganizationId"], + "isUnique": true + }, + "loom_migration_org_created_idx": { + "name": "loom_migration_org_created_idx", + "columns": ["organizationId", "createdAt"], + "isUnique": false + }, + "loom_migration_status_created_idx": { + "name": "loom_migration_status_created_idx", + "columns": ["status", "createdAt"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "loom_migration_requests_id": { + "name": "loom_migration_requests_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": {} + }, + "mcp_oauth_clients": { + "name": "mcp_oauth_clients", + "columns": { + "id": { + "name": "id", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "clientId": { + "name": "clientId", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "clientName": { + "name": "clientName", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "redirectUris": { + "name": "redirectUris", + "type": "json", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "activatedAt": { + "name": "activatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "client_id_idx": { + "name": "client_id_idx", + "columns": ["clientId"], + "isUnique": true + }, + "inactive_created_at_idx": { + "name": "inactive_created_at_idx", + "columns": ["activatedAt", "createdAt"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "mcp_oauth_clients_id": { + "name": "mcp_oauth_clients_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "mcp_oauth_codes": { + "name": "mcp_oauth_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 + }, + "clientId": { + "name": "clientId", + "type": "varchar(128)", + "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 + }, + "resource": { + "name": "resource", + "type": "varchar(512)", + "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_consumed_idx": { + "name": "user_consumed_idx", + "columns": ["userId", "consumedAt"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "mcp_oauth_codes_id": { + "name": "mcp_oauth_codes_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "mcp_oauth_registration_quotas": { + "name": "mcp_oauth_registration_quotas", + "columns": { + "windowId": { + "name": "windowId", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "registrations": { + "name": "registrations", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "expiresAt": { + "name": "expiresAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "expires_at_idx": { + "name": "expires_at_idx", + "columns": ["expiresAt"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "mcp_oauth_registration_quotas_windowId": { + "name": "mcp_oauth_registration_quotas_windowId", + "columns": ["windowId"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "mcp_oauth_tokens": { + "name": "mcp_oauth_tokens", + "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 + }, + "clientId": { + "name": "clientId", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "familyId": { + "name": "familyId", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "resource": { + "name": "resource", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "accessHash": { + "name": "accessHash", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "refreshHash": { + "name": "refreshHash", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "accessExpiresAt": { + "name": "accessExpiresAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "refreshExpiresAt": { + "name": "refreshExpiresAt", + "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())" + } + }, + "indexes": { + "access_hash_idx": { + "name": "access_hash_idx", + "columns": ["accessHash"], + "isUnique": true + }, + "refresh_hash_idx": { + "name": "refresh_hash_idx", + "columns": ["refreshHash"], + "isUnique": true + }, + "family_id_idx": { + "name": "family_id_idx", + "columns": ["familyId"], + "isUnique": false + }, + "user_revoked_idx": { + "name": "user_revoked_idx", + "columns": ["userId", "revokedAt"], + "isUnique": false + }, + "client_active_idx": { + "name": "client_active_idx", + "columns": ["clientId", "revokedAt", "refreshExpiresAt"], + "isUnique": false + }, + "refresh_expires_at_idx": { + "name": "refresh_expires_at_idx", + "columns": ["refreshExpiresAt"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "mcp_oauth_tokens_id": { + "name": "mcp_oauth_tokens_id", + "columns": ["id"] + } + }, + "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": {} + }, + "meeting_audio_usage": { + "name": "meeting_audio_usage", + "columns": { + "userId": { + "name": "userId", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "units": { + "name": "units", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "meeting_audio_usage_userId_day_pk": { + "name": "meeting_audio_usage_userId_day_pk", + "columns": ["userId", "day"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "meeting_notes_trial_uses": { + "name": "meeting_notes_trial_uses", + "columns": { + "userId": { + "name": "userId", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "meetingId": { + "name": "meetingId", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slot": { + "name": "slot", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "notesRuns": { + "name": "notesRuns", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + }, + "askRuns": { + "name": "askRuns", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "startedAt": { + "name": "startedAt", + "type": "datetime", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "completedAt": { + "name": "completedAt", + "type": "datetime", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "datetime", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "user_slot_idx": { + "name": "user_slot_idx", + "columns": ["userId", "slot"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "meeting_notes_trial_uses_userId_meetingId_pk": { + "name": "meeting_notes_trial_uses_userId_meetingId_pk", + "columns": ["userId", "meetingId"] + } + }, + "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": {} + }, + "mobile_push_claims": { + "name": "mobile_push_claims", + "columns": { + "id": { + "name": "id", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": { + "created_at_idx": { + "name": "created_at_idx", + "columns": ["createdAt"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "mobile_push_claims_id": { + "name": "mobile_push_claims_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "mobile_push_tokens": { + "name": "mobile_push_tokens", + "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 + }, + "token": { + "name": "token", + "type": "varchar(200)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sessionHash": { + "name": "sessionHash", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "environment": { + "name": "environment", + "type": "varchar(10)", + "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": { + "token_idx": { + "name": "token_idx", + "columns": ["token"], + "isUnique": true + }, + "user_id_idx": { + "name": "user_id_idx", + "columns": ["userId"], + "isUnique": false + }, + "session_hash_idx": { + "name": "session_hash_idx", + "columns": ["sessionHash"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "mobile_push_tokens_id": { + "name": "mobile_push_tokens_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 + }, + "video_id_idx": { + "name": "video_id_idx", + "columns": ["videoId"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "notifications_id": { + "name": "notifications_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "organization_directory_sync": { + "name": "organization_directory_sync", + "columns": { + "organizationId": { + "name": "organizationId", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "requestedAt": { + "name": "requestedAt", + "type": "datetime", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "syncedAt": { + "name": "syncedAt", + "type": "datetime", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "leaseExpiresAt": { + "name": "leaseExpiresAt", + "type": "datetime", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "lastError": { + "name": "lastError", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "heldRemovals": { + "name": "heldRemovals", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "removalsApprovedAt": { + "name": "removalsApprovedAt", + "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": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "organization_directory_sync_organizationId": { + "name": "organization_directory_sync_organizationId", + "columns": ["organizationId"] + } + }, + "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())" + }, + "position": { + "name": "position", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "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": {} + }, + "user_passkeys": { + "name": "user_passkeys", + "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 + }, + "credentialId": { + "name": "credentialId", + "type": "varchar(1400)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credentialIdHash": { + "name": "credentialIdHash", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "publicKey": { + "name": "publicKey", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "counter": { + "name": "counter", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "transports": { + "name": "transports", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "deviceType": { + "name": "deviceType", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "backedUp": { + "name": "backedUp", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "confirmsIdentity": { + "name": "confirmsIdentity", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "aaguid": { + "name": "aaguid", + "type": "varchar(36)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "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": { + "credential_id_hash_idx": { + "name": "credential_id_hash_idx", + "columns": ["credentialIdHash"], + "isUnique": true + }, + "user_id_idx": { + "name": "user_id_idx", + "columns": ["userId"], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "user_passkeys_id": { + "name": "user_passkeys_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_notes": { + "name": "video_notes", + "columns": { + "videoId": { + "name": "videoId", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ownerId": { + "name": "ownerId", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "documentId": { + "name": "documentId", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "excerpt": { + "name": "excerpt", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "summaryMarkdown": { + "name": "summaryMarkdown", + "type": "mediumtext", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "notesMarkdown": { + "name": "notesMarkdown", + "type": "mediumtext", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "transcript": { + "name": "transcript", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "participants": { + "name": "participants", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "meetingStartedAt": { + "name": "meetingStartedAt", + "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_document_idx": { + "name": "owner_document_idx", + "columns": ["ownerId", "documentId"], + "isUnique": true + } + }, + "foreignKeys": { + "video_notes_videoId_videos_id_fk": { + "name": "video_notes_videoId_videos_id_fk", + "tableFrom": "video_notes", + "tableTo": "videos", + "columnsFrom": ["videoId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "video_notes_videoId": { + "name": "video_notes_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 + }, + "started_at_idx": { + "name": "started_at_idx", + "columns": ["started_at"], + "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 + }, + "isNote": { + "name": "isNote", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "archivedAt": { + "name": "archivedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": 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 + }, + "owner_updated_id_idx": { + "name": "owner_updated_id_idx", + "columns": ["ownerId", "updatedAt", "id"], + "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_owner_folder_effective_idx": { + "name": "org_owner_folder_effective_idx", + "columns": ["orgId", "ownerId", "folderId", "effectiveCreatedAt"], + "isUnique": false + }, + "org_effective_created_idx": { + "name": "org_effective_created_idx", + "columns": ["orgId", "effectiveCreatedAt"], + "isUnique": false + }, + "org_owner_folder_archived_effective_idx": { + "name": "org_owner_folder_archived_effective_idx", + "columns": [ + "orgId", + "ownerId", + "folderId", + "archivedAt", + "effectiveCreatedAt" + ], + "isUnique": false + }, + "screenshot_transcription_created_idx": { + "name": "screenshot_transcription_created_idx", + "columns": ["isScreenshot", "transcriptionStatus", "createdAt"], + "isUnique": false + }, + "org_owner_folder_archived_kind_effective_idx": { + "name": "org_owner_folder_archived_kind_effective_idx", + "columns": [ + "orgId", + "ownerId", + "folderId", + "archivedAt", + "isNote", + "isScreenshot", + "effectiveCreatedAt" + ], + "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.json index c9a3913c58b..1081a384254 100644 --- a/packages/database/migrations/meta/_journal.json +++ b/packages/database/migrations/meta/_journal.json @@ -477,6 +477,13 @@ "when": 1795524690496, "tag": "0067_meeting_audio_usage", "breakpoints": true + }, + { + "idx": 68, + "version": "5", + "when": 1795918968701, + "tag": "0068_concerned_blue_marvel", + "breakpoints": true } ] } diff --git a/packages/database/schema.ts b/packages/database/schema.ts index 21bbb411e57..3e5631c7f69 100644 --- a/packages/database/schema.ts +++ b/packages/database/schema.ts @@ -477,6 +477,10 @@ export const folders = mysqlTable( }), ); +export const VIDEOS_FOLDER_LIST_INDEX = "org_owner_folder_effective_idx"; +export const VIDEOS_KIND_LIST_INDEX = + "org_owner_folder_archived_kind_effective_idx"; + export const videos = mysqlTable( "videos", { @@ -549,6 +553,7 @@ export const videos = mysqlTable( xStreamInfo: text("xStreamInfo"), firstViewEmailSentAt: timestamp("firstViewEmailSentAt"), isScreenshot: boolean("isScreenshot").notNull().default(false), + isNote: boolean("isNote").notNull().default(false), archivedAt: timestamp("archivedAt"), // DEPRECATED awsRegion: varchar("awsRegion", { length: 255 }), @@ -570,7 +575,7 @@ export const videos = mysqlTable( table.ownerId, table.folderId, ), - index("org_owner_folder_effective_idx").on( + index(VIDEOS_FOLDER_LIST_INDEX).on( table.orgId, table.ownerId, table.folderId, @@ -592,6 +597,45 @@ export const videos = mysqlTable( table.transcriptionStatus, table.createdAt, ), + index(VIDEOS_KIND_LIST_INDEX).on( + table.orgId, + table.ownerId, + table.folderId, + table.archivedAt, + table.isNote, + table.isScreenshot, + table.effectiveCreatedAt, + ), + ], +); + +export type VideoNoteTranscriptTurn = { + speaker: string; + startMs: number; + text: string; +}; + +export const videoNotes = mysqlTable( + "video_notes", + { + videoId: nanoId("videoId") + .notNull() + .primaryKey() + .$type() + .references(() => videos.id, { onDelete: "cascade" }), + ownerId: nanoId("ownerId").notNull().$type(), + documentId: varchar("documentId", { length: 64 }).notNull(), + excerpt: varchar("excerpt", { length: 512 }).notNull().default(""), + summaryMarkdown: mediumtext("summaryMarkdown"), + notesMarkdown: mediumtext("notesMarkdown"), + transcript: json("transcript").$type(), + participants: json("participants").$type(), + meetingStartedAt: timestamp("meetingStartedAt"), + createdAt: timestamp("createdAt").notNull().defaultNow(), + updatedAt: timestamp("updatedAt").notNull().defaultNow().onUpdateNow(), + }, + (table) => [ + uniqueIndex("owner_document_idx").on(table.ownerId, table.documentId), ], ); diff --git a/packages/web-backend/src/Organisations/index.ts b/packages/web-backend/src/Organisations/index.ts index 49212ec16d9..23435d42ec5 100644 --- a/packages/web-backend/src/Organisations/index.ts +++ b/packages/web-backend/src/Organisations/index.ts @@ -255,6 +255,9 @@ export class Organisations extends Effect.Service()( .where(Dz.eq(Db.folders.organizationId, id)); if (videoIds.length > 0) { + await tx + .delete(Db.videoNotes) + .where(Dz.inArray(Db.videoNotes.videoId, videoIds)); await tx .delete(Db.videos) .where(Dz.inArray(Db.videos.id, videoIds)); diff --git a/packages/web-backend/src/Videos/VideosRepo.ts b/packages/web-backend/src/Videos/VideosRepo.ts index 37566d36df0..7ef129fc84a 100644 --- a/packages/web-backend/src/Videos/VideosRepo.ts +++ b/packages/web-backend/src/Videos/VideosRepo.ts @@ -153,6 +153,7 @@ export class VideosRepo extends Effect.Service()("VideosRepo", { .delete(Db.notifications) .where(Dz.eq(Db.notifications.videoId, id)), db.delete(Db.importedVideos).where(Dz.eq(Db.importedVideos.id, id)), + db.delete(Db.videoNotes).where(Dz.eq(Db.videoNotes.videoId, id)), db.delete(Db.videos).where(Dz.eq(Db.videos.id, id)), db .delete(Db.videoUploads) diff --git a/packages/web-backend/src/Videos/index.ts b/packages/web-backend/src/Videos/index.ts index 0c0f5ef6304..1ae9e23ff86 100644 --- a/packages/web-backend/src/Videos/index.ts +++ b/packages/web-backend/src/Videos/index.ts @@ -297,6 +297,7 @@ export class Videos extends Effect.Service()("Videos", { const getThumbnailURLForVideo = Effect.fn("Videos.getThumbnailURLForVideo")( function* (video: Video.Video) { + if (video.isNote) return Option.none(); const [bucket] = yield* storage.getAccessForVideo(video); const customThumbnail = getCustomThumbnailKey({ id: video.id, @@ -464,6 +465,7 @@ export class Videos extends Effect.Service()("Videos", { if (Option.isNone(maybeVideo)) return yield* Effect.fail(new Video.NotFoundError()); const [video, password] = maybeVideo.value; + if (video.isNote) return yield* Effect.fail(new Video.NotFoundError()); const [row] = yield* db.use((db) => db @@ -893,6 +895,7 @@ export class Videos extends Effect.Service()("Videos", { if (Option.isNone(maybeVideo)) return yield* Effect.fail(new Video.NotFoundError()); const [video] = maybeVideo.value; + if (video.isNote) return Option.none(); const [bucket] = yield* storage.getAccessForVideo(video); const [videoRow] = yield* db.use((db) => diff --git a/packages/web-domain/src/Video.ts b/packages/web-domain/src/Video.ts index e9696e83ede..20002c50988 100644 --- a/packages/web-domain/src/Video.ts +++ b/packages/web-domain/src/Video.ts @@ -68,6 +68,7 @@ export class Video extends Schema.Class