@prefecthq/prefect-ui-library
Version:
This library is the Vue and Typescript component library for [Prefect 2](https://github.com/PrefectHQ/prefect) and [Prefect Cloud 2](https://www.prefect.io/cloud/). _The components and utilities in this project are not meant to be used independently_.
57 lines (49 loc) • 1.95 kB
text/typescript
import { AutomationTriggerEvent } from '@/automations/types/automationTriggerEvent'
import { DeploymentStatusTrigger } from '@/automations/types/deploymentStatusTrigger'
import { FlowRunStateTrigger } from '@/automations/types/flowRunStateTrigger'
import { AutomationTrigger } from '@/automations/types/triggers'
import { AutomationTriggerTemplate } from '@/automations/types/triggerTemplates'
import { WorkPoolStatusTrigger } from '@/automations/types/workPoolStatusTrigger'
import { WorkQueueStatusTrigger } from '@/automations/types/workQueueStatusTrigger'
import { mapper } from '@/services'
export function getDefaultAutomationTriggerValue(template: AutomationTriggerTemplate): AutomationTrigger {
return defaultAutomationTriggerValues[template]
}
const defaultAutomationTriggerValues = {
'deployment-status': mapper.map('DeploymentStatusTrigger', {
deployments: [],
posture: 'Reactive',
status: 'not_ready',
time: 30,
} satisfies DeploymentStatusTrigger, 'AutomationTrigger'),
'flow-run-state': mapper.map('FlowRunStateTrigger', {
posture: 'Reactive',
flowIds: [],
tags: [],
states: [],
time: 30,
} satisfies FlowRunStateTrigger, 'AutomationTrigger'),
'work-pool-status': mapper.map('WorkPoolStatusTrigger', {
workPools: [],
posture: 'Reactive',
status: 'not_ready',
time: 30,
} satisfies WorkPoolStatusTrigger, 'AutomationTrigger'),
'work-queue-status': mapper.map('WorkQueueStatusTrigger', {
workPools: [],
workQueues: [],
status: 'not_ready',
posture: 'Reactive',
time: 30,
} satisfies WorkQueueStatusTrigger, 'AutomationTrigger'),
'custom': new AutomationTriggerEvent({
posture: 'Reactive',
match: {
'prefect.resource.id': ['prefect.flow-run.*'],
},
forEach: [],
expect: ['prefect.flow-run.Failed'],
threshold: 5,
within: 60,
}),
} satisfies Record<AutomationTriggerTemplate | 'custom', AutomationTrigger>