UNPKG

4.26 kBTypeScriptView Raw
1import type { BasicMetaSysProps, DefaultElements, GetSpaceEnvironmentParams, GetWorkflowDefinitionParams, Link, MakeRequest, PaginationQueryOptions, SysLink } from '../common-types';
2type NonEmptyArray<T> = [T, ...T[]];
3export type WorkflowStepPermissionActors = 'all' | NonEmptyArray<Link<'User'> | Link<'Team'>>;
4export declare enum WorkflowStepPermissionType {
5 EntityPermission = "entity_permission",
6 WorkflowPermission = "workflow_permission"
7}
8export declare enum WorkflowStepPermissionAction {
9 Edit = "edit",
10 Publish = "publish",
11 Delete = "delete"
12}
13export declare enum WorkflowStepPermissionEffect {
14 Allow = "allow",
15 Deny = "deny"
16}
17export interface WorkflowStepPermission {
18 type: WorkflowStepPermissionType;
19 configuration: {
20 actors: WorkflowStepPermissionActors;
21 action: WorkflowStepPermissionAction;
22 effect: WorkflowStepPermissionEffect;
23 };
24}
25export declare enum WorkflowStepActionType {
26 App = "app",
27 Email = "email",
28 Task = "task"
29}
30export type WorkflowStepAction = WorkflowStepEmailAction | WorkflowStepTaskAction | WorkflowStepAppAction;
31export type WorkflowStepEmailActionRecipient = string | Link<'User'> | Link<'Team'>;
32export type WorkflowStepEmailAction = {
33 type: 'email';
34 configuration: {
35 recipients: WorkflowStepEmailActionRecipient[];
36 };
37};
38export type WorkflowStepTaskAction = {
39 type: 'task';
40 configuration: {
41 assignee: Link<'User'> | Link<'Team'>;
42 body: string;
43 dueDate?: number;
44 };
45};
46export type WorkflowStepAppAction = {
47 type: 'app';
48 appId: string;
49 appActionId: string;
50 configuration?: {
51 body?: Record<string, any>;
52 headers?: Record<string, string>;
53 };
54};
55export type WorkflowStepProps = {
56 id: string;
57 name: string;
58 description?: string;
59 actions?: WorkflowStepAction[];
60 annotations?: string[];
61 permissions?: WorkflowStepPermission[];
62};
63export type UpdateWorkflowStepProps = WorkflowStepProps;
64export type CreateWorkflowStepProps = Omit<WorkflowStepProps, 'id'>;
65export type WorkflowDefinitionSysProps = Pick<BasicMetaSysProps, 'id' | 'version' | 'createdAt' | 'createdBy' | 'updatedAt' | 'updatedBy'> & {
66 type: 'WorkflowDefinition';
67 space: SysLink;
68 environment: SysLink;
69 isLocked: boolean;
70};
71export type WorkflowDefinitionValidationLink = {
72 type: 'Link';
73 validations: Array<{
74 linkContentType: string[];
75 }>;
76 linkType: 'Entry';
77};
78export type WorkflowDefinitionProps = {
79 sys: WorkflowDefinitionSysProps;
80 name: string;
81 description?: string;
82 appliesTo?: WorkflowDefinitionValidationLink[];
83 steps: WorkflowStepProps[];
84 startOnEntityCreation?: boolean;
85 flowType?: 'no_restriction' | 'strict_neighbor';
86};
87export type CreateWorkflowDefinitionProps = Omit<WorkflowDefinitionProps, 'sys' | 'steps'> & {
88 steps: CreateWorkflowStepProps[];
89};
90export type UpdateWorkflowDefinitionProps = Omit<WorkflowDefinitionProps, 'sys' | 'steps'> & {
91 sys: Pick<WorkflowDefinitionSysProps, 'version'>;
92 steps: Array<CreateWorkflowStepProps | UpdateWorkflowStepProps>;
93};
94export type CreateWorkflowDefinitionParams = GetSpaceEnvironmentParams;
95export type UpdateWorkflowDefinitionParams = GetWorkflowDefinitionParams;
96export type DeleteWorkflowDefinitionParams = GetWorkflowDefinitionParams & {
97 version: number;
98};
99type WorkflowDefinitionApi = {
100 update(): Promise<WorkflowDefinition>;
101 delete(): Promise<void>;
102};
103export interface WorkflowDefinition extends WorkflowDefinitionProps, DefaultElements<WorkflowDefinitionProps>, WorkflowDefinitionApi {
104}
105export type WorkflowDefinitionQueryOptions = Omit<PaginationQueryOptions, 'order'>;
106/**
107 * @private
108 */
109export default function createWorkflowDefinitionApi(makeRequest: MakeRequest): WorkflowDefinitionApi;
110/**
111 * @private
112 */
113export declare function wrapWorkflowDefinition(makeRequest: MakeRequest, data: WorkflowDefinitionProps): WorkflowDefinition;
114/**
115 * @private
116 */
117export declare const wrapWorkflowDefinitionCollection: (makeRequest: MakeRequest, data: import("../common-types").CollectionProp<WorkflowDefinitionProps>) => import("../common-types").Collection<WorkflowDefinition, WorkflowDefinitionProps>;
118export {};