From 5ba11ca78819885fc41123f18c7fff3d10c29fb5 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Thu, 22 Aug 2024 11:27:57 -0700 Subject: [PATCH] Bump plugin deps --- plugins/exporter-curl/package-lock.json | 8 +++---- plugins/exporter-curl/package.json | 2 +- plugins/filter-jsonpath/package-lock.json | 8 +++---- plugins/filter-jsonpath/package.json | 2 +- plugins/filter-xpath/package-lock.json | 8 +++---- plugins/filter-xpath/package.json | 2 +- plugins/importer-curl/package-lock.json | 8 +++---- plugins/importer-curl/package.json | 2 +- plugins/importer-insomnia/package-lock.json | 8 +++---- plugins/importer-insomnia/package.json | 2 +- plugins/importer-openapi/package-lock.json | 8 +++---- plugins/importer-openapi/package.json | 2 +- plugins/importer-postman/package-lock.json | 8 +++---- plugins/importer-postman/package.json | 2 +- plugins/importer-yaak/package-lock.json | 8 +++---- plugins/importer-yaak/package.json | 2 +- .../package-lock.json | 8 +++---- .../template-function-response/package.json | 2 +- .../template-function-response/src/index.ts | 23 ++++++++++++++----- scripts/build-plugins.cjs | 8 +++---- 20 files changed, 66 insertions(+), 55 deletions(-) diff --git a/plugins/exporter-curl/package-lock.json b/plugins/exporter-curl/package-lock.json index 5a3b0fd8..673b3e0f 100644 --- a/plugins/exporter-curl/package-lock.json +++ b/plugins/exporter-curl/package-lock.json @@ -8,7 +8,7 @@ "name": "exporter-curl", "version": "0.0.1", "dependencies": { - "@yaakapp/api": "^0.1.9" + "@yaakapp/api": "^0.1.11" }, "devDependencies": { "@types/node": "^20.14.9", @@ -701,9 +701,9 @@ } }, "node_modules/@yaakapp/api": { - "version": "0.1.9", - "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.9.tgz", - "integrity": "sha512-5mgBoNplXUnNIUpLgGPCjcf6p/BcsU485cH3/MnIzcXIaMfFpZVVwHq5vf9cm+NDcr5hwYmPyIbwmBf9uVoV2Q==", + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.11.tgz", + "integrity": "sha512-dRZAXrQpftWygy9nJXiIYPzLA9om6reO/RiEacMe9RKqMjNG6FRF8cGmj7BcdyreizJOkH/DmcOpxn09kDD0XA==", "dependencies": { "@types/node": "^22.0.0" } diff --git a/plugins/exporter-curl/package.json b/plugins/exporter-curl/package.json index ed951740..b4c5f94b 100644 --- a/plugins/exporter-curl/package.json +++ b/plugins/exporter-curl/package.json @@ -11,6 +11,6 @@ "vitest": "^1.4.0" }, "dependencies": { - "@yaakapp/api": "^0.1.9" + "@yaakapp/api": "^0.1.11" } } diff --git a/plugins/filter-jsonpath/package-lock.json b/plugins/filter-jsonpath/package-lock.json index 8dffe40d..5de50098 100644 --- a/plugins/filter-jsonpath/package-lock.json +++ b/plugins/filter-jsonpath/package-lock.json @@ -8,7 +8,7 @@ "name": "filter-jsonpath", "version": "0.0.1", "dependencies": { - "@yaakapp/api": "^0.1.9", + "@yaakapp/api": "^0.1.11", "jsonpath-plus": "^9.0.0" }, "devDependencies": { @@ -48,9 +48,9 @@ } }, "node_modules/@yaakapp/api": { - "version": "0.1.9", - "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.9.tgz", - "integrity": "sha512-5mgBoNplXUnNIUpLgGPCjcf6p/BcsU485cH3/MnIzcXIaMfFpZVVwHq5vf9cm+NDcr5hwYmPyIbwmBf9uVoV2Q==", + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.11.tgz", + "integrity": "sha512-dRZAXrQpftWygy9nJXiIYPzLA9om6reO/RiEacMe9RKqMjNG6FRF8cGmj7BcdyreizJOkH/DmcOpxn09kDD0XA==", "dependencies": { "@types/node": "^22.0.0" } diff --git a/plugins/filter-jsonpath/package.json b/plugins/filter-jsonpath/package.json index cafa1603..fe6d9d9d 100644 --- a/plugins/filter-jsonpath/package.json +++ b/plugins/filter-jsonpath/package.json @@ -7,7 +7,7 @@ }, "dependencies": { "jsonpath-plus": "^9.0.0", - "@yaakapp/api": "^0.1.9" + "@yaakapp/api": "^0.1.11" }, "devDependencies": { "@types/node": "^20.14.9", diff --git a/plugins/filter-xpath/package-lock.json b/plugins/filter-xpath/package-lock.json index 03503ec5..64394d48 100644 --- a/plugins/filter-xpath/package-lock.json +++ b/plugins/filter-xpath/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.1", "dependencies": { "@xmldom/xmldom": "^0.8.10", - "@yaakapp/api": "^0.1.9", + "@yaakapp/api": "^0.1.11", "xpath": "^0.0.34" }, "devDependencies": { @@ -35,9 +35,9 @@ } }, "node_modules/@yaakapp/api": { - "version": "0.1.9", - "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.9.tgz", - "integrity": "sha512-5mgBoNplXUnNIUpLgGPCjcf6p/BcsU485cH3/MnIzcXIaMfFpZVVwHq5vf9cm+NDcr5hwYmPyIbwmBf9uVoV2Q==", + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.11.tgz", + "integrity": "sha512-dRZAXrQpftWygy9nJXiIYPzLA9om6reO/RiEacMe9RKqMjNG6FRF8cGmj7BcdyreizJOkH/DmcOpxn09kDD0XA==", "dependencies": { "@types/node": "^22.0.0" } diff --git a/plugins/filter-xpath/package.json b/plugins/filter-xpath/package.json index 34cb22bc..c9dc6e00 100644 --- a/plugins/filter-xpath/package.json +++ b/plugins/filter-xpath/package.json @@ -6,7 +6,7 @@ "build": "yaakcli ./src/index.js" }, "dependencies": { - "@yaakapp/api": "^0.1.9", + "@yaakapp/api": "^0.1.11", "@xmldom/xmldom": "^0.8.10", "xpath": "^0.0.34" }, diff --git a/plugins/importer-curl/package-lock.json b/plugins/importer-curl/package-lock.json index 82298cd8..9be007cd 100644 --- a/plugins/importer-curl/package-lock.json +++ b/plugins/importer-curl/package-lock.json @@ -8,7 +8,7 @@ "name": "importer-curl", "version": "0.0.1", "dependencies": { - "@yaakapp/api": "^0.1.9", + "@yaakapp/api": "^0.1.11", "shell-quote": "^1.8.1" }, "devDependencies": { @@ -709,9 +709,9 @@ } }, "node_modules/@yaakapp/api": { - "version": "0.1.9", - "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.9.tgz", - "integrity": "sha512-5mgBoNplXUnNIUpLgGPCjcf6p/BcsU485cH3/MnIzcXIaMfFpZVVwHq5vf9cm+NDcr5hwYmPyIbwmBf9uVoV2Q==", + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.11.tgz", + "integrity": "sha512-dRZAXrQpftWygy9nJXiIYPzLA9om6reO/RiEacMe9RKqMjNG6FRF8cGmj7BcdyreizJOkH/DmcOpxn09kDD0XA==", "dependencies": { "@types/node": "^22.0.0" } diff --git a/plugins/importer-curl/package.json b/plugins/importer-curl/package.json index 3d733080..91e2bc4a 100644 --- a/plugins/importer-curl/package.json +++ b/plugins/importer-curl/package.json @@ -6,7 +6,7 @@ "build": "yaakcli ./src/index.js" }, "dependencies": { - "@yaakapp/api": "^0.1.9", + "@yaakapp/api": "^0.1.11", "shell-quote": "^1.8.1" }, "devDependencies": { diff --git a/plugins/importer-insomnia/package-lock.json b/plugins/importer-insomnia/package-lock.json index 5ce31d16..29c44011 100644 --- a/plugins/importer-insomnia/package-lock.json +++ b/plugins/importer-insomnia/package-lock.json @@ -8,7 +8,7 @@ "name": "importer-insomnia", "version": "0.0.1", "dependencies": { - "@yaakapp/api": "^0.1.9", + "@yaakapp/api": "^0.1.11", "yaml": "^2.4.2" }, "devDependencies": { @@ -26,9 +26,9 @@ } }, "node_modules/@yaakapp/api": { - "version": "0.1.9", - "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.9.tgz", - "integrity": "sha512-5mgBoNplXUnNIUpLgGPCjcf6p/BcsU485cH3/MnIzcXIaMfFpZVVwHq5vf9cm+NDcr5hwYmPyIbwmBf9uVoV2Q==", + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.11.tgz", + "integrity": "sha512-dRZAXrQpftWygy9nJXiIYPzLA9om6reO/RiEacMe9RKqMjNG6FRF8cGmj7BcdyreizJOkH/DmcOpxn09kDD0XA==", "dependencies": { "@types/node": "^22.0.0" } diff --git a/plugins/importer-insomnia/package.json b/plugins/importer-insomnia/package.json index 0369d725..4eed9cca 100644 --- a/plugins/importer-insomnia/package.json +++ b/plugins/importer-insomnia/package.json @@ -6,7 +6,7 @@ "build": "yaakcli ./src/index.js" }, "dependencies": { - "@yaakapp/api": "^0.1.9", + "@yaakapp/api": "^0.1.11", "yaml": "^2.4.2" }, "devDependencies": { diff --git a/plugins/importer-openapi/package-lock.json b/plugins/importer-openapi/package-lock.json index b7c5e579..7fe8b9d5 100644 --- a/plugins/importer-openapi/package-lock.json +++ b/plugins/importer-openapi/package-lock.json @@ -8,7 +8,7 @@ "name": "importer-openapi", "version": "0.0.1", "dependencies": { - "@yaakapp/api": "^0.1.9", + "@yaakapp/api": "^0.1.11", "openapi-to-postmanv2": "^4.23.1", "yaml": "^2.4.2" }, @@ -56,9 +56,9 @@ } }, "node_modules/@yaakapp/api": { - "version": "0.1.9", - "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.9.tgz", - "integrity": "sha512-5mgBoNplXUnNIUpLgGPCjcf6p/BcsU485cH3/MnIzcXIaMfFpZVVwHq5vf9cm+NDcr5hwYmPyIbwmBf9uVoV2Q==", + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.11.tgz", + "integrity": "sha512-dRZAXrQpftWygy9nJXiIYPzLA9om6reO/RiEacMe9RKqMjNG6FRF8cGmj7BcdyreizJOkH/DmcOpxn09kDD0XA==", "dependencies": { "@types/node": "^22.0.0" } diff --git a/plugins/importer-openapi/package.json b/plugins/importer-openapi/package.json index 515019a7..355c9cb3 100644 --- a/plugins/importer-openapi/package.json +++ b/plugins/importer-openapi/package.json @@ -6,7 +6,7 @@ "build": "yaakcli ./src/index.js" }, "dependencies": { - "@yaakapp/api": "^0.1.9", + "@yaakapp/api": "^0.1.11", "openapi-to-postmanv2": "^4.23.1", "yaml": "^2.4.2" }, diff --git a/plugins/importer-postman/package-lock.json b/plugins/importer-postman/package-lock.json index 3a290e03..29c68466 100644 --- a/plugins/importer-postman/package-lock.json +++ b/plugins/importer-postman/package-lock.json @@ -8,7 +8,7 @@ "name": "importer-postman", "version": "0.0.1", "dependencies": { - "@yaakapp/api": "^0.1.9" + "@yaakapp/api": "^0.1.11" }, "devDependencies": { "@types/node": "^20.14.9", @@ -663,9 +663,9 @@ } }, "node_modules/@yaakapp/api": { - "version": "0.1.9", - "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.9.tgz", - "integrity": "sha512-5mgBoNplXUnNIUpLgGPCjcf6p/BcsU485cH3/MnIzcXIaMfFpZVVwHq5vf9cm+NDcr5hwYmPyIbwmBf9uVoV2Q==", + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.11.tgz", + "integrity": "sha512-dRZAXrQpftWygy9nJXiIYPzLA9om6reO/RiEacMe9RKqMjNG6FRF8cGmj7BcdyreizJOkH/DmcOpxn09kDD0XA==", "dependencies": { "@types/node": "^22.0.0" } diff --git a/plugins/importer-postman/package.json b/plugins/importer-postman/package.json index 693a9d70..bf5b89cb 100644 --- a/plugins/importer-postman/package.json +++ b/plugins/importer-postman/package.json @@ -7,7 +7,7 @@ "build": "yaakcli ./src/index.js" }, "dependencies": { - "@yaakapp/api": "^0.1.9" + "@yaakapp/api": "^0.1.11" }, "devDependencies": { "@types/node": "^20.14.9", diff --git a/plugins/importer-yaak/package-lock.json b/plugins/importer-yaak/package-lock.json index bbb32504..f96ee609 100644 --- a/plugins/importer-yaak/package-lock.json +++ b/plugins/importer-yaak/package-lock.json @@ -8,7 +8,7 @@ "name": "importer-yaak", "version": "0.0.1", "dependencies": { - "@yaakapp/api": "^0.1.9" + "@yaakapp/api": "^0.1.11" }, "devDependencies": { "@types/node": "^20.14.9", @@ -394,9 +394,9 @@ } }, "node_modules/@yaakapp/api": { - "version": "0.1.9", - "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.9.tgz", - "integrity": "sha512-5mgBoNplXUnNIUpLgGPCjcf6p/BcsU485cH3/MnIzcXIaMfFpZVVwHq5vf9cm+NDcr5hwYmPyIbwmBf9uVoV2Q==", + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.11.tgz", + "integrity": "sha512-dRZAXrQpftWygy9nJXiIYPzLA9om6reO/RiEacMe9RKqMjNG6FRF8cGmj7BcdyreizJOkH/DmcOpxn09kDD0XA==", "dependencies": { "@types/node": "^22.0.0" } diff --git a/plugins/importer-yaak/package.json b/plugins/importer-yaak/package.json index 6724d907..ea6ab6cb 100644 --- a/plugins/importer-yaak/package.json +++ b/plugins/importer-yaak/package.json @@ -6,7 +6,7 @@ "build": "yaakcli ./src/index.js" }, "dependencies": { - "@yaakapp/api": "^0.1.9" + "@yaakapp/api": "^0.1.11" }, "devDependencies": { "@types/node": "^20.14.9", diff --git a/plugins/template-function-response/package-lock.json b/plugins/template-function-response/package-lock.json index e6e882a9..3d64a872 100644 --- a/plugins/template-function-response/package-lock.json +++ b/plugins/template-function-response/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.1", "dependencies": { "@xmldom/xmldom": "^0.8.10", - "@yaakapp/api": "^0.1.9", + "@yaakapp/api": "^0.1.11", "jsonpath-plus": "^9.0.0", "xpath": "^0.0.34" }, @@ -741,9 +741,9 @@ } }, "node_modules/@yaakapp/api": { - "version": "0.1.9", - "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.9.tgz", - "integrity": "sha512-5mgBoNplXUnNIUpLgGPCjcf6p/BcsU485cH3/MnIzcXIaMfFpZVVwHq5vf9cm+NDcr5hwYmPyIbwmBf9uVoV2Q==", + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.11.tgz", + "integrity": "sha512-dRZAXrQpftWygy9nJXiIYPzLA9om6reO/RiEacMe9RKqMjNG6FRF8cGmj7BcdyreizJOkH/DmcOpxn09kDD0XA==", "dependencies": { "@types/node": "^22.0.0" } diff --git a/plugins/template-function-response/package.json b/plugins/template-function-response/package.json index 06d4c93b..b8147860 100644 --- a/plugins/template-function-response/package.json +++ b/plugins/template-function-response/package.json @@ -6,7 +6,7 @@ "build": "yaakcli src/index.ts" }, "dependencies": { - "@yaakapp/api": "^0.1.9", + "@yaakapp/api": "^0.1.11", "jsonpath-plus": "^9.0.0", "xpath": "^0.0.34", "@xmldom/xmldom": "^0.8.10" diff --git a/plugins/template-function-response/src/index.ts b/plugins/template-function-response/src/index.ts index 41968c64..966e23e9 100644 --- a/plugins/template-function-response/src/index.ts +++ b/plugins/template-function-response/src/index.ts @@ -1,5 +1,5 @@ import { DOMParser } from '@xmldom/xmldom'; -import { CallTemplateFunctionArgs, Context, Plugin } from '@yaakapp/api'; +import { CallTemplateFunctionArgs, Context, HttpResponse, Plugin } from '@yaakapp/api'; import { JSONPath } from 'jsonpath-plus'; import { readFileSync } from 'node:fs'; import xpath from 'xpath'; @@ -17,7 +17,7 @@ export const plugin: Plugin = { type: 'text', name: 'path', label: 'JSONPath or XPath', - placeholder: '$.books[0].id or /books[0]/id' + placeholder: '$.books[0].id or /books[0]/id', }, { type: 'select', @@ -48,9 +48,20 @@ export const plugin: Plugin = { return null; } - const response = (args.values.behavior === 'always' || responses[0] == null) - ? await ctx.httpRequest.send({ httpRequest: renderedHttpRequest }) - : responses[0]; + let response: HttpResponse | null = responses[0] ?? null; + + // Previews happen a ton, and we don't want to send too many times on "always," so treat + // it as "smart" during preview. + let behavior = args.values.behavior === 'always' && args.purpose === 'preview' ? 'smart' : args.values.behavior; + + // Send if no responses and "smart," or "always" + if ((behavior === 'smart' && response == null) || behavior === 'always') { + response = await ctx.httpRequest.send({ httpRequest: renderedHttpRequest }); + } + + if (response == null) { + return null; + } if (response.bodyPath == null) { return null; @@ -102,7 +113,7 @@ function filterXPath(body: string, path: string): string { const items = xpath.select(path, doc, false); if (Array.isArray(items)) { - return String(items[0] ?? ''); + return items[0] != null ? String(items[0].firstChild ?? '') : ''; } else { // Not sure what cases this happens in (?) return String(items); diff --git a/scripts/build-plugins.cjs b/scripts/build-plugins.cjs index 2e617472..687fc73c 100644 --- a/scripts/build-plugins.cjs +++ b/scripts/build-plugins.cjs @@ -1,5 +1,5 @@ -const {readdirSync, readFileSync} = require('node:fs'); -const {execSync} = require('node:child_process'); +const { readdirSync, readFileSync } = require('node:fs'); +const { execSync } = require('node:child_process'); const path = require('node:path'); async function main() { @@ -13,8 +13,8 @@ async function main() { const pkg = JSON.parse(readFileSync(path.join(pluginDir, 'package.json'), 'utf8')); console.log('Building plugin', pkg.name, pluginDir); - execSync(`npm ci`, {cwd: pluginDir}); - execSync(`npm run build`, {cwd: pluginDir}); + execSync(`npm install`, { cwd: pluginDir }); + execSync(`npm run build`, { cwd: pluginDir }); } }