Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

1.2 KB
Raw Blame
import { FolderPermission, FolderSummary } from "@/lib/types";
import { FolderAccessLevel, FolderUserRole } from "@prisma/client";

export const FOLDER_WORKSPACE_ACCESS: Record<FolderAccessLevel, string> = {
  write: "Can edit",
  read: "Can view",
} as const;

export const FOLDER_USER_ROLE: Record<FolderUserRole, string> = {
  owner: "Owner",
  editor: "Editor",
  viewer: "Viewer",
} as const;

export const FOLDER_PERMISSIONS = [
  "folders.read", // Read access to the folder
  "folders.write", // Full access to the folder
  "folders.links.write", // Manage links in the folder
  "folders.users.write", // Manage folder users
] as const;

export const FOLDER_WORKSPACE_ACCESS_TO_FOLDER_USER_ROLE: Record<
  FolderAccessLevel,
  FolderUserRole
> = {
  read: "viewer",
  write: "editor",
} as const;

export const FOLDER_USER_ROLE_TO_PERMISSIONS: Record<
  FolderUserRole,
  FolderPermission[]
> = {
  owner: [
    "folders.read",
    "folders.write",
    "folders.links.write",
    "folders.users.write",
  ],
  editor: ["folders.read", "folders.links.write"],
  viewer: ["folders.read"],
} as const;

export const unsortedLinks: FolderSummary = {
  id: "unsorted",
  name: "Links",
  description: "Unsorted links",
  accessLevel: "write",
};