PlatformWebhooks.mock.ts224 lines · main
| 1 | import type { |
| 2 | PlatformWebhooksMockSeed, |
| 3 | WebhookDelivery, |
| 4 | WebhookScope, |
| 5 | } from './PlatformWebhooks.types' |
| 6 | |
| 7 | const createDeliveries = ( |
| 8 | endpointId: string, |
| 9 | prefix: string, |
| 10 | deliveries: Array<Pick<WebhookDelivery, 'eventType' | 'status' | 'responseCode' | 'attemptAt'>> |
| 11 | ): WebhookDelivery[] => |
| 12 | deliveries.map((delivery, index) => ({ |
| 13 | id: `${prefix}-${index + 1}`, |
| 14 | endpointId, |
| 15 | ...delivery, |
| 16 | })) |
| 17 | |
| 18 | const organizationPrimaryDeliveries = createDeliveries( |
| 19 | '7f2c9d4a-6e31-4d9d-9a1f-2c4b5e6f7081', |
| 20 | 'org-delivery', |
| 21 | [ |
| 22 | { |
| 23 | eventType: 'project.created', |
| 24 | status: 'success', |
| 25 | responseCode: 200, |
| 26 | attemptAt: '2026-02-27T08:04:00.000Z', |
| 27 | }, |
| 28 | { |
| 29 | eventType: 'project.updated', |
| 30 | status: 'failure', |
| 31 | responseCode: 500, |
| 32 | attemptAt: '2026-02-27T07:56:00.000Z', |
| 33 | }, |
| 34 | { |
| 35 | eventType: 'project.deleted', |
| 36 | status: 'pending', |
| 37 | attemptAt: '2026-02-27T07:45:00.000Z', |
| 38 | }, |
| 39 | { |
| 40 | eventType: 'organization.member_invited', |
| 41 | status: 'success', |
| 42 | responseCode: 202, |
| 43 | attemptAt: '2026-02-27T07:37:00.000Z', |
| 44 | }, |
| 45 | { |
| 46 | eventType: 'project.resumed', |
| 47 | status: 'success', |
| 48 | responseCode: 204, |
| 49 | attemptAt: '2026-02-27T07:18:00.000Z', |
| 50 | }, |
| 51 | { |
| 52 | eventType: 'organization.member_removed', |
| 53 | status: 'failure', |
| 54 | responseCode: 400, |
| 55 | attemptAt: '2026-02-27T06:59:00.000Z', |
| 56 | }, |
| 57 | { |
| 58 | eventType: 'organization.updated', |
| 59 | status: 'skipped', |
| 60 | attemptAt: '2026-02-27T06:40:00.000Z', |
| 61 | }, |
| 62 | { |
| 63 | eventType: 'project.paused', |
| 64 | status: 'success', |
| 65 | responseCode: 200, |
| 66 | attemptAt: '2026-02-27T06:21:00.000Z', |
| 67 | }, |
| 68 | { |
| 69 | eventType: 'project.created', |
| 70 | status: 'failure', |
| 71 | responseCode: 503, |
| 72 | attemptAt: '2026-02-27T06:03:00.000Z', |
| 73 | }, |
| 74 | { |
| 75 | eventType: 'project.updated', |
| 76 | status: 'success', |
| 77 | responseCode: 200, |
| 78 | attemptAt: '2026-02-27T05:44:00.000Z', |
| 79 | }, |
| 80 | { |
| 81 | eventType: 'project.deleted', |
| 82 | status: 'skipped', |
| 83 | attemptAt: '2026-02-27T05:25:00.000Z', |
| 84 | }, |
| 85 | { |
| 86 | eventType: 'organization.member_invited', |
| 87 | status: 'success', |
| 88 | responseCode: 201, |
| 89 | attemptAt: '2026-02-27T05:07:00.000Z', |
| 90 | }, |
| 91 | ] |
| 92 | ) |
| 93 | |
| 94 | const organizationSecondaryDeliveries = createDeliveries( |
| 95 | '1a4e8c73-5b29-44af-8c62-9f1d2b3c4d5e', |
| 96 | 'org-secondary-delivery', |
| 97 | [ |
| 98 | { |
| 99 | eventType: 'organization.updated', |
| 100 | status: 'skipped', |
| 101 | attemptAt: '2026-02-26T14:12:00.000Z', |
| 102 | }, |
| 103 | ] |
| 104 | ) |
| 105 | |
| 106 | const projectDeliveries = createDeliveries( |
| 107 | '3c9b7e21-8d54-4f63-b2a1-6e7d8c9f0a12', |
| 108 | 'project-delivery', |
| 109 | [ |
| 110 | { |
| 111 | eventType: 'project.updated', |
| 112 | status: 'success', |
| 113 | responseCode: 200, |
| 114 | attemptAt: '2026-02-27T09:01:00.000Z', |
| 115 | }, |
| 116 | { |
| 117 | eventType: 'project.resource_exhausted', |
| 118 | status: 'failure', |
| 119 | responseCode: 429, |
| 120 | attemptAt: '2026-02-27T08:47:00.000Z', |
| 121 | }, |
| 122 | { |
| 123 | eventType: 'project.paused', |
| 124 | status: 'success', |
| 125 | responseCode: 202, |
| 126 | attemptAt: '2026-02-26T21:10:00.000Z', |
| 127 | }, |
| 128 | { |
| 129 | eventType: 'project.branch_created', |
| 130 | status: 'success', |
| 131 | responseCode: 200, |
| 132 | attemptAt: '2026-02-26T19:45:00.000Z', |
| 133 | }, |
| 134 | { |
| 135 | eventType: 'project.resumed', |
| 136 | status: 'pending', |
| 137 | attemptAt: '2026-02-26T18:30:00.000Z', |
| 138 | }, |
| 139 | { |
| 140 | eventType: 'project.branch_deleted', |
| 141 | status: 'success', |
| 142 | responseCode: 204, |
| 143 | attemptAt: '2026-02-26T17:04:00.000Z', |
| 144 | }, |
| 145 | { |
| 146 | eventType: 'project.updated', |
| 147 | status: 'failure', |
| 148 | responseCode: 500, |
| 149 | attemptAt: '2026-02-26T15:59:00.000Z', |
| 150 | }, |
| 151 | { |
| 152 | eventType: 'project.resource_exhausted', |
| 153 | status: 'skipped', |
| 154 | attemptAt: '2026-02-26T14:12:00.000Z', |
| 155 | }, |
| 156 | ] |
| 157 | ) |
| 158 | |
| 159 | export const PLATFORM_WEBHOOKS_MOCK_DATA: Record<WebhookScope, PlatformWebhooksMockSeed> = { |
| 160 | organization: { |
| 161 | eventTypes: [ |
| 162 | 'organization.member_invited', |
| 163 | 'organization.member_removed', |
| 164 | 'organization.updated', |
| 165 | 'project.created', |
| 166 | 'project.updated', |
| 167 | 'project.deleted', |
| 168 | 'project.paused', |
| 169 | 'project.resumed', |
| 170 | ], |
| 171 | endpoints: [ |
| 172 | { |
| 173 | id: '7f2c9d4a-6e31-4d9d-9a1f-2c4b5e6f7081', |
| 174 | name: 'Lovable production', |
| 175 | url: 'https://api.lovable.dev/webhooks/briven', |
| 176 | description: 'Primary organization webhook endpoint', |
| 177 | enabled: true, |
| 178 | eventTypes: ['project.created', 'project.updated', 'project.deleted'], |
| 179 | customHeaders: [ |
| 180 | { id: 'org-header-1', key: 'X-Lovable-Version', value: 'v2' }, |
| 181 | { id: 'org-header-2', key: 'X-Environment', value: 'production' }, |
| 182 | ], |
| 183 | createdBy: 'user@supabase.io', |
| 184 | createdAt: '2026-02-15T21:30:00.000Z', |
| 185 | }, |
| 186 | { |
| 187 | id: '1a4e8c73-5b29-44af-8c62-9f1d2b3c4d5e', |
| 188 | name: 'Slack notifications', |
| 189 | url: 'https://hooks.slack.com/services/abc1234/def5678/ghi9012', |
| 190 | description: 'Operational alerts for organization-level events', |
| 191 | enabled: false, |
| 192 | eventTypes: ['organization.updated'], |
| 193 | customHeaders: [], |
| 194 | createdBy: 'ops@supabase.io', |
| 195 | createdAt: '2026-02-12T10:14:00.000Z', |
| 196 | }, |
| 197 | ], |
| 198 | deliveries: [...organizationPrimaryDeliveries, ...organizationSecondaryDeliveries], |
| 199 | }, |
| 200 | project: { |
| 201 | eventTypes: [ |
| 202 | 'project.updated', |
| 203 | 'project.paused', |
| 204 | 'project.resumed', |
| 205 | 'project.branch_created', |
| 206 | 'project.branch_deleted', |
| 207 | 'project.resource_exhausted', |
| 208 | ], |
| 209 | endpoints: [ |
| 210 | { |
| 211 | id: '3c9b7e21-8d54-4f63-b2a1-6e7d8c9f0a12', |
| 212 | name: 'Project analytics', |
| 213 | url: 'https://analytics.example.com/hooks/briven-project', |
| 214 | description: 'Project-level status updates for analytics pipeline', |
| 215 | enabled: true, |
| 216 | eventTypes: ['project.updated', 'project.resource_exhausted'], |
| 217 | customHeaders: [{ id: 'project-header-1', key: 'X-Project-Type', value: 'platform' }], |
| 218 | createdBy: 'owner@project.dev', |
| 219 | createdAt: '2026-02-18T11:23:00.000Z', |
| 220 | }, |
| 221 | ], |
| 222 | deliveries: projectDeliveries, |
| 223 | }, |
| 224 | } |