Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

1.1 KB
Raw Blame
import type { WebhookScopeParams } from './platform-webhooks-fetchers'

const scopeId = (scope: WebhookScopeParams) =>
  scope.scope === 'organization' ? scope.orgSlug : scope.projectRef

export const platformWebhooksKeys = {
  endpoints: (scope: WebhookScopeParams, limit?: number, offset?: number) =>
    ['platform-webhooks', scope.scope, scopeId(scope), 'endpoints', { limit, offset }] as const,
  endpoint: (scope: WebhookScopeParams, id: string | undefined) =>
    ['platform-webhooks', scope.scope, scopeId(scope), 'endpoints', id] as const,
  deliveries: (
    scope: WebhookScopeParams,
    endpointId: string | undefined,
    size?: number,
    after?: string,
    before?: string
  ) =>
    [
      'platform-webhooks',
      scope.scope,
      scopeId(scope),
      'endpoints',
      endpointId,
      'deliveries',
      { size, after, before },
    ] as const,
  delivery: (scope: WebhookScopeParams, endpointId: string | undefined, id: string | undefined) =>
    [
      'platform-webhooks',
      scope.scope,
      scopeId(scope),
      'endpoints',
      endpointId,
      'deliveries',
      id,
    ] as const,
}