mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-12 20:39:00 +08:00
feat(webhook): add event picker
This commit is contained in:
parent
7c0b3ad098
commit
a6722d4a95
@ -317,6 +317,7 @@ export const webhookSchema = z.preprocess(
|
|||||||
url: z.string().url(),
|
url: z.string().url(),
|
||||||
headers: z.record(z.string(), z.string()).default({}),
|
headers: z.record(z.string(), z.string()).default({}),
|
||||||
metadata: z.record(z.string(), z.string()).default({}),
|
metadata: z.record(z.string(), z.string()).default({}),
|
||||||
|
events: z.array(z.enum(["completed", "failed", "page", "started"])).default(["completed", "failed", "page", "started"]),
|
||||||
})
|
})
|
||||||
.strict(strictMessage),
|
.strict(strictMessage),
|
||||||
);
|
);
|
||||||
|
@ -16,6 +16,13 @@ export const callWebhook = async (
|
|||||||
eventType: WebhookEventType = "crawl.page",
|
eventType: WebhookEventType = "crawl.page",
|
||||||
awaitWebhook: boolean = false,
|
awaitWebhook: boolean = false,
|
||||||
) => {
|
) => {
|
||||||
|
if (specified) {
|
||||||
|
let subType = eventType.split(".")[1];
|
||||||
|
if (!specified.events.includes(subType as any)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const selfHostedUrl = process.env.SELF_HOSTED_WEBHOOK_URL?.replace(
|
const selfHostedUrl = process.env.SELF_HOSTED_WEBHOOK_URL?.replace(
|
||||||
"{{JOB_ID}}",
|
"{{JOB_ID}}",
|
||||||
|
@ -168,6 +168,7 @@ export interface CrawlParams {
|
|||||||
url: string;
|
url: string;
|
||||||
headers?: Record<string, string>;
|
headers?: Record<string, string>;
|
||||||
metadata?: Record<string, string>;
|
metadata?: Record<string, string>;
|
||||||
|
events?: ["completed", "failed", "page", "started"][number][];
|
||||||
};
|
};
|
||||||
deduplicateSimilarURLs?: boolean;
|
deduplicateSimilarURLs?: boolean;
|
||||||
ignoreQueryParameters?: boolean;
|
ignoreQueryParameters?: boolean;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user