UNPKG

2.45 kBTypeScriptView Raw
1import type { BasicMetaSysProps, DefaultElements, GetSpaceEnvironmentParams, GetWorkflowParams, Link, MakeRequest, PaginationQueryOptions, SysLink } from '../common-types';
2export type WorkflowSysProps = Pick<BasicMetaSysProps, 'id' | 'version' | 'createdAt' | 'createdBy' | 'updatedAt' | 'updatedBy'> & {
3 type: 'Workflow';
4 space: SysLink;
5 environment: SysLink;
6 completedBy?: SysLink;
7 completedAt?: string;
8 deletedBy?: SysLink;
9 deletedAt?: string;
10 entity: Link<'Entry'>;
11 workflowDefinition: Link<'WorkflowDefinition'>;
12};
13export type WorkflowProps = {
14 sys: WorkflowSysProps;
15 stepId?: string;
16};
17export type CreateWorkflowProps = Omit<WorkflowProps, 'sys'> & {
18 entity: Link<'Entry'>;
19 workflowDefinition: Link<'WorkflowDefinition'>;
20};
21export type UpdateWorkflowProps = Omit<WorkflowProps, 'sys'> & {
22 sys: Pick<WorkflowSysProps, 'version'>;
23};
24export type CreateWorkflowParams = GetSpaceEnvironmentParams;
25export type UpdateWorkflowParams = GetWorkflowParams;
26export type DeleteWorkflowParams = GetWorkflowParams & {
27 version: number;
28};
29export type CompleteWorkflowParams = DeleteWorkflowParams;
30type WorkflowApi = {
31 update(): Promise<Workflow>;
32 get(): Promise<Workflow>;
33 delete(): Promise<void>;
34 complete(): Promise<void>;
35};
36type OrderQueryParam = 'sys.updatedAt' | '-sys.updatedAt' | 'sys.createdAt' | '-sys.createdAt';
37export interface Workflow extends WorkflowProps, DefaultElements<WorkflowProps>, WorkflowApi {
38}
39export type WorkflowQueryOptions = Omit<PaginationQueryOptions, 'order'> & {
40 'stepId[in]'?: string;
41 /** Find workflows filtered by the Entity type (Entry) */
42 'sys.entity.sys.linkType'?: string;
43 /** Find workflows containing the specified, comma-separated entities. Requires `sys.entity.sys.linkType` */
44 'sys.entity.sys.id[in]'?: string;
45 'sys.workflowDefinition.sys.id'?: string;
46 /**
47 * Order workflows by
48 * @default -sys.createdAt
49 * */
50 order?: OrderQueryParam;
51};
52/**
53 * @private
54 */
55export default function createWorkflowApi(makeRequest: MakeRequest): WorkflowApi;
56/**
57 * @private
58 */
59export declare function wrapWorkflow(makeRequest: MakeRequest, data: WorkflowProps): Workflow;
60/**
61 * @private
62 */
63export declare const wrapWorkflowCollection: (makeRequest: MakeRequest, data: import("../common-types").CollectionProp<WorkflowProps>) => import("../common-types").Collection<Workflow, WorkflowProps>;
64export {};