UNPKG

contentful-management

Version:
119 lines (118 loc) 4.26 kB
import type { BasicMetaSysProps, DefaultElements, GetSpaceEnvironmentParams, GetWorkflowDefinitionParams, Link, MakeRequest, PaginationQueryOptions, SysLink } from '../common-types'; type NonEmptyArray<T> = [T, ...T[]]; export type WorkflowStepPermissionActors = 'all' | NonEmptyArray<Link<'User'> | Link<'Team'>>; export declare enum WorkflowStepPermissionType { EntityPermission = "entity_permission", WorkflowPermission = "workflow_permission" } export declare enum WorkflowStepPermissionAction { Edit = "edit", Publish = "publish", Delete = "delete" } export declare enum WorkflowStepPermissionEffect { Allow = "allow", Deny = "deny" } export interface WorkflowStepPermission { type: WorkflowStepPermissionType; configuration: { actors: WorkflowStepPermissionActors; action: WorkflowStepPermissionAction; effect: WorkflowStepPermissionEffect; }; } export declare enum WorkflowStepActionType { App = "app", Email = "email", Task = "task" } export type WorkflowStepAction = WorkflowStepEmailAction | WorkflowStepTaskAction | WorkflowStepAppAction; export type WorkflowStepEmailActionRecipient = string | Link<'User'> | Link<'Team'>; export type WorkflowStepEmailAction = { type: 'email'; configuration: { recipients: WorkflowStepEmailActionRecipient[]; }; }; export type WorkflowStepTaskAction = { type: 'task'; configuration: { assignee: Link<'User'> | Link<'Team'>; body: string; dueDate?: number; }; }; export type WorkflowStepAppAction = { type: 'app'; appId: string; appActionId: string; configuration?: { body?: Record<string, any>; headers?: Record<string, string>; }; }; export type WorkflowStepProps = { id: string; name: string; description?: string; actions?: WorkflowStepAction[]; annotations?: string[]; permissions?: WorkflowStepPermission[]; }; export type UpdateWorkflowStepProps = WorkflowStepProps; export type CreateWorkflowStepProps = Omit<WorkflowStepProps, 'id'>; export type WorkflowDefinitionSysProps = Pick<BasicMetaSysProps, 'id' | 'version' | 'createdAt' | 'createdBy' | 'updatedAt' | 'updatedBy'> & { type: 'WorkflowDefinition'; space: SysLink; environment: SysLink; isLocked: boolean; }; export type WorkflowDefinitionValidationLink = { type: 'Link'; validations: Array<{ linkContentType: string[]; }>; linkType: 'Entry'; }; export type WorkflowDefinitionProps = { sys: WorkflowDefinitionSysProps; name: string; description?: string; appliesTo?: WorkflowDefinitionValidationLink[]; steps: WorkflowStepProps[]; startOnEntityCreation?: boolean; flowType?: 'no_restriction' | 'strict_neighbor'; }; export type CreateWorkflowDefinitionProps = Omit<WorkflowDefinitionProps, 'sys' | 'steps'> & { steps: CreateWorkflowStepProps[]; }; export type UpdateWorkflowDefinitionProps = Omit<WorkflowDefinitionProps, 'sys' | 'steps'> & { sys: Pick<WorkflowDefinitionSysProps, 'version'>; steps: Array<CreateWorkflowStepProps | UpdateWorkflowStepProps>; }; export type CreateWorkflowDefinitionParams = GetSpaceEnvironmentParams; export type UpdateWorkflowDefinitionParams = GetWorkflowDefinitionParams; export type DeleteWorkflowDefinitionParams = GetWorkflowDefinitionParams & { version: number; }; type WorkflowDefinitionApi = { update(): Promise<WorkflowDefinition>; delete(): Promise<void>; }; export interface WorkflowDefinition extends WorkflowDefinitionProps, DefaultElements<WorkflowDefinitionProps>, WorkflowDefinitionApi { } export type WorkflowDefinitionQueryOptions = Omit<PaginationQueryOptions, 'order'>; /** * @private */ export default function createWorkflowDefinitionApi(makeRequest: MakeRequest): WorkflowDefinitionApi; /** * @private */ export declare function wrapWorkflowDefinition(makeRequest: MakeRequest, data: WorkflowDefinitionProps): WorkflowDefinition; /** * @private */ export declare const wrapWorkflowDefinitionCollection: (makeRequest: MakeRequest, data: import("../common-types").CollectionProp<WorkflowDefinitionProps>) => import("../common-types").Collection<WorkflowDefinition, WorkflowDefinitionProps>; export {};