@integration-app/sdk
Advanced tools
Comparing version 0.1.36 to 0.1.37
@@ -131,3 +131,2 @@ "use strict"; | ||
const fetchFlowNodeRuns = async () => this.get(`flow-node-runs?filter[flowRunId]=${flowRunId}`); | ||
const fetchFlowNodeRun = async (flowNodeRunId) => this.get(`flow-node-runs/${flowNodeRunId}`); | ||
function updateFlowRun(nextFlowRun) { | ||
@@ -158,14 +157,4 @@ flowRun = { ...flowRun, ...nextFlowRun }; | ||
} | ||
async function completeFlowRunNodes() { | ||
if (!(flowRun === null || flowRun === void 0 ? void 0 : flowRun.nodeRuns)) { | ||
const latestNodeRuns = await fetchFlowNodeRuns(); | ||
updateFlowNodeRuns(latestNodeRuns); | ||
} | ||
const flowNodeRunFetches = flowRun.nodeRuns.map((nodeRun) => { | ||
return (nodeRun === null || nodeRun === void 0 ? void 0 : nodeRun.state) === FlowNodeRunState.COMPLETED | ||
? nodeRun | ||
: fetchFlowNodeRun(nodeRun.id); | ||
}); | ||
const flowNodeRuns = await Promise.all(flowNodeRunFetches); | ||
updateFlowNodeRuns(flowNodeRuns); | ||
async function fetchFinalState() { | ||
updateFlowNodeRuns(await fetchFlowNodeRuns()); | ||
} | ||
@@ -190,3 +179,3 @@ return new Promise((resolve, reject) => { | ||
async function onSuccess() { | ||
await completeFlowRunNodes(); | ||
await fetchFinalState(); | ||
options.onSuccess && options.onSuccess(flowRun); | ||
@@ -197,3 +186,3 @@ resolve(flowRun); | ||
async function onFailure() { | ||
await completeFlowRunNodes(); | ||
await fetchFinalState(); | ||
options.onFailure && options.onFailure(flowRun); | ||
@@ -200,0 +189,0 @@ reject(flowRun); |
{ | ||
"name": "@integration-app/sdk", | ||
"version": "0.1.36", | ||
"version": "0.1.37", | ||
"description": "JavaScript SDK for Integration.app", | ||
@@ -42,3 +42,4 @@ "main": "index.js", | ||
"penpal": "^5.3.0", | ||
"pusher-js": "^7.0.3" | ||
"pusher-js": "^7.0.3", | ||
"tslib": "^2.3.1" | ||
}, | ||
@@ -45,0 +46,0 @@ "jest": { |
@@ -186,4 +186,2 @@ import Pusher, { Channel } from 'pusher-js' | ||
this.get(`flow-node-runs?filter[flowRunId]=${flowRunId}`) | ||
const fetchFlowNodeRun = async (flowNodeRunId: string) => | ||
this.get(`flow-node-runs/${flowNodeRunId}`) | ||
@@ -218,16 +216,4 @@ function updateFlowRun(nextFlowRun: FlowRun) { | ||
async function completeFlowRunNodes() { | ||
if (!flowRun?.nodeRuns) { | ||
const latestNodeRuns = await fetchFlowNodeRuns() | ||
updateFlowNodeRuns(latestNodeRuns) | ||
} | ||
const flowNodeRunFetches = flowRun.nodeRuns.map((nodeRun) => { | ||
return nodeRun?.state === FlowNodeRunState.COMPLETED | ||
? nodeRun | ||
: fetchFlowNodeRun(nodeRun.id) | ||
}) | ||
const flowNodeRuns = await Promise.all(flowNodeRunFetches) | ||
updateFlowNodeRuns(flowNodeRuns) | ||
async function fetchFinalState() { | ||
updateFlowNodeRuns(await fetchFlowNodeRuns()) | ||
} | ||
@@ -256,3 +242,3 @@ | ||
async function onSuccess() { | ||
await completeFlowRunNodes() | ||
await fetchFinalState() | ||
options.onSuccess && options.onSuccess(flowRun) | ||
@@ -264,3 +250,3 @@ resolve(flowRun) | ||
async function onFailure() { | ||
await completeFlowRunNodes() | ||
await fetchFinalState() | ||
options.onFailure && options.onFailure(flowRun) | ||
@@ -267,0 +253,0 @@ reject(flowRun) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1002605
6
11823
+ Addedtslib@^2.3.1
+ Addedtslib@2.8.1(transitive)