Skip to content

Open-source status page, incident response and uptime monitoring

💸 pricing update (#932)

Thibault Le Ouayd002030cdf47
diff --git a/apps/server/package.json b/apps/server/package.json
index ac6021834..74ad5d539 100644
--- a/apps/server/package.json
+++ b/apps/server/package.json
@@ -22,7 +22,6 @@
"@openstatus/notification-pagerduty": "workspace:*",
"@openstatus/notification-slack": "workspace:*",
"@openstatus/notification-twillio-sms": "workspace:*",
- "@openstatus/plans": "workspace:*",
"@openstatus/tinybird": "workspace:*",
"@openstatus/tracker": "workspace:*",
"@openstatus/upstash": "workspace:*",
diff --git a/apps/server/src/checker/alerting.ts b/apps/server/src/checker/alerting.ts
index d0840604e..28c7e57be 100644
--- a/apps/server/src/checker/alerting.ts
+++ b/apps/server/src/checker/alerting.ts
@@ -1,8 +1,5 @@
import { db, eq, schema } from "@openstatus/db";
-import type {
- MonitorFlyRegion,
- MonitorStatus,
-} from "@openstatus/db/src/schema";
+import type { MonitorStatus } from "@openstatus/db/src/schema";
import {
selectMonitorSchema,
selectNotificationSchema,
@@ -10,6 +7,7 @@ import {
import { checkerAudit } from "../utils/audit-log";
import { providerToFunction } from "./utils";
+import type { MonitorFlyRegion } from "@openstatus/db/src/schema/constants";
export const triggerNotifications = async ({
monitorId,
diff --git a/apps/server/src/checker/index.ts b/apps/server/src/checker/index.ts
index 01b36ff4b..19ee5d8f3 100644
--- a/apps/server/src/checker/index.ts
+++ b/apps/server/src/checker/index.ts
@@ -4,7 +4,6 @@ import { z } from "zod";
import { and, db, eq, isNull, schema } from "@openstatus/db";
import { incidentTable } from "@openstatus/db/src/schema";
-import { flyRegions } from "@openstatus/db/src/schema/monitors/constants";
import {
monitorStatusSchema,
selectMonitorSchema,
@@ -14,6 +13,7 @@ import { Redis } from "@openstatus/upstash";
import { env } from "../env";
import { checkerAudit } from "../utils/audit-log";
import { triggerNotifications, upsertMonitorStatus } from "./alerting";
+import { flyRegions } from "@openstatus/db/src/schema/constants";
export const checkerRoute = new Hono();
const redis = Redis.fromEnv();
diff --git a/apps/server/src/env.ts b/apps/server/src/env.ts
index fc2dc20c7..b19eb6f0a 100644
--- a/apps/server/src/env.ts
+++ b/apps/server/src/env.ts
@@ -1,8 +1,7 @@
+import { flyRegions } from "@openstatus/db/src/schema/constants";
import { createEnv } from "@t3-oss/env-core";
import { z } from "zod";
-import { flyRegions } from "@openstatus/db/src/schema";
-
export const env = createEnv({
server: {
UNKEY_API_ID: z.string().min(1),
diff --git a/apps/server/src/v1/index.ts b/apps/server/src/v1/index.ts
index bb09d7799..20dcd80f5 100644
--- a/apps/server/src/v1/index.ts
+++ b/apps/server/src/v1/index.ts
@@ -3,8 +3,6 @@ import { cors } from "hono/cors";
import { logger } from "hono/logger";
import { apiReference } from "@scalar/hono-api-reference";
-import type { Limits } from "@openstatus/plans/src/types";
-
import { handleError, handleZodError } from "../libs/errors";
import { checkAPI } from "./check";
import { incidentsApi } from "./incidents";
@@ -15,6 +13,7 @@ import { pageSubscribersApi } from "./pageSubscribers";
import { pagesApi } from "./pages";
import { statusReportUpdatesApi } from "./statusReportUpdates";
import { statusReportsApi } from "./statusReports";
+import type { Limits } from "@openstatus/db/src/schema/plan/schema";
export type Variables = {
workspaceId: string;
@@ -22,8 +21,8 @@ export type Variables = {
title: "Hobby" | "Starter" | "Growth" | "Pro";
description: string;
price: number;
- limits: Limits;
};
+ limits: Limits;
};
export const api = new OpenAPIHono<{ Variables: Variables }>({
diff --git a/apps/server/src/v1/middleware.ts b/apps/server/src/v1/middleware.ts
index bb0359a34..9bda6a91e 100644
--- a/apps/server/src/v1/middleware.ts
+++ b/apps/server/src/v1/middleware.ts
@@ -2,8 +2,8 @@ import { verifyKey } from "@unkey/api";
import type { Context, Next } from "hono";
import { db, eq } from "@openstatus/db";
-import { workspace } from "@openstatus/db/src/schema";
-import { getPlanConfig } from "@openstatus/plans";
+import { selectWorkspaceSchema, workspace } from "@openstatus/db/src/schema";
+import { getPlanConfig } from "@openstatus/db/src/schema/plan/utils";
import type { Variables } from "./index";
import { HTTPException } from "hono/http-exception";
@@ -34,9 +34,10 @@ export async function middleware(
console.error("Workspace not found");
throw new HTTPException(401, { message: "Unauthorized" });
}
-
+ const _work = selectWorkspaceSchema.parse(_workspace);
c.set("workspacePlan", getPlanConfig(_workspace.plan));
c.set("workspaceId", `${result.ownerId}`);
+ c.set("limits", _work.limits);
await next();
}
diff --git a/apps/server/src/v1/monitors/post.ts b/apps/server/src/v1/monitors/post.ts
index 32acc4e7c..d3e16930b 100644
--- a/apps/server/src/v1/monitors/post.ts
+++ b/apps/server/src/v1/monitors/post.ts
@@ -12,6 +12,7 @@ import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses
import type { monitorsApi } from "./index";
import { MonitorSchema } from "./schema";
import { getAssertions } from "./utils";
+import { getLimit } from "@openstatus/db/src/schema/plan/utils";
const postRoute = createRoute({
method: "post",
@@ -44,8 +45,7 @@ const postRoute = createRoute({
export function registerPostMonitor(api: typeof monitorsApi) {
return api.openapi(postRoute, async (c) => {
const workspaceId = c.get("workspaceId");
- const workspacePlan = c.get("workspacePlan");
-
+ const limits = c.get("limits");
const input = c.req.valid("json");
const count = (
await db
@@ -60,18 +60,18 @@ export function registerPostMonitor(api: typeof monitorsApi) {
.all()
)[0].count;
- if (count >= workspacePlan.limits.monitors) {
+ if (count >= getLimit(limits, "monitors")) {
throw new HTTPException(403, {
message: "Upgrade for more monitors",
});
}
- if (!workspacePlan.limits.periodicity.includes(input.periodicity)) {
+ if (!getLimit(limits, "periodicity").includes(input.periodicity)) {
throw new HTTPException(403, { message: "Forbidden" });
}
for (const region of input.regions) {
- if (!workspacePlan.limits.regions.includes(region)) {
+ if (!getLimit(limits, "regions").includes(region)) {
throw new HTTPException(403, { message: "Upgrade for more region" });
}
}
diff --git a/apps/server/src/v1/monitors/put.ts b/apps/server/src/v1/monitors/put.ts
index 5dbd22c27..aaebb4de4 100644
--- a/apps/server/src/v1/monitors/put.ts
+++ b/apps/server/src/v1/monitors/put.ts
@@ -42,16 +42,16 @@ const putRoute = createRoute({
export function registerPutMonitor(api: typeof monitorsApi) {
return api.openapi(putRoute, async (c) => {
const workspaceId = c.get("workspaceId");
- const workspacePlan = c.get("workspacePlan");
+ const limits = c.get("limits");
const { id } = c.req.valid("param");
const input = c.req.valid("json");
- if (!workspacePlan.limits.periodicity.includes(input.periodicity)) {
+ if (!limits.periodicity.includes(input.periodicity)) {
throw new HTTPException(403, { message: "Forbidden" });
}
for (const region of input.regions) {
- if (!workspacePlan.limits.regions.includes(region)) {
+ if (!limits.regions.includes(region)) {
throw new HTTPException(403, { message: "Upgrade for more region" });
}
}
diff --git a/apps/server/src/v1/monitors/schema.ts b/apps/server/src/v1/monitors/schema.ts
index 6f74d4821..cf0f936a9 100644
--- a/apps/server/src/v1/monitors/schema.ts
+++ b/apps/server/src/v1/monitors/schema.ts
@@ -1,15 +1,15 @@
import { z } from "@hono/zod-openapi";
-import {
- flyRegions,
- monitorMethods,
- monitorPeriodicitySchema,
-} from "@openstatus/db/src/schema";
+import { monitorMethods } from "@openstatus/db/src/schema";
import { ZodError } from "zod";
import {
numberCompare,
stringCompare,
} from "../../../../../packages/assertions/src/v1";
+import {
+ flyRegions,
+ monitorPeriodicitySchema,
+} from "@openstatus/db/src/schema/constants";
const statusAssertion = z
.object({
@@ -113,7 +113,7 @@ export const MonitorSchema = z
]);
}
},
- z.array(z.enum(flyRegions)),
+ z.array(z.enum(flyRegions))
)
.default([])
.openapi({
@@ -161,7 +161,7 @@ export const MonitorSchema = z
]);
}
},
- z.array(z.object({ key: z.string(), value: z.string() })).default([]),
+ z.array(z.object({ key: z.string(), value: z.string() })).default([])
)
.nullish()
.openapi({
diff --git a/apps/server/src/v1/notifications/post.ts b/apps/server/src/v1/notifications/post.ts
index 5bdc650fb..b89cde0dd 100644
--- a/apps/server/src/v1/notifications/post.ts
+++ b/apps/server/src/v1/notifications/post.ts
@@ -12,6 +12,7 @@ import { HTTPException } from "hono/http-exception";
import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses";
import type { notificationsApi } from "./index";
import { NotificationSchema } from "./schema";
+import { getLimit } from "@openstatus/db/src/schema/plan/utils";
const postRoute = createRoute({
method: "post",
@@ -45,6 +46,7 @@ export function registerPostNotification(api: typeof notificationsApi) {
return api.openapi(postRoute, async (c) => {
const workspaceId = c.get("workspaceId");
const workspacePlan = c.get("workspacePlan");
+ const limits = c.get("limits");
const input = c.req.valid("json");
if (input.provider === "sms" && workspacePlan.title === "Hobby") {
@@ -59,7 +61,7 @@ export function registerPostNotification(api: typeof notificationsApi) {
.all()
)[0].count;
- if (count >= workspacePlan.limits["notification-channels"]) {
+ if (count >= getLimit(limits, "notification-channels")) {
throw new HTTPException(403, {
message: "Upgrade for more notification channels",
});
diff --git a/apps/server/src/v1/pages/post.ts b/apps/server/src/v1/pages/post.ts
index 47fa3e726..43e1b0088 100644
--- a/apps/server/src/v1/pages/post.ts
+++ b/apps/server/src/v1/pages/post.ts
@@ -9,6 +9,7 @@ import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses
import { isNumberArray } from "../utils";
import type { pagesApi } from "./index";
import { PageSchema } from "./schema";
+import { getLimit } from "@openstatus/db/src/schema/plan/utils";
const postRoute = createRoute({
method: "post",
@@ -41,7 +42,7 @@ const postRoute = createRoute({
export function registerPostPage(api: typeof pagesApi) {
return api.openapi(postRoute, async (c) => {
const workspaceId = c.get("workspaceId");
- const workspacePlan = c.get("workspacePlan");
+ const limits = c.get("limits");
const input = c.req.valid("json");
const count = (
@@ -52,14 +53,14 @@ export function registerPostPage(api: typeof pagesApi) {
.all()
)[0].count;
- if (count >= workspacePlan.limits["status-pages"]) {
+ if (count >= getLimit(limits, "status-pages")) {
throw new HTTPException(403, {
message: "Upgrade for more status pages",
});
}
if (
- workspacePlan.limits["password-protection"] === false &&
+ getLimit(limits, "password-protection") === false &&
input?.passwordProtected === true
) {
throw new HTTPException(403, {
diff --git a/apps/server/src/v1/pages/put.ts b/apps/server/src/v1/pages/put.ts
index d1f7b612a..fc5d9ba10 100644
--- a/apps/server/src/v1/pages/put.ts
+++ b/apps/server/src/v1/pages/put.ts
@@ -42,12 +42,12 @@ const putRoute = createRoute({
export function registerPutPage(api: typeof pagesApi) {
return api.openapi(putRoute, async (c) => {
const workspaceId = c.get("workspaceId");
- const workspacePlan = c.get("workspacePlan");
+ const limits = c.get("limits");
const { id } = c.req.valid("param");
const input = c.req.valid("json");
if (
- workspacePlan.limits["password-protection"] === false &&
+ limits["password-protection"] === false &&
input?.passwordProtected === true
) {
throw new HTTPException(403, {
diff --git a/apps/server/src/v1/statusReports/post.ts b/apps/server/src/v1/statusReports/post.ts
index 07eca637f..e69024c8b 100644
--- a/apps/server/src/v1/statusReports/post.ts
+++ b/apps/server/src/v1/statusReports/post.ts
@@ -1,6 +1,6 @@
import { createRoute, z } from "@hono/zod-openapi";
-import { and, asc, db, eq, inArray, isNotNull, isNull } from "@openstatus/db";
+import { and, db, eq, inArray, isNotNull, isNull } from "@openstatus/db";
import {
monitor,
monitorsToStatusReport,
@@ -16,6 +16,7 @@ import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses
import { isoDate } from "../utils";
import type { statusReportsApi } from "./index";
import { StatusReportSchema } from "./schema";
+import { getLimit } from "@openstatus/db/src/schema/plan/utils";
const postRoute = createRoute({
method: "post",
@@ -59,7 +60,7 @@ export function registerPostStatusReport(api: typeof statusReportsApi) {
return api.openapi(postRoute, async (c) => {
const input = c.req.valid("json");
const workspaceId = c.get("workspaceId");
- const workspacePlan = c.get("workspacePlan");
+ const limits = c.get("limits");
const { monitorIds, date, ...rest } = input;
@@ -81,22 +82,21 @@ export function registerPostStatusReport(api: typeof statusReportsApi) {
}
}
-
- if(rest.pageId){
+ if (rest.pageId) {
const _pages = await db
- .select()
- .from(page)
- .where(
- and(
- eq(page.workspaceId, Number(workspaceId)),
- eq(page.id, rest.pageId)
+ .select()
+ .from(page)
+ .where(
+ and(
+ eq(page.workspaceId, Number(workspaceId)),
+ eq(page.id, rest.pageId)
+ )
)
- )
- .all();
+ .all();
- if (_pages.length !== 1) {
- throw new HTTPException(400, { message: "Page not found" });
- }
+ if (_pages.length !== 1) {
+ throw new HTTPException(400, { message: "Page not found" });
+ }
}
const _newStatusReport = await db
@@ -132,7 +132,7 @@ export function registerPostStatusReport(api: typeof statusReportsApi) {
.returning();
}
- if (workspacePlan.limits.notifications && _newStatusReport.pageId) {
+ if (getLimit(limits, "status-subscribers") && _newStatusReport.pageId) {
const subscribers = await db
.select()
.from(pageSubscriber)
diff --git a/apps/server/src/v1/statusReports/schema.ts b/apps/server/src/v1/statusReports/schema.ts
index 46aff08fc..7536bd86f 100644
--- a/apps/server/src/v1/statusReports/schema.ts
+++ b/apps/server/src/v1/statusReports/schema.ts
@@ -1,6 +1,6 @@
import { z } from "@hono/zod-openapi";
-import { page, statusReportStatusSchema } from "@openstatus/db/src/schema";
+import { statusReportStatusSchema } from "@openstatus/db/src/schema";
export const ParamsSchema = z.object({
id: z
@@ -50,10 +50,9 @@ export const StatusReportSchema = z.object({
})
.nullable(),
- pageId: z.number().optional().nullable().openapi({
- description: "The id of the page this status report belongs to",
-
- }),
+ pageId: z.number().optional().nullable().openapi({
+ description: "The id of the page this status report belongs to",
+ }),
});
export type StatusReportSchema = z.infer<typeof StatusReportSchema>;
diff --git a/apps/web/package.json b/apps/web/package.json
index c030b687f..174df06db 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -28,7 +28,6 @@
"@openstatus/notification-emails": "workspace:*",
"@openstatus/notification-pagerduty": "workspace:*",
"@openstatus/notification-slack": "workspace:*",
- "@openstatus/plans": "workspace:*",
"@openstatus/react": "workspace:*",
"@openstatus/rum": "workspace:*",
"@openstatus/tinybird": "workspace:*",
diff --git a/apps/web/src/app/(content)/features/monitoring/page.tsx b/apps/web/src/app/(content)/features/monitoring/page.tsx
index 7ada7089e..46e37eb4b 100644
--- a/apps/web/src/app/(content)/features/monitoring/page.tsx
+++ b/apps/web/src/app/(content)/features/monitoring/page.tsx
@@ -3,7 +3,7 @@ import { Chart } from "@/components/monitor-charts/chart";
import { RegionsPreset } from "@/components/monitor-dashboard/region-preset";
import { ResponseDetailTabs } from "@/components/ping-response-analysis/response-detail-tabs";
import { marketingProductPagesConfig } from "@/config/pages";
-import { flyRegions } from "@openstatus/db/src/schema";
+import { flyRegions } from "@openstatus/db/src/schema/constants";
import type { Region } from "@openstatus/tinybird";
import { Button } from "@openstatus/ui";
import { allUnrelateds } from "contentlayer/generated";
@@ -15,7 +15,11 @@ import { Hero } from "../_components/hero";
import { InteractiveFeature } from "../_components/interactive-feature";
import { mockChartData, mockResponseData } from "../mock";
import type { Metadata } from "next";
-import { defaultMetadata, ogMetadata, twitterMetadata } from "@/app/shared-metadata";
+import {
+ defaultMetadata,
+ ogMetadata,
+ twitterMetadata,
+} from "@/app/shared-metadata";
const { description, subtitle } = marketingProductPagesConfig[0];
const code = allUnrelateds.find(
@@ -25,20 +29,22 @@ const code = allUnrelateds.find(
export const metadata: Metadata = {
...defaultMetadata,
title: "API & Website Monitoring",
- description:'Get insights of the latency of your API and website from all over the world.',
+ description:
+ "Get insights of the latency of your API and website from all over the world.",
twitter: {
...twitterMetadata,
title: "API & Website Monitoring",
- description:'Get insights of the latency of your API and website from all over the world.',
+ description:
+ "Get insights of the latency of your API and website from all over the world.",
},
openGraph: {
...ogMetadata,
title: "API & Website Monitoring",
- description:'Get insights of the latency of your API and website from all over the world.',
+ description:
+ "Get insights of the latency of your API and website from all over the world.",
},
};
-
export default function FeaturePage() {
return (
<div className="grid w-full gap-12">
diff --git a/apps/web/src/app/api/checker/test/route.ts b/apps/web/src/app/api/checker/test/route.ts
index 126e95b57..827e94610 100644
--- a/apps/web/src/app/api/checker/test/route.ts
+++ b/apps/web/src/app/api/checker/test/route.ts
@@ -1,7 +1,7 @@
import { NextResponse } from "next/server";
import { z } from "zod";
-import { monitorFlyRegionSchema } from "@openstatus/db/src/schema";
+import { monitorFlyRegionSchema } from "@openstatus/db/src/schema/constants";
import { checkRegion } from "@/components/ping-response-analysis/utils";
import { payloadSchema } from "../schema";
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/data/_components/data-table-wrapper.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/data/_components/data-table-wrapper.tsx
index c01963f51..fe6777a82 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/data/_components/data-table-wrapper.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/data/_components/data-table-wrapper.tsx
@@ -20,7 +20,7 @@ import { LoadingAnimation } from "@/components/loading-animation";
import { ResponseDetailTabs } from "@/components/ping-response-analysis/response-detail-tabs";
import { api } from "@/trpc/client";
import type { z } from "zod";
-import type { monitorFlyRegionSchema } from "@openstatus/db/src/schema";
+import type { monitorFlyRegionSchema } from "@openstatus/db/src/schema/constants";
// EXAMPLE: get the type of the response of the endpoint
// biome-ignore lint/correctness/noUnusedVariables: <explanation>
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/details/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/details/page.tsx
index 940cd9d7a..b4dafca35 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/details/page.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/details/page.tsx
@@ -6,7 +6,7 @@ import { Button } from "@openstatus/ui";
import { EmptyState } from "@/components/dashboard/empty-state";
import { ResponseDetails } from "@/components/monitor-dashboard/response-details";
import { api } from "@/trpc/server";
-import { monitorFlyRegionSchema } from "@openstatus/db/src/schema";
+import { monitorFlyRegionSchema } from "@openstatus/db/src/schema/constants";
//
/**
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/edit/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/edit/page.tsx
index 6e17a62ac..dd1481d4a 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/edit/page.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/edit/page.tsx
@@ -49,10 +49,11 @@ export default async function EditPage({
)
.map(({ id }) => id),
}}
- plan={workspace?.plan}
+ limits={workspace.limits}
notifications={notifications}
tags={tags}
pages={pages}
+ plan={workspace.plan}
/>
);
}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/page.tsx
index 8c91aa243..35c2f0a87 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/page.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/page.tsx
@@ -2,7 +2,7 @@ import { notFound } from "next/navigation";
import * as React from "react";
import * as z from "zod";
-import { flyRegions } from "@openstatus/db/src/schema";
+import { flyRegions } from "@openstatus/db/src/schema/constants";
import type { Region } from "@openstatus/tinybird";
import { OSTinybird } from "@openstatus/tinybird";
import { Separator } from "@openstatus/ui";
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/new/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/new/page.tsx
index e782dbd50..1ca457f0b 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/new/page.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/new/page.tsx
@@ -27,12 +27,13 @@ export default async function Page({
return (
<MonitorForm
- plan={workspace?.plan}
defaultSection={search.success ? search.data.section : undefined}
notifications={notifications}
pages={pages}
tags={tags}
+ limits={workspace.limits}
nextUrl="./" // back to the overview page
+ plan={workspace.plan}
/>
);
}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/(overview)/_components/channel-table.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/(overview)/_components/channel-table.tsx
index 6d96f78e7..8c9dbb410 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/(overview)/_components/channel-table.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/(overview)/_components/channel-table.tsx
@@ -1,5 +1,6 @@
import type { Workspace } from "@openstatus/db/src/schema";
-import { getLimit } from "@openstatus/plans";
+import { getLimit } from "@openstatus/db/src/schema/plan/utils";
+
import { Button, Separator } from "@openstatus/ui";
import Link from "next/link";
@@ -11,8 +12,8 @@ interface ChannelTable {
}
export default function ChannelTable({ workspace, disabled }: ChannelTable) {
- const isPagerDutyAllowed = getLimit(workspace.plan, "pagerduty");
- const isSMSAllowed = getLimit(workspace.plan, "sms");
+ const isPagerDutyAllowed = getLimit(workspace.limits, "pagerduty");
+ const isSMSAllowed = getLimit(workspace.limits, "sms");
return (
<div className="col-span-full w-full rounded-lg border border-border border-dashed bg-background p-8">
<h2 className="font-cal text-2xl">Channels</h2>
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/new/[channel]/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/new/[channel]/page.tsx
index 0a3f4e80f..71197d24c 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/new/[channel]/page.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/new/[channel]/page.tsx
@@ -2,7 +2,8 @@ import { ProFeatureAlert } from "@/components/billing/pro-feature-alert";
import { NotificationForm } from "@/components/forms/notification/form";
import { api } from "@/trpc/server";
import { notificationProviderSchema } from "@openstatus/db/src/schema";
-import { getLimit } from "@openstatus/plans";
+import { getLimit } from "@openstatus/db/src/schema/plan/utils";
+
import { notFound } from "next/navigation";
export default async function ChannelPage({
@@ -22,7 +23,7 @@ export default async function ChannelPage({
const provider = validation.data;
const allowed =
- provider === "sms" ? getLimit(workspace.plan, provider) : true;
+ provider === "sms" ? getLimit(workspace.limits, provider) : true;
if (!allowed) return <ProFeatureAlert feature="SMS channel notification" />;
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/new/pagerduty/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/new/pagerduty/page.tsx
index 2e8cd9005..6a16f94b8 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/new/pagerduty/page.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/new/pagerduty/page.tsx
@@ -2,7 +2,8 @@ import { ProFeatureAlert } from "@/components/billing/pro-feature-alert";
import { NotificationForm } from "@/components/forms/notification/form";
import { api } from "@/trpc/server";
import { PagerDutySchema } from "@openstatus/notification-pagerduty";
-import { getLimit } from "@openstatus/plans";
+import { getLimit } from "@openstatus/db/src/schema/plan/utils";
+
import { z } from "zod";
// REMINDER: PagerDuty requires a different workflow, thus the separate page
@@ -29,9 +30,9 @@ export default async function PagerDutyPage({
return <div>Invalid data</div>;
}
- const allowed = getLimit(workspace.plan, "pagerduty");
-
- if (!allowed) return <ProFeatureAlert feature="SMS channel notification" />;
+ const allowed = getLimit(workspace.limits, "pagerduty");
+ if (!allowed)
+ return <ProFeatureAlert feature="PagerDuty channel notification" />;
return (
<>
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/billing/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/billing/page.tsx
index 78d2c2799..3fe506819 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/billing/page.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/billing/page.tsx
@@ -1,4 +1,3 @@
-import { getLimits } from "@openstatus/plans";
import { Progress, Separator } from "@openstatus/ui";
import { api } from "@/trpc/server";
@@ -9,8 +8,6 @@ export default async function BillingPage() {
const workspace = await api.workspace.getWorkspace.query();
const currentNumbers = await api.workspace.getCurrentWorkspaceNumbers.query();
- const limits = getLimits(workspace.plan);
-
return (
<div className="grid gap-4">
<div className="flex items-center justify-between gap-3">
@@ -21,7 +18,7 @@ export default async function BillingPage() {
</div>
<div className="grid max-w-lg gap-3">
{Object.entries(currentNumbers).map(([key, value]) => {
- const limit = limits[key as keyof typeof currentNumbers];
+ const limit = workspace.limits[key as keyof typeof currentNumbers];
return (
<div key={key}>
<div className="mb-1 flex items-center justify-between text-muted-foreground">
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/domain/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/domain/page.tsx
index fdeb6eb63..6d1d7502a 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/domain/page.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/domain/page.tsx
@@ -1,6 +1,6 @@
import { notFound } from "next/navigation";
-import { allPlans } from "@openstatus/plans";
+import { allPlans } from "@openstatus/db/src/schema/plan/config";
import { ProFeatureAlert } from "@/components/billing/pro-feature-alert";
import { CustomDomainForm } from "@/components/forms/custom-domain-form";
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/subscribers/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/subscribers/page.tsx
index b17e54c63..07ea7eea4 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/subscribers/page.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/status-pages/[id]/subscribers/page.tsx
@@ -1,6 +1,6 @@
import { notFound } from "next/navigation";
-import { allPlans } from "@openstatus/plans";
+import { allPlans } from "@openstatus/db/src/schema/plan/config";
import { ProFeatureAlert } from "@/components/billing/pro-feature-alert";
import { columns } from "@/components/data-table/page-subscriber/columns";
diff --git a/apps/web/src/app/app/[workspaceSlug]/onboarding/page.tsx b/apps/web/src/app/app/[workspaceSlug]/onboarding/page.tsx
index 65b38f77a..d9da83ccc 100644
--- a/apps/web/src/app/app/[workspaceSlug]/onboarding/page.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/onboarding/page.tsx
@@ -16,6 +16,7 @@ export default async function Onboarding({
}) {
const { workspaceSlug } = params;
+ const workspace = await api.workspace.getWorkspace.query();
const allMonitors = await api.monitor.getMonitorsByWorkspace.query();
const allPages = await api.page.getPagesByWorkspace.query();
const allNotifications =
@@ -38,6 +39,8 @@ export default async function Onboarding({
<MonitorForm
notifications={allNotifications}
defaultSection="request"
+ limits={workspace.limits}
+ plan={workspace.plan}
/>
</div>
<div className="hidden h-full md:col-span-1 md:block">
diff --git a/apps/web/src/app/play/checker/[id]/page.tsx b/apps/web/src/app/play/checker/[id]/page.tsx
index a656d2039..6bef578c3 100644
--- a/apps/web/src/app/play/checker/[id]/page.tsx
+++ b/apps/web/src/app/play/checker/[id]/page.tsx
@@ -3,7 +3,7 @@ import Link from "next/link";
import { redirect } from "next/navigation";
import * as z from "zod";
-import { monitorFlyRegionSchema } from "@openstatus/db/src/schema";
+import { monitorFlyRegionSchema } from "@openstatus/db/src/schema/constants";
import { Separator } from "@openstatus/ui";
import {
diff --git a/apps/web/src/app/pricing/page.tsx b/apps/web/src/app/pricing/page.tsx
index a29049a62..96fb84665 100644
--- a/apps/web/src/app/pricing/page.tsx
+++ b/apps/web/src/app/pricing/page.tsx
@@ -1,16 +1,17 @@
import type { Metadata } from "next";
-import Link from "next/link";
import { Shell } from "@/components/dashboard/shell";
import { MarketingLayout } from "@/components/layout/marketing-layout";
import { FAQs } from "@/components/marketing/faqs";
import { EnterpricePlan } from "@/components/marketing/pricing/enterprice-plan";
+import { PricingSlider } from "@/components/marketing/pricing/pricing-slider";
import { PricingWrapperSuspense } from "@/components/marketing/pricing/pricing-wrapper";
import {
defaultMetadata,
ogMetadata,
twitterMetadata,
} from "../shared-metadata";
+import { Separator } from "@openstatus/ui";
export const metadata: Metadata = {
...defaultMetadata,
@@ -30,7 +31,7 @@ export default function PricingPage() {
return (
<MarketingLayout>
<div className="grid w-full gap-6">
- <Shell className="grid w-full gap-8">
+ <Shell className="grid w-full gap-12">
<div className="grid gap-3 text-center">
<h1 className="font-cal text-4xl text-foreground">Pricing</h1>
<p className="text-muted-foreground">
@@ -38,16 +39,8 @@ export default function PricingPage() {
</p>
</div>
<PricingWrapperSuspense />
- <p className="text-muted-foreground text-sm">
- Learn more about the{" "}
- <Link
- href="/blog/our-new-pricing-explained"
- className="text-foreground underline underline-offset-4 hover:no-underline"
- >
- decision behind the plans
- </Link>
- .
- </p>
+ <Separator />
+ <PricingSlider />
</Shell>
<Shell>
<EnterpricePlan />
diff --git a/apps/web/src/app/public/monitors/[id]/page.tsx b/apps/web/src/app/public/monitors/[id]/page.tsx
index 3be7cca37..4ca96e6de 100644
--- a/apps/web/src/app/public/monitors/[id]/page.tsx
+++ b/apps/web/src/app/public/monitors/[id]/page.tsx
@@ -2,7 +2,7 @@ import { notFound } from "next/navigation";
import * as React from "react";
import * as z from "zod";
-import { flyRegions } from "@openstatus/db/src/schema";
+import { flyRegions } from "@openstatus/db/src/schema/constants";
import type { Region } from "@openstatus/tinybird";
import { OSTinybird } from "@openstatus/tinybird";
import { Separator } from "@openstatus/ui";
diff --git a/apps/web/src/app/status-page/[domain]/_components/footer.tsx b/apps/web/src/app/status-page/[domain]/_components/footer.tsx
index 7cc28397e..569c1a834 100644
--- a/apps/web/src/app/status-page/[domain]/_components/footer.tsx
+++ b/apps/web/src/app/status-page/[domain]/_components/footer.tsx
@@ -1,5 +1,5 @@
-import { allPlans } from "@openstatus/plans";
-import type { WorkspacePlan } from "@openstatus/plans";
+import { allPlans } from "@openstatus/db/src/schema/plan/config";
+import type { WorkspacePlan } from "@openstatus/db/src/schema/workspaces/validation";
import { ThemeToggle } from "@/components/theme-toggle";
diff --git a/apps/web/src/app/status-page/[domain]/_components/header.tsx b/apps/web/src/app/status-page/[domain]/_components/header.tsx
index 9d9f25831..9a9d285ef 100644
--- a/apps/web/src/app/status-page/[domain]/_components/header.tsx
+++ b/apps/web/src/app/status-page/[domain]/_components/header.tsx
@@ -4,8 +4,8 @@ import Image from "next/image";
import { useSelectedLayoutSegment } from "next/navigation";
import type { PublicPage } from "@openstatus/db/src/schema";
-import { allPlans } from "@openstatus/plans";
-import type { WorkspacePlan } from "@openstatus/plans";
+import { allPlans } from "@openstatus/db/src/schema/plan/config";
+import type { WorkspacePlan } from "@openstatus/db/src/schema/workspaces/validation";
import { Shell } from "@/components/dashboard/shell";
import { TabsContainer, TabsLink } from "@/components/dashboard/tabs-link";
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.tsx
index 425a89f55..5b4e1e293 100644
--- a/apps/web/src/app/status-page/[domain]/_components/password-protected.tsx
+++ b/apps/web/src/app/status-page/[domain]/_components/password-protected.tsx
@@ -1,4 +1,4 @@
-import type { WorkspacePlan } from "@openstatus/plans";
+import type { WorkspacePlan } from "@openstatus/db/src/schema/workspaces/validation";
import { Shell } from "@/components/dashboard/shell";
import { Footer } from "../_components/footer";
diff --git a/apps/web/src/app/status-page/[domain]/monitors/[id]/page.tsx b/apps/web/src/app/status-page/[domain]/monitors/[id]/page.tsx
index 5e105f8d4..7a632bcb7 100644
--- a/apps/web/src/app/status-page/[domain]/monitors/[id]/page.tsx
+++ b/apps/web/src/app/status-page/[domain]/monitors/[id]/page.tsx
@@ -2,7 +2,7 @@ import { notFound } from "next/navigation";
import * as React from "react";
import * as z from "zod";
-import { flyRegions } from "@openstatus/db/src/schema";
+import { flyRegions } from "@openstatus/db/src/schema/constants";
import type { Region } from "@openstatus/tinybird";
import { OSTinybird } from "@openstatus/tinybird";
import { Separator } from "@openstatus/ui";
@@ -74,7 +74,6 @@ export default async function Page({
const { period, quantile, interval, regions } = search.data;
- console.log(regions.length);
// TODO: work it out easier
const intervalMinutes = getMinutesByInterval(interval);
const periodicityMinutes = getMinutesByInterval(monitor.periodicity);
diff --git a/apps/web/src/components/billing/pro-feature-alert.tsx b/apps/web/src/components/billing/pro-feature-alert.tsx
index dd489ed64..24e3d66f6 100644
--- a/apps/web/src/components/billing/pro-feature-alert.tsx
+++ b/apps/web/src/components/billing/pro-feature-alert.tsx
@@ -5,7 +5,7 @@ import Link from "next/link";
import { useParams } from "next/navigation";
import { Alert, AlertDescription, AlertTitle } from "@openstatus/ui";
-import type { WorkspacePlan } from "@openstatus/plans";
+import type { WorkspacePlan } from "@openstatus/db/src/schema/workspaces/validation";
interface Props {
feature: string;
diff --git a/apps/web/src/components/billing/pro-feature-hover-card.tsx b/apps/web/src/components/billing/pro-feature-hover-card.tsx
index cb9b173e0..f5be24476 100644
--- a/apps/web/src/components/billing/pro-feature-hover-card.tsx
+++ b/apps/web/src/components/billing/pro-feature-hover-card.tsx
@@ -3,7 +3,7 @@
import { useState } from "react";
import { workspacePlanHierarchy } from "@openstatus/db/src/schema";
-import type { WorkspacePlan } from "@openstatus/plans";
+import type { WorkspacePlan } from "@openstatus/db/src/schema/workspaces/validation";
import { HoverCard, HoverCardContent, HoverCardTrigger } from "@openstatus/ui";
function upgradePlan(current: WorkspacePlan, required: WorkspacePlan) {
diff --git a/apps/web/src/components/forms/monitor-form.tsx b/apps/web/src/components/forms/monitor-form.tsx
deleted file mode 100644
index 795b4ef53..000000000
--- a/apps/web/src/components/forms/monitor-form.tsx
+++ /dev/null
@@ -1,729 +0,0 @@
-// REMINDER: legacy form - please use /forms/monitor/form.tsx
-
-"use client";
-
-import { zodResolver } from "@hookform/resolvers/zod";
-import { Check, ChevronsUpDown, Wand2, X } from "lucide-react";
-import { useRouter } from "next/navigation";
-import * as React from "react";
-import { useFieldArray, useForm } from "react-hook-form";
-
-import type {
- InsertMonitor,
- Notification,
- WorkspacePlan,
-} from "@openstatus/db/src/schema";
-import {
- flyRegions,
- insertMonitorSchema,
- monitorMethods,
- monitorMethodsSchema,
- monitorPeriodicitySchema,
-} from "@openstatus/db/src/schema";
-import { getLimit } from "@openstatus/plans";
-import {
- Accordion,
- AccordionContent,
- AccordionItem,
- AccordionTrigger,
- Button,
- Checkbox,
- Command,
- CommandEmpty,
- CommandGroup,
- CommandInput,
- CommandItem,
- CommandList,
- Dialog,
- DialogTrigger,
- Form,
- FormControl,
- FormDescription,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
- Input,
- Popover,
- PopoverContent,
- PopoverTrigger,
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
- Switch,
- Textarea,
- Tooltip,
- TooltipContent,
- TooltipProvider,
- TooltipTrigger,
-} from "@openstatus/ui";
-import { flyRegionsDict } from "@openstatus/utils";
-
-import { LoadingAnimation } from "@/components/loading-animation";
-import { FailedPingAlertConfirmation } from "@/components/modals/failed-ping-alert-confirmation";
-import type { RegionChecker } from "@/components/ping-response-analysis/utils";
-import { toastAction } from "@/lib/toast";
-import { cn } from "@/lib/utils";
-import { api } from "@/trpc/client";
-
-const cronJobs = [
- { value: "30s", label: "30 seconds" },
- { value: "1m", label: "1 minute" },
- { value: "5m", label: "5 minutes" },
- { value: "10m", label: "10 minutes" },
- { value: "30m", label: "30 minutes" },
- { value: "1h", label: "1 hour" },
-] as const;
-
-interface Props {
- defaultValues?: InsertMonitor;
- plan?: WorkspacePlan;
- notifications?: Notification[];
- nextUrl?: string;
-}
-
-export function MonitorForm({
- defaultValues,
- plan = "free",
- notifications,
- nextUrl,
-}: Props) {
- const form = useForm<InsertMonitor>({
- resolver: zodResolver(insertMonitorSchema),
- defaultValues: {
- url: defaultValues?.url || "",
- name: defaultValues?.name || "",
- description: defaultValues?.description || "",
- periodicity: defaultValues?.periodicity || "30m",
- active: defaultValues?.active ?? true,
- id: defaultValues?.id || 0,
- regions: defaultValues?.regions || getLimit("free", "regions"),
- headers: defaultValues?.headers?.length
- ? defaultValues?.headers
- : [{ key: "", value: "" }],
- body: defaultValues?.body ?? "",
- method: defaultValues?.method ?? "GET",
- notifications: defaultValues?.notifications ?? [],
- },
- });
- const router = useRouter();
- const [isPending, startTransition] = React.useTransition();
- const [isTestPending, startTestTransition] = React.useTransition();
- const [pingFailed, setPingFailed] = React.useState(false);
- const [openDialog, setOpenDialog] = React.useState(false);
- const watchMethod = form.watch("method");
-
- const { fields, append, remove } = useFieldArray({
- name: "headers",
- control: form.control,
- });
-
- const handleDataUpdateOrInsertion = async (props: InsertMonitor) => {
- try {
- if (defaultValues) {
- await api.monitor.update.mutate(props);
- } else {
- await api.monitor.create.mutate(props);
- }
- if (nextUrl) {
- router.push(nextUrl);
- }
- router.refresh();
- toastAction("saved");
- } catch (_error) {
- toastAction("error");
- }
- };
-
- const onSubmit = ({ ...props }: InsertMonitor) => {
- startTransition(async () => {
- const pingResult = await pingEndpoint();
- if (!pingResult) {
- setPingFailed(true);
- return;
- }
- await handleDataUpdateOrInsertion(props);
- });
- };
-
- const validateJSON = (value?: string) => {
- if (!value) return;
- try {
- const obj = JSON.parse(value) as Record<string, unknown>;
- form.clearErrors("body");
- return obj;
- } catch (_e) {
- form.setError("body", {
- message: "Not a valid JSON object",
- });
- return false;
- }
- };
-
- const onPrettifyJSON = () => {
- const body = form.getValues("body");
- const obj = validateJSON(body);
- if (obj) {
- const pretty = JSON.stringify(obj, undefined, 4);
- form.setValue("body", pretty);
- }
- };
-
- const pingEndpoint = async () => {
- const { url, body, method, headers } = form.getValues();
- const res = await fetch("/api/checker/test", {
- method: "POST",
- headers: new Headers({
- "Content-Type": "application/json",
- }),
- body: JSON.stringify({ url, body, method, headers }),
- });
- const data = (await res.json()) as RegionChecker;
- return data;
- };
-
- const sendTestPing = () => {
- if (isTestPending) {
- return;
- }
- const { url } = form.getValues();
- if (!url) {
- toastAction("test-warning-empty-url");
- return;
- }
-
- startTestTransition(async () => {
- try {
- const data = await pingEndpoint();
- if (data.status >= 200 && data.status < 300) {
- toastAction("test-success");
- } else {
- toastAction("test-error");
- }
- } catch {
- toastAction("error");
- }
- });
- };
-
- const periodicityLimit = getLimit(plan, "periodicity");
- const notificationLimit = getLimit(plan, "notification-channels");
- const notificationLimitReached = notifications
- ? notifications.length >= notificationLimit
- : false;
-
- return (
- <Dialog open={openDialog} onOpenChange={(val) => setOpenDialog(val)}>
- <Form {...form}>
- <form
- onSubmit={form.handleSubmit(onSubmit)}
- className="grid w-full gap-6"
- >
- <div className="grid gap-4 sm:grid-cols-3">
- <div className="my-1.5 flex flex-col gap-2">
- <p className="font-semibold text-sm leading-none">
- Endpoint Check
- </p>
- <p className="text-muted-foreground text-sm">
- The easiest way to get started.
- </p>
- </div>
- <div className="grid gap-6 sm:col-span-2">
- <FormField
- control={form.control}
- name="name"
- render={({ field }) => (
- <FormItem>
- <FormLabel>Name</FormLabel>
- <FormControl>
- <Input placeholder="Documenso" {...field} />
- </FormControl>
- <FormDescription>
- Displayed on the status page.
- </FormDescription>
- <FormMessage />
- </FormItem>
- )}
- />
- <FormField
- control={form.control}
- name="url"
- render={({ field }) => (
- <FormItem>
- <FormLabel>URL</FormLabel>
- <FormControl>
- {/* <InputWithAddons
- leading="https://"
- placeholder="documenso.com/api/health"
- {...field}
- /> */}
- <Input
- placeholder="https://documenso.com/api/health"
- {...field}
- />
- </FormControl>
- <FormDescription>
- Here is the URL you want to monitor.{" "}
- </FormDescription>
- <FormMessage />
- </FormItem>
- )}
- />
- </div>
- </div>
- <Accordion type="single" collapsible>
- <AccordionItem value="http-request-settings">
- <AccordionTrigger>HTTP Request Settings</AccordionTrigger>
- <AccordionContent>
- <div className="grid gap-4 sm:grid-cols-3">
- <div className="my-1.5 flex flex-col gap-2">
- <p className="font-semibold text-sm leading-none">
- Custom Request
- </p>
- <p className="text-muted-foreground text-sm">
- If your endpoint is secured, add additional configuration
- to the request we send.
- </p>
- </div>
- <div className="grid gap-6 sm:col-span-2 sm:grid-cols-4">
- <FormField
- control={form.control}
- name="method"
- render={({ field }) => (
- <FormItem className="sm:col-span-1 sm:self-baseline">
- <FormLabel>Method</FormLabel>
- <Select
- onValueChange={(value) => {
- field.onChange(monitorMethodsSchema.parse(value));
- form.resetField("body", { defaultValue: "" });
- }}
- defaultValue={field.value}
- >
- <FormControl>
- <SelectTrigger>
- <SelectValue placeholder="Select" />
- </SelectTrigger>
- </FormControl>
- <SelectContent>
- {monitorMethods.map((method) => (
- <SelectItem key={method} value={method}>
- {method}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- <FormMessage />
- </FormItem>
- )}
- />
- <div className="space-y-2 sm:col-span-full">
- <FormLabel>Request Header</FormLabel>
- {fields.map((field, index) => (
- <div key={field.id} className="grid grid-cols-6 gap-6">
- <FormField
- control={form.control}
- name={`headers.${index}.key`}
- render={({ field }) => (
- <FormItem className="col-span-2">
- <FormControl>
- <Input placeholder="key" {...field} />
- </FormControl>
- </FormItem>
- )}
- />
- <div className="col-span-4 flex items-center space-x-2">
- <FormField
- control={form.control}
- name={`headers.${index}.value`}
- render={({ field }) => (
- <FormItem className="w-full">
- <FormControl>
- <Input placeholder="value" {...field} />
- </FormControl>
- </FormItem>
- )}
- />
- <Button
- size="icon"
- variant="ghost"
- type="button"
- onClick={() => remove(Number(field.id))}
- >
- <X className="h-4 w-4" />
- </Button>
- </div>
- </div>
- ))}
- <div>
- <Button
- type="button"
- variant="outline"
- onClick={() => append({ key: "", value: "" })}
- >
- Add Custom Header
- </Button>
- </div>
- </div>
- {watchMethod === "POST" && (
- <div className="sm:col-span-full">
- <FormField
- control={form.control}
- name="body"
- render={({ field }) => (
- <FormItem>
- <div className="flex items-end justify-between">
- <FormLabel>Body</FormLabel>
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- type="button"
- variant="ghost"
- size="icon"
- onClick={onPrettifyJSON}
- >
- <Wand2 className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>Prettify JSON</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
- <FormControl>
- <Textarea
- rows={8}
- placeholder='{ "hello": "world" }'
- {...field}
- />
- </FormControl>
- <FormDescription>
- Write your json payload.
- </FormDescription>
- <FormMessage />
- </FormItem>
- )}
- />
- </div>
- )}
- </div>
- </div>
- </AccordionContent>
- </AccordionItem>
- <AccordionItem value="advanced-settings">
- <AccordionTrigger>Advanced Settings</AccordionTrigger>
- <AccordionContent>
- <div className="grid gap-4 sm:grid-cols-3">
- <div className="my-1.5 flex flex-col gap-2">
- <p className="font-semibold text-sm leading-none">
- More Configurations
- </p>
- <p className="text-muted-foreground text-sm">
- Make it your own. Contact us if you wish for more and we
- will implement it!
- </p>
- </div>
- <div className="grid gap-6 sm:col-span-2 sm:grid-cols-2">
- <FormField
- control={form.control}
- name="periodicity"
- render={({ field }) => (
- <FormItem className="sm:col-span-1 sm:self-baseline">
- <FormLabel>Frequency</FormLabel>
- <Select
- onValueChange={(value) =>
- field.onChange(
- monitorPeriodicitySchema.parse(value)
- )
- }
- defaultValue={field.value}
- >
- <FormControl>
- <SelectTrigger>
- <SelectValue placeholder="How often should it check your endpoint?" />
- </SelectTrigger>
- </FormControl>
- <SelectContent>
- {cronJobs.map(({ label, value }) => (
- <SelectItem
- key={value}
- value={value}
- disabled={!periodicityLimit.includes(value)}
- >
- {label}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- <FormDescription>
- Frequency of how often your endpoint will be pinged.
- </FormDescription>
- <FormMessage />
- </FormItem>
- )}
- />
- <FormField
- control={form.control}
- name="regions"
- render={({ field }) => {
- const numberOfSelectedRegions =
- field.value?.length || 0;
- function renderText() {
- if (numberOfSelectedRegions === 0)
- return "Select region";
- if (numberOfSelectedRegions === flyRegions.length)
- return "All regions";
- return `${numberOfSelectedRegions} regions`;
- }
- return (
- <FormItem className="sm:col-span-1 sm:self-baseline">
- <FormLabel>Regions</FormLabel>
- <Popover>
- <PopoverTrigger asChild>
- <FormControl>
- <Button
- variant="outline"
- role="combobox"
- className={cn(
- "h-10 w-full justify-between",
- !field.value && "text-muted-foreground"
- )}
- >
- {renderText()}
- <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
- </Button>
- </FormControl>
- </PopoverTrigger>
- <PopoverContent className="w-full p-0">
- <Command>
- <CommandInput placeholder="Select a region..." />
- <CommandList>
- <CommandEmpty>
- No regions found.
- </CommandEmpty>
- <CommandGroup className="max-h-[150px] overflow-y-scroll">
- {Object.keys(flyRegionsDict).map(
- (region) => {
- const { code, location } =
- flyRegionsDict[
- region as keyof typeof flyRegionsDict
- ];
- const isSelected =
- field.value?.includes(code);
- return (
- <CommandItem
- value={code}
- key={code}
- onSelect={() => {
- const currentRegions =
- form.getValues("regions") ||
- [];
- form.setValue(
- "regions",
- currentRegions.includes(code)
- ? currentRegions.filter(
- (r) => r !== code
- )
- : [...currentRegions, code]
- );
- }}
- >
- <Check
- className={cn(
- "mr-2 h-4 w-4",
- isSelected
- ? "opacity-100"
- : "opacity-0"
- )}
- />
- {location}
- </CommandItem>
- );
- }
- )}
- </CommandGroup>
- </CommandList>
- </Command>
- </PopoverContent>
- </Popover>
- <FormDescription>
- Select your regions. If none, region will be
- random.
- </FormDescription>
- <FormMessage />
- </FormItem>
- );
- }}
- />
- <FormField
- control={form.control}
- name="description"
- render={({ field }) => (
- <FormItem className="sm:col-span-2">
- <FormLabel>Description</FormLabel>
- <FormControl>
- <Input
- placeholder="Determines the api health of our services."
- {...field}
- />
- </FormControl>
- <FormDescription>
- Provide your users with information about it.
- </FormDescription>
- <FormMessage />
- </FormItem>
- )}
- />
- <FormField
- control={form.control}
- name="active"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between sm:col-span-full">
- <div className="space-y-0.5">
- <FormLabel>Active</FormLabel>
- <FormDescription>
- This will start ping your endpoint on based on the
- selected frequence.
- </FormDescription>
- </div>
- <FormControl>
- <Switch
- checked={field.value || false}
- onCheckedChange={(value) => field.onChange(value)}
- />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- </div>
- </div>
- </AccordionContent>
- </AccordionItem>
- <AccordionItem value="notification-settings">
- <AccordionTrigger>Notification Settings</AccordionTrigger>
- <AccordionContent>
- <div className="grid gap-4 sm:grid-cols-3">
- <div className="my-1.5 flex flex-col gap-2">
- <p className="font-semibold text-sm leading-none">Alerts</p>
- <p className="text-muted-foreground text-sm">
- How do you want to get informed if things break?
- </p>
- </div>
- <div className="grid gap-6 sm:col-span-2">
- <FormField
- control={form.control}
- name="notifications"
- render={() => (
- <FormItem>
- <div className="mb-4">
- <FormLabel className="text-base">
- Notifications
- </FormLabel>
- <FormDescription>
- Select the notification channels you want to be
- informed.
- </FormDescription>
- </div>
- {notifications?.map((item) => (
- <FormField
- key={item.id}
- control={form.control}
- name="notifications"
- render={({ field }) => {
- return (
- <FormItem
- key={item.id}
- className="flex flex-row items-start space-x-3 space-y-0"
- >
- <FormControl>
- <Checkbox
- checked={field.value?.includes(item.id)}
- onCheckedChange={(checked) => {
- return checked
- ? field.onChange([
- ...(field.value || []),
- item.id,
- ])
- : field.onChange(
- field.value?.filter(
- (value) => value !== item.id
- )
- );
- }}
- />
- </FormControl>
- <div className="space-y-1 leading-none">
- <FormLabel className="font-normal">
- {item.name}
- </FormLabel>
- <FormDescription>
- {item.provider}
- </FormDescription>
- </div>
- </FormItem>
- );
- }}
- />
- ))}
- <FormMessage />
- <div className="sm:col-span-2 sm:col-start-1">
- <DialogTrigger asChild>
- <Button
- variant="outline"
- disabled={notificationLimitReached}
- >
- Add Notifications
- </Button>
- </DialogTrigger>
- </div>
- </FormItem>
- )}
- />
- </div>
- </div>
- </AccordionContent>
- </AccordionItem>
- </Accordion>
- <div className="grid justify-end gap-3">
- <div className="flex flex-col gap-6 sm:col-span-full sm:flex-row sm:justify-end">
- <Button
- type="button"
- variant="secondary"
- className="w-full sm:w-auto"
- size="lg"
- onClick={sendTestPing}
- >
- {!isTestPending ? (
- "Test Request"
- ) : (
- <LoadingAnimation variant="inverse" />
- )}
- </Button>
- <Button
- className="w-full sm:w-auto"
- size="lg"
- disabled={isPending}
- >
- {!isPending ? "Confirm" : <LoadingAnimation />}
- </Button>
- </div>
- <div className="flex w-full justify-end">
- <p className="text-muted-foreground text-xs">
- We test your endpoint connection on submit.
- </p>
- </div>
- </div>
- </form>
- </Form>
- <FailedPingAlertConfirmation
- monitor={form.getValues()}
- {...{ pingFailed, setPingFailed }}
- onConfirm={handleDataUpdateOrInsertion}
- />
- </Dialog>
- );
-}
diff --git a/apps/web/src/components/forms/monitor/form.tsx b/apps/web/src/components/forms/monitor/form.tsx
index 664c81179..f5c8193ce 100644
--- a/apps/web/src/components/forms/monitor/form.tsx
+++ b/apps/web/src/components/forms/monitor/form.tsx
@@ -4,12 +4,11 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { usePathname, useRouter } from "next/navigation";
import * as React from "react";
import { useForm } from "react-hook-form";
-import { getLimit } from "@openstatus/plans";
+import { getLimit } from "@openstatus/db/src/schema/plan/utils";
import * as assertions from "@openstatus/assertions";
import type {
InsertMonitor,
- MonitorFlyRegion,
MonitorTag,
Notification,
Page,
@@ -38,11 +37,14 @@ import { SectionNotifications } from "./section-notifications";
import { SectionRequests } from "./section-requests";
import { SectionScheduling } from "./section-scheduling";
import { SectionStatusPage } from "./section-status-page";
+import type { MonitorFlyRegion } from "@openstatus/db/src/schema/constants";
+import type { Limits } from "@openstatus/db/src/schema/plan/schema";
interface Props {
defaultSection?: string;
+ limits: Limits;
+ plan: WorkspacePlan;
defaultValues?: InsertMonitor;
- plan?: WorkspacePlan;
notifications?: Notification[];
tags?: MonitorTag[];
pages?: Page[];
@@ -55,11 +57,12 @@ const ABORT_TIMEOUT = 7_000; // in ms
export function MonitorForm({
defaultSection,
defaultValues,
- plan = "free",
notifications,
pages,
tags,
nextUrl,
+ limits,
+ plan,
withTestButton = true,
}: Props) {
const _assertions = defaultValues?.assertions
@@ -74,7 +77,7 @@ export function MonitorForm({
periodicity: defaultValues?.periodicity || "30m",
active: defaultValues?.active ?? true,
id: defaultValues?.id || 0,
- regions: defaultValues?.regions || getLimit("free", "regions"),
+ regions: defaultValues?.regions || getLimit(limits, "regions"),
headers: defaultValues?.headers?.length
? defaultValues?.headers
: [{ key: "", value: "" }],
@@ -253,7 +256,7 @@ export function MonitorForm({
onKeyDown={(e) => e.key === "Enter" && e.preventDefault()}
className="flex w-full flex-col gap-6"
>
- <General {...{ form, plan, tags }} />
+ <General {...{ form, tags }} />
<Tabs
defaultValue={defaultSection}
className="w-full"
@@ -291,19 +294,19 @@ export function MonitorForm({
) : null}
</TabsList>
<TabsContent value="request">
- <SectionRequests {...{ form, plan, pingEndpoint }} />
+ <SectionRequests {...{ form, pingEndpoint }} />
</TabsContent>
<TabsContent value="assertions">
<SectionAssertions {...{ form }} />
</TabsContent>
<TabsContent value="scheduling">
- <SectionScheduling {...{ form, plan }} />
+ <SectionScheduling {...{ form, limits, plan }} />
</TabsContent>
<TabsContent value="notifications">
- <SectionNotifications {...{ form, plan, notifications }} />
+ <SectionNotifications {...{ form, notifications }} />
</TabsContent>
<TabsContent value="status-page">
- <SectionStatusPage {...{ form, plan, pages }} />
+ <SectionStatusPage {...{ form, pages }} />
</TabsContent>
{defaultValues?.id ? (
<TabsContent value="danger">
@@ -313,7 +316,7 @@ export function MonitorForm({
</Tabs>
<div className="grid gap-4 sm:flex sm:items-start sm:justify-end">
{withTestButton ? (
- <RequestTestButton {...{ form, pingEndpoint }} />
+ <RequestTestButton {...{ form, limits, pingEndpoint }} />
) : null}
<SaveButton
isPending={isPending}
diff --git a/apps/web/src/components/forms/monitor/general.tsx b/apps/web/src/components/forms/monitor/general.tsx
index cccc6ab0a..dc64eeb73 100644
--- a/apps/web/src/components/forms/monitor/general.tsx
+++ b/apps/web/src/components/forms/monitor/general.tsx
@@ -24,7 +24,6 @@ import { TagsMultiBox } from "./tags-multi-box";
interface Props {
form: UseFormReturn<InsertMonitor>;
- plan: WorkspacePlan;
tags?: MonitorTag[];
}
diff --git a/apps/web/src/components/forms/monitor/request-test-button.tsx b/apps/web/src/components/forms/monitor/request-test-button.tsx
index 2d341cc3d..b30a7f011 100644
--- a/apps/web/src/components/forms/monitor/request-test-button.tsx
+++ b/apps/web/src/components/forms/monitor/request-test-button.tsx
@@ -5,11 +5,11 @@ import React from "react";
import type { UseFormReturn } from "react-hook-form";
import { deserialize } from "@openstatus/assertions";
-import type {
- InsertMonitor,
- MonitorFlyRegion,
-} from "@openstatus/db/src/schema";
-import { flyRegions } from "@openstatus/db/src/schema";
+import type { InsertMonitor } from "@openstatus/db/src/schema";
+import {
+ flyRegions,
+ type MonitorFlyRegion,
+} from "@openstatus/db/src/schema/constants";
import {
Button,
Dialog,
@@ -33,16 +33,18 @@ import { RegionInfo } from "@/components/ping-response-analysis/region-info";
import { ResponseDetailTabs } from "@/components/ping-response-analysis/response-detail-tabs";
import type { RegionChecker } from "@/components/ping-response-analysis/utils";
import { toast, toastAction } from "@/lib/toast";
-import { getLimit } from "@openstatus/plans";
+import { getLimit } from "@openstatus/db/src/schema/plan/utils";
+import type { Limits } from "@openstatus/db/src/schema/plan/schema";
interface Props {
form: UseFormReturn<InsertMonitor>;
+ limits: Limits;
pingEndpoint(
region?: MonitorFlyRegion
): Promise<{ data?: RegionChecker; error?: string }>;
}
-export function RequestTestButton({ form, pingEndpoint }: Props) {
+export function RequestTestButton({ form, pingEndpoint, limits }: Props) {
const [check, setCheck] = React.useState<
{ data: RegionChecker; error?: string } | undefined
>();
@@ -79,7 +81,7 @@ export function RequestTestButton({ form, pingEndpoint }: Props) {
const { statusAssertions, headerAssertions } = form.getValues();
- const regions = getLimit("free", "regions");
+ const regions = getLimit(limits, "regions");
return (
<Dialog open={!!check} onOpenChange={() => setCheck(undefined)}>
diff --git a/apps/web/src/components/forms/monitor/section-notifications.tsx b/apps/web/src/components/forms/monitor/section-notifications.tsx
index 7a5c01c3c..aa49ad413 100644
--- a/apps/web/src/components/forms/monitor/section-notifications.tsx
+++ b/apps/web/src/components/forms/monitor/section-notifications.tsx
@@ -22,11 +22,10 @@ import { CheckboxLabel } from "../shared/checkbox-label";
interface Props {
form: UseFormReturn<InsertMonitor>;
- plan: WorkspacePlan;
notifications?: Notification[];
}
-export function SectionNotifications({ form, plan, notifications }: Props) {
+export function SectionNotifications({ form, notifications }: Props) {
return (
<div className="grid w-full gap-4">
{/* <div className="grid gap-1">
diff --git a/apps/web/src/components/forms/monitor/section-requests.tsx b/apps/web/src/components/forms/monitor/section-requests.tsx
index 92c5099e1..6aa5c4f7b 100644
--- a/apps/web/src/components/forms/monitor/section-requests.tsx
+++ b/apps/web/src/components/forms/monitor/section-requests.tsx
@@ -35,7 +35,6 @@ import { SectionHeader } from "../shared/section-header";
interface Props {
form: UseFormReturn<InsertMonitor>;
- plan: WorkspacePlan;
}
// TODO: add Dialog with response informations when pingEndpoint!
diff --git a/apps/web/src/components/forms/monitor/section-scheduling.tsx b/apps/web/src/components/forms/monitor/section-scheduling.tsx
index 55b8f3357..da34a3465 100644
--- a/apps/web/src/components/forms/monitor/section-scheduling.tsx
+++ b/apps/web/src/components/forms/monitor/section-scheduling.tsx
@@ -3,11 +3,9 @@
import type { UseFormReturn } from "react-hook-form";
import type { InsertMonitor, WorkspacePlan } from "@openstatus/db/src/schema";
-import {
- flyRegions,
- monitorPeriodicitySchema,
-} from "@openstatus/db/src/schema";
-import { getLimit } from "@openstatus/plans";
+import { monitorPeriodicitySchema } from "@openstatus/db/src/schema/constants";
+import { getLimit } from "@openstatus/db/src/schema/plan/utils";
+
import {
FormControl,
FormDescription,
@@ -25,6 +23,7 @@ import { groupByContinent } from "@openstatus/utils";
import { CheckboxLabel } from "../shared/checkbox-label";
import { SectionHeader } from "../shared/section-header";
+import type { Limits } from "@openstatus/db/src/schema/plan/schema";
// TODO: centralize in a shared file!
const cronJobs = [
@@ -38,13 +37,13 @@ const cronJobs = [
interface Props {
form: UseFormReturn<InsertMonitor>;
+ limits: Limits;
plan: WorkspacePlan;
}
-export function SectionScheduling({ form, plan }: Props) {
- const periodicityLimit = getLimit(plan, "periodicity");
- const regionsLimit = getLimit(plan, "regions");
- console.log(form.getValues());
+export function SectionScheduling({ form, limits, plan }: Props) {
+ const periodicityLimit = getLimit(limits, "periodicity");
+ const regionsLimit = getLimit(limits, "regions");
return (
<div className="grid w-full gap-4">
<SectionHeader
diff --git a/apps/web/src/components/forms/monitor/section-status-page.tsx b/apps/web/src/components/forms/monitor/section-status-page.tsx
index de319ef05..126b808b0 100644
--- a/apps/web/src/components/forms/monitor/section-status-page.tsx
+++ b/apps/web/src/components/forms/monitor/section-status-page.tsx
@@ -22,7 +22,6 @@ import { SectionHeader } from "../shared/section-header";
interface Props {
form: UseFormReturn<InsertMonitor>;
- plan: WorkspacePlan;
pages?: Page[];
}
@@ -89,8 +88,8 @@ export function SectionStatusPage({ form, pages }: Props) {
])
: field.onChange(
field.value?.filter(
- (value) => value !== item.id,
- ),
+ (value) => value !== item.id
+ )
);
}}
>
diff --git a/apps/web/src/components/forms/notification/config.ts b/apps/web/src/components/forms/notification/config.ts
index 7f39a3294..343bd1a7e 100644
--- a/apps/web/src/components/forms/notification/config.ts
+++ b/apps/web/src/components/forms/notification/config.ts
@@ -4,8 +4,8 @@ import type {
} from "@openstatus/db/src/schema";
import { sendTestDiscordMessage } from "@openstatus/notification-discord";
import { sendTestSlackMessage } from "@openstatus/notification-slack";
-import { allPlans, plans } from "@openstatus/plans";
-
+import { allPlans } from "@openstatus/db/src/schema/plan/config";
+import { workspacePlans } from "@openstatus/db/src/schema/workspaces/constants";
export function getDefaultProviderData(defaultValues?: InsertNotification) {
if (!defaultValues?.provider) return ""; // FIXME: input can empty - needs to be undefined
return JSON.parse(defaultValues?.data || "{}")[defaultValues?.provider];
@@ -24,7 +24,7 @@ export function getProviderMetaData(provider: NotificationProvider) {
placeholder: "[email protected]",
setupDocLink: null,
sendTest: null,
- plans: plans,
+ plans: workspacePlans,
};
case "slack":
@@ -35,7 +35,7 @@ export function getProviderMetaData(provider: NotificationProvider) {
setupDocLink:
"https://api.slack.com/messaging/webhooks#getting_started",
sendTest: sendTestSlackMessage,
- plans: plans,
+ plans: workspacePlans,
};
case "discord":
@@ -45,7 +45,7 @@ export function getProviderMetaData(provider: NotificationProvider) {
placeholder: "https://discord.com/api/webhooks/{channelId}/xxx...",
setupDocLink: "https://support.discord.com/hc/en-us/articles/228383668",
sendTest: sendTestDiscordMessage,
- plans: plans,
+ plans: workspacePlans,
};
case "sms":
return {
@@ -54,7 +54,7 @@ export function getProviderMetaData(provider: NotificationProvider) {
placeholder: "+123456789",
setupDocLink: null,
sendTest: null,
- plans: plans.filter((plan) => allPlans[plan].limits.sms),
+ plans: workspacePlans.filter((plan) => allPlans[plan].limits.sms),
};
case "pagerduty":
@@ -65,7 +65,7 @@ export function getProviderMetaData(provider: NotificationProvider) {
setupDocLink:
"https://docs.openstatus.dev/synthetic/features/notification/pagerduty",
sendTest: null,
- plans: plans.filter((plan) => allPlans[plan].limits.pagerduty),
+ plans: workspacePlans.filter((plan) => allPlans[plan].limits.pagerduty),
};
default:
@@ -75,7 +75,7 @@ export function getProviderMetaData(provider: NotificationProvider) {
placeholder: "xxxx",
setupDocLink: `https://docs.openstatus.dev/integrations/${provider}`,
send: null,
- plans: plans,
+ plans: workspacePlans,
};
}
}
diff --git a/apps/web/src/components/marketing/pricing/pricing-plan-radio.tsx b/apps/web/src/components/marketing/pricing/pricing-plan-radio.tsx
index f54b8f81a..6652d8507 100644
--- a/apps/web/src/components/marketing/pricing/pricing-plan-radio.tsx
+++ b/apps/web/src/components/marketing/pricing/pricing-plan-radio.tsx
@@ -1,8 +1,8 @@
"use client";
import { useRouter } from "next/navigation";
-
-import { allPlans, plans } from "@openstatus/plans";
+import { allPlans } from "@openstatus/db/src/schema/plan/config";
+import { workspacePlans } from "@openstatus/db/src/schema/workspaces/constants";
import { Label, RadioGroup, RadioGroupItem } from "@openstatus/ui";
import useUpdateSearchParams from "@/hooks/use-update-search-params";
@@ -20,14 +20,14 @@ export function PricingPlanRadio() {
router.replace(`?${searchParams}`, { scroll: false });
}}
>
- {plans.map((key) => (
+ {workspacePlans.map((key) => (
<div key={key}>
<RadioGroupItem value={key} id={key} className="peer sr-only" />
<Label
htmlFor={key}
className={cn(
"flex flex-col items-center justify-between rounded-md border-2 border-muted bg-popover p-4 [&:has([data-state=checked])]:border-primary peer-data-[state=checked]:border-primary hover:bg-accent hover:text-accent-foreground",
- key === "team" && "bg-muted/50",
+ key === "team" && "bg-muted/50"
)}
>
<span className="text-sm capitalize">{key}</span>
diff --git a/apps/web/src/components/marketing/pricing/pricing-slider.tsx b/apps/web/src/components/marketing/pricing/pricing-slider.tsx
new file mode 100644
index 000000000..8e89216a4
--- /dev/null
+++ b/apps/web/src/components/marketing/pricing/pricing-slider.tsx
@@ -0,0 +1,114 @@
+"use client";
+
+import { cn } from "@/lib/utils";
+import { InputWithAddons, Slider } from "@openstatus/ui";
+import { useMemo, useState } from "react";
+
+const MAX_REGIONS = 35;
+
+const slides = [
+ {
+ key: "30s",
+ value: 2 * 60 * 24 * 30,
+ },
+ {
+ key: "1m",
+ value: 60 * 24 * 30,
+ },
+ {
+ key: "5m",
+ value: 12 * 24 * 30,
+ },
+ {
+ key: "10m",
+ value: 6 * 24 * 30,
+ },
+ {
+ key: "30m",
+ value: 2 * 24 * 30,
+ },
+ {
+ key: "1h",
+ value: 24 * 30,
+ },
+];
+
+export function PricingSlider() {
+ const [index, setIndex] = useState<number[]>([2]);
+ const [inputValue, setInputValue] = useState<number>(6);
+ const region = useMemo(() => slides[index[0]].value, [index]);
+ const total = useMemo(() => region * inputValue, [region, inputValue]);
+
+ return (
+ <div className="grid gap-4">
+ <div className="grid gap-8 sm:grid-cols-3">
+ <div className="grid gap-2 sm:col-span-2">
+ <h4 className="font-semibold text-2xl">Total requests per monitor</h4>
+ <p className="text-muted-foreground">
+ Check how many requests you will make with OpenStatus for a single
+ monitor over the selected time period.
+ </p>
+ </div>
+ <div className="flex justify-end">
+ <div className="min-w-36 max-w-min">
+ <InputWithAddons
+ type="number"
+ min={0}
+ max={MAX_REGIONS}
+ step={1}
+ trailing="regions"
+ className="text-right font-mono"
+ value={inputValue}
+ onChange={(e) =>
+ setInputValue(Number.parseInt(e.target.value) || 0)
+ }
+ />
+ </div>
+ </div>
+ </div>
+ <div className="grid gap-8 sm:grid-cols-3">
+ <div className="mt-2 grid w-full gap-2 sm:col-span-2">
+ <Slider
+ min={0}
+ max={slides.length - 1}
+ step={1}
+ minStepsBetweenThumbs={1}
+ value={index}
+ onValueChange={setIndex}
+ />
+ <div className="flex items-center justify-between">
+ {slides.map((slide, i) => (
+ // TODO: make them clickable
+ <div
+ key={slide.key}
+ className={cn(
+ "text-left font-mono text-muted-foreground text-xs"
+ )}
+ >
+ {slide.key}
+ </div>
+ ))}
+ </div>
+ </div>
+ <div>
+ <p className="mt-0.5 text-right text-sm">
+ <span className="font-medium font-mono">
+ {new Intl.NumberFormat("us").format(region).toString()} pings{" "}
+ </span>{" "}
+ <span className="font-normal text-muted-foreground">
+ / region / month
+ </span>
+ </p>
+ </div>
+ </div>
+ <div>
+ <p className="text-right">
+ <span className="font-medium font-mono text-lg">
+ {new Intl.NumberFormat("us").format(total).toString()} pings{" "}
+ </span>{" "}
+ <span className="font-normal text-muted-foreground">/ month</span>
+ </p>
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/src/components/marketing/pricing/pricing-table.tsx b/apps/web/src/components/marketing/pricing/pricing-table.tsx
index 3dd863d27..5b62011d4 100644
--- a/apps/web/src/components/marketing/pricing/pricing-table.tsx
+++ b/apps/web/src/components/marketing/pricing/pricing-table.tsx
@@ -4,12 +4,9 @@ import { Check } from "lucide-react";
import { useRouter } from "next/navigation";
import { Fragment } from "react";
-import type { WorkspacePlan } from "@openstatus/plans";
-import {
- allPlans,
- plans as defaultPlans,
- pricingTableConfig,
-} from "@openstatus/plans";
+import type { WorkspacePlan } from "@openstatus/db/src/schema/workspaces/validation";
+import { pricingTableConfig } from "../../../config/pricing-table";
+import { workspacePlans } from "@openstatus/db/src/schema/workspaces/constants";
import {
Badge,
Button,
@@ -24,9 +21,10 @@ import {
import { LoadingAnimation } from "@/components/loading-animation";
import { cn } from "@/lib/utils";
+import { allPlans } from "@openstatus/db/src/schema/plan/config";
export function PricingTable({
- plans = defaultPlans,
+ plans = workspacePlans,
currentPlan,
events,
isLoading,
@@ -57,7 +55,7 @@ export function PricingTable({
key={key}
className={cn(
"h-auto px-3 py-3 align-bottom text-foreground",
- key === "team" ? "bg-muted/30" : "bg-background",
+ key === "team" ? "bg-muted/30" : "bg-background"
)}
>
<p className="sticky top-0 mb-2 font-cal text-2xl">
@@ -140,7 +138,11 @@ export function PricingTable({
}
if (typeof limitValue === "number") {
return (
- <span className="font-mono">{limitValue}</span>
+ <span className="font-mono">
+ {new Intl.NumberFormat("us")
+ .format(limitValue)
+ .toString()}
+ </span>
);
}
if (
@@ -157,7 +159,7 @@ export function PricingTable({
key={key}
className={cn(
"p-3",
- plan.key === "team" && "bg-muted/30",
+ plan.key === "team" && "bg-muted/30"
)}
>
{renderContent()}
@@ -169,7 +171,7 @@ export function PricingTable({
})}
</Fragment>
);
- },
+ }
)}
</TableBody>
</Table>
diff --git a/apps/web/src/components/marketing/pricing/pricing-wrapper.tsx b/apps/web/src/components/marketing/pricing/pricing-wrapper.tsx
index dd664ccac..9aefd5657 100644
--- a/apps/web/src/components/marketing/pricing/pricing-wrapper.tsx
+++ b/apps/web/src/components/marketing/pricing/pricing-wrapper.tsx
@@ -2,7 +2,7 @@
import { useSearchParams } from "next/navigation";
-import type { WorkspacePlan } from "@openstatus/plans";
+import type { WorkspacePlan } from "@openstatus/db/src/schema/workspaces/validation";
import { Suspense } from "react";
import { PricingPlanRadio } from "./pricing-plan-radio";
diff --git a/apps/web/src/components/ping-response-analysis/select-region.tsx b/apps/web/src/components/ping-response-analysis/select-region.tsx
index 48f996bf5..1ae33cb19 100644
--- a/apps/web/src/components/ping-response-analysis/select-region.tsx
+++ b/apps/web/src/components/ping-response-analysis/select-region.tsx
@@ -2,8 +2,8 @@
import { usePathname, useRouter } from "next/navigation";
-import type { MonitorFlyRegion } from "@openstatus/db/src/schema";
-import { flyRegions } from "@openstatus/db/src/schema";
+import type { MonitorFlyRegion } from "@openstatus/db/src/schema/constants";
+import { flyRegions } from "@openstatus/db/src/schema/constants";
import {
Label,
Select,
diff --git a/apps/web/src/components/ping-response-analysis/utils.ts b/apps/web/src/components/ping-response-analysis/utils.ts
index 5324d25f6..d5c911231 100644
--- a/apps/web/src/components/ping-response-analysis/utils.ts
+++ b/apps/web/src/components/ping-response-analysis/utils.ts
@@ -1,8 +1,11 @@
import { Redis } from "@upstash/redis";
import { z } from "zod";
-import { flyRegions, monitorFlyRegionSchema } from "@openstatus/db/src/schema";
-import type { MonitorFlyRegion } from "@openstatus/db/src/schema";
+import {
+ flyRegions,
+ monitorFlyRegionSchema,
+} from "@openstatus/db/src/schema/constants";
+import type { MonitorFlyRegion } from "@openstatus/db/src/schema/constants";
import { flyRegionsDict } from "@openstatus/utils";
export function latencyFormatter(value: number) {
diff --git a/packages/plans/src/pricing-table.ts b/apps/web/src/config/pricing-table.ts
similarity index 87%
rename from packages/plans/src/pricing-table.ts
rename to apps/web/src/config/pricing-table.ts
index 7e2545264..d53c57230 100644
--- a/packages/plans/src/pricing-table.ts
+++ b/apps/web/src/config/pricing-table.ts
@@ -1,4 +1,4 @@
-import type { Limits } from "./types";
+import type { Limits } from "@openstatus/db/src/schema/plan/schema";
export const pricingTableConfig: Record<
string,
@@ -26,6 +26,15 @@ export const pricingTableConfig: Record<
{ value: "data-retention", label: "Data retention" },
],
},
+ "synthetic-checks": {
+ label: "Synthetic API Checks",
+ features: [
+ {
+ value: "synthetic-checks",
+ label: "Number of synthetic API checks",
+ },
+ ],
+ },
"status-pages": {
label: "Status Pages",
features: [
diff --git a/packages/api/package.json b/packages/api/package.json
index 065f828a2..3a1763dc3 100644
--- a/packages/api/package.json
+++ b/packages/api/package.json
@@ -12,7 +12,6 @@
"@openstatus/db": "workspace:*",
"@openstatus/emails": "workspace:*",
"@openstatus/error": "workspace:*",
- "@openstatus/plans": "workspace:*",
"@openstatus/tinybird": "workspace:*",
"@t3-oss/env-core": "0.7.0",
"@trpc/client": "10.45.2",
diff --git a/packages/api/src/router/invitation.ts b/packages/api/src/router/invitation.ts
index 201141738..049be0899 100644
--- a/packages/api/src/router/invitation.ts
+++ b/packages/api/src/router/invitation.ts
@@ -9,7 +9,7 @@ import {
user,
usersToWorkspaces,
} from "@openstatus/db/src/schema";
-import { allPlans } from "@openstatus/plans";
+import { allPlans } from "@openstatus/db/src/schema/plan/config";
import { trackNewInvitation } from "../analytics";
import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc";
@@ -34,7 +34,7 @@ export const invitationRouter = createTRPCRouter({
where: and(
eq(invitation.workspaceId, opts.ctx.workspace.id),
gte(invitation.expiresAt, new Date()),
- isNull(invitation.acceptedAt),
+ isNull(invitation.acceptedAt)
),
})
).length;
@@ -60,7 +60,7 @@ export const invitationRouter = createTRPCRouter({
if (process.env.NODE_ENV === "development") {
console.log(
- `>>>> Invitation token: http://localhost:3000/app/invite?token=${token} <<<< `,
+ `>>>> Invitation token: http://localhost:3000/app/invite?token=${token} <<<< `
);
} else {
await fetch("https://api.resend.com/emails", {
@@ -104,8 +104,8 @@ export const invitationRouter = createTRPCRouter({
.where(
and(
eq(invitation.id, opts.input.id),
- eq(invitation.workspaceId, opts.ctx.workspace.id),
- ),
+ eq(invitation.workspaceId, opts.ctx.workspace.id)
+ )
)
.run();
}),
@@ -115,7 +115,7 @@ export const invitationRouter = createTRPCRouter({
where: and(
eq(invitation.workspaceId, opts.ctx.workspace.id),
gte(invitation.expiresAt, new Date()),
- isNull(invitation.acceptedAt),
+ isNull(invitation.acceptedAt)
),
});
return _invitations;
@@ -144,13 +144,13 @@ export const invitationRouter = createTRPCRouter({
z.object({
message: z.string(),
data: selectWorkspaceSchema.optional(),
- }),
+ })
)
.mutation(async (opts) => {
const _invitation = await opts.ctx.db.query.invitation.findFirst({
where: and(
eq(invitation.token, opts.input.token),
- isNull(invitation.acceptedAt),
+ isNull(invitation.acceptedAt)
),
with: {
workspace: true,
diff --git a/packages/api/src/router/monitor.ts b/packages/api/src/router/monitor.ts
index 5d1817418..5b48471c9 100644
--- a/packages/api/src/router/monitor.ts
+++ b/packages/api/src/router/monitor.ts
@@ -24,7 +24,7 @@ import {
selectNotificationSchema,
selectPublicMonitorSchema,
} from "@openstatus/db/src/schema";
-import { allPlans } from "@openstatus/plans";
+import { allPlans } from "@openstatus/db/src/schema/plan/config";
import { trackNewMonitor } from "../analytics";
import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc";
diff --git a/packages/api/src/router/notification.ts b/packages/api/src/router/notification.ts
index 614140d43..c22a85629 100644
--- a/packages/api/src/router/notification.ts
+++ b/packages/api/src/router/notification.ts
@@ -11,7 +11,6 @@ import {
selectMonitorSchema,
selectNotificationSchema,
} from "@openstatus/db/src/schema";
-import { getLimit } from "@openstatus/plans";
import { SchemaError } from "@openstatus/error";
import { trackNewNotification } from "../analytics";
@@ -24,10 +23,8 @@ export const notificationRouter = createTRPCRouter({
.mutation(async (opts) => {
const { monitors, ...props } = opts.input;
- const notificationLimit = getLimit(
- opts.ctx.workspace.plan,
- "notification-channels",
- );
+ const notificationLimit =
+ opts.ctx.workspace.limits["notification-channels"];
const notificationNumber = (
await opts.ctx.db.query.notification.findMany({
@@ -97,8 +94,8 @@ export const notificationRouter = createTRPCRouter({
.where(
and(
eq(notification.id, opts.input.id),
- eq(notification.workspaceId, opts.ctx.workspace.id),
- ),
+ eq(notification.workspaceId, opts.ctx.workspace.id)
+ )
)
.returning()
.get();
@@ -109,7 +106,7 @@ export const notificationRouter = createTRPCRouter({
const allMonitors = await opts.ctx.db.query.monitor.findMany({
where: and(
eq(monitor.workspaceId, opts.ctx.workspace.id),
- inArray(monitor.id, monitors),
+ inArray(monitor.id, monitors)
),
});
@@ -125,7 +122,7 @@ export const notificationRouter = createTRPCRouter({
.select()
.from(notificationsToMonitors)
.where(
- eq(notificationsToMonitors.notificationId, currentNotification.id),
+ eq(notificationsToMonitors.notificationId, currentNotification.id)
)
.all();
@@ -139,11 +136,8 @@ export const notificationRouter = createTRPCRouter({
.where(
and(
inArray(notificationsToMonitors.monitorId, removedMonitors),
- eq(
- notificationsToMonitors.notificationId,
- currentNotification.id,
- ),
- ),
+ eq(notificationsToMonitors.notificationId, currentNotification.id)
+ )
);
}
@@ -170,8 +164,8 @@ export const notificationRouter = createTRPCRouter({
.where(
and(
eq(notification.id, opts.input.id),
- eq(notification.id, opts.input.id),
- ),
+ eq(notification.id, opts.input.id)
+ )
)
.run();
}),
@@ -183,7 +177,7 @@ export const notificationRouter = createTRPCRouter({
where: and(
eq(notification.id, opts.input.id),
eq(notification.id, opts.input.id),
- eq(notification.workspaceId, opts.ctx.workspace.id),
+ eq(notification.workspaceId, opts.ctx.workspace.id)
),
// FIXME: plural
with: { monitor: { with: { monitor: true } } },
@@ -193,7 +187,7 @@ export const notificationRouter = createTRPCRouter({
monitor: z.array(
z.object({
monitor: selectMonitorSchema,
- }),
+ })
),
});
@@ -213,7 +207,7 @@ export const notificationRouter = createTRPCRouter({
monitor: z.array(
z.object({
monitor: selectMonitorSchema,
- }),
+ })
),
});
@@ -221,10 +215,8 @@ export const notificationRouter = createTRPCRouter({
}),
isNotificationLimitReached: protectedProcedure.query(async (opts) => {
- const notificationLimit = getLimit(
- opts.ctx.workspace.plan,
- "notification-channels",
- );
+ const notificationLimit =
+ opts.ctx.workspace.limits["notification-channels"];
const notificationNumbers = (
await opts.ctx.db.query.notification.findMany({
where: eq(notification.workspaceId, opts.ctx.workspace.id),
diff --git a/packages/api/src/router/page.ts b/packages/api/src/router/page.ts
index d6ee75dc1..a8b6b7a1a 100644
--- a/packages/api/src/router/page.ts
+++ b/packages/api/src/router/page.ts
@@ -25,7 +25,7 @@ import {
statusReport,
workspace,
} from "@openstatus/db/src/schema";
-import { allPlans } from "@openstatus/plans";
+import { allPlans } from "@openstatus/db/src/schema/plan/config";
import { trackNewPage } from "../analytics";
import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc";
@@ -75,7 +75,7 @@ export const pageRouter = createTRPCRouter({
where: and(
inArray(monitor.id, monitorIds),
eq(monitor.workspaceId, opts.ctx.workspace.id),
- isNull(monitor.deletedAt),
+ isNull(monitor.deletedAt)
),
});
@@ -105,7 +105,7 @@ export const pageRouter = createTRPCRouter({
const firstPage = await opts.ctx.db.query.page.findFirst({
where: and(
eq(page.id, opts.input.id),
- eq(page.workspaceId, opts.ctx.workspace.id),
+ eq(page.workspaceId, opts.ctx.workspace.id)
),
with: {
monitorsToPages: {
@@ -142,8 +142,8 @@ export const pageRouter = createTRPCRouter({
.where(
and(
eq(page.id, pageInput.id),
- eq(page.workspaceId, opts.ctx.workspace.id),
- ),
+ eq(page.workspaceId, opts.ctx.workspace.id)
+ )
)
.returning()
.get();
@@ -154,7 +154,7 @@ export const pageRouter = createTRPCRouter({
where: and(
inArray(monitor.id, monitorIds),
eq(monitor.workspaceId, opts.ctx.workspace.id),
- isNull(monitor.deletedAt),
+ isNull(monitor.deletedAt)
),
});
@@ -183,8 +183,8 @@ export const pageRouter = createTRPCRouter({
.where(
and(
inArray(monitorsToPages.monitorId, removedMonitors),
- eq(monitorsToPages.pageId, currentPage.id),
- ),
+ eq(monitorsToPages.pageId, currentPage.id)
+ )
);
}
@@ -212,8 +212,8 @@ export const pageRouter = createTRPCRouter({
.where(
and(
eq(page.id, opts.input.id),
- eq(page.workspaceId, opts.ctx.workspace.id),
- ),
+ eq(page.workspaceId, opts.ctx.workspace.id)
+ )
)
.run();
}),
@@ -225,7 +225,7 @@ export const pageRouter = createTRPCRouter({
maintenancesToPages: {
where: and(
lte(maintenance.from, new Date()),
- gte(maintenance.to, new Date()),
+ gte(maintenance.to, new Date())
),
},
},
@@ -261,12 +261,12 @@ export const pageRouter = createTRPCRouter({
.leftJoin(monitor, eq(monitorsToPages.monitorId, monitor.id))
.where(
// make sur only active monitors are returned!
- and(eq(monitorsToPages.pageId, result.id), eq(monitor.active, true)),
+ and(eq(monitorsToPages.pageId, result.id), eq(monitor.active, true))
)
.all();
const monitorsId = monitorsToPagesResult.map(
- ({ monitors_to_pages }) => monitors_to_pages.monitorId,
+ ({ monitors_to_pages }) => monitors_to_pages.monitorId
);
const monitorsToStatusReportResult =
@@ -279,7 +279,7 @@ export const pageRouter = createTRPCRouter({
: [];
const monitorStatusReportIds = monitorsToStatusReportResult.map(
- ({ statusReportId }) => statusReportId,
+ ({ statusReportId }) => statusReportId
);
const statusReportIds = Array.from(new Set([...monitorStatusReportIds]));
@@ -307,8 +307,8 @@ export const pageRouter = createTRPCRouter({
and(
inArray(monitor.id, monitorsId),
eq(monitor.active, true),
- isNull(monitor.deletedAt),
- ), // REMINDER: this is hardcoded
+ isNull(monitor.deletedAt)
+ ) // REMINDER: this is hardcoded
)
.all()
: [];
@@ -321,8 +321,8 @@ export const pageRouter = createTRPCRouter({
.where(
inArray(
incidentTable.monitorId,
- monitors.map((m) => m.id),
- ),
+ monitors.map((m) => m.id)
+ )
)
.all()
: [];
@@ -361,7 +361,7 @@ export const pageRouter = createTRPCRouter({
// had filter on some words we want to keep for us
if (
["api", "app", "www", "docs", "checker", "time", "help"].includes(
- opts.input.slug,
+ opts.input.slug
)
) {
return false;
@@ -374,7 +374,7 @@ export const pageRouter = createTRPCRouter({
addCustomDomain: protectedProcedure
.input(
- z.object({ customDomain: z.string().toLowerCase(), pageId: z.number() }),
+ z.object({ customDomain: z.string().toLowerCase(), pageId: z.number() })
)
.mutation(async (opts) => {
// TODO Add some check ?
diff --git a/packages/api/src/router/stripe/utils.ts b/packages/api/src/router/stripe/utils.ts
index dc0c12725..d8af8841f 100644
--- a/packages/api/src/router/stripe/utils.ts
+++ b/packages/api/src/router/stripe/utils.ts
@@ -20,7 +20,7 @@ export const PLANS = [
monthly: {
priceIds: {
test: "price_1NdurjBXJcTfzsyJdAzIxXnT",
- production: "price_1OUvJvBXJcTfzsyJMA07Uew7",
+ production: "price_1PdJ3lBXJcTfzsyJHgqcfVG9",
},
},
},
@@ -31,7 +31,7 @@ export const PLANS = [
monthly: {
priceIds: {
test: "price_1OVHQDBXJcTfzsyJjfiXl10Y",
- production: "price_1OWM4TBXJcTfzsyJBdu71AhE",
+ production: "price_1PdJ5MBXJcTfzsyJqWXeMUEQ",
},
},
},
@@ -42,7 +42,7 @@ export const PLANS = [
monthly: {
priceIds: {
test: "price_1OVHPlBXJcTfzsyJvPlB1kNb",
- production: "price_1OWM5kBXJcTfzsyJ6Z2bUWcQ",
+ production: "price_1PdJ4eBXJcTfzsyJ0hsHMAxh",
},
},
},
diff --git a/packages/api/src/router/stripe/webhook.ts b/packages/api/src/router/stripe/webhook.ts
index f06499245..2ecfad9bd 100644
--- a/packages/api/src/router/stripe/webhook.ts
+++ b/packages/api/src/router/stripe/webhook.ts
@@ -9,6 +9,7 @@ import { user, workspace } from "@openstatus/db/src/schema";
import { createTRPCRouter, publicProcedure } from "../../trpc";
import { stripe } from "./shared";
import { getPlanFromPriceId } from "./utils";
+import { getLimits } from "@openstatus/db/src/schema/plan/utils";
const webhookProcedure = publicProcedure.input(
z.object({
@@ -22,7 +23,7 @@ const webhookProcedure = publicProcedure.input(
}),
type: z.string(),
}),
- }),
+ })
);
export const webhookRouter = createTRPCRouter({
@@ -35,7 +36,7 @@ export const webhookRouter = createTRPCRouter({
});
}
const subscription = await stripe.subscriptions.retrieve(
- session.subscription,
+ session.subscription
);
const customerId =
typeof subscription.customer === "string"
@@ -67,6 +68,7 @@ export const webhookRouter = createTRPCRouter({
subscriptionId: subscription.id,
endsAt: new Date(subscription.current_period_end * 1000),
paidUntil: new Date(subscription.current_period_end * 1000),
+ limits: JSON.stringify(getLimits(plan.plan)),
})
.where(eq(workspace.id, result.id))
.run();
diff --git a/packages/api/src/router/tinybird/index.ts b/packages/api/src/router/tinybird/index.ts
index d822c5ed3..7a92b3dd5 100644
--- a/packages/api/src/router/tinybird/index.ts
+++ b/packages/api/src/router/tinybird/index.ts
@@ -1,10 +1,10 @@
import { z } from "zod";
-import { flyRegions } from "@openstatus/db/src/schema";
import { OSTinybird } from "@openstatus/tinybird";
import { env } from "../../env";
import { createTRPCRouter, protectedProcedure } from "../../trpc";
+import { flyRegions } from "@openstatus/db/src/schema/constants";
const tb = new OSTinybird({ token: env.TINY_BIRD_API_KEY });
@@ -29,7 +29,7 @@ export const tinybirdRouter = createTRPCRouter({
url: z.string().url().optional(),
region: z.enum(flyRegions).optional(),
cronTimestamp: z.number().int().optional(),
- }),
+ })
)
.query(async (opts) => {
return await tb.endpointResponseDetails("7d")(opts.input);
@@ -52,7 +52,7 @@ export const tinybirdRouter = createTRPCRouter({
dsn: z.string(),
path: z.string(),
period: z.enum(["24h", "7d", "30d"]),
- }),
+ })
)
.query(async (opts) => {
return await tb.applicationRUMMetricsForPath()(opts.input);
@@ -63,7 +63,7 @@ export const tinybirdRouter = createTRPCRouter({
dsn: z.string(),
path: z.string(),
period: z.enum(["24h", "7d", "30d"]),
- }),
+ })
)
.query(async (opts) => {
return await tb.applicationSessionMetricsPerPath()(opts.input);
diff --git a/packages/api/src/router/workspace.ts b/packages/api/src/router/workspace.ts
index bbbdcff5c..4d7174226 100644
--- a/packages/api/src/router/workspace.ts
+++ b/packages/api/src/router/workspace.ts
@@ -16,7 +16,7 @@ import {
workspace,
workspacePlanSchema,
} from "@openstatus/db/src/schema";
-import type { Limits } from "@openstatus/plans";
+import type { Limits } from "@openstatus/db/src/schema/plan/schema";
import { createTRPCRouter, protectedProcedure } from "../trpc";
@@ -124,7 +124,7 @@ export const workspaceRouter = createTRPCRouter({
await opts.ctx.db.query.usersToWorkspaces.findFirst({
where: and(
eq(usersToWorkspaces.userId, opts.ctx.user.id),
- eq(usersToWorkspaces.workspaceId, opts.ctx.workspace.id),
+ eq(usersToWorkspaces.workspaceId, opts.ctx.workspace.id)
),
});
@@ -141,8 +141,8 @@ export const workspaceRouter = createTRPCRouter({
.where(
and(
eq(usersToWorkspaces.userId, opts.input.id),
- eq(usersToWorkspaces.workspaceId, opts.ctx.workspace.id),
- ),
+ eq(usersToWorkspaces.workspaceId, opts.ctx.workspace.id)
+ )
)
.run();
}),
@@ -154,7 +154,7 @@ export const workspaceRouter = createTRPCRouter({
await opts.ctx.db.query.usersToWorkspaces.findFirst({
where: and(
eq(usersToWorkspaces.userId, opts.ctx.user.id),
- eq(usersToWorkspaces.workspaceId, opts.ctx.workspace.id),
+ eq(usersToWorkspaces.workspaceId, opts.ctx.workspace.id)
),
});
@@ -209,8 +209,8 @@ export const workspaceRouter = createTRPCRouter({
.where(
and(
eq(monitor.workspaceId, opts.ctx.workspace.id),
- isNotNull(monitor.deletedAt),
- ),
+ isNotNull(monitor.deletedAt)
+ )
);
const pages = await tx
.select({ count: sql<number>`count(*)` })
diff --git a/packages/db/drizzle/0035_open_the_professor.sql b/packages/db/drizzle/0035_open_the_professor.sql
new file mode 100644
index 000000000..d2f2142ae
--- /dev/null
+++ b/packages/db/drizzle/0035_open_the_professor.sql
@@ -0,0 +1 @@
+ALTER TABLE `workspace` ADD `limits` text DEFAULT '{}' NOT NULL;
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/0035_snapshot.json b/packages/db/drizzle/meta/0035_snapshot.json
new file mode 100644
index 000000000..766e531ae
--- /dev/null
+++ b/packages/db/drizzle/meta/0035_snapshot.json
@@ -0,0 +1,2194 @@
+{
+ "version": "6",
+ "dialect": "sqlite",
+ "id": "d42f0027-40b6-4d43-9d76-160e0a6e35e7",
+ "prevId": "145f2782-3cb0-4066-9842-881a17636999",
+ "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_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
+ },
+ "page_id": {
+ "name": "page_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"
+ },
+ "status_report_page_id_page_id_fk": {
+ "name": "status_report_page_id_page_id_fk",
+ "tableFrom": "status_report",
+ "tableTo": "page",
+ "columnsFrom": [
+ "page_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
+ },
+ "timeout": {
+ "name": "timeout",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 45000
+ },
+ "degraded_after": {
+ "name": "degraded_after",
+ "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'))"
+ },
+ "order": {
+ "name": "order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 0
+ }
+ },
+ "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": {}
+ },
+ "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
+ },
+ "limits": {
+ "name": "limits",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "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'))"
+ },
+ "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": {}
+ },
+ "account": {
+ "name": "account",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider_account_id": {
+ "name": "provider_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "session_state": {
+ "name": "session_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "account_provider_provider_account_id_pk": {
+ "columns": [
+ "provider",
+ "provider_account_id"
+ ],
+ "name": "account_provider_provider_account_id_pk"
+ }
+ },
+ "uniqueConstraints": {}
+ },
+ "session": {
+ "name": "session",
+ "columns": {
+ "session_token": {
+ "name": "session_token",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires": {
+ "name": "expires",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "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": "''"
+ },
+ "photo_url": {
+ "name": "photo_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "emailVerified": {
+ "name": "emailVerified",
+ "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": {
+ "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": {}
+ },
+ "verification_token": {
+ "name": "verification_token",
+ "columns": {
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires": {
+ "name": "expires",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "verification_token_identifier_token_pk": {
+ "columns": [
+ "identifier",
+ "token"
+ ],
+ "name": "verification_token_identifier_token_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": {}
+ },
+ "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": {}
+ },
+ "application": {
+ "name": "application",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "dsn": {
+ "name": "dsn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "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": {
+ "application_dsn_unique": {
+ "name": "application_dsn_unique",
+ "columns": [
+ "dsn"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "application_workspace_id_workspace_id_fk": {
+ "name": "application_workspace_id_workspace_id_fk",
+ "tableFrom": "application",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "maintenance": {
+ "name": "maintenance",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "from": {
+ "name": "from",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "to": {
+ "name": "to",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "page_id": {
+ "name": "page_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": {
+ "maintenance_workspace_id_workspace_id_fk": {
+ "name": "maintenance_workspace_id_workspace_id_fk",
+ "tableFrom": "maintenance",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "maintenance_page_id_page_id_fk": {
+ "name": "maintenance_page_id_page_id_fk",
+ "tableFrom": "maintenance",
+ "tableTo": "page",
+ "columnsFrom": [
+ "page_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "maintenance_to_monitor": {
+ "name": "maintenance_to_monitor",
+ "columns": {
+ "monitor_id": {
+ "name": "monitor_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "maintenance_id": {
+ "name": "maintenance_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": {
+ "maintenance_to_monitor_monitor_id_monitor_id_fk": {
+ "name": "maintenance_to_monitor_monitor_id_monitor_id_fk",
+ "tableFrom": "maintenance_to_monitor",
+ "tableTo": "monitor",
+ "columnsFrom": [
+ "monitor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "maintenance_to_monitor_maintenance_id_maintenance_id_fk": {
+ "name": "maintenance_to_monitor_maintenance_id_maintenance_id_fk",
+ "tableFrom": "maintenance_to_monitor",
+ "tableTo": "maintenance",
+ "columnsFrom": [
+ "maintenance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "maintenance_to_monitor_monitor_id_maintenance_id_pk": {
+ "columns": [
+ "maintenance_id",
+ "monitor_id"
+ ],
+ "name": "maintenance_to_monitor_monitor_id_maintenance_id_pk"
+ }
+ },
+ "uniqueConstraints": {}
+ },
+ "check": {
+ "name": "check",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "regions": {
+ "name": "regions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "url": {
+ "name": "url",
+ "type": "text(4096)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "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'"
+ },
+ "count_requests": {
+ "name": "count_requests",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 1
+ },
+ "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'))"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "check_workspace_id_workspace_id_fk": {
+ "name": "check_workspace_id_workspace_id_fk",
+ "tableFrom": "check",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ }
+ },
+ "enums": {},
+ "_meta": {
+ "schemas": {},
+ "tables": {},
+ "columns": {}
+ }
+}
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/_journal.json b/packages/db/drizzle/meta/_journal.json
index 932f409f9..ad37f5e84 100644
--- a/packages/db/drizzle/meta/_journal.json
+++ b/packages/db/drizzle/meta/_journal.json
@@ -246,6 +246,13 @@
"when": 1720727898360,
"tag": "0034_serious_shard",
"breakpoints": true
+ },
+ {
+ "idx": 35,
+ "version": "6",
+ "when": 1721159796428,
+ "tag": "0035_open_the_professor",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/packages/db/src/schema/constants.ts b/packages/db/src/schema/constants.ts
new file mode 100644
index 000000000..a3b837003
--- /dev/null
+++ b/packages/db/src/schema/constants.ts
@@ -0,0 +1,55 @@
+import { z } from "zod";
+
+export const flyRegions = [
+ "ams",
+ "arn",
+ "atl",
+ "bog",
+ "bom",
+ "bos",
+ "cdg",
+ "den",
+ "dfw",
+ "ewr",
+ "eze",
+ "fra",
+ "gdl",
+ "gig",
+ "gru",
+ "hkg",
+ "iad",
+ "jnb",
+ "lax",
+ "lhr",
+ "mad",
+ "mia",
+ "nrt",
+ "ord",
+ "otp",
+ "phx",
+ "qro",
+ "scl",
+ "sjc",
+ "sea",
+ "sin",
+ "syd",
+ "waw",
+ "yul",
+ "yyz",
+] as const;
+
+export const monitorPeriodicity = [
+ "30s",
+ "1m",
+ "5m",
+ "10m",
+ "30m",
+ "1h",
+ "other",
+] as const;
+
+export const monitorRegions = [...flyRegions] as const;
+export const monitorPeriodicitySchema = z.enum(monitorPeriodicity);
+export const monitorRegionSchema = z.enum(monitorRegions);
+export const monitorFlyRegionSchema = z.enum(flyRegions);
+export type MonitorFlyRegion = z.infer<typeof monitorFlyRegionSchema>;
diff --git a/packages/db/src/schema/index.ts b/packages/db/src/schema/index.ts
index acb63d36f..759a140d1 100644
--- a/packages/db/src/schema/index.ts
+++ b/packages/db/src/schema/index.ts
@@ -2,9 +2,9 @@ export * from "./status_reports";
export * from "./integration";
export * from "./pages";
export * from "./monitors";
+export * from "./workspaces";
export * from "./users";
export * from "./page_subscribers";
-export * from "./workspaces";
export * from "./shared";
export * from "./notifications";
export * from "./monitor_status";
diff --git a/packages/db/src/schema/monitor_status/validation.ts b/packages/db/src/schema/monitor_status/validation.ts
index 5beaff5b9..a0e1605cb 100644
--- a/packages/db/src/schema/monitor_status/validation.ts
+++ b/packages/db/src/schema/monitor_status/validation.ts
@@ -1,8 +1,9 @@
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
import type { z } from "zod";
-import { monitorRegionSchema, monitorStatusSchema } from "../monitors";
+import { monitorStatusSchema } from "../monitors";
import { monitorStatusTable } from "./monitor_status";
+import { monitorRegionSchema } from "../constants";
export const selectMonitorStatusSchema = createSelectSchema(
monitorStatusTable,
diff --git a/packages/db/src/schema/monitors/constants.ts b/packages/db/src/schema/monitors/constants.ts
index 2b06c9b9f..2b05d96bd 100644
--- a/packages/db/src/schema/monitors/constants.ts
+++ b/packages/db/src/schema/monitors/constants.ts
@@ -1,52 +1,4 @@
-export const flyRegions = [
- "ams",
- "arn",
- "atl",
- "bog",
- "bom",
- "bos",
- "cdg",
- "den",
- "dfw",
- "ewr",
- "eze",
- "fra",
- "gdl",
- "gig",
- "gru",
- "hkg",
- "iad",
- "jnb",
- "lax",
- "lhr",
- "mad",
- "mia",
- "nrt",
- "ord",
- "otp",
- "phx",
- "qro",
- "scl",
- "sjc",
- "sea",
- "sin",
- "syd",
- "waw",
- "yul",
- "yyz",
-] as const;
-
-export const monitorPeriodicity = [
- "30s",
- "1m",
- "5m",
- "10m",
- "30m",
- "1h",
- "other",
-] as const;
export const monitorMethods = ["GET", "POST", "HEAD"] as const;
export const monitorStatus = ["active", "error", "degraded"] as const;
-export const monitorRegions = [...flyRegions] as const;
export const monitorJobTypes = ["website", "cron", "other"] as const;
diff --git a/packages/db/src/schema/monitors/monitor.ts b/packages/db/src/schema/monitors/monitor.ts
index 047b18652..3c2b26646 100644
--- a/packages/db/src/schema/monitors/monitor.ts
+++ b/packages/db/src/schema/monitors/monitor.ts
@@ -11,13 +11,9 @@ import { monitorTagsToMonitors } from "../monitor_tags";
import { notificationsToMonitors } from "../notifications";
import { page } from "../pages";
import { monitorsToStatusReport } from "../status_reports";
-import { workspace } from "../workspaces";
-import {
- monitorJobTypes,
- monitorMethods,
- monitorPeriodicity,
- monitorStatus,
-} from "./constants";
+import { workspace } from "../workspaces/workspace";
+import { monitorJobTypes, monitorMethods, monitorStatus } from "./constants";
+import { monitorPeriodicity } from "../constants";
export const monitor = sqliteTable("monitor", {
id: integer("id").primaryKey(),
diff --git a/packages/db/src/schema/monitors/validation.ts b/packages/db/src/schema/monitors/validation.ts
index 035841a24..59962cca6 100644
--- a/packages/db/src/schema/monitors/validation.ts
+++ b/packages/db/src/schema/monitors/validation.ts
@@ -3,22 +3,13 @@ import { z } from "zod";
import * as assertions from "@openstatus/assertions";
-import {
- flyRegions,
- monitorJobTypes,
- monitorMethods,
- monitorPeriodicity,
- monitorRegions,
- monitorStatus,
-} from "./constants";
+import { monitorJobTypes, monitorMethods, monitorStatus } from "./constants";
import { monitor, monitorsToPages } from "./monitor";
+import { monitorPeriodicitySchema, monitorRegionSchema } from "../constants";
-export const monitorPeriodicitySchema = z.enum(monitorPeriodicity);
export const monitorMethodsSchema = z.enum(monitorMethods);
export const monitorStatusSchema = z.enum(monitorStatus);
-export const monitorRegionSchema = z.enum(monitorRegions);
export const monitorJobTypesSchema = z.enum(monitorJobTypes);
-export const monitorFlyRegionSchema = z.enum(flyRegions);
// TODO: shared function
// biome-ignore lint/correctness/noUnusedVariables: <explanation>
@@ -90,5 +81,4 @@ export type MonitorStatus = z.infer<typeof monitorStatusSchema>;
export type MonitorPeriodicity = z.infer<typeof monitorPeriodicitySchema>;
export type MonitorMethod = z.infer<typeof monitorMethodsSchema>;
export type MonitorRegion = z.infer<typeof monitorRegionSchema>;
-export type MonitorFlyRegion = z.infer<typeof monitorFlyRegionSchema>;
export type MonitorJobType = z.infer<typeof monitorJobTypesSchema>;
diff --git a/packages/plans/src/config.ts b/packages/db/src/schema/plan/config.ts
similarity index 92%
rename from packages/plans/src/config.ts
rename to packages/db/src/schema/plan/config.ts
index decdebdba..b48752f10 100644
--- a/packages/plans/src/config.ts
+++ b/packages/db/src/schema/plan/config.ts
@@ -1,6 +1,5 @@
-import type { WorkspacePlan } from "@openstatus/db/src/schema";
-
-import type { Limits } from "./types";
+import type { WorkspacePlan } from "../workspaces/validation";
+import type { Limits } from "./schema";
// TODO: rename to `planConfig`
export const allPlans: Record<
@@ -17,7 +16,8 @@ export const allPlans: Record<
description: "For personal projects",
price: 0,
limits: {
- monitors: 3,
+ monitors: 1,
+ "synthetic-checks": 1000,
periodicity: ["10m", "30m", "1h"],
"multi-region": true,
"max-regions": 6,
@@ -40,9 +40,10 @@ export const allPlans: Record<
starter: {
title: "Starter",
description: "For small projects",
- price: 29,
+ price: 30,
limits: {
- monitors: 30,
+ monitors: 5,
+ "synthetic-checks": 10000,
periodicity: ["1m", "5m", "10m", "30m", "1h"],
"multi-region": true,
"max-regions": 35,
@@ -101,9 +102,10 @@ export const allPlans: Record<
team: {
title: "Growth",
description: "For small teams",
- price: 79,
+ price: 100,
limits: {
- monitors: 100,
+ monitors: 15,
+ "synthetic-checks": 50000,
periodicity: ["30s", "1m", "5m", "10m", "30m", "1h"],
"multi-region": true,
"max-regions": 35,
@@ -162,9 +164,10 @@ export const allPlans: Record<
pro: {
title: "Pro",
description: "For bigger teams",
- price: 149,
+ price: 300,
limits: {
- monitors: 500,
+ monitors: 50,
+ "synthetic-checks": 150000,
periodicity: ["30s", "1m", "5m", "10m", "30m", "1h"],
"multi-region": true,
"max-regions": 35,
diff --git a/packages/db/src/schema/plan/schema.ts b/packages/db/src/schema/plan/schema.ts
new file mode 100644
index 000000000..c1b378fa5
--- /dev/null
+++ b/packages/db/src/schema/plan/schema.ts
@@ -0,0 +1,41 @@
+import { z } from "zod";
+import { monitorFlyRegionSchema, monitorPeriodicitySchema } from "../constants";
+
+// This is not a database table but just a schema for the limits of the plan
+
+export const limitsV1 = z.object({
+ version: z.undefined(),
+ monitors: z.number(),
+ "synthetic-checks": z.number(),
+ periodicity: monitorPeriodicitySchema.array(),
+ "multi-region": z.boolean(),
+ "max-regions": z.number(),
+ "data-retention": z.enum(["14 days", "3 months", "12 months", "24 months"]),
+ // status pages
+ "status-pages": z.number(),
+ maintenance: z.boolean(),
+ "status-subscribers": z.boolean(),
+ "custom-domain": z.boolean(),
+ "password-protection": z.boolean(),
+ "white-label": z.boolean(),
+ // alerts
+ notifications: z.boolean(),
+ pagerduty: z.boolean(),
+ sms: z.boolean(),
+ "notification-channels": z.number(),
+ // collaboration
+ members: z.literal("Unlimited").or(z.number()),
+ "audit-log": z.boolean(),
+ regions: monitorFlyRegionSchema.array(),
+});
+
+const unknownLimit = z.discriminatedUnion("version", [limitsV1]);
+
+// export const limitSchema = unknownLimit.transform((val) => {
+// if (!val.version) {
+// return migrateFromV1ToV2(val);
+// }
+// return val;
+// });
+
+export type Limits = z.infer<typeof unknownLimit>;
diff --git a/packages/db/src/schema/plan/utils.ts b/packages/db/src/schema/plan/utils.ts
new file mode 100644
index 000000000..89fb20d93
--- /dev/null
+++ b/packages/db/src/schema/plan/utils.ts
@@ -0,0 +1,15 @@
+import type { Limits } from "./schema";
+import { allPlans } from "./config";
+import type { WorkspacePlan } from "../workspaces/validation";
+
+export function getLimit<T extends keyof Limits>(limits: Limits, limit: T) {
+ return limits[limit] || allPlans.free.limits[limit];
+}
+
+export function getLimits(plan: WorkspacePlan | null) {
+ return allPlans[plan || "free"].limits;
+}
+
+export function getPlanConfig(plan: WorkspacePlan | null) {
+ return allPlans[plan || "free"];
+}
diff --git a/packages/db/src/schema/shared.ts b/packages/db/src/schema/shared.ts
index 5cb511402..524a39a62 100644
--- a/packages/db/src/schema/shared.ts
+++ b/packages/db/src/schema/shared.ts
@@ -26,7 +26,7 @@ export const selectStatusReportPageSchema = selectStatusReportSchema.extend({
monitorId: z.number(),
statusReportId: z.number(),
monitor: selectPublicMonitorSchema,
- }),
+ })
)
.default([]),
});
@@ -37,7 +37,7 @@ export const selectMaintenancePageSchema = selectMaintenanceSchema.extend({
z.object({
monitorId: z.number(),
maintenanceId: z.number(),
- }),
+ })
)
.default([]),
});
@@ -56,7 +56,7 @@ export const selectPageSchemaWithMonitorsRelation = selectPageSchema.extend({
pageId: z.number(),
order: z.number().default(0).optional(),
monitor: selectMonitorSchema,
- }),
+ })
),
maintenancesToPages: selectMaintenanceSchema.array().default([]),
});
@@ -85,7 +85,7 @@ export const selectPublicStatusReportSchemaWithRelation =
monitorId: z.number(),
statusReportId: z.number(),
monitor: selectPublicMonitorSchema,
- }),
+ })
)
.default([]),
statusReportUpdates: z.array(selectStatusReportUpdateSchema),
diff --git a/packages/db/src/schema/workspaces/validation.ts b/packages/db/src/schema/workspaces/validation.ts
index 0b247ba74..ddd9e730c 100644
--- a/packages/db/src/schema/workspaces/validation.ts
+++ b/packages/db/src/schema/workspaces/validation.ts
@@ -3,11 +3,25 @@ import { z } from "zod";
import { workspacePlans, workspaceRole } from "./constants";
import { workspace } from "./workspace";
+import { limitsV1 } from "../plan/schema";
+import { allPlans } from "../plan/config";
export const workspacePlanSchema = z.enum(workspacePlans);
export const workspaceRoleSchema = z.enum(workspaceRole);
export const selectWorkspaceSchema = createSelectSchema(workspace).extend({
+ limits: z.string().transform((val) => {
+ const parsed = JSON.parse(val);
+ const result = limitsV1.safeParse(parsed);
+ if (result.error) {
+ // Fallback to default limits
+ return limitsV1.parse({
+ ...allPlans.free.limits,
+ });
+ }
+
+ return result.data;
+ }),
plan: z
.enum(workspacePlans)
.nullable()
diff --git a/packages/db/src/schema/workspaces/workspace.ts b/packages/db/src/schema/workspaces/workspace.ts
index ebcf3f834..5e25fb4d9 100644
--- a/packages/db/src/schema/workspaces/workspace.ts
+++ b/packages/db/src/schema/workspaces/workspace.ts
@@ -17,19 +17,19 @@ export const workspace = sqliteTable(
plan: text("plan", { enum: workspacePlans }),
endsAt: integer("ends_at", { mode: "timestamp" }),
paidUntil: integer("paid_until", { mode: "timestamp" }),
-
+ limits: text("limits").default("{}").notNull(),
createdAt: integer("created_at", { mode: "timestamp" }).default(
- sql`(strftime('%s', 'now'))`,
+ sql`(strftime('%s', 'now'))`
),
updatedAt: integer("updated_at", { mode: "timestamp" }).default(
- sql`(strftime('%s', 'now'))`,
+ sql`(strftime('%s', 'now'))`
),
dsn: text("dsn"), // should be removed soon
},
(t) => ({
unique: unique().on(t.id, t.dsn),
- }),
+ })
);
export const workspaceRelations = relations(workspace, ({ many }) => ({
diff --git a/packages/db/src/seed.mts b/packages/db/src/seed.mts
index 921439120..441661157 100644
--- a/packages/db/src/seed.mts
+++ b/packages/db/src/seed.mts
@@ -35,6 +35,8 @@ async function main() {
plan: "pro",
endsAt: null,
paidUntil: null,
+ limits:
+ '{"monitors":50,"synthetic-checks":150000,"periodicity":["30s","1m","5m","10m","30m","1h"],"multi-region":true,"max-regions":35,"data-retention":"24 months","status-pages":20,"maintenance":true,"status-subscribers":true,"custom-domain":true,"password-protection":true,"white-label":true,"notifications":true,"sms":true,"pagerduty":true,"notification-channels":50,"members":"Unlimited","audit-log":true,"regions":["ams","arn","atl","bog","bom","bos","cdg","den","dfw","ewr","eze","fra","gdl","gig","gru","hkg","iad","jnb","lax","lhr","mad","mia","nrt","ord","otp","phx","qro","scl","sea","sin","sjc","syd","waw","yul","yyz"]}',
},
{
id: 2,
@@ -142,7 +144,7 @@ async function main() {
.values({
id: 1,
workspaceId: 1,
- pageId:1,
+ pageId: 1,
title: "Test Status Report",
status: "investigating",
updatedAt: new Date(),
@@ -165,7 +167,7 @@ async function main() {
.values({
id: 2,
workspaceId: 1,
- pageId:1,
+ pageId: 1,
title: "Test Status Report",
status: "investigating",
updatedAt: new Date(),
diff --git a/packages/plans/package.json b/packages/plans/package.json
deleted file mode 100644
index 0df469ac8..000000000
--- a/packages/plans/package.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "name": "@openstatus/plans",
- "version": "1.0.0",
- "description": "",
- "main": "src/index.ts",
- "scripts": {},
- "dependencies": {
- "@openstatus/db": "workspace:*",
- "zod": "3.23.8"
- },
- "devDependencies": {
- "@openstatus/tsconfig": "workspace:*",
- "typescript": "5.5.2"
- },
- "keywords": [],
- "author": "",
- "license": "ISC"
-}
diff --git a/packages/plans/src/index.ts b/packages/plans/src/index.ts
deleted file mode 100644
index 5f52ac8ba..000000000
--- a/packages/plans/src/index.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-export * from "./config";
-export * from "./utils";
-export * from "./pricing-table";
-export * from "./types";
-
-export { workspacePlans as plans } from "@openstatus/db/src/schema";
-export type { WorkspacePlan } from "@openstatus/db/src/schema";
diff --git a/packages/plans/src/types.ts b/packages/plans/src/types.ts
deleted file mode 100644
index 846e78969..000000000
--- a/packages/plans/src/types.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import type {
- MonitorFlyRegion,
- MonitorPeriodicity,
-} from "@openstatus/db/src/schema";
-
-export type Limits = {
- // monitors
- monitors: number;
- periodicity: Partial<MonitorPeriodicity>[];
- "multi-region": boolean;
- "max-regions": number;
- "data-retention": string;
- // status pages
- "status-pages": number;
- maintenance: boolean;
- "status-subscribers": boolean;
- "custom-domain": boolean;
- "password-protection": boolean;
- "white-label": boolean;
- // alerts
- notifications: boolean;
- pagerduty: boolean;
- sms: boolean;
- "notification-channels": number;
- // collaboration
- members: "Unlimited" | number;
- "audit-log": boolean;
- regions: Partial<MonitorFlyRegion>[];
-};
diff --git a/packages/plans/src/utils.ts b/packages/plans/src/utils.ts
deleted file mode 100644
index 969c763fe..000000000
--- a/packages/plans/src/utils.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import type { WorkspacePlan } from "@openstatus/db/src/schema";
-
-import { allPlans } from "./index";
-import type { Limits } from "./types";
-
-// TODO: use getLimit utils function
-export function getLimit<T extends keyof Limits>(
- plan: WorkspacePlan,
- limit: T,
-) {
- return allPlans[plan].limits[limit];
-}
-
-export function getLimits(plan: WorkspacePlan | null) {
- return allPlans[plan || "free"].limits;
-}
-
-export function getPlanConfig(plan: WorkspacePlan | null) {
- return allPlans[plan || "free"];
-}
diff --git a/packages/plans/tsconfig.json b/packages/plans/tsconfig.json
deleted file mode 100644
index aed15c74a..000000000
--- a/packages/plans/tsconfig.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "extends": "@openstatus/tsconfig/base.json",
- "include": ["src", "*.ts"]
-}
diff --git a/packages/tinybird/src/os-client.ts b/packages/tinybird/src/os-client.ts
index 1e5220dcf..f6d52df48 100644
--- a/packages/tinybird/src/os-client.ts
+++ b/packages/tinybird/src/os-client.ts
@@ -1,7 +1,7 @@
import { NoopTinybird, Tinybird } from "@chronark/zod-bird";
import { z } from "zod";
-import { flyRegions } from "../../db/src/schema/monitors/constants";
+import { flyRegions } from "../../db/src/schema/constants";
import type { tbIngestWebVitalsArray } from "./validation";
import {
diff --git a/packages/tinybird/src/validation.ts b/packages/tinybird/src/validation.ts
index 4a8d3886c..482a308a0 100644
--- a/packages/tinybird/src/validation.ts
+++ b/packages/tinybird/src/validation.ts
@@ -1,6 +1,6 @@
import * as z from "zod";
-import { monitorFlyRegionSchema } from "../../db/src/schema/monitors/validation";
-import type { flyRegions } from "../../db/src/schema/monitors/constants";
+import { monitorFlyRegionSchema } from "../../db/src/schema/constants";
+import type { flyRegions } from "../../db/src/schema/constants";
export const tbIngestWebVitals = z.object({
dsn: z.string(),
diff --git a/packages/ui/package.json b/packages/ui/package.json
index 1bd67338b..f417ea397 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -38,6 +38,7 @@
"@radix-ui/react-radio-group": "1.1.3",
"@radix-ui/react-select": "2.0.0",
"@radix-ui/react-separator": "1.0.3",
+ "@radix-ui/react-slider": "1.2.0",
"@radix-ui/react-slot": "1.0.2",
"@radix-ui/react-switch": "1.0.3",
"@radix-ui/react-tabs": "1.0.4",
diff --git a/packages/ui/src/components/slider.tsx b/packages/ui/src/components/slider.tsx
new file mode 100644
index 000000000..0c6120e5e
--- /dev/null
+++ b/packages/ui/src/components/slider.tsx
@@ -0,0 +1,28 @@
+"use client";
+
+import * as React from "react";
+import * as SliderPrimitive from "@radix-ui/react-slider";
+
+import { cn } from "../lib/utils";
+
+const Slider = React.forwardRef<
+ React.ElementRef<typeof SliderPrimitive.Root>,
+ React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>
+>(({ className, ...props }, ref) => (
+ <SliderPrimitive.Root
+ ref={ref}
+ className={cn(
+ "relative flex w-full touch-none select-none items-center",
+ className
+ )}
+ {...props}
+ >
+ <SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary">
+ <SliderPrimitive.Range className="absolute h-full bg-primary" />
+ </SliderPrimitive.Track>
+ <SliderPrimitive.Thumb className="block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" />
+ </SliderPrimitive.Root>
+));
+Slider.displayName = SliderPrimitive.Root.displayName;
+
+export { Slider };
diff --git a/packages/ui/src/index.tsx b/packages/ui/src/index.tsx
index d603697b9..dcdf507f7 100644
--- a/packages/ui/src/index.tsx
+++ b/packages/ui/src/index.tsx
@@ -38,3 +38,4 @@ export * from "./components/collabsible";
export * from "./components/sonner";
export * from "./components/sortable";
export * from "./components/navigation-menu";
+export * from "./components/slider";
diff --git a/packages/utils/index.ts b/packages/utils/index.ts
index e4cde27c2..8d57718e2 100644
--- a/packages/utils/index.ts
+++ b/packages/utils/index.ts
@@ -3,7 +3,7 @@
* https://vercel.com/docs/concepts/edge-network/regions#region-list
*/
-import type { MonitorFlyRegion } from "@openstatus/db/src/schema";
+import type { MonitorFlyRegion } from "@openstatus/db/src/schema/constants";
// export const vercelRegionsDict = {
// /**
@@ -392,7 +392,7 @@ export const groupByContinent = Object.entries(flyRegionsDict).reduce<
Oceania: [],
Asia: [],
Africa: [],
- },
+ }
);
export const vercelRegions = [
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 7cdf49b5d..476114756 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -178,9 +178,6 @@ importers:
'@openstatus/notification-twillio-sms':
specifier: workspace:*
version: link:../../packages/notifications/twillio-sms
- '@openstatus/plans':
- specifier: workspace:*
- version: link:../../packages/plans
'@openstatus/tinybird':
specifier: workspace:*
version: link:../../packages/tinybird
@@ -290,9 +287,6 @@ importers:
'@openstatus/notification-slack':
specifier: workspace:*
version: link:../../packages/notifications/slack
- '@openstatus/plans':
- specifier: workspace:*
- version: link:../../packages/plans
'@openstatus/react':
specifier: workspace:*
version: link:../../packages/react
@@ -559,9 +553,6 @@ importers:
'@openstatus/error':
specifier: workspace:*
version: link:../error
- '@openstatus/plans':
- specifier: workspace:*
- version: link:../plans
'@openstatus/tinybird':
specifier: workspace:*
version: link:../tinybird
@@ -908,22 +899,6 @@ importers:
specifier: 5.5.2
version: 5.5.2
- packages/plans:
- dependencies:
- '@openstatus/db':
- specifier: workspace:*
- version: link:../db
- zod:
- specifier: 3.23.8
- version: 3.23.8
- devDependencies:
- '@openstatus/tsconfig':
- specifier: workspace:*
- version: link:../tsconfig
- typescript:
- specifier: 5.5.2
- version: 5.5.2
-
packages/react:
dependencies:
react:
@@ -1070,6 +1045,9 @@ importers:
'@radix-ui/react-separator':
specifier: 1.0.3
+ '@radix-ui/react-slider':
+ specifier: 1.2.0
'@radix-ui/react-slot':
specifier: 1.0.2
version: 1.0.2(@types/[email protected])([email protected])
@@ -3593,6 +3571,9 @@ packages:
'@radix-ui/[email protected]':
resolution: {integrity: sha512-T5gIdVO2mmPW3NNhjNgEP3cqMXjXL9UbO0BzWcXfvdBs+BohbQxvd/K5hSVKmn9/lbTdsQVKbUcP5WLCwvUbBg==}
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-V3gRzhVNU1ldS5XhAPTom1fOIo4ccrjjJgmE+LI2h/WaFpHmx0MQApT+KZHnx8abG6Avtfcz4WoEciMnpFT3HQ==}
+
'@radix-ui/[email protected]':
resolution: {integrity: sha512-yQ8oGX2GVsEYMWGxcovu1uGWPCxV5BFfeeYxqPmuAzUyLT9qmaMXSAhXpb0WrspIeqYzdJpkh2vHModJPgRIaw==}
@@ -4127,6 +4108,19 @@ packages:
'@types/react-dom':
optional: true
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-dAHCDA4/ySXROEPaRtaMV5WHL8+JB/DbtyTbJjYkY0RXmKMO2Ln8DFZhywG5/mVQ4WqHDBc8smc14yPXPqZHYA==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+
'@radix-ui/[email protected]':
resolution: {integrity: sha512-3mrKauI/tWXo1Ll+gN5dHcxDPdm/Df1ufcDLCecn+pnCIVcdWE7CujXo8QaXOWRJyZyQWWbpB8eFwHzWXlv5mQ==}
peerDependencies:
@@ -4310,6 +4304,15 @@ packages:
'@types/react':
optional: true
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-XW3/vWuIXHa+2Uwcc2ABSfcCledmXhhQPlGbfcRXbiUQI5Icjcg19BGCZVKKInYbvUCut/ufbbLLPFC5cbb1hw==}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+
'@radix-ui/[email protected]':
resolution: {integrity: sha512-D4w41yN5YRKtu464TLnByKzMDG/JlMPHtfZgQAu9v6mNakUqGUI9vUrfQKz8NK41VMm/xbZbh76NUTVtIYqOMA==}
peerDependencies:
@@ -13195,6 +13198,8 @@ snapshots:
dependencies:
'@babel/runtime': 7.23.2
+ '@radix-ui/[email protected]': {}
+
'@radix-ui/[email protected]':
dependencies:
'@babel/runtime': 7.23.2
@@ -13792,6 +13797,25 @@ snapshots:
'@types/react': 18.3.3
'@types/react-dom': 18.3.0
+ dependencies:
+ '@radix-ui/number': 1.1.0
+ '@radix-ui/primitive': 1.1.0
+ '@radix-ui/react-collection': 1.1.0(@types/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected])
+ '@radix-ui/react-compose-refs': 1.1.0(@types/[email protected])([email protected])
+ '@radix-ui/react-context': 1.1.0(@types/[email protected])([email protected])
+ '@radix-ui/react-direction': 1.1.0(@types/[email protected])([email protected])
+ '@radix-ui/react-primitive': 2.0.0(@types/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected])
+ '@radix-ui/react-use-controllable-state': 1.1.0(@types/[email protected])([email protected])
+ '@radix-ui/react-use-layout-effect': 1.1.0(@types/[email protected])([email protected])
+ '@radix-ui/react-use-previous': 1.1.0(@types/[email protected])([email protected])
+ '@radix-ui/react-use-size': 1.1.0(@types/[email protected])([email protected])
+ react: 18.3.1
+ react-dom: 18.3.1([email protected])
+ optionalDependencies:
+ '@types/react': 18.3.3
+ '@types/react-dom': 18.3.0
+
dependencies:
'@babel/runtime': 7.23.2
@@ -13964,6 +13988,13 @@ snapshots:
optionalDependencies:
'@types/react': 18.3.3
+ dependencies:
+ '@radix-ui/react-use-layout-effect': 1.1.0(@types/[email protected])([email protected])
+ react: 18.3.1
+ optionalDependencies:
+ '@types/react': 18.3.3
+
dependencies:
'@babel/runtime': 7.23.2