first commit

This commit is contained in:
Matt Kane
2026-04-01 10:44:22 +01:00
commit 43fcb9a131
1789 changed files with 395041 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
/**
* Webhook Notifier Plugin for EmDash CMS
*
* Posts to external URLs when content changes occur.
*
* Features:
* - Configurable webhook URLs (admin settings)
* - Secret token for authentication (encrypted)
* - Retry logic with exponential backoff
* - Event filtering by collection and action
* - Manual trigger via API route
*
* Demonstrates:
* - network:fetch:any capability (unrestricted outbound for user-configured URLs)
* - settings.secret() for encrypted tokens
* - apiRoutes for custom endpoints
* - content:afterDelete hook
* - Hook dependencies (runs after audit-log)
* - errorPolicy: "continue" (don't block save on webhook failure)
*/
import type { PluginDescriptor } from "emdash";
export interface WebhookPayload {
event: "content:create" | "content:update" | "content:delete" | "media:upload";
timestamp: string;
collection?: string;
resourceId: string;
resourceType: "content" | "media";
data?: Record<string, unknown>;
metadata?: Record<string, unknown>;
}
/**
* Create the webhook notifier plugin descriptor
*/
export function webhookNotifierPlugin(): PluginDescriptor {
return {
id: "webhook-notifier",
version: "0.1.0",
format: "standard",
entrypoint: "@emdashcms/plugin-webhook-notifier/sandbox",
capabilities: ["network:fetch:any"],
storage: {
deliveries: { indexes: ["timestamp", "webhookUrl", "status"] },
},
adminPages: [{ path: "/settings", label: "Webhook Settings", icon: "send" }],
adminWidgets: [{ id: "status", title: "Webhooks", size: "third" }],
};
}