Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(api/monitor): accept origin field in create/update body

firecrawl-spring[bot]4d2f303eef34
diff --git a/apps/api/src/__tests__/snips/v2/lib.ts b/apps/api/src/__tests__/snips/v2/lib.ts
index f647bfc6e..581bde158 100644
--- a/apps/api/src/__tests__/snips/v2/lib.ts
+++ b/apps/api/src/__tests__/snips/v2/lib.ts
@@ -115,6 +115,9 @@ export type MonitorCreateInput = {
}
>;
retentionDays?: number;
+ goal?: string;
+ judgeEnabled?: boolean;
+ origin?: string;
};
export async function monitorCreateRaw(
diff --git a/apps/api/src/__tests__/snips/v2/monitor.test.ts b/apps/api/src/__tests__/snips/v2/monitor.test.ts
index caba1621c..12f82c1cd 100644
--- a/apps/api/src/__tests__/snips/v2/monitor.test.ts
+++ b/apps/api/src/__tests__/snips/v2/monitor.test.ts
@@ -68,6 +68,49 @@ describeIf(ALLOW_TEST_SUITE_WEBSITE && !TEST_SELF_HOST)("/v2/monitor", () => {
expect(del.body.success).toBe(true);
});
+ it("accepts an origin field in the create body", async () => {
+ const create = await monitorCreateRaw(
+ {
+ name: "origin monitor",
+ schedule: { cron: "*/30 * * * *", timezone: "UTC" },
+ targets: [
+ {
+ type: "scrape",
+ urls: [createTestIdUrl()],
+ },
+ ],
+ origin: "[email protected]",
+ },
+ identity,
+ );
+
+ expect(create.statusCode).toBe(200);
+ expect(create.body.success).toBe(true);
+ const id = create.body.data.id;
+ await monitorDeleteRaw(id, identity);
+ });
+
+ it("still rejects unknown keys in the create body", async () => {
+ const create = await monitorCreateRaw(
+ {
+ name: "unknown key monitor",
+ schedule: { cron: "*/30 * * * *", timezone: "UTC" },
+ targets: [
+ {
+ type: "scrape",
+ urls: [createTestIdUrl()],
+ },
+ ],
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ nonsenseField: "value",
+ } as any,
+ identity,
+ );
+
+ expect(create.statusCode).toBe(400);
+ expect(create.body.success).toBe(false);
+ });
+
it("rejects cron schedules under 15 minutes", async () => {
const response = await monitorCreateRaw(
{
diff --git a/apps/api/src/services/monitoring/types.ts b/apps/api/src/services/monitoring/types.ts
index 149de20a1..79258566e 100644
--- a/apps/api/src/services/monitoring/types.ts
+++ b/apps/api/src/services/monitoring/types.ts
@@ -116,6 +116,7 @@ const createMonitorBaseSchema = z.strictObject({
retentionDays: z.number().int().positive().max(365).optional().default(30),
goal: z.string().max(2000).nullish(),
judgeEnabled: z.boolean().optional(),
+ origin: z.string().optional().prefault("api"),
});
export const createMonitorSchema = createMonitorBaseSchema.transform(