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