Doohickey Types

Doohickey Types is an NPM package that is available to help you build out your templates.

Getting Started

If you generated your integration project with doohickey init, Doohickey Types has already been installed and is ready for you to begin using it within your templates. Otherwise, follow these instructions to install it:

  1. If you haven't already, create a package.json by running the command npm init -y . This creates a package.json file with default values for all the fields.
  2. Once your package.json is created, install Doohickey Types as a dev dependency by running the command npm i -D @blendededge/doohickey-types .
  3. Require the doohickey-types package in your template file and it is ready to use.

OIH Flows

The OIHFlow object helps you scaffold out your flow and contains both the required and optional properties for generating the flow in OIH.

Here is an example of initializing a flow using the OIHFlow object within a Doohickey template.

Copy
Copied
  const { OIHFlow } = require('@blendededge/doohickey-types');

  module.exports = function ({ components, tenant }) {
      const myTestFlow = OIHFlow;
      myTestFlow.name = 'Sample Test Flow using Doohickey Types';
      myTestFlow.description = 'Just a sample test flow';
      myTestFlow.tenant = tenant.id;
  }

OIH Components

Doohickey Types comes preloaded with all of the Doohickey standard components. You can find a list of these components here.

Similar to the OIHFlow object, the individual component objects will contain all of the required and optional properites for that component, including any component-specific configuration fields.

Here is an example of initalizing a flow step using the JSONataComponent object, a Doohickey CLI aliased JSONata component named jsonata, and the DOOHICKEY.file.formatJSONata method to read the JSONata file rather than having to input it directly to the template.

Copy
Copied
  const { JSONataComponent } = require('@blendededge/doohickey-types');

  module.exports = function ({ components, tenant }) {
    const transformSalesOrder = JSONataComponent.transform({
        name: 'Transform SalesOrder',
        id: 'transform-sales-order',
        componentId: components.jsonata,
        description: 'Transforms a JSON object to Sales Order',
        fields: {
            expression: DOOHICKEY.file.formatJSONata('jsonata/transform-sales-order.jsonata')
        }
    });
  }

Adding a Component to a Flow Object

After you have a flow step created, you can add it to your OIHFlow object. Here is an example of adding the transformSalesOrder component we created previously to our myTestFlow graph.

Copy
Copied
  const { JSONataComponent, OIHFlow } = require('@blendededge/doohickey-types');

  module.exports = function ({ components, tenant }) {
    const myTestFlow = OIHFlow;
    myTestFlow.name = 'Sample Test Flow using Doohickey Types';
    myTestFlow.description = 'Just a sample test flow';
    myTestFlow.tenant = tenant.id;

    const transformSalesOrder = JSONataComponent.transform({
        name: 'Transform SalesOrder',
        id: 'transform-sales-order',
        componentId: components.jsonata,
        description: 'Transforms a JSON object to Sales Order',
        fields: {
            expression: DOOHICKEY.file.formatJSONata('jsonata/transform-sales-order.jsonata')
        }
    });

    myTestFlow.graph.nodes.push(transformSalesOrder)
  }

Adding Graph Edges to a Flow Object

Once a component has been added to the graph.nodes property, you can create an edge to link it to another component, connecting them in the data flow.

Here is an example of linking a JSONata component to a Webhook debug step.

Copy
Copied
  const { JSONataComponent, CodeComponent, OIHFlow } = require('@blendededge/doohickey-types');

  module.exports = function ({ components, tenant }) {
    const myTestFlow = OIHFlow;
    myTestFlow.name = 'Sample Test Flow using Doohickey Types';
    myTestFlow.description = 'Just a sample test flow';
    myTestFlow.tenant = tenant.id;

    const transformSalesOrder = JSONataComponent.transform({
        // removed for brevity
    });

    const sendDebugMessage = CodeComponent.execute({
        // removed for brevity
    })

    myTestFlow.graph.nodes.push(transformSalesOrder, sendDebugMessage);
    myTestFlow.graph.edges.push(
        transformSalesOrder.edge(sendDebugMessage)
    )
  }