mirror of
https://github.com/supabase/supabase.git
synced 2026-09-07 02:20:52 +08:00
## What kind of change does this PR introduce?
Impending feature addition. Resolves DEPR-340.
## What is the current behavior?
We don’t have any platform webhook support.
## What is the new behavior?
This puts the scaffolding for platform webhooks **behind a feature
flag**. The content is currently UI-only (with mock data and a
[temporary tracking
file](8adadc61f5/apps/studio/components/interfaces/Platform/Webhooks/DEPR-340-backend-integration-tracker.md)).
Merging this in lets us work incrementally from here on.
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import type { WebhookScope } from './PlatformWebhooks.types'
|
|
|
|
export const shouldHandleEndpointNotFound = ({
|
|
endpointId,
|
|
hasSelectedEndpoint,
|
|
pendingCreatedEndpointId,
|
|
}: {
|
|
endpointId?: string
|
|
hasSelectedEndpoint: boolean
|
|
pendingCreatedEndpointId: string | null
|
|
}) => {
|
|
if (!endpointId) return false
|
|
if (hasSelectedEndpoint) return false
|
|
return endpointId !== pendingCreatedEndpointId
|
|
}
|
|
|
|
interface PendingSigningSecretReveal {
|
|
endpointId: string
|
|
signingSecret: string
|
|
}
|
|
|
|
const pendingSigningSecretRevealByScope: Partial<Record<WebhookScope, PendingSigningSecretReveal>> =
|
|
{}
|
|
|
|
export const setPendingSigningSecretReveal = (
|
|
scope: WebhookScope,
|
|
value: PendingSigningSecretReveal
|
|
) => {
|
|
pendingSigningSecretRevealByScope[scope] = value
|
|
}
|
|
|
|
export const getPendingSigningSecretReveal = (scope: WebhookScope, endpointId?: string) => {
|
|
const pending = pendingSigningSecretRevealByScope[scope]
|
|
if (!pending) return null
|
|
if (endpointId && pending.endpointId !== endpointId) return null
|
|
return pending
|
|
}
|
|
|
|
export const clearPendingSigningSecretReveal = (scope: WebhookScope) => {
|
|
delete pendingSigningSecretRevealByScope[scope]
|
|
}
|
|
|
|
export const resetPendingSigningSecretRevealForTests = () => {
|
|
for (const key of Object.keys(pendingSigningSecretRevealByScope) as WebhookScope[]) {
|
|
delete pendingSigningSecretRevealByScope[key]
|
|
}
|
|
}
|