171 lines · 6.3 KB
import { env } from "cloudflare:workers";
import { all, chunks, first, placeholders } from "./db";
import { accountDb, repoDb } from "./scoped-db";
import { locate } from "./scoped-db/locators";
import { canCreateInAccount, visibleReposClause } from "./repos";
import { viewerFromSessionCookie } from "./auth";
import { limitBrowse, rawRequestIp } from "./limits";
import { HttpError, forbidden, notFoundError } from "./errors";
import type { Viewer } from "~/lib/types";

const LIVE_PATH = /^\/projects\/([^/]+)\/(\d+)\/live$/;

export type ProjectRow = {
  id: string;
  owner_id: string;
  number: number;
  title: string;
  description: string;
  visibility: "public" | "private";
  closed: number;
  created_by: string;
  created_at: number;
  updated_at: number;
};

export type ProjectFieldRow = {
  id: string;
  project_id: string;
  name: string;
  kind: "text" | "number" | "date" | "single_select";
  options: string;
  position: number;
};

export type ProjectAccess = {
  project: ProjectRow;
  ownerName: string;
  canWrite: boolean;
};