Two reviewer agents did a second-pass deep audit of the 21-commit refactor. Eight findings; four fixed here (one was deferred with a schema comment, three were 🟡 nice-to-haves left for follow-up). Integration regressions (🟠 high): - Outbound webhook `interest.berth_linked` now fires from the new junction-add handler. Was emitting a socket-only event, leaving external integrations silent post-refactor. - Two new webhook events `interest.berth_unlinked` and `interest.berth_link_updated` added to WEBHOOK_EVENTS + INTERNAL_TO_WEBHOOK_MAP. PATCH and DELETE handlers now dispatch them alongside the existing socket emits — lifecycle parity restored. - BerthInterestPulse adds useRealtimeInvalidation for berth-link events. The query key was berth-scoped while the linked-berths dialog invalidates interest-scoped keys (no prefix match), so the pulse went stale. Bridges via the realtime hook now. Recommender semantic fix (🟠 medium-high): - aggregates CTE: active_interest_count now filters on `ib.is_specific_interest = true`, matching the public-map "Under Offer" derivation. EOI-bundle-only links no longer demote a berth to Tier C for other reps. Smoke test confirms previously-all-Tier-C results now correctly classify as Tier A. - Same CTE: `total_interest_count` uses COUNT(ib.berth_id) instead of COUNT(*) so a berth with no junction rows reports 0 (not 1 from the LEFT JOIN's NULL-right-side row). Prevents heat over-counting. Data integrity (🟠): - AcroForm tier rejects negative numerics in coerceFieldValue (was letting through `length_ft="-50"` which would poison the recommender feasibility filter on apply). - FilesystemBackend.resolveHmacSecret throws in production when storage_proxy_hmac_secret_encrypted is null. Dev still derives from BETTER_AUTH_SECRET for ergonomics; prod must explicitly configure. - Documented the circular FK between berths.current_pdf_version_id and berth_pdf_versions.id. Drizzle's `.references()` can't express the cycle so the schema column is plain text + a comment; the FK is authoritatively maintained by migration 0030. Tests still 1163/1163. tsc clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
86 lines
3.1 KiB
TypeScript
86 lines
3.1 KiB
TypeScript
// ─── Webhook Event Map ────────────────────────────────────────────────────────
|
|
// Defines the canonical set of outbound webhook event names and provides a
|
|
// translation map from internal camelCase socket events to dot-style webhook
|
|
// event names.
|
|
|
|
export const WEBHOOK_EVENTS = [
|
|
'client.created',
|
|
'client.updated',
|
|
'client.archived',
|
|
'client.merged',
|
|
'interest.created',
|
|
'interest.stage_changed',
|
|
'interest.berth_linked',
|
|
'interest.berth_unlinked',
|
|
'interest.berth_link_updated',
|
|
'berth.status_changed',
|
|
'berth.updated',
|
|
'document.sent',
|
|
'document.signed',
|
|
'document.completed',
|
|
'document.expired',
|
|
'expense.created',
|
|
'expense.updated',
|
|
'invoice.created',
|
|
'invoice.sent',
|
|
'invoice.paid',
|
|
'invoice.overdue',
|
|
'registration.new',
|
|
'yacht.created',
|
|
'yacht.updated',
|
|
'yacht.ownership_transferred',
|
|
'yacht.archived',
|
|
'company.created',
|
|
'company.updated',
|
|
'company.archived',
|
|
'company_membership.added',
|
|
'company_membership.updated',
|
|
'company_membership.ended',
|
|
'berth_reservation.created',
|
|
'berth_reservation.activated',
|
|
'berth_reservation.ended',
|
|
'berth_reservation.cancelled',
|
|
] as const;
|
|
|
|
export type WebhookEvent = (typeof WEBHOOK_EVENTS)[number];
|
|
|
|
/** Maps internal socket event names to outbound webhook event names. */
|
|
export const INTERNAL_TO_WEBHOOK_MAP: Record<string, WebhookEvent> = {
|
|
'client:created': 'client.created',
|
|
'client:updated': 'client.updated',
|
|
'client:archived': 'client.archived',
|
|
'client:merged': 'client.merged',
|
|
'interest:created': 'interest.created',
|
|
'interest:stageChanged': 'interest.stage_changed',
|
|
'interest:berthLinked': 'interest.berth_linked',
|
|
'interest:berthUnlinked': 'interest.berth_unlinked',
|
|
'interest:berthLinkUpdated': 'interest.berth_link_updated',
|
|
'berth:statusChanged': 'berth.status_changed',
|
|
'berth:updated': 'berth.updated',
|
|
'document:sent': 'document.sent',
|
|
'document:signed': 'document.signed',
|
|
'document:completed': 'document.completed',
|
|
'document:expired': 'document.expired',
|
|
'expense:created': 'expense.created',
|
|
'expense:updated': 'expense.updated',
|
|
'invoice:created': 'invoice.created',
|
|
'invoice:sent': 'invoice.sent',
|
|
'invoice:paid': 'invoice.paid',
|
|
'invoice:overdue': 'invoice.overdue',
|
|
'registration:new': 'registration.new',
|
|
'yacht:created': 'yacht.created',
|
|
'yacht:updated': 'yacht.updated',
|
|
'yacht:ownership_transferred': 'yacht.ownership_transferred',
|
|
'yacht:archived': 'yacht.archived',
|
|
'company:created': 'company.created',
|
|
'company:updated': 'company.updated',
|
|
'company:archived': 'company.archived',
|
|
'company_membership:added': 'company_membership.added',
|
|
'company_membership:updated': 'company_membership.updated',
|
|
'company_membership:ended': 'company_membership.ended',
|
|
'berth_reservation:created': 'berth_reservation.created',
|
|
'berth_reservation:activated': 'berth_reservation.activated',
|
|
'berth_reservation:ended': 'berth_reservation.ended',
|
|
'berth_reservation:cancelled': 'berth_reservation.cancelled',
|
|
};
|