insomnia-plugin-response
Advanced tools
Comparing version 1.0.19 to 1.0.20
41
index.js
@@ -51,5 +51,27 @@ const jq = require('jsonpath'); | ||
}, | ||
{ | ||
displayName: 'Trigger Behavior', | ||
help: 'Configure when to resend the dependent request', | ||
type: 'enum', | ||
options: [ | ||
{ | ||
displayName: 'Never', | ||
description: 'never resend request', | ||
value: 'never', | ||
}, | ||
{ | ||
displayName: 'No History', | ||
description: 'resend when no responses present', | ||
value: 'no-history', | ||
}, | ||
{ | ||
displayName: 'Always', | ||
description: 'resend request when needed', | ||
value: 'always', | ||
}, | ||
], | ||
}, | ||
], | ||
async run(context, field, id, filter) { | ||
async run(context, field, id, filter, resendBehavior) { | ||
filter = filter || ''; | ||
@@ -70,4 +92,19 @@ | ||
const response = await context.util.models.response.getLatestForRequestId(id); | ||
let response = await context.util.models.response.getLatestForRequestId(id); | ||
let shouldResend = false; | ||
if (resendBehavior === 'ALWAYS') { | ||
shouldResend = true; | ||
} else if (resendBehavior === 'NO_HISTORY' && !response) { | ||
shouldResend = true; | ||
} else if (resendBehavior === 'NEVER') { | ||
shouldResend = false; | ||
} | ||
// Resend dependent request if needed but only if we're rendering for a send | ||
if (shouldResend && (!response || context.renderPurpose === 'send')) { | ||
console.log('[response tag] Resending dependency'); | ||
response = await context.network.sendRequest(request); | ||
} | ||
if (!response) { | ||
@@ -74,0 +111,0 @@ throw new Error('No responses for request'); |
{ | ||
"name": "insomnia-plugin-response", | ||
"version": "1.0.19", | ||
"version": "1.0.20", | ||
"author": "Gregory Schier <gschier1990@gmail.com>", | ||
@@ -20,6 +20,6 @@ "description": "Insomnia response template tag", | ||
"iconv-lite": "^0.4.19", | ||
"insomnia-xpath": "^1.0.12", | ||
"insomnia-xpath": "^1.0.13", | ||
"jsonpath": "^1.0.0" | ||
}, | ||
"gitHead": "74d5de69a1365dccd86a668aa815d1e7c4187dd2" | ||
"gitHead": "0d333b008bba19422618c8e85808def1678b5d9b" | ||
} |
20600
569
Updatedinsomnia-xpath@^1.0.13