Official Plugins (Kuzzle v2.x)
Workflows v0.x
2

This plugin is part of the Kuzzle Enterprise Plan. If you are interested, please contact us.

WorkflowContent #

import { KDocumentContent } from "kuzzle";
import {
  WorkflowEventTrigger,
  WorkflowNotificationTrigger,
  WorkflowSchedulerTrigger,
} from "../triggers";
import { Action } from "../actions";
export interface WorkflowTrigger {
  type: "event" | "notification" | "scheduler";
}
export type WorkflowAnyTrigger =
  | WorkflowEventTrigger
  | WorkflowSchedulerTrigger
  | WorkflowNotificationTrigger;
export interface WorkflowContent<
  TTrigger extends WorkflowTrigger = WorkflowAnyTrigger,
> extends KDocumentContent {
  /**
    *  Workflow name
    */
  name: string;
  /**
    *  Workflow description
    */
  description: string;
  /**
    * Enable or disable a workflow
    */
  disabled?: boolean;
  /**
    * Path to extract the payload (lodash style)
    */
  payloadPath: string;
  /**
    *  Workflow trigger
    */
  trigger: TTrigger;
  /**
    * Actions to execute when the workflow is triggered
    */
  actions: Action[];
  /**
    * Lifecycle hooks
    */
  lifecycle?: {
    /**
      * Hook triggered each time the workflow is loaded.
      *
      * E.g. at startup, when the document is updated
      */
    load?: WorkflowLifecycleHook;
  };
}
export interface WorkflowLifecycleHook {
  type: "request";
  request?: {
    controller: string;
    action: string;
    [key: string]: any;
  };
}