UNPKG

2.42 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 delete(): Promise<void>;
33 complete(): Promise<void>;
34};
35type OrderQueryParam = 'sys.updatedAt' | '-sys.updatedAt' | 'sys.createdAt' | '-sys.createdAt';
36export interface Workflow extends WorkflowProps, DefaultElements<WorkflowProps>, WorkflowApi {
37}
38export type WorkflowQueryOptions = Omit<PaginationQueryOptions, 'order'> & {
39 'stepId[in]'?: string;
40 /** Find workflows filtered by the Entity type (Entry) */
41 'sys.entity.sys.linkType'?: string;
42 /** Find workflows containing the specified, comma-separated entities. Requires `sys.entity.sys.linkType` */
43 'sys.entity.sys.id[in]'?: string;
44 'sys.workflowDefinition.sys.id'?: string;
45 /**
46 * Order workflows by
47 * @default -sys.createdAt
48 * */
49 order?: OrderQueryParam;
50};
51/**
52 * @private
53 */
54export default function createWorkflowApi(makeRequest: MakeRequest): WorkflowApi;
55/**
56 * @private
57 */
58export declare function wrapWorkflow(makeRequest: MakeRequest, data: WorkflowProps): Workflow;
59/**
60 * @private
61 */
62export declare const wrapWorkflowCollection: (makeRequest: MakeRequest, data: import("../common-types").CollectionProp<WorkflowProps>) => import("../common-types").Collection<Workflow, WorkflowProps>;
63export {};