@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_.
76 lines (61 loc) • 2.41 kB
text/typescript
import { AutomationTriggerCompoundRequire } from '@/automations/types/automationTriggerCompound'
import { isRecord } from '@/utilities/object'
import { createTuple } from '@/utilities/tuples'
export type AutomationTriggerEventResourceLabel =
| 'prefect.resource.id'
| 'prefect.resource.role'
| 'prefect.resource.name'
| 'prefect-cloud.incident.severity'
export type AutomationTriggerEventResource =
| 'prefect.deployment'
| 'prefect.flow-run'
| 'prefect.flow'
| 'prefect.tag'
| 'prefect.work-pool'
| 'prefect.work-queue'
| 'prefect-cloud.incident'
export type AutomationTriggerEventResourceRole =
| 'flow'
| 'tag'
| 'work-queue'
| 'work-pool'
export type EventResourceValue = string | string[] | undefined
export type AutomationTriggerMatch = Partial<Record<AutomationTriggerEventResourceLabel, EventResourceValue>>
export const { values: automationTriggerEventPosture, isValue: isAutomationTriggerEventPosture } = createTuple([
'Reactive',
'Proactive',
])
export const DEFAULT_EVENT_TRIGGER_WITHIN = 0
export type AutomationTriggerEventPosture = typeof automationTriggerEventPosture[number]
export type AutomationTriggerEventResponse = {
type: 'event',
match?: AutomationTriggerMatch,
match_related?: AutomationTriggerMatch,
after?: string[],
expect?: string[],
for_each?: string[],
posture: AutomationTriggerEventPosture,
threshold: number,
within?: number,
}
export function isAutomationTriggerEventResponse(value: unknown): value is AutomationTriggerEventResponse {
return isRecord(value) && value.type === 'event' && isAutomationTriggerEventPosture(value.posture)
}
export type AutomationTriggerCompoundResponse = {
type: 'compound',
triggers: AutomationTriggerResponse[],
within: number,
require: AutomationTriggerCompoundRequire,
}
export function isAutomationTriggerCompoundResponse(value: AutomationTriggerResponse): value is AutomationTriggerCompoundResponse {
return value.type === 'compound'
}
export type AutomationTriggerSequenceResponse = {
type: 'sequence',
triggers: AutomationTriggerResponse[],
within: number,
}
export function isAutomationTriggerSequenceResponse(value: AutomationTriggerResponse): value is AutomationTriggerSequenceResponse {
return value.type === 'sequence'
}
export type AutomationTriggerResponse = AutomationTriggerEventResponse | AutomationTriggerCompoundResponse | AutomationTriggerSequenceResponse