Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/web/actions/caps/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import {
spaceVideos,
videos,
} from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import type { Organisation, Space, Video } from "@cap/web-domain";
import { and, eq, inArray } from "drizzle-orm";
import { revalidatePath } from "next/cache";

interface ShareCapParams {
capId: Video.VideoId;
spaceIds: string[];
spaceIds: Space.SpaceIdOrOrganisationId[];
public?: boolean;
}

Expand Down Expand Up @@ -53,7 +53,7 @@ export async function shareCap({
.from(organizations)
.where(
and(
inArray(organizations.id, spaceIds),
inArray(organizations.id, spaceIds as Organisation.OrganisationId[]),
inArray(organizations.id, userOrganizationIds),
),
)
Expand Down
5 changes: 4 additions & 1 deletion apps/web/actions/organization/check-domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { organizations } from "@cap/database/schema";
import type { Organisation } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { checkDomainStatus } from "./domain-utils";

export async function checkOrganizationDomain(organizationId: string) {
export async function checkOrganizationDomain(
organizationId: Organisation.OrganisationId,
) {
const user = await getCurrentUser();

if (!user || !organizationId) {
Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/organization/create-space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { nanoId, nanoIdLength } from "@cap/database/helpers";
import { spaceMembers, spaces, users } from "@cap/database/schema";
import { serverEnv } from "@cap/env";
import { S3Buckets } from "@cap/web-backend";
import { Space } from "@cap/web-domain";
import { and, eq, inArray } from "drizzle-orm";
import { Effect, Option } from "effect";
import { revalidatePath } from "next/cache";
Expand Down Expand Up @@ -62,7 +63,7 @@ export async function createSpace(
}

// Generate the space ID early so we can use it in the file path
const spaceId = nanoId();
const spaceId = Space.SpaceId.make(nanoId());

const iconFile = formData.get("icon") as File | null;
let iconUrl = null;
Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/organization/delete-space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
spaceVideos,
} from "@cap/database/schema";
import { S3Buckets } from "@cap/web-backend";
import type { Space } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { Effect, Option } from "effect";
import { revalidatePath } from "next/cache";
Expand All @@ -20,7 +21,7 @@ interface DeleteSpaceResponse {
}

export async function deleteSpace(
spaceId: string,
spaceId: Space.SpaceIdOrOrganisationId,
): Promise<DeleteSpaceResponse> {
try {
const user = await getCurrentUser();
Expand Down
5 changes: 4 additions & 1 deletion apps/web/actions/organization/get-organization-sso-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import { db } from "@cap/database";
import { organizations } from "@cap/database/schema";
import type { Organisation } from "@cap/web-domain";
import { eq } from "drizzle-orm";

export async function getOrganizationSSOData(organizationId: string) {
export async function getOrganizationSSOData(
organizationId: Organisation.OrganisationId,
) {
if (!organizationId) {
throw new Error("Organization ID is required");
}
Expand Down
5 changes: 4 additions & 1 deletion apps/web/actions/organization/remove-domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { organizations } from "@cap/database/schema";
import type { Organisation } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function removeOrganizationDomain(organizationId: string) {
export async function removeOrganizationDomain(
organizationId: Organisation.OrganisationId,
) {
const user = await getCurrentUser();

if (!user) {
Expand Down
5 changes: 4 additions & 1 deletion apps/web/actions/organization/remove-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { organizations } from "@cap/database/schema";
import type { Organisation } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function removeOrganizationIcon(organizationId: string) {
export async function removeOrganizationIcon(
organizationId: Organisation.OrganisationId,
) {
const user = await getCurrentUser();

if (!user) {
Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/organization/remove-invite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { organizationInvites, organizations } from "@cap/database/schema";
import type { Organisation } from "@cap/web-domain";
import { and, eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function removeOrganizationInvite(
inviteId: string,
organizationId: string,
organizationId: Organisation.OrganisationId,
) {
const user = await getCurrentUser();

Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/organization/remove-member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { organizationMembers, organizations } from "@cap/database/schema";
import type { Organisation } from "@cap/web-domain";
import { and, eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";

Expand All @@ -13,7 +14,7 @@ import { revalidatePath } from "next/cache";
*/
export async function removeOrganizationMember(
memberId: string,
organizationId: string,
organizationId: Organisation.OrganisationId,
) {
const user = await getCurrentUser();
if (!user) throw new Error("Unauthorized");
Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/organization/send-invites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import { OrganizationInvite } from "@cap/database/emails/organization-invite";
import { nanoId } from "@cap/database/helpers";
import { organizationInvites, organizations } from "@cap/database/schema";
import { serverEnv } from "@cap/env";
import type { Organisation } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function sendOrganizationInvites(
invitedEmails: string[],
organizationId: string,
organizationId: Organisation.OrganisationId,
) {
const user = await getCurrentUser();

Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/organization/update-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { organizations } from "@cap/database/schema";
import type { Organisation } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";

Expand All @@ -13,7 +14,7 @@ export async function updateOrganizationDetails({
}: {
organizationName?: string | null;
allowedEmailDomain?: string | null;
organizationId: string;
organizationId: Organisation.OrganisationId;
}) {
const user = await getCurrentUser();

Expand Down
6 changes: 5 additions & 1 deletion apps/web/actions/organization/update-domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { organizations } from "@cap/database/schema";
import type { Organisation } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";
import { addDomain, checkDomainStatus } from "./domain-utils";

export async function updateDomain(domain: string, organizationId: string) {
export async function updateDomain(
domain: string,
organizationId: Organisation.OrganisationId,
) {
const user = await getCurrentUser();

if (!user) {
Expand Down
5 changes: 3 additions & 2 deletions apps/web/actions/organization/update-space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getCurrentUser } from "@cap/database/auth/session";
import { nanoIdLength } from "@cap/database/helpers";
import { spaceMembers, spaces } from "@cap/database/schema";
import { S3Buckets } from "@cap/web-backend";
import { Space, type User } from "@cap/web-domain";
import { and, eq } from "drizzle-orm";
import { Effect, Option } from "effect";
import { revalidatePath } from "next/cache";
Expand All @@ -16,9 +17,9 @@ export async function updateSpace(formData: FormData) {
const user = await getCurrentUser();
if (!user) return { success: false, error: "Unauthorized" };

const id = formData.get("id") as string;
const id = Space.SpaceId.make(formData.get("id") as string);
const name = formData.get("name") as string;
const members = formData.getAll("members[]") as string[];
const members = formData.getAll("members[]") as User.UserId[];
const iconFile = formData.get("icon") as File | null;

const [membership] = await db()
Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/organization/upload-organization-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getCurrentUser } from "@cap/database/auth/session";
import { organizations } from "@cap/database/schema";
import { serverEnv } from "@cap/env";
import { S3Buckets } from "@cap/web-backend";
import type { Organisation } from "@cap/web-domain";
import DOMPurify from "dompurify";
import { eq } from "drizzle-orm";
import { Effect, Option } from "effect";
Expand All @@ -15,7 +16,7 @@ import { runPromise } from "@/lib/server";

export async function uploadOrganizationIcon(
formData: FormData,
organizationId: string,
organizationId: Organisation.OrganisationId,
) {
const user = await getCurrentUser();

Expand Down
6 changes: 5 additions & 1 deletion apps/web/actions/organization/upload-space-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ import { getCurrentUser } from "@cap/database/auth/session";
import { spaces } from "@cap/database/schema";
import { serverEnv } from "@cap/env";
import { S3Buckets } from "@cap/web-backend";
import type { Space } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { Effect, Option } from "effect";
import { revalidatePath } from "next/cache";
import { sanitizeFile } from "@/lib/sanitizeFile";
import { runPromise } from "@/lib/server";

export async function uploadSpaceIcon(formData: FormData, spaceId: string) {
export async function uploadSpaceIcon(
formData: FormData,
spaceId: Space.SpaceId,
) {
const user = await getCurrentUser();

if (!user) {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/actions/organizations/add-videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
sharedVideos,
videos,
} from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import type { Organisation, Video } from "@cap/web-domain";
import { and, eq, inArray } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function addVideosToOrganization(
organizationId: string,
organizationId: Organisation.OrganisationId,
videoIds: Video.VideoId[],
) {
try {
Expand Down
5 changes: 4 additions & 1 deletion apps/web/actions/organizations/get-organization-videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { sharedVideos } from "@cap/database/schema";
import type { Organisation } from "@cap/web-domain";
import { eq } from "drizzle-orm";

export async function getOrganizationVideoIds(organizationId: string) {
export async function getOrganizationVideoIds(
organizationId: Organisation.OrganisationId,
) {
try {
const user = await getCurrentUser();

Expand Down
4 changes: 2 additions & 2 deletions apps/web/actions/organizations/remove-videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
sharedVideos,
videos,
} from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import type { Organisation, Video } from "@cap/web-domain";
import { and, eq, inArray } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function removeVideosFromOrganization(
organizationId: string,
organizationId: Organisation.OrganisationId,
videoIds: Video.VideoId[],
) {
try {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/actions/spaces/add-videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { nanoId } from "@cap/database/helpers";
import { spaces, spaceVideos, videos } from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import type { Space, Video } from "@cap/web-domain";
import { and, eq, inArray } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function addVideosToSpace(
spaceId: string,
spaceId: Space.SpaceIdOrOrganisationId,
videoIds: Video.VideoId[],
) {
try {
Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/spaces/get-space-videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { spaceVideos } from "@cap/database/schema";
import type { Space } from "@cap/web-domain";
import { eq } from "drizzle-orm";

export async function getSpaceVideoIds(spaceId: string) {
export async function getSpaceVideoIds(spaceId: Space.SpaceIdOrOrganisationId) {
try {
const user = await getCurrentUser();

Expand Down
4 changes: 2 additions & 2 deletions apps/web/actions/spaces/remove-videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { folders, spaceVideos, videos } from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import type { Space, Video } from "@cap/web-domain";
import { and, eq, inArray } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function removeVideosFromSpace(
spaceId: string,
spaceId: Space.SpaceIdOrOrganisationId,
videoIds: Video.VideoId[],
) {
try {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/actions/video/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { s3Buckets, videos, videoUploads } from "@cap/database/schema";
import { buildEnv, NODE_ENV, serverEnv } from "@cap/env";
import { userIsPro } from "@cap/utils";
import { S3Buckets } from "@cap/web-backend";
import { type Folder, Video } from "@cap/web-domain";
import { type Folder, type Organisation, Video } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { Effect, Option } from "effect";
import { revalidatePath } from "next/cache";
Expand Down Expand Up @@ -175,7 +175,7 @@ export async function createVideoAndGetUploadUrl({
isScreenshot?: boolean;
isUpload?: boolean;
folderId?: Folder.FolderId;
orgId: string;
orgId: Organisation.OrganisationId;
// TODO: Remove this once we are happy with it's stability
supportsUploadProgress?: boolean;
}) {
Expand Down
7 changes: 4 additions & 3 deletions apps/web/actions/videos/delete-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { comments, notifications } from "@cap/database/schema";
import type { Comment, Video } from "@cap/web-domain";
import { and, eq, sql } from "drizzle-orm";
import { revalidatePath } from "next/cache";

Expand All @@ -11,9 +12,9 @@ export async function deleteComment({
parentId,
videoId,
}: {
commentId: string;
parentId?: string;
videoId: string;
commentId: Comment.CommentId;
parentId?: Comment.CommentId;
videoId: Video.VideoId;
}) {
const user = await getCurrentUser();

Expand Down
Loading
Loading