206 lines · 7.6 KB
import { env } from "cloudflare:workers";
import { all, first, run } from "../db";
import { badRequest, conflict } from "../errors";
import { claimDomainFromSites } from "../sites/site";
import { hostKey, isForgeRelatedHost, isValidHostname, pagesDomain, PAGES_LIMITS, siteUrl, slotKey } from "./config";
import type { PagesDeploymentRow, PagesSiteRow, PagesSource, SitePointer } from "./config";
import {
  createCustomHostname,
  customDomainsEnabled,
  deleteCustomHostname,
  domainStatus,
  getCustomHostname,
} from "./domains";
import { unpublish } from "./deploy";
import type { RepoRow } from "~/lib/types";

/** Unverified domain claims lapse so a squatter cannot block the domain's real owner. */
const UNVERIFIED_CLAIM_MS = 72 * 60 * 60 * 1000;

export type SiteSettings = {
  source: PagesSource;
  branch: string;
  folder: string;
  artifactName: string;
  spa: boolean;
  previews: boolean;
};

export type PagesDeploymentView = {
  id: string;
  environment: PagesDeploymentRow["environment"];
  prNumber: number | null;
  source: PagesDeploymentRow["source"];
  ref: string;
  sha: string;
  status: PagesDeploymentRow["status"];
  fileCount: number;
  totalBytes: number;
  error: string | null;
  createdAt: number;