@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_.
60 lines (47 loc) • 2.2 kB
text/typescript
import { isArray } from '@prefecthq/prefect-design'
import { AutomationAction, isAutomationAction } from '@/automations/types/actions'
import { isRecord } from '@/utilities/object'
export type CreateEventAutomationQuery = {
from: 'event',
event: { id: string, occurred: Date },
}
export function isCreateEventAutomationQuery(value: unknown): value is CreateEventAutomationQuery {
return isRecord(value) && 'from' in value && value.from === 'event'
}
export type CreateFlowAutomationQuery = {
from: 'flow',
flowId: string,
}
export function isCreateFlowAutomationQuery(value: unknown): value is CreateFlowAutomationQuery {
return isRecord(value) && 'from' in value && value.from === 'flow'
}
export type CreateWorkPoolAutomationQuery = {
from: 'workPool',
workPoolId: string,
}
export function isCreateWorkPoolAutomationQuery(value: unknown): value is CreateWorkPoolAutomationQuery {
return isRecord(value) && 'from' in value && value.from === 'workPool'
}
export type CreateWorkPoolQueueAutomationQuery = {
from: 'workPoolQueue',
workPoolQueueId: string,
}
export function isCreateWorkPoolQueueAutomationQuery(value: unknown): value is CreateWorkPoolQueueAutomationQuery {
return isRecord(value) && 'from' in value && value.from === 'workPoolQueue'
}
export type CreateAutomationTriggerQuery =
| CreateEventAutomationQuery
| CreateFlowAutomationQuery
| CreateWorkPoolAutomationQuery
| CreateWorkPoolQueueAutomationQuery
export function isCreateAutomationTriggerQuery(value: unknown): value is CreateAutomationTriggerQuery {
return isCreateEventAutomationQuery(value) || isCreateFlowAutomationQuery(value) || isCreateWorkPoolAutomationQuery(value) || isCreateWorkPoolQueueAutomationQuery(value)
}
export type CreateAutomationActionQuery = { actions: AutomationAction[] }
export function isCreateAutomationActionQuery(value: unknown): value is CreateAutomationActionQuery {
return isRecord(value) && 'actions' in value && isArray(value.actions) && value.actions.every(isAutomationAction)
}
export type CreateAutomationQuery =
| CreateAutomationTriggerQuery
| CreateAutomationActionQuery
| CreateAutomationTriggerQuery & CreateAutomationActionQuery