Flow Action API

Methods

execute

Runs the logic of the component.

Usage

function getFlowAction(actionId) {
  if (actionId !== "7139e63b-a05b-4eee-a6b5-87039437df2e") {
    throw new Error(`Unknown action ${actionId}`);
  }

  return {
    execute(executionContext) {
      const [nextStepUniqueName] = executionContext.step.nextStepUniqueNames;
      return {
        succeeded: true,
        nextStepUniqueName,
        outputData: { hello: "world" },
      };
    },
  };
}

Parameters

NameTypeRequiredDescription
executionContextStepExecutionContextYesAn object that contains useful information, such as its configured parameters.

Returns

StepExecutionResult

getFlowAction

A function that runs when FL0 executes one of the integration's actions.

Usage

function getFlowAction(actionId) {
  if (actionId !== "7139e63b-a05b-4eee-a6b5-87039437df2e") {
    throw new Error(`Unknown action ${actionId}`);
  }

  return {
    getPossibleOutputs: (designTimeContext) => {
      // Configure the action's outputs
    },
    execute: (executionContext) => {
      // Run the action's logic
    },
  };
}

Parameters

NameTypeRequiredDescription
actionIdGUIDYesThe ID of an action that's defined in the manifest.json file.

Returns

FlowAction

getPossibleOutputs

A function that describes the possible outputs of the component. This is what lets other components in a workflow access the component's outputs.

Usage

function getFlowAction(actionId) {
  if (actionId !== "7139e63b-a05b-4eee-a6b5-87039437df2e") {
    throw new Error(`Unknown action ${actionId}`);
  }

  return {
    getPossibleOutputs(designTimeContext) {
      return [
        {
          name: "Result",
          description: "Result of sending message",
          path: "result",
          type: {
            name: "object",
            objectProperties: {
              result: { name: "string" },
            },
          },
        },
      ];
    },
  };
}

Parameters

NameTypeRequiredDescription
designTimeContextStepDesignTimeContextYesAn object that contains information for identifying the possible outputs, such as the step's parameters.

Returns

StepValueDescriptor[]

http.get

Sends a GET request to a URL.

Signature

get(url: string, options?: HttpOptions): HttpResponse

Usage

const response = http.get("...");
console.log(response);

Properties

NameTypeRequiredDescription
urlstringYesThe URL to send the request to.
optionsHttpOptionsNoOptions for configuring the request.

Returns

HttpResponse

http.post

Sends a POST request to a URL.

Signature

post(url: string, options?: HttpOptions): HttpResponse

Usage

const response = http.post("...");
console.log(response);

Properties

NameTypeRequiredDescription
urlstringYesThe URL to send the request to.
optionsHttpOptionsNoOptions for configuring the request.

Returns

HttpResponse

Types

FlowAction

The return value of the getFlowAction method.

Signature

type FlowAction = {
  getPossibleOutputs(
    designTimeContext: StepDesignTimeContext
  ): StepValueDescriptor[];
  execute(executionContext: StepExecutionContext): StepExecutionResult;
};

Properties

NameTypeRequiredDescription
getPossibleOutputsgetPossibleOutputs]YesTo learn more, see getPossibleOutputs.
executeexecute]YesTo learn more, see execute.

Http

Signature

type Http = {
  get(url: string, options?: HttpOptions): HttpResponse;
  post(url: string, options?: HttpOptions): HttpResponse;
};

Properties

NameTypeRequiredDescription
getfunctionYesSends a GET request to a URL.
postfunctionYesSends a POST request to a URL.

ScopedLogger

An object that contains methods for logging messages.

Signature

type ScopedLogger = {
  info(message: string): void;
  warn(message: string): void;
  error(message: string): void;
};

Properties

NameTypeRequiredDescription
info(message: string) => voidYesA function for logging a message with a severity level of info.
warn(message: string) => voidYesA function for logging a message with a severity level of warn.
error(message: string) => voidYesA function for logging a message with a severity level of error.

Step

Represents an individual step in a workflow.

Signature

type Step = {
  uniqueName: string;
  nextStepUniqueNames: string[];
  actionId: string;
  parameters: StepParameter[];
};

Properties

NameTypeRequiredDescription
uniqueNamestringYesThe user-configurable name of the step.
nextStepUniqueNamesstring[]YesThe user-configurable names of the steps that come after the current step.
actionIdstringYesThe GUID of the step's action.
parametersStepParameter[]YesThe step's user-configurable parameters.

StepDesignTimeContext

Signature

type StepDesignTimeContext = {
  parameters: StepDesignTimeParameter[];
  step: Step;
  appConfigs: object;
  workspaceId: string;
};

Properties

NameTypeRequiredDescription
parametersStepDesignTimeParameter[]Yes
stepStepYes
appConfigsobjectYes
workspaceIdstringYes

StepDesignTimeParameter

Signature

type StepDesignTimeParameter = {
  key: string;
  value: string;
  type: StepValueType;
};

Properties

NameTypeRequiredDescription
keystringYes
valuestringYes
typeStepValueTypeYes

StepExecutionContext

An object that's passed into an action's execute function. It contains data that the action needs to run, such as the action's parameters.

Signature

type StepExecutionContext = {
  executionId: string;
  parameters: { [key: string]: any };
  step: Step;
  appConfigs: object;
  logger: ScopedLogger;
  workspaceId: string;
};

Properties

NameTypeRequiredDescription
executionIdstringYesA unique ID for the current execution of the step.
parametersobjectYesThe user-configurable values of the step's parameters.
stepStepYesAdditional information about the step, such as the complete list of parameters.
appConfigsobjectYes???
loggerScopedLoggerYesFunctions for logging messages.
workspaceIdstringYesThe ID of the workspace that the step exists within.

StepExecutionResult

Describes the result of a step's execution. This object must be returned by the execute method. It identifies if the action executed successfully and, if necessary, returns any data output by the action.

Signature

type StepExecutionResult = {
  succeeded: boolean;
  nextStepUniqueName: string;
  outputData: any;
};

Properties

NameTypeRequiredDescription
succeededbooleanYesIf true, the action executed successfully.
nextStepUniqueNamestringYesThe user-configurable name of the next step in the workflow.
outputDataanyYesThe data that's output by the component. This should match what's returned by the getPossibleOutputs function.

StepParameter

Signature

type StepParameter = {
  key: string;
  expression: string;
};

Properties

NameTypeRequiredDescription
keystringYes
expressionstringYes

StepValueDescriptor

Describes a possible output of an action. An array of these objects must be returned by the getPossibleOutputs function.

Signature

type StepValueDescriptor = {
  name: string;
  description: string;
  path: string;
  type: StepValueType;
};

Properties

NameTypeRequiredDescription
namestringYesThe name of the output. This appears in FL0s' UI.
descriptionstringYesA description of the output. This appears in FL0s' UI.
pathstringYes???
typeStepValueTypeYes???

StepValueType

Signature

type StepValueType = {
  name: string;
  objectProperties?: { [key: string]: StepValueType };
  arrayItemType?: StepValueType;
};

Properties

NameTypeRequiredDescription
namestringYes
objectPropertiesRecord<string, StepValueType>No
arrayItemTypeStepValueTypeNo

ValidationResult

Describes the result of an installation's validation.

Signature

type ValidationResult = {
  isValid: boolean;
  errorMessage: string | null;
};

Properties

NameTypeRequiredDescription
isValidbooleanYesIf true, the installation is valid.
errorMessagestring | nullYesAn error message to show when the installation is not valid.