@integration-app/sdk
Advanced tools
Comparing version 0.1.27 to 0.1.28
@@ -8,2 +8,3 @@ import { ErrorData } from './errors'; | ||
export interface FlowNodeRun { | ||
id: string; | ||
flowId: string; | ||
@@ -10,0 +11,0 @@ flowNodeId: string; |
@@ -19,2 +19,3 @@ import { ErrorData } from './errors'; | ||
export interface FlowNode { | ||
id: string; | ||
key: string; | ||
@@ -21,0 +22,0 @@ name: string; |
@@ -0,1 +1,2 @@ | ||
import { ErrorData } from './errors'; | ||
export declare enum FlowRunState { | ||
@@ -6,1 +7,9 @@ RUNNING = "running", | ||
} | ||
export interface FlowRun { | ||
id: string; | ||
flowId: string; | ||
state: FlowRunState; | ||
startTime: Date; | ||
endTime?: Date; | ||
errorsData?: ErrorData[]; | ||
} |
import { FlowNode } from './flow-nodes'; | ||
import { JSONSchema } from './json-schema'; | ||
export interface Flow { | ||
id: string; | ||
blueprintKey?: string; | ||
@@ -13,1 +14,4 @@ endpointKey: string; | ||
} | ||
export declare function getLinkedNodes(flow: Flow, node: FlowNode): FlowNode[]; | ||
export declare function getDownstreamNodes(flow: Flow, node: FlowNode): FlowNode[]; | ||
export declare function getUpstreamNodes(flow: Flow, node: FlowNode): FlowNode[]; |
20
flows.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getUpstreamNodes = exports.getDownstreamNodes = exports.getLinkedNodes = void 0; | ||
function getLinkedNodes(flow, node) { | ||
return node.links | ||
? node.links.map((nodeLink) => getNodeByKey(flow, nodeLink.key)) | ||
: []; | ||
} | ||
exports.getLinkedNodes = getLinkedNodes; | ||
function getDownstreamNodes(flow, node) { | ||
const linkedNodes = getLinkedNodes(flow, node); | ||
return linkedNodes.concat(linkedNodes.map((n) => getLinkedNodes(flow, n)).flat()); | ||
} | ||
exports.getDownstreamNodes = getDownstreamNodes; | ||
function getUpstreamNodes(flow, node) { | ||
const upLinkedNodes = flow.nodes.filter((n) => n.links.some((l) => l.key == node.key)); | ||
return upLinkedNodes.concat(upLinkedNodes.map((n) => getUpstreamNodes(flow, n)).flat()); | ||
} | ||
exports.getUpstreamNodes = getUpstreamNodes; | ||
function getNodeByKey(flow, nodeKey) { | ||
return flow.nodes.find((n) => n.key == nodeKey); | ||
} | ||
//# sourceMappingURL=flows.js.map |
{ | ||
"name": "@integration-app/sdk", | ||
"version": "0.1.27", | ||
"version": "0.1.28", | ||
"description": "JavaScript SDK for Integration.app", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -10,2 +10,4 @@ import { ErrorData } from './errors' | ||
export interface FlowNodeRun { | ||
id: string | ||
flowId: string | ||
@@ -12,0 +14,0 @@ |
@@ -22,2 +22,4 @@ import { ErrorData } from './errors' | ||
export interface FlowNode { | ||
id: string // Backwards compatibility - will be removed soon. | ||
/** | ||
@@ -24,0 +26,0 @@ * Key that uniquely identifies this node inside a flow. |
@@ -0,1 +1,3 @@ | ||
import { ErrorData } from './errors' | ||
export enum FlowRunState { | ||
@@ -6,1 +8,15 @@ RUNNING = 'running', | ||
} | ||
export interface FlowRun { | ||
id: string | ||
flowId: string | ||
state: FlowRunState | ||
startTime: Date | ||
endTime?: Date | ||
errorsData?: ErrorData[] | ||
} |
@@ -5,2 +5,4 @@ import { FlowNode } from './flow-nodes' | ||
export interface Flow { | ||
id: string | ||
blueprintKey?: string | ||
@@ -22,1 +24,38 @@ | ||
} | ||
/** | ||
* Returns nodes of a given flow linked from the given node via `node.links` | ||
*/ | ||
export function getLinkedNodes(flow: Flow, node: FlowNode): FlowNode[] { | ||
return node.links | ||
? node.links.map((nodeLink) => getNodeByKey(flow, nodeLink.key)) | ||
: [] | ||
} | ||
/** | ||
* Return nodes that follow a given node - all the way until the end of the flow. | ||
*/ | ||
export function getDownstreamNodes(flow: Flow, node: FlowNode): FlowNode[] { | ||
const linkedNodes = getLinkedNodes(flow, node) | ||
// Recursively find linked nodes for each linked node | ||
return linkedNodes.concat( | ||
linkedNodes.map((n) => getLinkedNodes(flow, n)).flat(), | ||
) | ||
} | ||
/** | ||
* Return nodes that precede a given node - all the way to the beginning(s) of the flow. | ||
*/ | ||
export function getUpstreamNodes(flow: Flow, node: FlowNode): FlowNode[] { | ||
const upLinkedNodes = flow.nodes.filter((n) => | ||
n.links.some((l) => l.key == node.key), | ||
) | ||
// Recursively find previous nodes for each directly previous node | ||
return upLinkedNodes.concat( | ||
upLinkedNodes.map((n) => getUpstreamNodes(flow, n)).flat(), | ||
) | ||
} | ||
function getNodeByKey(flow, nodeKey): FlowNode { | ||
return flow.nodes.find((n) => n.key == nodeKey) | ||
} |
{ | ||
"compilerOptions": { | ||
"lib": [ | ||
"ES2017", | ||
"ES2019", | ||
"DOM" | ||
@@ -6,0 +6,0 @@ ], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
977526
11294