Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
feat: password protection (#799)
Maximilian Kaske0a659cbb588e
diff --git a/apps/server/src/v1/page.ts b/apps/server/src/v1/page.tsindex 1438532bd..8d7ca30e9 100644--- a/apps/server/src/v1/page.ts+++ b/apps/server/src/v1/page.ts@@ -66,6 +66,26 @@ const PageSchema = z.object({.or(z.literal("")).transform((val) => (val ? val : undefined)).nullish(),++ passwordProtected: z+ .boolean()+ .openapi({+ description:+ "Make the page password protected. Used with the 'passwordProtected' property.",+ example: true,+ })+ .default(false)+ .optional(),++ password: z+ .string()+ .openapi({+ description: "Your password to protect the page from the publi",+ example: "hidden-password",+ })+ .optional()+ .nullish(),+monitors: z.array(z.number()).openapi({@@ -111,6 +131,24 @@ const CreatePageSchema = z.object({example: [1, 2],}).nullish(),++ passwordProtected: z+ .boolean()+ .openapi({+ description: "Make the page password protected",+ example: true,+ })+ .default(false)+ .optional(),++ password: z+ .string()+ .openapi({+ description: "Your password to protect the page from the publi",+ example: "hidden-password",+ })+ .optional()+ .nullish(),});const UpdatePageSchema = z.object({@@ -155,6 +193,24 @@ const UpdatePageSchema = z.object({example: [1, 2],}).nullish(),++ passwordProtected: z+ .boolean()+ .openapi({+ description: "Make the page password protected",+ example: true,+ })+ .default(false)+ .optional(),++ password: z+ .string()+ .openapi({+ description: "Your password to protect the page from the publi",+ example: "hidden-password",+ })+ .optional()+ .nullish(),});const pageSubscriberSchema = z.object({@@ -400,6 +456,13 @@ pageApi.openapi(postRoute, async (c) => {const input = c.req.valid("json");+ if (+ workspacePlan.limits["password-protection"] === false &&+ input?.passwordProtected === true+ ) {+ return c.json({ code: 403, message: "Forbidden" }, 403);+ }+const countSlug = (await db.select({ count: sql<number>`count(*)` })@@ -488,6 +551,15 @@ pageApi.openapi(putRoute, async (c) => {if (!id) return c.json({ code: 400, message: "Bad Request" }, 400);+ const workspacePlan = c.get("workspacePlan");++ if (+ workspacePlan.limits["password-protection"] === false &&+ input?.passwordProtected === true+ ) {+ return c.json({ code: 403, message: "Forbidden" }, 403);+ }+const _page = await db.select().from(page)diff --git a/apps/web/public/assets/changelog/password-protected-status-page.png b/apps/web/public/assets/changelog/password-protected-status-page.pngnew file mode 100644index 000000000..d6fa85af1Binary files /dev/null and b/apps/web/public/assets/changelog/password-protected-status-page.png differdiff --git a/apps/web/src/app/api/og/page/route.tsx b/apps/web/src/app/api/og/page/route.tsxindex e19bee05e..96b567e73 100644--- a/apps/web/src/app/api/og/page/route.tsx+++ b/apps/web/src/app/api/og/page/route.tsx@@ -18,18 +18,20 @@ export async function GET(req: Request) {const { searchParams } = new URL(req.url);const slug = searchParams.has("slug") ? searchParams.get("slug") : undefined;+ const passwordProtected = searchParams.has("passwordProtected")+ ? searchParams.get("passwordProtected") === "true" // FIXME: can we use Boolean("true") or Boolean("false")?+ : undefined;const page = await api.page.getPageBySlug.query({ slug: slug || "" });const title = page ? page.title : TITLE;const description = page ? "" : DESCRIPTION;+ // REMINDER: if password protected, we keep the status 'operational' by default, hiding the actual statusconst tracker = new Tracker({- incidents: page?.incidents,- statusReports: page?.statusReports,+ incidents: passwordProtected ? undefined : page?.incidents,+ statusReports: passwordProtected ? undefined : page?.statusReports,});- // const status = tracker.currentStatus;-return new ImageResponse((<BasicLayout title={title} description={description} tw="py-24 px-24">diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/(overview)/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/(overview)/page.tsxindex ae310d3e5..c83467f1f 100644--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/(overview)/page.tsx+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/(overview)/page.tsx@@ -13,8 +13,6 @@ import { DataTable } from "@/components/data-table/monitor/data-table";import { env } from "@/env";import { api } from "@/trpc/server";-// import { RefreshWidget } from "../_components/refresh-widget";-const tb = new OSTinybird({ token: env.TINY_BIRD_API_KEY });export const dynamic = "force-dynamic";@@ -27,6 +25,16 @@ const searchParamsSchema = z.object({.string().transform((v) => v?.split(",")).optional(),+ public: z+ .string()+ .transform((v) =>+ v?.split(",").map((v) => {+ if (v === "true") return true;+ if (v === "false") return false;+ return undefined;+ }),+ )+ .optional(),});export default async function MonitorPage({@@ -91,24 +99,18 @@ export default async function MonitorPage({}),);- // const lastCronTimestamp = monitorsWithData?.reduce((prev, acc) => {- // const lastTimestamp = acc.metrics?.lastTimestamp || 0;- // if (lastTimestamp > prev) return lastTimestamp;- // return prev;- // }, 0);-return (<><DataTable- defaultColumnFilters={[{ id: "tags", value: search.data.tags }].filter(- (v) => v.value !== undefined,- )}+ defaultColumnFilters={[+ { id: "tags", value: search.data.tags },+ { id: "public", value: search.data.public },+ ].filter((v) => v.value !== undefined)}columns={columns}data={monitorsWithData}tags={tags}/>{isLimitReached ? <Limit /> : null}- {/* <RefreshWidget defaultValue={lastCronTimestamp} /> */}</>);}diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/team/_components/invite-button.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/team/_components/invite-button.tsxindex 44c95de3b..1be75c84f 100644--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/team/_components/invite-button.tsx+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/team/_components/invite-button.tsx@@ -27,7 +27,6 @@ import {import { LoadingAnimation } from "@/components/loading-animation";import { toastAction } from "@/lib/toast";-import { wait } from "@/lib/utils";import { api } from "@/trpc/client";const schema = insertInvitationSchema.pick({ email: true });@@ -51,7 +50,6 @@ export function InviteButton({async function onSubmit(data: Schema) {startTransition(async () => {try {- wait(2000);api.invitation.create.mutate(data);toastAction("saved");router.refresh();diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/edit/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/edit/page.tsxindex 71a05eb9a..382527110 100644--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/edit/page.tsx+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/edit/page.tsx@@ -17,6 +17,7 @@ export default async function EditPage({}) {const id = Number(params.id);const page = await api.page.getPageById.query({ id });+ const workspace = await api.workspace.getWorkspace.query();const allMonitors = await api.monitor.getMonitorsByWorkspace.query();if (!page) {@@ -34,6 +35,8 @@ export default async function EditPage({monitors: page.monitorsToPages.map(({ monitor }) => monitor.id),}}defaultSection={search.success ? search.data.section : undefined}+ plan={workspace?.plan}+ workspaceSlug={params.workspaceSlug}/>);}diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/layout.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/layout.tsxindex 09f620731..28040033e 100644--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/layout.tsx+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/layout.tsx@@ -31,7 +31,15 @@ export default async function Layout({description={page.description}actions={<Button variant="outline" asChild>- <Link target="_blank" href={`https://${page.slug}.openstatus.dev`}>+ <Link+ target="_blank"+ href={+ process.env.NODE_ENV === "development"+ ? `http://localhost:3000/status-page/${page.slug}`+ : // TODO: add custom domain support+ `https://${page.slug}.openstatus.dev`+ }+ >Visit</Link></Button>diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/new/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/new/page.tsxindex ec7605c95..5d39ecd3a 100644--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/new/page.tsx+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/new/page.tsx@@ -3,7 +3,11 @@ import { redirect } from "next/navigation";import { StatusPageForm } from "@/components/forms/status-page/form";import { api } from "@/trpc/server";-export default async function Page() {+export default async function Page({+ params,+}: {+ params: { workspaceSlug: string };+}) {const allMonitors = await api.monitor.getMonitorsByWorkspace.query();const isLimitReached = await api.page.isPageLimitReached.query();@@ -14,6 +18,7 @@ export default async function Page() {allMonitors={allMonitors} // FIXME: rename to just 'monitors'nextUrl="./" // back to the overview pagedefaultSection="monitors"+ workspaceSlug={params.workspaceSlug}/>);}diff --git a/apps/web/src/app/status-page/[domain]/_components/actions.ts b/apps/web/src/app/status-page/[domain]/_components/actions.tsindex 192c90186..b7227f589 100644--- a/apps/web/src/app/status-page/[domain]/_components/actions.ts+++ b/apps/web/src/app/status-page/[domain]/_components/actions.ts@@ -8,7 +8,7 @@ import { db } from "@openstatus/db/src/db";import { page, pageSubscriber } from "@openstatus/db/src/schema";import { sendEmail, SubscribeEmail } from "@openstatus/emails";-const schema = z.object({+const subscribeSchema = z.object({email: z.string({invalid_type_error: "Invalid Email",@@ -18,7 +18,7 @@ const schema = z.object({});export async function handleSubscribe(formData: FormData) {- const validatedFields = schema.safeParse({+ const validatedFields = subscribeSchema.safeParse({email: formData.get("email"),slug: formData.get("slug"),});@@ -92,3 +92,44 @@ export async function handleSubscribe(formData: FormData) {slug: pageData.slug,});}++const passwordSchema = z.object({+ password: z.string(),+ slug: z.string(),+});++export async function handleValidatePassword(formData: FormData) {+ const validatedFields = passwordSchema.safeParse({+ password: formData.get("password"),+ slug: formData.get("slug"),+ });++ console.log({ validatedFields });++ if (!validatedFields.success) {+ const fieldErrors = validatedFields.error.flatten().fieldErrors;+ return {+ error: fieldErrors?.password?.[0] || "Invalid form data",+ };+ }++ const _page = await db+ .select()+ .from(page)+ .where(eq(page.slug, validatedFields.data.slug))+ .get();++ if (!_page) {+ return {+ error: "Page not found",+ };+ }++ if (_page.password !== validatedFields.data.password) {+ return {+ error: "Invalid password",+ };+ }++ return { data: _page.password };+}diff --git a/apps/web/src/app/status-page/[domain]/_components/password-form.tsx b/apps/web/src/app/status-page/[domain]/_components/password-form.tsxnew file mode 100644index 000000000..3be8b2030--- /dev/null+++ b/apps/web/src/app/status-page/[domain]/_components/password-form.tsx@@ -0,0 +1,117 @@+"use client";++import { useEffect, useState, useTransition } from "react";+import { usePathname, useRouter, useSearchParams } from "next/navigation";+import { zodResolver } from "@hookform/resolvers/zod";+import { useForm } from "react-hook-form";+import { z } from "zod";++import {+ Button,+ Form,+ FormControl,+ FormDescription,+ FormField,+ FormItem,+ FormLabel,+ FormMessage,+ Input,+} from "@openstatus/ui";++import { LoadingAnimation } from "@/components/loading-animation";+import { useCookieState } from "@/hooks/use-cookie-state";+import { toast, toastAction } from "@/lib/toast";+import { createProtectedCookieKey } from "../utils";+import { handleValidatePassword } from "./actions";++// TODO: add 'hide/show' button to show the password+// FIXME: we could do the `?authorize` thing in the server side (e.g. middleware) - but not+// in the `layout.tsx` because we cannot access the search params there++const schema = z.object({+ password: z.string(),+});++type Schema = z.infer<typeof schema>;++export function PasswordForm({ slug }: { slug: string }) {+ const form = useForm<Schema>({+ resolver: zodResolver(schema),+ defaultValues: { password: "" },+ });+ const [loading, setLoading] = useState(true);+ const router = useRouter();+ const pathname = usePathname();+ const searchParams = useSearchParams();+ const [isPending, startTransition] = useTransition();+ const [_, handleChange] = useCookieState(createProtectedCookieKey(slug)); // what if we do not define the expires date?++ useEffect(() => {+ if (searchParams.has("authorize")) {+ const authorize = searchParams.get("authorize");+ if (!authorize) return;+ form.setValue("password", authorize);+ }+ setLoading(false);+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, []);++ async function onSubmit(data: Schema) {+ startTransition(async () => {+ try {+ const formData = new FormData();+ formData.append("password", data.password);+ formData.append("slug", slug);++ const res = await handleValidatePassword(formData);++ if (res?.error || res.data === undefined) {+ toast.error(res.error || "An error occurred. Please retry.");+ return;+ }++ handleChange(res.data);+ toastAction("saved");++ router.replace(pathname);+ router.refresh();+ } catch {+ toastAction("error");+ }+ });+ }++ return (+ <Form {...form}>+ <form+ onSubmit={form.handleSubmit(onSubmit)}+ className="grid w-full gap-4"+ >+ <FormField+ control={form.control}+ name="password"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Password</FormLabel>+ <FormControl>+ <Input+ placeholder="top-secret"+ type="password"+ disabled={loading}+ {...field}+ />+ </FormControl>+ <FormDescription>+ Enter the password to access the status page.+ </FormDescription>+ <FormMessage />+ </FormItem>+ )}+ />+ <Button size="lg" disabled={isPending || loading}>+ {isPending || loading ? <LoadingAnimation /> : "Confirm"}+ </Button>+ </form>+ </Form>+ );+}diff --git a/apps/web/src/app/status-page/[domain]/_components/password-protected.tsx b/apps/web/src/app/status-page/[domain]/_components/password-protected.tsxnew file mode 100644index 000000000..09ebd506e--- /dev/null+++ b/apps/web/src/app/status-page/[domain]/_components/password-protected.tsx@@ -0,0 +1,25 @@+import type { WorkspacePlan } from "@openstatus/plans";++import { Shell } from "@/components/dashboard/shell";+import { Footer } from "../_components/footer";+import { PasswordForm } from "../_components/password-form";++export default function PasswordProtected({+ slug,+ plan,+}: {+ slug: string;+ plan: WorkspacePlan;+}) {+ return (+ <div className="mx-auto flex min-h-screen w-full max-w-3xl flex-col space-y-6 p-4 md:p-8">+ <main className="flex h-full w-full flex-1 flex-col justify-center">+ <Shell className="mx-auto grid gap-6">+ <h1 className="text-2xl font-semibold">Protected Page</h1>+ <PasswordForm slug={slug} />+ </Shell>+ </main>+ <Footer plan={plan} />+ </div>+ );+}diff --git a/apps/web/src/app/status-page/[domain]/layout.tsx b/apps/web/src/app/status-page/[domain]/layout.tsxindex 93f26dd8c..bd89e6396 100644--- a/apps/web/src/app/status-page/[domain]/layout.tsx+++ b/apps/web/src/app/status-page/[domain]/layout.tsx@@ -1,4 +1,5 @@import type { Metadata } from "next";+import { cookies } from "next/headers";import { notFound } from "next/navigation";import {@@ -10,7 +11,8 @@ import { Shell } from "@/components/dashboard/shell";import { api } from "@/trpc/server";import { Footer } from "./_components/footer";import { Header } from "./_components/header";-import { setPrefixUrl } from "./utils";+import PasswordProtected from "./_components/password-protected";+import { createProtectedCookieKey, setPrefixUrl } from "./utils";type Props = {params: { domain: string };@@ -19,6 +21,7 @@ type Props = {export default async function StatusPageLayout({ children, params }: Props) {const page = await api.page.getPageBySlug.query({ slug: params.domain });+if (!page) return notFound();const plan = page.workspacePlan;@@ -43,6 +46,17 @@ export default async function StatusPageLayout({ children, params }: Props) {},];+ // TODO: move to middleware using NextResponse.rewrite keeping the path without using redirect+ // and move the PasswordProtected into a page.tsx+ if (page.passwordProtected) {+ const cookie = cookies();+ const protectedCookie = cookie.get(createProtectedCookieKey(params.domain));+ const password = protectedCookie ? protectedCookie.value : undefined;+ if (password !== page.password) {+ return <PasswordProtected plan={plan} slug={params.domain} />;+ }+ }+return (<div className="mx-auto flex min-h-screen w-full max-w-3xl flex-col space-y-6 p-4 md:p-8"><Header navigation={navigation} plan={plan} page={page} />@@ -64,13 +78,17 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {icons: page?.icon,twitter: {...twitterMetadata,- images: [`/api/og/page?slug=${page?.slug}`],+ images: [+ `/api/og/page?slug=${page?.slug}&passwordProtected=${page?.passwordProtected}`,+ ],title: page?.title,description: page?.description,},openGraph: {...ogMetadata,- images: [`/api/og/page?slug=${page?.slug}`],+ images: [+ `/api/og/page?slug=${page?.slug}&passwordProtected=${page?.passwordProtected}`,+ ],title: page?.title,description: page?.description,},diff --git a/apps/web/src/app/status-page/[domain]/utils.tsx b/apps/web/src/app/status-page/[domain]/utils.tsxindex 73166e059..ebedbaa17 100644--- a/apps/web/src/app/status-page/[domain]/utils.tsx+++ b/apps/web/src/app/status-page/[domain]/utils.tsx@@ -8,3 +8,7 @@ export function setPrefixUrl(value: string, params: { domain: string }) {}return suffix;}++export function createProtectedCookieKey(value: string) {+ return `secured-${value}`;+}diff --git a/apps/web/src/components/billing/pro-feature-hover-card.tsx b/apps/web/src/components/billing/pro-feature-hover-card.tsxnew file mode 100644index 000000000..3c95945d3--- /dev/null+++ b/apps/web/src/components/billing/pro-feature-hover-card.tsx@@ -0,0 +1,60 @@+"use client";++import { useState } from "react";++import { workspacePlanHierarchy } from "@openstatus/db/src/schema";+import type { WorkspacePlan } from "@openstatus/plans";+import { HoverCard, HoverCardContent, HoverCardTrigger } from "@openstatus/ui";++function upgradePlan(current: WorkspacePlan, required: WorkspacePlan) {+ return workspacePlanHierarchy[current] < workspacePlanHierarchy[required];+}++// TBD: we could useParams() to access workspaceSlug++export function ProFeatureHoverCard({+ children,+ plan,+ minRequiredPlan,+ workspaceSlug,+}: {+ children: React.ReactNode;+ plan?: WorkspacePlan;+ minRequiredPlan: WorkspacePlan;+ workspaceSlug: string;+}) {+ console.log({ workspaceSlug, plan, minRequiredPlan });+ const [open, setOpen] = useState(false);+ const shouldUpgrade = upgradePlan(plan || "free", minRequiredPlan);++ if (!shouldUpgrade) return children;++ return (+ <HoverCard openDelay={0} open={open} onOpenChange={setOpen}>+ <HoverCardTrigger+ onClick={() => setOpen(true)}+ className="opacity-70"+ asChild+ >+ {children}+ </HoverCardTrigger>+ <HoverCardContent side="top" className="grid gap-2">+ <p className="text-muted-foreground text-sm">+ This feature is only available starting from the{" "}+ <span className="font-semibold capitalize">{minRequiredPlan}</span>{" "}+ plan.+ </p>+ <p className="text-sm">+ <a+ href={`/app/${workspaceSlug}/settings/billing`}+ target="_blank"+ className="text-foreground inline-flex items-center font-medium underline underline-offset-4 hover:no-underline"+ >+ Upgrade now+ </a>+ .+ </p>+ </HoverCardContent>+ </HoverCard>+ );+}diff --git a/apps/web/src/components/dashboard/copy-to-clipboard-button.tsx b/apps/web/src/components/dashboard/copy-to-clipboard-button.tsxindex f0f6519e9..07f7e16b6 100644--- a/apps/web/src/components/dashboard/copy-to-clipboard-button.tsx+++ b/apps/web/src/components/dashboard/copy-to-clipboard-button.tsx@@ -11,14 +11,16 @@ import {} from "@openstatus/ui";import { Icons } from "@/components/icons";-import { copyToClipboard } from "@/lib/utils";+import { cn, copyToClipboard } from "@/lib/utils";export function CopyToClipboardButton({text,tooltipText,+ className,}: {text: string;tooltipText: string;+ className?: string;}) {const [hasCopied, setHasCopied] = React.useState(false);@@ -35,9 +37,10 @@ export function CopyToClipboardButton({<Tooltip><TooltipTrigger asChild><Button+ type="button"variant="ghost"size="icon"- className="h-7 w-7"+ className={cn("h-7 w-7", className)}onClick={() => {copyToClipboard(text);setHasCopied(true);diff --git a/apps/web/src/components/forms/status-page/form.tsx b/apps/web/src/components/forms/status-page/form.tsxindex 3cfcb3537..1f67d8ded 100644--- a/apps/web/src/components/forms/status-page/form.tsx+++ b/apps/web/src/components/forms/status-page/form.tsx@@ -7,7 +7,11 @@ import { zodResolver } from "@hookform/resolvers/zod";import { useForm } from "react-hook-form";import { insertPageSchema } from "@openstatus/db/src/schema";-import type { InsertPage, Monitor } from "@openstatus/db/src/schema";+import type {+ InsertPage,+ Monitor,+ WorkspacePlan,+} from "@openstatus/db/src/schema";import { Badge, Form } from "@openstatus/ui";import {@@ -25,6 +29,7 @@ import { SaveButton } from "../shared/save-button";import { General } from "./general";import { SectionAdvanced } from "./section-advanced";import { SectionMonitor } from "./section-monitor";+import { SectionVisibility } from "./section-visibility";interface Props {defaultSection?: string;@@ -38,6 +43,8 @@ interface Props {* on submit, allows to push a url*/nextUrl?: string;+ plan?: WorkspacePlan;+ workspaceSlug: string;}export function StatusPageForm({@@ -46,6 +53,8 @@ export function StatusPageForm({allMonitors,checkAllMonitors,nextUrl,+ plan,+ workspaceSlug,}: Props) {const form = useForm<InsertPage>({resolver: zodResolver(insertPageSchema),@@ -61,6 +70,8 @@ export function StatusPageForm({: defaultValues?.monitors ?? [],customDomain: defaultValues?.customDomain || "",icon: defaultValues?.icon || "",+ password: defaultValues?.password || "",+ passwordProtected: defaultValues?.passwordProtected || false,},});const pathname = usePathname();@@ -123,6 +134,8 @@ export function StatusPageForm({?.location,},});+ // otherwise, the form will stay dirty - keepValues is used to keep the current values in the form+ form.reset({}, { keepValues: true });if (nextUrl) {router.push(nextUrl);}@@ -174,6 +187,7 @@ export function StatusPageForm({) : null}</TabsTrigger><TabsTrigger value="advanced">Advanced</TabsTrigger>+ <TabsTrigger value="visibility">Visibility</TabsTrigger></TabsList><TabsContent value="monitors"><SectionMonitor form={form} monitors={allMonitors} />@@ -181,6 +195,9 @@ export function StatusPageForm({<TabsContent value="advanced"><SectionAdvanced form={form} /></TabsContent>+ <TabsContent value="visibility">+ <SectionVisibility {...{ form, plan, workspaceSlug }} />+ </TabsContent></Tabs><SaveButtonisPending={isPending}diff --git a/apps/web/src/components/forms/status-page/section-monitor.tsx b/apps/web/src/components/forms/status-page/section-monitor.tsxindex b6243d246..040da0c7e 100644--- a/apps/web/src/components/forms/status-page/section-monitor.tsx+++ b/apps/web/src/components/forms/status-page/section-monitor.tsx@@ -25,7 +25,7 @@ export function SectionMonitor({ monitors, form }: Props) {<div className="grid w-full gap-4"><SectionHeadertitle="Connected Monitors"- description="Select the monitors you want to display on your status page. Inactve monitors will not be shown."+ description="Select the monitors you want to display on your status page. Inactive monitors will not be shown."/><FormFieldcontrol={form.control}diff --git a/apps/web/src/components/forms/status-page/section-visibility.tsx b/apps/web/src/components/forms/status-page/section-visibility.tsxnew file mode 100644index 000000000..b8ef42be4--- /dev/null+++ b/apps/web/src/components/forms/status-page/section-visibility.tsx@@ -0,0 +1,136 @@+"use client";++import * as React from "react";+import { X } from "lucide-react";+import type { UseFormReturn } from "react-hook-form";++import type { InsertPage, WorkspacePlan } from "@openstatus/db/src/schema";+import {+ Button,+ Checkbox,+ FormControl,+ FormDescription,+ FormField,+ FormItem,+ FormLabel,+ FormMessage,+ Input,+} from "@openstatus/ui";++import { ProFeatureHoverCard } from "@/components/billing/pro-feature-hover-card";+import { CopyToClipboardButton } from "@/components/dashboard/copy-to-clipboard-button";+import { SectionHeader } from "../shared/section-header";++interface Props {+ form: UseFormReturn<InsertPage>;+ plan?: WorkspacePlan;+ workspaceSlug: string;+}++export function SectionVisibility({ form, plan, workspaceSlug }: Props) {+ const watchPasswordProtected = form.watch("passwordProtected");+ const watchPassword = form.watch("password");++ const getBaseUrl = () => {+ if (process.env.NODE_ENV === "development") {+ return `http://localhost:3000/status-page/${form.getValues("slug")}`;+ }+ if (form.getValues("customDomain") !== "") {+ return `https://${form.getValues("customDomain")}`;+ }+ return `https://${form.getValues("slug")}.openstatus.dev`;+ };++ const link = `${getBaseUrl()}?authorize=${watchPassword}`;++ const hasFreePlan = !plan || plan === "free" ? true : false;++ return (+ <div className="grid w-full gap-4 md:grid-cols-2">+ <SectionHeader+ title="Visibility"+ description="Hide your page from the public by setting a password."+ className="md:col-span-full"+ />+ <ProFeatureHoverCard+ workspaceSlug={workspaceSlug}+ plan={plan}+ minRequiredPlan="starter"+ >+ <div className="grid w-full gap-4 md:col-span-full md:grid-cols-2">+ <FormField+ control={form.control}+ name="passwordProtected"+ disabled={hasFreePlan}+ render={({ field }) => (+ <FormItem className="flex flex-row items-start space-x-3 space-y-0 md:col-span-full">+ <FormControl>+ <Checkbox+ disabled={field.disabled}+ checked={field.value ?? false}+ onCheckedChange={field.onChange}+ />+ </FormControl>+ <div className="space-y-1 leading-none">+ <FormLabel>Protect with password</FormLabel>+ <FormDescription>+ Hide the page from the public+ </FormDescription>+ </div>+ </FormItem>+ )}+ />+ <FormField+ control={form.control}+ name="password"+ disabled={hasFreePlan}+ render={({ field }) => (+ <FormItem className="md:col-span-1">+ <FormLabel>Password</FormLabel>+ <div className="flex items-center gap-2">+ <FormControl>+ <Input+ {...field}+ placeholder="top-secret"+ disabled={!watchPasswordProtected}+ value={field.value ?? ""} // REMINDER: remove nullish coalescing from db schema+ />+ </FormControl>+ <Button+ size="icon"+ variant="ghost"+ type="button"+ onClick={() => form.setValue("password", "")}+ disabled={!field.value || !watchPasswordProtected}+ >+ <X className="h-4 w-4" />+ </Button>+ </div>+ <FormDescription>+ No restriction on the password. It's just a simple+ password you define.+ </FormDescription>+ <FormMessage />+ </FormItem>+ )}+ />+ {watchPasswordProtected ? (+ <div className="text-sm md:col-span-full">+ <p className="text-muted-foreground">+ If you want to share the page without the need to enter the+ password, you can share the following link:+ </p>+ <div className="flex flex-wrap items-center gap-2">+ <p className="text-foreground">{link} </p>+ <CopyToClipboardButton+ text={link}+ tooltipText="Copy to clipboard"+ />+ </div>+ </div>+ ) : null}+ </div>+ </ProFeatureHoverCard>+ </div>+ );+}diff --git a/apps/web/src/content/changelog/password-protected-status-page.mdx b/apps/web/src/content/changelog/password-protected-status-page.mdxnew file mode 100644index 000000000..dc97e2c70--- /dev/null+++ b/apps/web/src/content/changelog/password-protected-status-page.mdx@@ -0,0 +1,13 @@+---+title: Password-protected status page+description: Hide your page from the public.+image: /assets/changelog/password-protected-status-page.png+publishedAt: 2024-05-03+---++You can now protect your status page with a password. This will hide the page+from the public and only allow access to users with the password.++You can enable the password protection from the status page settings.++> This feature is available on the Starter plan and above.diff --git a/packages/api/src/router/page.ts b/packages/api/src/router/page.tsindex 92c8c250c..1a5b1e01c 100644--- a/packages/api/src/router/page.ts+++ b/packages/api/src/router/page.ts@@ -10,6 +10,7 @@ import {monitorsToStatusReport,page,pagesToStatusReports,+ selectPageSchemaWithMonitorsRelation,selectPublicPageSchemaWithRelation,statusReport,workspace,@@ -29,16 +30,27 @@ export const pageRouter = createTRPCRouter({})).length;- const limit = allPlans[opts.ctx.workspace.plan].limits["status-pages"];+ const limit = allPlans[opts.ctx.workspace.plan].limits;- // the user has reached the limits- if (pageNumbers >= limit) {+ // the user has reached the status page number limits+ if (pageNumbers >= limit["status-pages"]) {throw new TRPCError({code: "FORBIDDEN",message: "You reached your status-page limits.",});}+ // the user is not eligible for password protection+ if (+ limit["password-protection"] === false &&+ opts.input.passwordProtected === true+ ) {+ throw new TRPCError({+ code: "FORBIDDEN",+ message: "Password protection is not available for your current plan.",+ });+ }+const newPage = await opts.ctx.db.insert(page).values({ workspaceId: opts.ctx.workspace.id, ...pageProps })@@ -70,7 +82,7 @@ export const pageRouter = createTRPCRouter({getPageById: protectedProcedure.input(z.object({ id: z.number() })).query(async (opts) => {- return await opts.ctx.db.query.page.findFirst({+ const firstPage = await opts.ctx.db.query.page.findFirst({where: and(eq(page.id, opts.input.id),eq(page.workspaceId, opts.ctx.workspace.id),@@ -79,12 +91,26 @@ export const pageRouter = createTRPCRouter({monitorsToPages: { with: { monitor: true } },},});+ return selectPageSchemaWithMonitorsRelation.parse(firstPage);}),update: protectedProcedure.input(insertPageSchema).mutation(async (opts) => {const { monitors, ...pageInput } = opts.input;if (!pageInput.id) return;+ const limit = allPlans[opts.ctx.workspace.plan].limits;++ // the user is not eligible for password protection+ if (+ limit["password-protection"] === false &&+ opts.input.passwordProtected === true+ ) {+ throw new TRPCError({+ code: "FORBIDDEN",+ message: "Password protection is not available for your current plan.",+ });+ }+const currentPage = await opts.ctx.db.update(page).set({ ...pageInput, updatedAt: new Date() })@@ -146,12 +172,13 @@ export const pageRouter = createTRPCRouter({.run();}),getPagesByWorkspace: protectedProcedure.query(async (opts) => {- return opts.ctx.db.query.page.findMany({+ const allPages = await opts.ctx.db.query.page.findMany({where: and(eq(page.workspaceId, opts.ctx.workspace.id)),with: {monitorsToPages: { with: { monitor: true } },},});+ return z.array(selectPageSchemaWithMonitorsRelation).parse(allPages);}),// public if we use trpc hooks to get the page from the urldiff --git a/packages/db/drizzle/0027_bizarre_bastion.sql b/packages/db/drizzle/0027_bizarre_bastion.sqlnew file mode 100644index 000000000..7283d87db--- /dev/null+++ b/packages/db/drizzle/0027_bizarre_bastion.sql@@ -0,0 +1,2 @@+ALTER TABLE page ADD `password` text(256);--> statement-breakpoint+ALTER TABLE page ADD `password_protected` integer DEFAULT false;\ No newline at end of filediff --git a/packages/db/drizzle/meta/0027_snapshot.json b/packages/db/drizzle/meta/0027_snapshot.jsonnew file mode 100644index 000000000..6a414f697--- /dev/null+++ b/packages/db/drizzle/meta/0027_snapshot.json@@ -0,0 +1,1671 @@+{+ "version": "5",+ "dialect": "sqlite",+ "id": "4488e03b-52ea-45eb-aac9-7d263c8f2e43",+ "prevId": "0021b887-ceab-4294-a17c-34c902d14a12",+ "tables": {+ "status_report_to_monitors": {+ "name": "status_report_to_monitors",+ "columns": {+ "monitor_id": {+ "name": "monitor_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "status_report_id": {+ "name": "status_report_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "status_report_to_monitors_monitor_id_monitor_id_fk": {+ "name": "status_report_to_monitors_monitor_id_monitor_id_fk",+ "tableFrom": "status_report_to_monitors",+ "tableTo": "monitor",+ "columnsFrom": [+ "monitor_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "status_report_to_monitors_status_report_id_status_report_id_fk": {+ "name": "status_report_to_monitors_status_report_id_status_report_id_fk",+ "tableFrom": "status_report_to_monitors",+ "tableTo": "status_report",+ "columnsFrom": [+ "status_report_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "status_report_to_monitors_monitor_id_status_report_id_pk": {+ "columns": [+ "monitor_id",+ "status_report_id"+ ],+ "name": "status_report_to_monitors_monitor_id_status_report_id_pk"+ }+ },+ "uniqueConstraints": {}+ },+ "status_reports_to_pages": {+ "name": "status_reports_to_pages",+ "columns": {+ "page_id": {+ "name": "page_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "status_report_id": {+ "name": "status_report_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "status_reports_to_pages_page_id_page_id_fk": {+ "name": "status_reports_to_pages_page_id_page_id_fk",+ "tableFrom": "status_reports_to_pages",+ "tableTo": "page",+ "columnsFrom": [+ "page_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "status_reports_to_pages_status_report_id_status_report_id_fk": {+ "name": "status_reports_to_pages_status_report_id_status_report_id_fk",+ "tableFrom": "status_reports_to_pages",+ "tableTo": "status_report",+ "columnsFrom": [+ "status_report_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "status_reports_to_pages_page_id_status_report_id_pk": {+ "columns": [+ "page_id",+ "status_report_id"+ ],+ "name": "status_reports_to_pages_page_id_status_report_id_pk"+ }+ },+ "uniqueConstraints": {}+ },+ "status_report": {+ "name": "status_report",+ "columns": {+ "id": {+ "name": "id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "title": {+ "name": "title",+ "type": "text(256)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "status_report_workspace_id_workspace_id_fk": {+ "name": "status_report_workspace_id_workspace_id_fk",+ "tableFrom": "status_report",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {}+ },+ "status_report_update": {+ "name": "status_report_update",+ "columns": {+ "id": {+ "name": "id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "status": {+ "name": "status",+ "type": "text(4)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "date": {+ "name": "date",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "message": {+ "name": "message",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "status_report_id": {+ "name": "status_report_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "status_report_update_status_report_id_status_report_id_fk": {+ "name": "status_report_update_status_report_id_status_report_id_fk",+ "tableFrom": "status_report_update",+ "tableTo": "status_report",+ "columnsFrom": [+ "status_report_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {}+ },+ "integration": {+ "name": "integration",+ "columns": {+ "id": {+ "name": "id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text(256)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "credential": {+ "name": "credential",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ },+ "data": {+ "name": "data",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "integration_workspace_id_workspace_id_fk": {+ "name": "integration_workspace_id_workspace_id_fk",+ "tableFrom": "integration",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {}+ },+ "page": {+ "name": "page",+ "columns": {+ "id": {+ "name": "id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "icon": {+ "name": "icon",+ "type": "text(256)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "''"+ },+ "slug": {+ "name": "slug",+ "type": "text(256)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "custom_domain": {+ "name": "custom_domain",+ "type": "text(256)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "published": {+ "name": "published",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": false+ },+ "password": {+ "name": "password",+ "type": "text(256)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "password_protected": {+ "name": "password_protected",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ }+ },+ "indexes": {+ "page_slug_unique": {+ "name": "page_slug_unique",+ "columns": [+ "slug"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "page_workspace_id_workspace_id_fk": {+ "name": "page_workspace_id_workspace_id_fk",+ "tableFrom": "page",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {}+ },+ "monitor": {+ "name": "monitor",+ "columns": {+ "id": {+ "name": "id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "job_type": {+ "name": "job_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'other'"+ },+ "periodicity": {+ "name": "periodicity",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'other'"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'active'"+ },+ "active": {+ "name": "active",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": false+ },+ "regions": {+ "name": "regions",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "''"+ },+ "url": {+ "name": "url",+ "type": "text(2048)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text(256)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "''"+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "''"+ },+ "headers": {+ "name": "headers",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "''"+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "''"+ },+ "method": {+ "name": "method",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "'GET'"+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "assertions": {+ "name": "assertions",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "public": {+ "name": "public",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "monitor_workspace_id_workspace_id_fk": {+ "name": "monitor_workspace_id_workspace_id_fk",+ "tableFrom": "monitor",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {}+ },+ "monitors_to_pages": {+ "name": "monitors_to_pages",+ "columns": {+ "monitor_id": {+ "name": "monitor_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "page_id": {+ "name": "page_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "monitors_to_pages_monitor_id_monitor_id_fk": {+ "name": "monitors_to_pages_monitor_id_monitor_id_fk",+ "tableFrom": "monitors_to_pages",+ "tableTo": "monitor",+ "columnsFrom": [+ "monitor_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "monitors_to_pages_page_id_page_id_fk": {+ "name": "monitors_to_pages_page_id_page_id_fk",+ "tableFrom": "monitors_to_pages",+ "tableTo": "page",+ "columnsFrom": [+ "page_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "monitors_to_pages_monitor_id_page_id_pk": {+ "columns": [+ "monitor_id",+ "page_id"+ ],+ "name": "monitors_to_pages_monitor_id_page_id_pk"+ }+ },+ "uniqueConstraints": {}+ },+ "user": {+ "name": "user",+ "columns": {+ "id": {+ "name": "id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "tenant_id": {+ "name": "tenant_id",+ "type": "text(256)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "first_name": {+ "name": "first_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "''"+ },+ "last_name": {+ "name": "last_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "''"+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "''"+ },+ "photo_url": {+ "name": "photo_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "''"+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ }+ },+ "indexes": {+ "user_tenant_id_unique": {+ "name": "user_tenant_id_unique",+ "columns": [+ "tenant_id"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {}+ },+ "users_to_workspaces": {+ "name": "users_to_workspaces",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'member'"+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "users_to_workspaces_user_id_user_id_fk": {+ "name": "users_to_workspaces_user_id_user_id_fk",+ "tableFrom": "users_to_workspaces",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "users_to_workspaces_workspace_id_workspace_id_fk": {+ "name": "users_to_workspaces_workspace_id_workspace_id_fk",+ "tableFrom": "users_to_workspaces",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "users_to_workspaces_user_id_workspace_id_pk": {+ "columns": [+ "user_id",+ "workspace_id"+ ],+ "name": "users_to_workspaces_user_id_workspace_id_pk"+ }+ },+ "uniqueConstraints": {}+ },+ "page_subscriber": {+ "name": "page_subscriber",+ "columns": {+ "id": {+ "name": "id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "page_id": {+ "name": "page_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "accepted_at": {+ "name": "accepted_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "page_subscriber_page_id_page_id_fk": {+ "name": "page_subscriber_page_id_page_id_fk",+ "tableFrom": "page_subscriber",+ "tableTo": "page",+ "columnsFrom": [+ "page_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {}+ },+ "workspace": {+ "name": "workspace",+ "columns": {+ "id": {+ "name": "id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "slug": {+ "name": "slug",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "stripe_id": {+ "name": "stripe_id",+ "type": "text(256)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "subscription_id": {+ "name": "subscription_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "plan": {+ "name": "plan",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "ends_at": {+ "name": "ends_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "paid_until": {+ "name": "paid_until",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ },+ "dsn": {+ "name": "dsn",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "workspace_slug_unique": {+ "name": "workspace_slug_unique",+ "columns": [+ "slug"+ ],+ "isUnique": true+ },+ "workspace_stripe_id_unique": {+ "name": "workspace_stripe_id_unique",+ "columns": [+ "stripe_id"+ ],+ "isUnique": true+ },+ "workspace_id_dsn_unique": {+ "name": "workspace_id_dsn_unique",+ "columns": [+ "id",+ "dsn"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {}+ },+ "notification": {+ "name": "notification",+ "columns": {+ "id": {+ "name": "id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "data": {+ "name": "data",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "'{}'"+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "notification_workspace_id_workspace_id_fk": {+ "name": "notification_workspace_id_workspace_id_fk",+ "tableFrom": "notification",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {}+ },+ "notifications_to_monitors": {+ "name": "notifications_to_monitors",+ "columns": {+ "monitor_id": {+ "name": "monitor_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "notification_id": {+ "name": "notification_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "notifications_to_monitors_monitor_id_monitor_id_fk": {+ "name": "notifications_to_monitors_monitor_id_monitor_id_fk",+ "tableFrom": "notifications_to_monitors",+ "tableTo": "monitor",+ "columnsFrom": [+ "monitor_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "notifications_to_monitors_notification_id_notification_id_fk": {+ "name": "notifications_to_monitors_notification_id_notification_id_fk",+ "tableFrom": "notifications_to_monitors",+ "tableTo": "notification",+ "columnsFrom": [+ "notification_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "notifications_to_monitors_monitor_id_notification_id_pk": {+ "columns": [+ "monitor_id",+ "notification_id"+ ],+ "name": "notifications_to_monitors_monitor_id_notification_id_pk"+ }+ },+ "uniqueConstraints": {}+ },+ "monitor_status": {+ "name": "monitor_status",+ "columns": {+ "monitor_id": {+ "name": "monitor_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "region": {+ "name": "region",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "''"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'active'"+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ }+ },+ "indexes": {+ "monitor_status_idx": {+ "name": "monitor_status_idx",+ "columns": [+ "monitor_id",+ "region"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "monitor_status_monitor_id_monitor_id_fk": {+ "name": "monitor_status_monitor_id_monitor_id_fk",+ "tableFrom": "monitor_status",+ "tableTo": "monitor",+ "columnsFrom": [+ "monitor_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "monitor_status_monitor_id_region_pk": {+ "columns": [+ "monitor_id",+ "region"+ ],+ "name": "monitor_status_monitor_id_region_pk"+ }+ },+ "uniqueConstraints": {}+ },+ "invitation": {+ "name": "invitation",+ "columns": {+ "id": {+ "name": "id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'member'"+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ },+ "accepted_at": {+ "name": "accepted_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {}+ },+ "incident": {+ "name": "incident",+ "columns": {+ "id": {+ "name": "id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "''"+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "''"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'triage'"+ },+ "monitor_id": {+ "name": "monitor_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "started_at": {+ "name": "started_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ },+ "acknowledged_at": {+ "name": "acknowledged_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "acknowledged_by": {+ "name": "acknowledged_by",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "resolved_by": {+ "name": "resolved_by",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "incident_screenshot_url": {+ "name": "incident_screenshot_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "recovery_screenshot_url": {+ "name": "recovery_screenshot_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "auto_resolved": {+ "name": "auto_resolved",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ }+ },+ "indexes": {+ "incident_monitor_id_started_at_unique": {+ "name": "incident_monitor_id_started_at_unique",+ "columns": [+ "monitor_id",+ "started_at"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "incident_monitor_id_monitor_id_fk": {+ "name": "incident_monitor_id_monitor_id_fk",+ "tableFrom": "incident",+ "tableTo": "monitor",+ "columnsFrom": [+ "monitor_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set default",+ "onUpdate": "no action"+ },+ "incident_workspace_id_workspace_id_fk": {+ "name": "incident_workspace_id_workspace_id_fk",+ "tableFrom": "incident",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "incident_acknowledged_by_user_id_fk": {+ "name": "incident_acknowledged_by_user_id_fk",+ "tableFrom": "incident",+ "tableTo": "user",+ "columnsFrom": [+ "acknowledged_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "incident_resolved_by_user_id_fk": {+ "name": "incident_resolved_by_user_id_fk",+ "tableFrom": "incident",+ "tableTo": "user",+ "columnsFrom": [+ "resolved_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {}+ },+ "monitor_tag": {+ "name": "monitor_tag",+ "columns": {+ "id": {+ "name": "id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "monitor_tag_workspace_id_workspace_id_fk": {+ "name": "monitor_tag_workspace_id_workspace_id_fk",+ "tableFrom": "monitor_tag",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {}+ },+ "monitor_tag_to_monitor": {+ "name": "monitor_tag_to_monitor",+ "columns": {+ "monitor_id": {+ "name": "monitor_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "monitor_tag_id": {+ "name": "monitor_tag_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "(strftime('%s', 'now'))"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "monitor_tag_to_monitor_monitor_id_monitor_id_fk": {+ "name": "monitor_tag_to_monitor_monitor_id_monitor_id_fk",+ "tableFrom": "monitor_tag_to_monitor",+ "tableTo": "monitor",+ "columnsFrom": [+ "monitor_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "monitor_tag_to_monitor_monitor_tag_id_monitor_tag_id_fk": {+ "name": "monitor_tag_to_monitor_monitor_tag_id_monitor_tag_id_fk",+ "tableFrom": "monitor_tag_to_monitor",+ "tableTo": "monitor_tag",+ "columnsFrom": [+ "monitor_tag_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "monitor_tag_to_monitor_monitor_id_monitor_tag_id_pk": {+ "columns": [+ "monitor_id",+ "monitor_tag_id"+ ],+ "name": "monitor_tag_to_monitor_monitor_id_monitor_tag_id_pk"+ }+ },+ "uniqueConstraints": {}+ }+ },+ "enums": {},+ "_meta": {+ "schemas": {},+ "tables": {},+ "columns": {}+ }+}\ No newline at end of filediff --git a/packages/db/drizzle/meta/_journal.json b/packages/db/drizzle/meta/_journal.jsonindex 2aa0a07ca..a08d6a8df 100644--- a/packages/db/drizzle/meta/_journal.json+++ b/packages/db/drizzle/meta/_journal.json@@ -190,6 +190,13 @@"when": 1713384976187,"tag": "0026_giant_absorbing_man","breakpoints": true+ },+ {+ "idx": 27,+ "version": "5",+ "when": 1714586658374,+ "tag": "0027_bizarre_bastion",+ "breakpoints": true}]}\ No newline at end of filediff --git a/packages/db/src/schema/pages/page.ts b/packages/db/src/schema/pages/page.tsindex 0dcaec9cd..58111a83f 100644--- a/packages/db/src/schema/pages/page.ts+++ b/packages/db/src/schema/pages/page.ts@@ -19,6 +19,12 @@ export const page = sqliteTable("page", {customDomain: text("custom_domain", { length: 256 }).notNull(),published: integer("published", { mode: "boolean" }).default(false),+ // Password protecting the status page - no specific restriction on password+ password: text("password", { length: 256 }),+ passwordProtected: integer("password_protected", { mode: "boolean" }).default(+ false,+ ),+createdAt: integer("created_at", { mode: "timestamp" }).default(sql`(strftime('%s', 'now'))`,),diff --git a/packages/db/src/schema/pages/validation.ts b/packages/db/src/schema/pages/validation.tsindex dcebbbf9b..a577a8731 100644--- a/packages/db/src/schema/pages/validation.ts+++ b/packages/db/src/schema/pages/validation.ts@@ -25,10 +25,13 @@ export const insertPageSchema = createInsertSchema(page, {icon: z.string().optional(),slug: slugSchema,}).extend({+ password: z.string().nullable().optional().default(""),monitors: z.array(z.number()).optional().default([]),});-export const selectPageSchema = createSelectSchema(page);+export const selectPageSchema = createSelectSchema(page).extend({+ password: z.string().optional().nullable().default(""),+});export type InsertPage = z.infer<typeof insertPageSchema>;export type Page = z.infer<typeof selectPageSchema>;diff --git a/packages/db/src/schema/shared.ts b/packages/db/src/schema/shared.tsindex 326220852..e6c6c7ac0 100644--- a/packages/db/src/schema/shared.ts+++ b/packages/db/src/schema/shared.ts@@ -35,6 +35,16 @@ export const selectPageSchemaWithRelation = selectPageSchema.extend({statusReports: z.array(selectStatusReportPageSchema),});+export const selectPageSchemaWithMonitorsRelation = selectPageSchema.extend({+ monitorsToPages: z.array(+ z.object({+ monitorId: z.number(),+ pageId: z.number(),+ monitor: selectMonitorSchema,+ }),+ ),+});+export const selectPublicPageSchemaWithRelation = selectPageSchema.extend({monitors: z.array(selectPublicMonitorSchema),diff --git a/packages/db/src/schema/workspaces/constants.ts b/packages/db/src/schema/workspaces/constants.tsindex 122364ef4..2d1c617fc 100644--- a/packages/db/src/schema/workspaces/constants.ts+++ b/packages/db/src/schema/workspaces/constants.ts@@ -1,2 +1,12 @@export const workspacePlans = ["free", "starter", "team", "pro"] as const;export const workspaceRole = ["owner", "admin", "member"] as const;++export const workspacePlanHierarchy: Record<+ (typeof workspacePlans)[number],+ number+> = {+ free: 0,+ starter: 1,+ team: 2,+ pro: 3,+};diff --git a/packages/plans/src/config.ts b/packages/plans/src/config.tsindex 9a67d10e6..aa67cfb82 100644--- a/packages/plans/src/config.ts+++ b/packages/plans/src/config.ts@@ -24,6 +24,7 @@ export const allPlans: Record<"status-pages": 1,"status-subscribers": false,"custom-domain": false,+ "password-protection": false,"white-label": false,notifications: true,sms: false,@@ -44,6 +45,7 @@ export const allPlans: Record<"status-pages": 1,"status-subscribers": true,"custom-domain": true,+ "password-protection": true,"white-label": false,notifications: true,sms: true,@@ -64,6 +66,7 @@ export const allPlans: Record<"status-pages": 5,"status-subscribers": true,"custom-domain": true,+ "password-protection": true,"white-label": false,notifications: true,sms: true,@@ -84,6 +87,7 @@ export const allPlans: Record<"status-pages": 20,"status-subscribers": true,"custom-domain": true,+ "password-protection": true,"white-label": true,notifications: true,sms: true,diff --git a/packages/plans/src/pricing-table.ts b/packages/plans/src/pricing-table.tsindex f0c0ca6a6..03cdf8fbb 100644--- a/packages/plans/src/pricing-table.ts+++ b/packages/plans/src/pricing-table.ts@@ -40,6 +40,10 @@ export const pricingTableConfig: Record<value: "custom-domain",label: "Custom domain",},+ {+ value: "password-protection",+ label: "Password-protected",+ },{value: "white-label",label: "White Label",diff --git a/packages/plans/src/types.ts b/packages/plans/src/types.tsindex 5a9faf740..599277def 100644--- a/packages/plans/src/types.ts+++ b/packages/plans/src/types.ts@@ -10,6 +10,7 @@ export type Limits = {"status-pages": number;"status-subscribers": boolean;"custom-domain": boolean;+ "password-protection": boolean;"white-label": boolean;// alertsnotifications: boolean;