@blendededge/doohickey-types
v0.3.0
Published
Doohickey Component Types are an NPM package that is available to help you build out your Doohickey integration templates. Using the Doohickey Types package, you get out-of-the-box autocomplete for component properties. No more looking up the documentati
Downloads
671
Readme
Doohickey Component Types
Doohickey Component Types are an NPM package that is available to help you build out your Doohickey integration templates. Using the Doohickey Types package, you get out-of-the-box autocomplete for component properties. No more looking up the documentation for each component and finding what options are available. You can just start typing and Intellisense will start making suggestions.
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:
- If you haven't already, create a
package.json
by running the commandnpm init -y
. This creates apackage.json
file with default values for all the fields. - Once your
package.json
is created, install Doohickey Types as a dev dependency by running the commandnpm i -D @blendededge/doohickey-types
. - 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.
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.
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.
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.
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)
)
}