Files
speckle-server/packages/server/modules/webhooks/domain/operations.ts
T
2024-09-17 10:25:03 +02:00

53 lines
1.2 KiB
TypeScript

import { Webhook, WebhookEvent } from '@/modules/webhooks/domain/types'
export type CreateWebhookConfig = (
webhook: Pick<
Webhook,
'id' | 'streamId' | 'url' | 'description' | 'secret' | 'enabled' | 'triggers'
>
) => Promise<string>
export type CountWebhooksByStreamId = ({
streamId
}: Pick<Webhook, 'streamId'>) => Promise<number>
export type GetWebhookById = ({ id }: Pick<Webhook, 'id'>) => Promise<Webhook | null>
export type UpdateWebhookConfig = ({
webhookId,
webhookInput
}: {
webhookId: string
webhookInput: Pick<Webhook, 'updatedAt'> &
Partial<
Pick<
Webhook,
'triggers' | 'streamId' | 'url' | 'enabled' | 'secret' | 'description'
>
>
}) => Promise<string>
export type DeleteWebhookConfig = ({ id }: Pick<Webhook, 'id'>) => Promise<number>
export type GetStreamWebhooks = ({
streamId
}: Pick<Webhook, 'streamId'>) => Promise<Webhook[]>
export type CreateWebhookEvent = (
event: Pick<WebhookEvent, 'id' | 'payload' | 'webhookId'>
) => Promise<string>
export type GetLastWebhookEvents = ({
webhookId,
limit
}: {
webhookId: string
limit?: number
}) => Promise<WebhookEvent[]>
export type GetWebhookEventsCount = ({
webhookId
}: {
webhookId: string
}) => Promise<number>