UNPKG

3.89 kBTypeScriptView Raw
1import type { RawAxiosRequestHeaders } from 'axios';
2import type { GetSpaceEnvironmentParams, CollectionProp } from '../../common-types';
3import type { CreateWorkflowParams, UpdateWorkflowParams, CompleteWorkflowParams, WorkflowQueryOptions, WorkflowProps, CreateWorkflowProps, UpdateWorkflowProps, DeleteWorkflowParams } from '../../entities/workflow';
4import type { OptionalDefaults } from '../wrappers/wrap';
5export type WorkflowPlainClientAPI = {
6 /**
7 * Query Workflows with certain filters
8 * @param params entity IDs to identify the Space/Environment, optional query parameters to filter returned Workflows
9 * @returns an object containing the list of Workflows
10 * @throws if the request fails, or the Space/Environment is not found
11 * @example
12 * ```javascript
13 * const workflows = await client.workflow.getMany({
14 * spaceId: '<space_id>',
15 * environmentId: '<environment_id>',
16 * query: {
17 * limit: 10
18 * }
19 * });
20 * ```
21 */
22 getMany(params: OptionalDefaults<GetSpaceEnvironmentParams & {
23 query?: WorkflowQueryOptions;
24 }>, headers?: RawAxiosRequestHeaders): Promise<CollectionProp<WorkflowProps>>;
25 /**
26 * Start a Workflow
27 * @param params entity IDs to identify the Space/Environment
28 * @param rawData the Workflow configuration, including the entity to start the Workflow on and the Workflow Definition to use
29 * @returns the created Workflow
30 * @throws if the request fails
31 * @example
32 * ```javascript
33 * const workflow = await client.workflow.create({
34 * spaceId: '<space_id>',
35 * environmentId: '<environment_id>',
36 * }, {
37 * entity: {
38 * sys: {
39 * type: 'Link',
40 * linkType: 'Entry',
41 * id: '<entry_id>'
42 * }
43 * },
44 * workflowDefinition: {
45 * sys: {
46 * type: 'Link',
47 * linkType: 'WorkflowDefinition',
48 * id: <workflow_definition_id>
49 * }
50 * }
51 * });
52 * ```
53 */
54 create(params: OptionalDefaults<CreateWorkflowParams>, rawData: CreateWorkflowProps, headers?: RawAxiosRequestHeaders): Promise<WorkflowProps>;
55 /**
56 * Update a Workflow (i.e. move to another step)
57 * @param params entity IDs to identify the Space/Environment and Workflow
58 * @param rawData the step to move to
59 * @returns the updated Workflow
60 * @throws if the request fails
61 * @example
62 * ```javascript
63 * const workflow = await client.workflow.update({
64 * spaceId: '<space_id>',
65 * environmentId: '<environment_id>',
66 * workflowId: '<workflow_id>',
67 * }, {
68 * stepId: '<step_id>'
69 * });
70 * ```
71 */
72 update(params: OptionalDefaults<UpdateWorkflowParams>, rawData: UpdateWorkflowProps, headers?: RawAxiosRequestHeaders): Promise<WorkflowProps>;
73 /**
74 * Delete a Workflow
75 * @param params entity IDs to identify the Space/Environment and Workflow
76 * @throws if the request fails
77 * @example
78 * ```javascript
79 * await client.workflow.delete({
80 * spaceId: '<space_id>',
81 * environmentId: '<environment_id>',
82 * workflowId: '<workflow_id>',
83 * });
84 * ```
85 */
86 delete(params: OptionalDefaults<DeleteWorkflowParams>, headers?: RawAxiosRequestHeaders): Promise<void>;
87 /**
88 * Complete a Workflow, allowing a new one to be created for the same entry
89 * @param params entity IDs to identify the Space/Environment and Workflow
90 * @throws if the request fails
91 * @example
92 * ```javascript
93 * await client.workflow.complete({
94 * spaceId: '<space_id>',
95 * environmentId: '<environment_id>',
96 * workflowId: '<workflow_id>',
97 * });
98 * ```
99 */
100 complete(params: OptionalDefaults<CompleteWorkflowParams>, headers?: RawAxiosRequestHeaders): Promise<void>;
101};