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 #

Copied to clipboard!
import { JSONObject } from 'kuzzle';
import { Action } from './Action';
import { LifecycleHook } from './LifecycleHook';
/**
  * Trigger of type event plugged to the Internal Event System
  *
  * @example
  *
{
  type: 'event',
  event: 'document:afterCreate',
  filters: {
    equals: { 'result._source.type': 'container' }
  },
}
  *
  */
export type WorkflowTriggerEvent = {
  /**
    * Trigger type
    */
  type: 'event';
  /**
    * Filters to match with the extracted payload.
    *
    * @see https://docs.kuzzle.io/core/2/api/koncorde-filters-syntax
    */
  filters: JSONObject;
  /**
    * Trigger this workflow when the specified event is triggered.
    */
  event: string;
};
/**
  * Trigger of type notification plugged to the Realtime Engine.
  *
  * @example
  *
{
  type: 'notification',
  collection: 'assets',
  filters: {
    equals: { 'result._source.type': 'container' }
  },
  scope: 'all'
}
  *
  */
export type WorkflowTriggerNotification = {
  /**
    * Trigger type
    */
  type: 'notification';
  /**
    * Collection to filter
    */
  collection: string;
  /**
    * Filters for the Realtime Engine
    *
    * @see https://docs.kuzzle.io/core/2/api/koncorde-filters-syntax
    */
  filters: JSONObject;
  /**
    * Specify whether you want to receive trigger the workflow on documents
    * entering or leaving the scope only.
    *
    * Default: `in`
    */
  scope?: 'all' | 'in' | 'out';
};
export type WorkflowContent = {
  /**
    *  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: WorkflowTriggerEvent | WorkflowTriggerNotification | { type: string };
  /**
    * 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?: LifecycleHook;
  };
  /**
    * Kuzzle metadata
    * @todo use DocumentMetadata when it's not an interface anymore
    */
  _kuzzle_info?: {
    author?: string,
    createdAt?: number,
    updater?: string | null,
    updatedAt?: number | null
  };
};