···44import Link from "next/link";
55import { useRouter } from "next/navigation";
66import { MoreVertical } from "lucide-react";
77-import type * as z from "zod";
8799-import type { insertPageSchemaWithMonitors } from "@openstatus/db/src/schema";
88+import type { Page } from "@openstatus/db/src/schema";
109import {
1110 AlertDialog,
1211 AlertDialogAction,
···2827import { useToastAction } from "@/hooks/use-toast-action";
2928import { api } from "@/trpc/client";
30293131-type PageSchema = z.infer<typeof insertPageSchemaWithMonitors>;
3232-3330interface ActionButtonProps {
3434- page: PageSchema;
3131+ page: Page;
3532}
36333734export function ActionButton({ page }: ActionButtonProps) {
···11import Link from "next/link";
22-import type * as z from "zod";
3244-import type { allMonitorsExtendedSchema } from "@openstatus/db/src/schema";
33+import type { Monitor } from "@openstatus/db/src/schema";
54import { Button } from "@openstatus/ui";
6576import { EmptyState as DefaultEmptyState } from "@/components/dashboard/empty-state";
8799-export function EmptyState({
1010- allMonitors,
1111-}: {
1212- allMonitors?: z.infer<typeof allMonitorsExtendedSchema>;
1313-}) {
1414- // Navigate user to monitor if they don't have one
88+export function EmptyState({ allMonitors }: { allMonitors?: Monitor[] }) {
159 if (!Boolean(allMonitors?.length)) {
1610 return (
1711 <DefaultEmptyState
···11+export * from "./incident";
22+export * from "./validation";
33+export type * from "./validation";
+44
packages/db/src/schema/incidents/validation.ts
···11+import { createInsertSchema, createSelectSchema } from "drizzle-zod";
22+import * as z from "zod";
33+44+import { incident, incidentStatus, incidentUpdate } from "./incident";
55+66+export const incidentStatusSchema = z.enum(incidentStatus);
77+88+export const insertIncidentUpdateSchema = createInsertSchema(incidentUpdate, {
99+ status: incidentStatusSchema,
1010+}).extend({
1111+ workspaceSlug: z.string(), // FIXME: we should do it differently!
1212+});
1313+1414+export const insertIncidentSchema = createInsertSchema(incident, {
1515+ status: incidentStatusSchema,
1616+})
1717+ .extend({
1818+ date: z.date().optional().default(new Date()),
1919+ workspaceSlug: z.string(),
2020+ /**
2121+ * relationship to monitors and pages
2222+ */
2323+ monitors: z.number().array().optional().default([]),
2424+ pages: z.number().array().optional().default([]),
2525+ })
2626+ .extend({
2727+ /**
2828+ * message for the `InsertIncidentUpdate`
2929+ */
3030+ message: z.string(),
3131+ });
3232+3333+export const selectIncidentSchema = createSelectSchema(incident, {
3434+ status: incidentStatusSchema,
3535+});
3636+3737+export const selectIncidentUpdateSchema = createSelectSchema(incidentUpdate, {
3838+ status: incidentStatusSchema,
3939+});
4040+4141+export type InsertIncident = z.infer<typeof insertIncidentSchema>;
4242+export type Incident = z.infer<typeof selectIncidentSchema>;
4343+export type InsertIncidentUpdate = z.infer<typeof insertIncidentUpdateSchema>;
4444+export type IncidentUpdate = z.infer<typeof selectIncidentUpdateSchema>;
+6-6
packages/db/src/schema/index.ts
···11-export * from "./incident";
11+export * from "./incidents";
22export * from "./integration";
33-export * from "./page";
44-export * from "./monitor";
55-export * from "./user";
66-export * from "./workspace";
33+export * from "./pages";
44+export * from "./monitors";
55+export * from "./users";
66+export * from "./workspaces";
77export * from "./shared";
88-export * from "./notification";
88+export * from "./notifications";
+2-2
packages/db/src/schema/integration.ts
···11import { sql } from "drizzle-orm";
22import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
33-import { createInsertSchema, createSelectSchema } from "drizzle-zod";
33+import { createInsertSchema } from "drizzle-zod";
4455-import { workspace } from "./workspace";
55+import { workspace } from "./workspaces";
6677export const integration = sqliteTable("integration", {
88 id: integer("id").primaryKey(),
···11import { relations, sql } from "drizzle-orm";
22import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
33-import { createSelectSchema } from "drizzle-zod";
44-import { z } from "zod";
5366-import { page } from "./page";
77-import { usersToWorkspaces } from "./user";
88-99-const plan = ["free", "pro"] as const;
44+import { page } from "../pages";
55+import { usersToWorkspaces } from "../users";
66+import { workspacePlans } from "./constants";
107118export const workspace = sqliteTable("workspace", {
129 id: integer("id").primaryKey(),
···15121613 stripeId: text("stripe_id", { length: 256 }).unique(),
1714 subscriptionId: text("subscription_id"),
1818- plan: text("plan", plan),
1515+ plan: text("plan", { enum: workspacePlans }),
1916 endsAt: integer("ends_at", { mode: "timestamp" }),
2017 paidUntil: integer("paid_until", { mode: "timestamp" }),
2118···3128 usersToWorkspaces: many(usersToWorkspaces),
3229 pages: many(page),
3330}));
3434-3535-export const selectWorkspaceSchema = createSelectSchema(workspace).extend({
3636- plan: z
3737- .enum(plan)
3838- .nullable()
3939- .default("free")
4040- .transform((val) => val ?? "free"),
4141-});
+1
packages/db/src/schema/workspaces/constants.ts
···11+export const workspacePlans = ["free", "pro"] as const;
+4
packages/db/src/schema/workspaces/index.ts
···11+export * from "./constants";
22+export * from "./workspace";
33+export * from "./validation";
44+export type * from "./validation";
+20
packages/db/src/schema/workspaces/validation.ts
···11+import { createSelectSchema } from "drizzle-zod";
22+import { z } from "zod";
33+44+import { workspacePlans } from "./constants";
55+import { workspace } from "./workspace";
66+77+export const workspacePlanSchema = z.enum(workspacePlans);
88+99+export const selectWorkspaceSchema = createSelectSchema(workspace).extend({
1010+ plan: z
1111+ .enum(workspacePlans)
1212+ .nullable()
1313+ .default("free")
1414+ .transform((val) => val ?? "free"),
1515+});
1616+1717+export const insertWorkspaceSchema = createSelectSchema(workspace);
1818+1919+export type Workspace = z.infer<typeof selectWorkspaceSchema>;
2020+export type WorkspacePlan = z.infer<typeof workspacePlanSchema>;
+4-8
packages/notifications/email/src/index.ts
···11-import type { z } from "zod";
22-33-import type {
44- basicMonitorSchema,
55- selectNotificationSchema,
66-} from "@openstatus/db/src/schema";
11+import type { Monitor, Notification } from "@openstatus/db/src/schema";
7283import { env } from "../env";
94import { EmailConfigurationSchema } from "./schema/config";
···127 monitor,
138 notification,
149}: {
1515- monitor: z.infer<typeof basicMonitorSchema>;
1616- notification: z.infer<typeof selectNotificationSchema>;
1010+ monitor: Monitor;
1111+ notification: Notification;
1712}) => {
1313+ // FIXME:
1814 const config = EmailConfigurationSchema.parse(JSON.parse(notification.data));
1915 const { email } = config;
2016
+2-4
packages/plans/index.ts
···11-import type * as z from "zod";
22-33-import type { periodicityEnum } from "@openstatus/db/src/schema";
11+import type { MonitorPeriodicity } from "@openstatus/db/src/schema";
4253export type Plan = {
64 limits: {
75 monitors: number;
86 "status-pages": number;
99- periodicity: Partial<z.infer<typeof periodicityEnum>>[];
77+ periodicity: Partial<MonitorPeriodicity>[];
108 };
119};
1210