协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
hex-webhooks-events【开发与工程】Implement Hex webhook signature validation and event handling. Use when setting up webhook endpoints, implementing signature verification, or handling Hex event notifications securely. Trigger with phrases like "hex webhook", "hex events", "hex webhook signature", "handle hex events", "hex notifications".
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: hex-webhooks-events description: 'Implement Hex webhook signature validation and event handling.
Use when setting up webhook endpoints, implementing signature verification,
or handling Hex event notifications securely.
Trigger with phrases like "hex webhook", "hex events",
"hex webhook signature", "handle hex events", "hex notifications".
' allowed-tools: Read, Write, Edit, Bash(curl:*) version: 1.6.0 license: MIT author: Jeremy Longshore jeremy@intentsolutions.io tags:
Hex doesn't provide push webhooks. For event-driven integrations, poll run status or build your own notification system around run completions.
async function runWithCallback(
client: HexClient,
projectId: string,
params: Record<string, any>,
onComplete: (result: any) => void,
onError: (error: Error) => void
) {
try {
const { runId } = await client.runProject(projectId, params);
const poll = async () => {
const status = await client.getRunStatus(projectId, runId);
if (status.status === 'COMPLETED') { onComplete(status); return; }
if (status.status === 'ERRORED' || status.status === 'KILLED') { onError(new Error(status.status)); return; }
setTimeout(poll, 5000);
};
poll();
} catch (err) { onError(err as Error); }
}
runWithCallback(client, 'project-id', { date: '2025-01-01' },
(result) => {
// Send Slack notification, email, etc.
fetch(process.env.SLACK_WEBHOOK_URL!, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: `Hex project completed: ${result.runId}` }),
});
},
(error) => console.error('Run failed:', error)
);
Return an event receipt with type, opaque event/run ID, signature/timestamp result, idempotency outcome, queue state, canary result, and rollback reference. Exclude payload data, SQL, output, and signatures.
Reject unknown origin, stale/replayed delivery, malformed payload, unknown project destination, or non-idempotent retry. Quarantine the opaque event and disable the consumer if integrity is uncertain.
type=run.completed; event=evt-opaque-9; signature=pass; replay=absent; project=proj-sandbox-12; enqueue=once; rollback=consumer-disabled proves the event boundary.