Fixed turnstile
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
import type { BasePayload, Field } from 'payload';
|
||||
/**
|
||||
* Health of a third-party integration (Turnstile today, SMTP/Graph later),
|
||||
* stored on the SiteIntegrations global so the panel can show it:
|
||||
* - a banner on the integration's tab (IntegrationStatusBanner),
|
||||
* - an alert on the admin dashboard (IntegrationAlerts).
|
||||
*
|
||||
* Written by the server when it USES the integration (e.g. verifying a form
|
||||
* token) — no polling, no cron. Writes are throttled: only on a state change, or
|
||||
* at most every REFRESH_MS while an error persists, so a broken integration on a
|
||||
* busy form doesn't turn every submission into a DB write.
|
||||
*/
|
||||
export type IntegrationState = 'degraded' | 'ok';
|
||||
export type IntegrationStatus = {
|
||||
/** Last time the integration was used (refreshed at most every REFRESH_MS). */
|
||||
checkedAt?: null | string;
|
||||
/** Machine code from the provider or the plugin, e.g. 'invalid-input-secret', 'missing-secret'. */
|
||||
code?: null | string;
|
||||
/** Human explanation shown in the panel (English — panel language). */
|
||||
message?: null | string;
|
||||
/** When the current state started. */
|
||||
since?: null | string;
|
||||
state?: IntegrationState | null;
|
||||
};
|
||||
/** Hidden group field holding the status — add next to the integration's fields. */
|
||||
export declare function buildIntegrationStatusField(name: string): Field;
|
||||
/** Read-only banner (UI field) — shows the status group `statusField` on the tab. */
|
||||
export declare function buildIntegrationStatusBanner(statusField: string, label: string): Field;
|
||||
/**
|
||||
* Persist a status change. Never throws — a status write must not break the
|
||||
* request that triggered it.
|
||||
*/
|
||||
export declare function recordIntegrationStatus(payload: BasePayload, field: string, previous: IntegrationStatus | null | undefined, next: {
|
||||
code?: string;
|
||||
message?: string;
|
||||
state: IntegrationState;
|
||||
}): Promise<void>;
|
||||
Reference in New Issue
Block a user