mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
wip: refactor watchlist triggers
This commit is contained in:
@@ -16,7 +16,7 @@ export type EventAction =
|
||||
| 'enum validation expiration'
|
||||
| string
|
||||
|
||||
export type TriggerAction = 'email' | string
|
||||
export type TriggerAction = 'email' | 'chat'
|
||||
|
||||
export interface Event {
|
||||
action: EventAction
|
||||
@@ -74,19 +74,26 @@ export interface User {
|
||||
roles: string[]
|
||||
}
|
||||
|
||||
export interface WatchlistTrigger {
|
||||
event: EventAction
|
||||
action: TriggerAction
|
||||
watchList?: string
|
||||
}
|
||||
|
||||
export interface WatchlistRequest {
|
||||
name?: string
|
||||
domains: string[]
|
||||
triggers: Array<{ event: EventAction, action: TriggerAction }>
|
||||
triggers?: Array<WatchlistTrigger>
|
||||
connector?: string
|
||||
dsn?: string[]
|
||||
}
|
||||
|
||||
export interface Watchlist {
|
||||
'@id': string
|
||||
name?: string
|
||||
token: string
|
||||
domains: Domain[]
|
||||
triggers?: Array<{ event: EventAction, action: string }>
|
||||
triggers?: Array<WatchlistTrigger>
|
||||
dsn?: string[]
|
||||
connector?: {
|
||||
id: string
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { TrackedDomains, Watchlist, WatchlistRequest} from './index'
|
||||
import type {TrackedDomains, Watchlist, WatchlistRequest, WatchlistTrigger} from './index'
|
||||
import {request} from './index'
|
||||
|
||||
interface WatchlistList {
|
||||
@@ -56,3 +56,12 @@ export async function getTrackedDomainList(params: { page: number, itemsPerPage:
|
||||
})
|
||||
return response.data
|
||||
}
|
||||
|
||||
export async function putWatchlistTrigger(watchListToken: string, watchListTrigger: WatchlistTrigger): Promise<WatchlistTrigger> {
|
||||
const response = await request<WatchlistTrigger>({
|
||||
method: 'PUT',
|
||||
url: `watchlists/${watchListToken}/triggers`,
|
||||
data: watchListTrigger,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user