2023-03-01 20:43:22 +00:00
|
|
|
export interface WebhookFields {
|
|
|
|
url: string;
|
|
|
|
eventTypes: Array<"add"|"update">;
|
|
|
|
tableId: string;
|
|
|
|
enabled?: boolean;
|
|
|
|
isReadyColumn?: string|null;
|
2023-05-08 22:06:24 +00:00
|
|
|
name?: string;
|
|
|
|
memo?: string;
|
2023-03-01 20:43:22 +00:00
|
|
|
}
|
|
|
|
|
2023-05-08 22:06:24 +00:00
|
|
|
// Union discriminated by type
|
|
|
|
export type WebhookBatchStatus = 'success'|'failure'|'rejected';
|
|
|
|
export type WebhookStatus = 'idle'|'sending'|'retrying'|'postponed'|'error'|'invalid';
|
|
|
|
|
|
|
|
|
2023-03-01 20:43:22 +00:00
|
|
|
// WebhookSubscribe should be `Omit<WebhookFields, 'tableId'>` (because subscribe endpoint read
|
|
|
|
// tableId from the url) but generics are not yet supported by ts-interface-builder
|
|
|
|
export interface WebhookSubscribe {
|
|
|
|
url: string;
|
|
|
|
eventTypes: Array<"add"|"update">;
|
|
|
|
enabled?: boolean;
|
|
|
|
isReadyColumn?: string|null;
|
2023-05-08 22:06:24 +00:00
|
|
|
name?: string;
|
|
|
|
memo?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface WebhookSummary {
|
|
|
|
id: string;
|
|
|
|
fields: {
|
|
|
|
url: string;
|
|
|
|
unsubscribeKey: string;
|
|
|
|
eventTypes: string[];
|
|
|
|
isReadyColumn: string|null;
|
|
|
|
tableId: string;
|
|
|
|
enabled: boolean;
|
|
|
|
name: string;
|
|
|
|
memo: string;
|
|
|
|
},
|
|
|
|
usage: WebhookUsage|null,
|
2023-03-01 20:43:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Describes fields to update a webhook
|
|
|
|
export interface WebhookUpdate {
|
|
|
|
id: string;
|
|
|
|
fields: WebhookPatch;
|
|
|
|
}
|
|
|
|
|
|
|
|
// WebhookPatch should be `Partial<WebhookFields>` but generics are not yet supported by
|
|
|
|
// ts-interface-builder
|
|
|
|
export interface WebhookPatch {
|
|
|
|
url?: string;
|
|
|
|
eventTypes?: Array<"add"|"update">;
|
|
|
|
tableId?: string;
|
|
|
|
enabled?: boolean;
|
|
|
|
isReadyColumn?: string|null;
|
2023-05-08 22:06:24 +00:00
|
|
|
name?: string;
|
|
|
|
memo?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export interface WebhookUsage {
|
|
|
|
// As minimum we need number of waiting events and status (by default pending).
|
|
|
|
numWaiting: number,
|
|
|
|
status: WebhookStatus;
|
|
|
|
updatedTime?: number|null;
|
|
|
|
lastSuccessTime?: number|null;
|
|
|
|
lastFailureTime?: number|null;
|
|
|
|
lastErrorMessage?: string|null;
|
|
|
|
lastHttpStatus?: number|null;
|
|
|
|
lastEventBatch?: null | {
|
|
|
|
size: number;
|
|
|
|
errorMessage: string|null;
|
|
|
|
httpStatus: number|null;
|
|
|
|
status: WebhookBatchStatus;
|
|
|
|
attempts: number;
|
|
|
|
},
|
|
|
|
numSuccess?: {
|
|
|
|
pastHour: number;
|
|
|
|
past24Hours: number;
|
|
|
|
},
|
2023-03-01 20:43:22 +00:00
|
|
|
}
|