import { type Task, useAsyncTask } from "vue-concurrency" import { API } from "@/api" import type { Alerts, AlertSearchParams, ArtifactWithTags, Config, CreateRule, IPInfo, Rule, Rules, RuleSearchParams, UpdateRule } from "@/types" export function generateGetAlertsTask(): Task { return useAsyncTask(async (_signal, params) => { return await API.getAlerts(params) }) } export function generateDeleteAlertTask(): Task { return useAsyncTask(async (_signal, id) => { return await API.deleteAlert(id) }) } export function generateGetTagsTask(): Task { return useAsyncTask(async () => { return await API.getTags() }) } export function generateDeleteTagTask(): Task { return useAsyncTask(async (_signal, tag) => { return await API.deleteTag(tag) }) } export function generateGetRuleSetTask(): Task { return useAsyncTask(async () => { return await API.getRuleSet() }) } export function generateGetArtifactTask(): Task { return useAsyncTask(async (_signal, id) => { return await API.getArtifact(id) }) } export function generateDeleteArtifactTask(): Task { return useAsyncTask(async (_signal, id) => { return await API.deleteArtifact(id) }) } export function generateEnrichArtifactTask(): Task { return useAsyncTask(async (_signal, id) => { return await API.enrichArtifact(id) }) } export function generateGetConfigsTask(): Task { return useAsyncTask(async () => { return await API.getConfigs() }) } export function generateGetIPTask(): Task { return useAsyncTask(async (_signal, ipAddress: string) => { return await API.getIPInfo(ipAddress) }) } export function generateGetRulesTask(): Task { return useAsyncTask(async (_signal, params: RuleSearchParams) => { return await API.getRules(params) }) } export function generateGetRuleTask(): Task { return useAsyncTask(async (_signal, id: string) => { return await API.getRule(id) }) } export function generateDeleteRuleTask(): Task { return useAsyncTask(async (_signal, id: string) => { return await API.deleteRule(id) }) } export function generateRunRuleTask(): Task { return useAsyncTask(async (_signal, id) => { return await API.runRule(id) }) } export function generateCreateRuleTask(): Task { return useAsyncTask(async (_signal, payload) => { return await API.createRule(payload) }) } export function generateUpdateRuleTask(): Task { return useAsyncTask(async (_signal, payload) => { return await API.updateRule(payload) }) }