Template response plugin

This commit is contained in:
Gregory Schier
2024-08-19 19:11:36 -07:00
parent 54efb6ae4e
commit d1871b19ee
30 changed files with 2272 additions and 329 deletions

191
package-lock.json generated
View File

@@ -5,10 +5,8 @@
"packages": { "packages": {
"": { "": {
"name": "@yaakapp/plugins", "name": "@yaakapp/plugins",
"dependencies": {
"xml-formatter": "^3.6.3"
},
"devDependencies": { "devDependencies": {
"jsonpath": "^1.1.1",
"vitest": "^2.0.4" "vitest": "^2.0.4"
} }
}, },
@@ -819,6 +817,12 @@
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/deep-is": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",
"integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==",
"dev": true
},
"node_modules/esbuild": { "node_modules/esbuild": {
"version": "0.21.5", "version": "0.21.5",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz",
@@ -857,6 +861,63 @@
"@esbuild/win32-x64": "0.21.5" "@esbuild/win32-x64": "0.21.5"
} }
}, },
"node_modules/escodegen": {
"version": "1.14.3",
"resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz",
"integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==",
"dev": true,
"dependencies": {
"esprima": "^4.0.1",
"estraverse": "^4.2.0",
"esutils": "^2.0.2",
"optionator": "^0.8.1"
},
"bin": {
"escodegen": "bin/escodegen.js",
"esgenerate": "bin/esgenerate.js"
},
"engines": {
"node": ">=4.0"
},
"optionalDependencies": {
"source-map": "~0.6.1"
}
},
"node_modules/escodegen/node_modules/esprima": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
"dev": true,
"bin": {
"esparse": "bin/esparse.js",
"esvalidate": "bin/esvalidate.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/esprima": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.2.tgz",
"integrity": "sha512-+JpPZam9w5DuJ3Q67SqsMGtiHKENSMRVoxvArfJZK01/BfLEObtZ6orJa/MtoGNR/rfMgp5837T41PAmTwAv/A==",
"dev": true,
"bin": {
"esparse": "bin/esparse.js",
"esvalidate": "bin/esvalidate.js"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/estraverse": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz",
"integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==",
"dev": true,
"engines": {
"node": ">=4.0"
}
},
"node_modules/estree-walker": { "node_modules/estree-walker": {
"version": "3.0.3", "version": "3.0.3",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz",
@@ -866,6 +927,15 @@
"@types/estree": "^1.0.0" "@types/estree": "^1.0.0"
} }
}, },
"node_modules/esutils": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/execa": { "node_modules/execa": {
"version": "8.0.1", "version": "8.0.1",
"resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz",
@@ -889,6 +959,12 @@
"url": "https://github.com/sindresorhus/execa?sponsor=1" "url": "https://github.com/sindresorhus/execa?sponsor=1"
} }
}, },
"node_modules/fast-levenshtein": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
"integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==",
"dev": true
},
"node_modules/fsevents": { "node_modules/fsevents": {
"version": "2.3.3", "version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
@@ -951,6 +1027,30 @@
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
"dev": true "dev": true
}, },
"node_modules/jsonpath": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/jsonpath/-/jsonpath-1.1.1.tgz",
"integrity": "sha512-l6Cg7jRpixfbgoWgkrl77dgEj8RPvND0wMH6TwQmi9Qs4TFfS9u5cUFnbeKTwj5ga5Y3BTGGNI28k117LJ009w==",
"dev": true,
"dependencies": {
"esprima": "1.2.2",
"static-eval": "2.0.2",
"underscore": "1.12.1"
}
},
"node_modules/levn": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz",
"integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==",
"dev": true,
"dependencies": {
"prelude-ls": "~1.1.2",
"type-check": "~0.3.2"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/loupe": { "node_modules/loupe": {
"version": "3.1.1", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.1.tgz", "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.1.tgz",
@@ -1053,6 +1153,23 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/optionator": {
"version": "0.8.3",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz",
"integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==",
"dev": true,
"dependencies": {
"deep-is": "~0.1.3",
"fast-levenshtein": "~2.0.6",
"levn": "~0.3.0",
"prelude-ls": "~1.1.2",
"type-check": "~0.3.2",
"word-wrap": "~1.2.3"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/path-key": { "node_modules/path-key": {
"version": "3.1.1", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
@@ -1111,6 +1228,15 @@
"node": "^10 || ^12 || >=14" "node": "^10 || ^12 || >=14"
} }
}, },
"node_modules/prelude-ls": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",
"integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==",
"dev": true,
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/rollup": { "node_modules/rollup": {
"version": "4.19.0", "version": "4.19.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.19.0.tgz", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.19.0.tgz",
@@ -1185,6 +1311,16 @@
"url": "https://github.com/sponsors/isaacs" "url": "https://github.com/sponsors/isaacs"
} }
}, },
"node_modules/source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true,
"optional": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/source-map-js": { "node_modules/source-map-js": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz",
@@ -1200,6 +1336,15 @@
"integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==",
"dev": true "dev": true
}, },
"node_modules/static-eval": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.0.2.tgz",
"integrity": "sha512-N/D219Hcr2bPjLxPiV+TQE++Tsmrady7TqAJugLy7Xk1EumfDWS/f5dtBbkRCGE7wKKXuYockQoj8Rm2/pVKyg==",
"dev": true,
"dependencies": {
"escodegen": "^1.8.1"
}
},
"node_modules/std-env": { "node_modules/std-env": {
"version": "3.7.0", "version": "3.7.0",
"resolved": "https://registry.npmjs.org/std-env/-/std-env-3.7.0.tgz", "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.7.0.tgz",
@@ -1251,6 +1396,24 @@
"node": ">=14.0.0" "node": ">=14.0.0"
} }
}, },
"node_modules/type-check": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
"integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==",
"dev": true,
"dependencies": {
"prelude-ls": "~1.1.2"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/underscore": {
"version": "1.12.1",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.12.1.tgz",
"integrity": "sha512-hEQt0+ZLDVUMhebKxL4x1BTtDY7bavVofhZ9KZ4aI26X9SRaE+Y3m83XUL1UP2jn8ynjndwCCpEHdUG+9pP1Tw==",
"dev": true
},
"node_modules/vite": { "node_modules/vite": {
"version": "5.3.4", "version": "5.3.4",
"resolved": "https://registry.npmjs.org/vite/-/vite-5.3.4.tgz", "resolved": "https://registry.npmjs.org/vite/-/vite-5.3.4.tgz",
@@ -1423,23 +1586,13 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/xml-formatter": { "node_modules/word-wrap": {
"version": "3.6.3", "version": "1.2.5",
"resolved": "https://registry.npmjs.org/xml-formatter/-/xml-formatter-3.6.3.tgz", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz",
"integrity": "sha512-++x1TlRO1FRlQ82AZ4WnoCSufaI/PT/sycn4K8nRl4gnrNC1uYY2VV/67aALZ2m0Q4Q/BLj/L69K360Itw9NNg==", "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==",
"dependencies": { "dev": true,
"xml-parser-xo": "^4.1.2"
},
"engines": { "engines": {
"node": ">= 16" "node": ">=0.10.0"
}
},
"node_modules/xml-parser-xo": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/xml-parser-xo/-/xml-parser-xo-4.1.2.tgz",
"integrity": "sha512-Z/DRB0ZAKj5vAQg++XsfQQKfT73Vfj5n5lKIVXobBDQEva6NHWUTxOA6OohJmEcpoy8AEqBmSGkXXAnFwt5qAA==",
"engines": {
"node": ">= 16"
} }
} }
} }

View File

@@ -6,6 +6,7 @@
"build": "node scripts/build-plugins.cjs" "build": "node scripts/build-plugins.cjs"
}, },
"devDependencies": { "devDependencies": {
"jsonpath": "^1.1.1",
"vitest": "^2.0.4" "vitest": "^2.0.4"
} }
} }

View File

@@ -8,7 +8,7 @@
"name": "exporter-curl", "name": "exporter-curl",
"version": "0.0.1", "version": "0.0.1",
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.1.6" "@yaakapp/api": "^0.1.9"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.14.9", "@types/node": "^20.14.9",
@@ -701,9 +701,9 @@
} }
}, },
"node_modules/@yaakapp/api": { "node_modules/@yaakapp/api": {
"version": "0.1.6", "version": "0.1.9",
"resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.6.tgz", "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.9.tgz",
"integrity": "sha512-5lYXKcOVmLzVUrkfU4JOCbz+CBV5Dm/cALoZvfbelvZWOVu3sTrBxS9cbNVQQq2B6WwLInSevk7pMq58GqIj5Q==", "integrity": "sha512-5mgBoNplXUnNIUpLgGPCjcf6p/BcsU485cH3/MnIzcXIaMfFpZVVwHq5vf9cm+NDcr5hwYmPyIbwmBf9uVoV2Q==",
"dependencies": { "dependencies": {
"@types/node": "^22.0.0" "@types/node": "^22.0.0"
} }

View File

@@ -1,5 +1,6 @@
{ {
"name": "exporter-curl", "name": "exporter-curl",
"private": true,
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"build": "yaakcli ./src/index.js" "build": "yaakcli ./src/index.js"
@@ -10,6 +11,6 @@
"vitest": "^1.4.0" "vitest": "^1.4.0"
}, },
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.1.6" "@yaakapp/api": "^0.1.9"
} }
} }

View File

@@ -1,8 +1,8 @@
import { HttpRequest, YaakContext, YaakPlugin } from '@yaakapp/api'; import { Context, HttpRequest, Plugin } from '@yaakapp/api';
const NEWLINE = '\\\n '; const NEWLINE = '\\\n ';
export const plugin: YaakPlugin = { export const plugin: Plugin = {
httpRequestActions: [{ httpRequestActions: [{
key: 'export-curl', key: 'export-curl',
label: 'Copy as Curl', label: 'Copy as Curl',
@@ -16,7 +16,7 @@ export const plugin: YaakPlugin = {
}], }],
}; };
export async function pluginHookExport(_ctx: YaakContext, request: Partial<HttpRequest>) { export async function pluginHookExport(_ctx: Context, request: Partial<HttpRequest>) {
const xs = ['curl']; const xs = ['curl'];
// Add method and URL all on first line // Add method and URL all on first line

View File

@@ -8,21 +8,35 @@
"name": "filter-jsonpath", "name": "filter-jsonpath",
"version": "0.0.1", "version": "0.0.1",
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.1.6", "@yaakapp/api": "^0.1.9",
"jsonpath": "^1.1.1" "jsonpath-plus": "^9.0.0"
}, },
"devDependencies": { "devDependencies": {
"@types/jsonpath": "^0.2.4",
"@types/node": "^20.14.9", "@types/node": "^20.14.9",
"cross-env": "^7.0.3",
"typescript": "^5.5.2" "typescript": "^5.5.2"
} }
}, },
"node_modules/@types/jsonpath": { "node_modules/@jsep-plugin/assignment": {
"version": "0.2.4", "version": "1.2.1",
"resolved": "https://registry.npmjs.org/@types/jsonpath/-/jsonpath-0.2.4.tgz", "resolved": "https://registry.npmjs.org/@jsep-plugin/assignment/-/assignment-1.2.1.tgz",
"integrity": "sha512-K3hxB8Blw0qgW6ExKgMbXQv2UPZBoE2GqLpVY+yr7nMD2Pq86lsuIzyAaiQ7eMqFL5B6di6pxSkogLJEyEHoGA==", "integrity": "sha512-gaHqbubTi29aZpVbBlECRpmdia+L5/lh2BwtIJTmtxdbecEyyX/ejAOg7eQDGNvGOUmPY7Z2Yxdy9ioyH/VJeA==",
"dev": true "engines": {
"node": ">= 10.16.0"
},
"peerDependencies": {
"jsep": "^0.4.0||^1.0.0"
}
},
"node_modules/@jsep-plugin/regex": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@jsep-plugin/regex/-/regex-1.0.3.tgz",
"integrity": "sha512-XfZgry4DwEZvSFtS/6Y+R48D7qJYJK6R9/yJFyUFHCIUMEEHuJ4X95TDgJp5QkmzfLYvapMPzskV5HpIDrREug==",
"engines": {
"node": ">= 10.16.0"
},
"peerDependencies": {
"jsep": "^0.4.0||^1.0.0"
}
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "20.14.9", "version": "20.14.9",
@@ -34,9 +48,9 @@
} }
}, },
"node_modules/@yaakapp/api": { "node_modules/@yaakapp/api": {
"version": "0.1.6", "version": "0.1.9",
"resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.6.tgz", "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.9.tgz",
"integrity": "sha512-5lYXKcOVmLzVUrkfU4JOCbz+CBV5Dm/cALoZvfbelvZWOVu3sTrBxS9cbNVQQq2B6WwLInSevk7pMq58GqIj5Q==", "integrity": "sha512-5mgBoNplXUnNIUpLgGPCjcf6p/BcsU485cH3/MnIzcXIaMfFpZVVwHq5vf9cm+NDcr5hwYmPyIbwmBf9uVoV2Q==",
"dependencies": { "dependencies": {
"@types/node": "^22.0.0" "@types/node": "^22.0.0"
} }
@@ -54,217 +68,29 @@
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.18.2.tgz", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.18.2.tgz",
"integrity": "sha512-5ruQbENj95yDYJNS3TvcaxPMshV7aizdv/hWYjGIKoANWKjhWNBsr2YEuYZKodQulB1b8l7ILOuDQep3afowQQ==" "integrity": "sha512-5ruQbENj95yDYJNS3TvcaxPMshV7aizdv/hWYjGIKoANWKjhWNBsr2YEuYZKodQulB1b8l7ILOuDQep3afowQQ=="
}, },
"node_modules/cross-env": { "node_modules/jsep": {
"version": "7.0.3", "version": "1.3.9",
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", "resolved": "https://registry.npmjs.org/jsep/-/jsep-1.3.9.tgz",
"integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", "integrity": "sha512-i1rBX5N7VPl0eYb6+mHNp52sEuaS2Wi8CDYx1X5sn9naevL78+265XJqy1qENEk7mRKwS06NHpUqiBwR7qeodw==",
"dev": true, "engines": {
"node": ">= 10.16.0"
}
},
"node_modules/jsonpath-plus": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-9.0.0.tgz",
"integrity": "sha512-bqE77VIDStrOTV/czspZhTn+o27Xx9ZJRGVkdVShEtPoqsIx5yALv3lWVU6y+PqYvWPJNWE7ORCQheQkEe0DDA==",
"dependencies": { "dependencies": {
"cross-spawn": "^7.0.1" "@jsep-plugin/assignment": "^1.2.1",
"@jsep-plugin/regex": "^1.0.3",
"jsep": "^1.3.8"
}, },
"bin": { "bin": {
"cross-env": "src/bin/cross-env.js", "jsonpath": "bin/jsonpath-cli.js",
"cross-env-shell": "src/bin/cross-env-shell.js" "jsonpath-plus": "bin/jsonpath-cli.js"
}, },
"engines": { "engines": {
"node": ">=10.14", "node": ">=14.0.0"
"npm": ">=6",
"yarn": ">=1"
}
},
"node_modules/cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
"dev": true,
"dependencies": {
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
"which": "^2.0.1"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/deep-is": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",
"integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ=="
},
"node_modules/escodegen": {
"version": "1.14.3",
"resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz",
"integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==",
"dependencies": {
"esprima": "^4.0.1",
"estraverse": "^4.2.0",
"esutils": "^2.0.2",
"optionator": "^0.8.1"
},
"bin": {
"escodegen": "bin/escodegen.js",
"esgenerate": "bin/esgenerate.js"
},
"engines": {
"node": ">=4.0"
},
"optionalDependencies": {
"source-map": "~0.6.1"
}
},
"node_modules/escodegen/node_modules/esprima": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
"bin": {
"esparse": "bin/esparse.js",
"esvalidate": "bin/esvalidate.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/esprima": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.2.tgz",
"integrity": "sha512-+JpPZam9w5DuJ3Q67SqsMGtiHKENSMRVoxvArfJZK01/BfLEObtZ6orJa/MtoGNR/rfMgp5837T41PAmTwAv/A==",
"bin": {
"esparse": "bin/esparse.js",
"esvalidate": "bin/esvalidate.js"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/estraverse": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz",
"integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==",
"engines": {
"node": ">=4.0"
}
},
"node_modules/esutils": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/fast-levenshtein": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
"integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw=="
},
"node_modules/isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
"dev": true
},
"node_modules/jsonpath": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/jsonpath/-/jsonpath-1.1.1.tgz",
"integrity": "sha512-l6Cg7jRpixfbgoWgkrl77dgEj8RPvND0wMH6TwQmi9Qs4TFfS9u5cUFnbeKTwj5ga5Y3BTGGNI28k117LJ009w==",
"dependencies": {
"esprima": "1.2.2",
"static-eval": "2.0.2",
"underscore": "1.12.1"
}
},
"node_modules/levn": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz",
"integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==",
"dependencies": {
"prelude-ls": "~1.1.2",
"type-check": "~0.3.2"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/optionator": {
"version": "0.8.3",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz",
"integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==",
"dependencies": {
"deep-is": "~0.1.3",
"fast-levenshtein": "~2.0.6",
"levn": "~0.3.0",
"prelude-ls": "~1.1.2",
"type-check": "~0.3.2",
"word-wrap": "~1.2.3"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/path-key": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/prelude-ls": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",
"integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==",
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/shebang-command": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
"dev": true,
"dependencies": {
"shebang-regex": "^3.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/shebang-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"optional": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/static-eval": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.0.2.tgz",
"integrity": "sha512-N/D219Hcr2bPjLxPiV+TQE++Tsmrady7TqAJugLy7Xk1EumfDWS/f5dtBbkRCGE7wKKXuYockQoj8Rm2/pVKyg==",
"dependencies": {
"escodegen": "^1.8.1"
}
},
"node_modules/type-check": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
"integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==",
"dependencies": {
"prelude-ls": "~1.1.2"
},
"engines": {
"node": ">= 0.8.0"
} }
}, },
"node_modules/typescript": { "node_modules/typescript": {
@@ -280,39 +106,11 @@
"node": ">=14.17" "node": ">=14.17"
} }
}, },
"node_modules/underscore": {
"version": "1.12.1",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.12.1.tgz",
"integrity": "sha512-hEQt0+ZLDVUMhebKxL4x1BTtDY7bavVofhZ9KZ4aI26X9SRaE+Y3m83XUL1UP2jn8ynjndwCCpEHdUG+9pP1Tw=="
},
"node_modules/undici-types": { "node_modules/undici-types": {
"version": "5.26.5", "version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
"dev": true "dev": true
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"dependencies": {
"isexe": "^2.0.0"
},
"bin": {
"node-which": "bin/node-which"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/word-wrap": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz",
"integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==",
"engines": {
"node": ">=0.10.0"
}
} }
} }
} }

View File

@@ -1,17 +1,16 @@
{ {
"name": "filter-jsonpath", "name": "filter-jsonpath",
"private": true,
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"build": "cross-env BUILD_PLATFORM=browser yaakcli src/index.ts" "build": "yaakcli src/index.ts"
}, },
"dependencies": { "dependencies": {
"jsonpath": "^1.1.1", "jsonpath-plus": "^9.0.0",
"@yaakapp/api": "^0.1.6" "@yaakapp/api": "^0.1.9"
}, },
"devDependencies": { "devDependencies": {
"@types/jsonpath": "^0.2.4",
"@types/node": "^20.14.9", "@types/node": "^20.14.9",
"cross-env": "^7.0.3",
"typescript": "^5.5.2" "typescript": "^5.5.2"
} }
} }

View File

@@ -1,8 +1,8 @@
import { YaakContext } from '@yaakapp/api'; import { Context } from '@yaakapp/api';
import jp from 'jsonpath'; import { JSONPath } from 'jsonpath-plus';
export function pluginHookResponseFilter(_ctx: YaakContext, args: { filter: string; body: string }) { export function pluginHookResponseFilter(_ctx: Context, args: { filter: string; body: string }) {
const parsed = JSON.parse(args.body); const parsed = JSON.parse(args.body);
const filtered = jp.query(parsed, args.filter); const filtered = JSONPath({ path: args.filter, json: parsed });
return JSON.stringify(filtered, null, 2); return JSON.stringify(filtered, null, 2);
} }

View File

@@ -8,17 +8,20 @@
"name": "filter-xpath", "name": "filter-xpath",
"version": "0.0.1", "version": "0.0.1",
"dependencies": { "dependencies": {
"@types/node": "^20.14.9",
"@xmldom/xmldom": "^0.8.10", "@xmldom/xmldom": "^0.8.10",
"@yaakapp/api": "^0.1.6", "@yaakapp/api": "^0.1.9",
"typescript": "^5.5.2",
"xpath": "^0.0.34" "xpath": "^0.0.34"
},
"devDependencies": {
"@types/node": "^20.14.9",
"typescript": "^5.5.2"
} }
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "20.14.9", "version": "20.14.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.9.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.9.tgz",
"integrity": "sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==", "integrity": "sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==",
"dev": true,
"dependencies": { "dependencies": {
"undici-types": "~5.26.4" "undici-types": "~5.26.4"
} }
@@ -32,9 +35,9 @@
} }
}, },
"node_modules/@yaakapp/api": { "node_modules/@yaakapp/api": {
"version": "0.1.6", "version": "0.1.9",
"resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.6.tgz", "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.9.tgz",
"integrity": "sha512-5lYXKcOVmLzVUrkfU4JOCbz+CBV5Dm/cALoZvfbelvZWOVu3sTrBxS9cbNVQQq2B6WwLInSevk7pMq58GqIj5Q==", "integrity": "sha512-5mgBoNplXUnNIUpLgGPCjcf6p/BcsU485cH3/MnIzcXIaMfFpZVVwHq5vf9cm+NDcr5hwYmPyIbwmBf9uVoV2Q==",
"dependencies": { "dependencies": {
"@types/node": "^22.0.0" "@types/node": "^22.0.0"
} }
@@ -56,6 +59,7 @@
"version": "5.5.2", "version": "5.5.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz",
"integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==", "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==",
"dev": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
"tsserver": "bin/tsserver" "tsserver": "bin/tsserver"
@@ -67,7 +71,8 @@
"node_modules/undici-types": { "node_modules/undici-types": {
"version": "5.26.5", "version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
"dev": true
}, },
"node_modules/xpath": { "node_modules/xpath": {
"version": "0.0.34", "version": "0.0.34",

View File

@@ -1,14 +1,17 @@
{ {
"name": "filter-xpath", "name": "filter-xpath",
"private": true,
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"build": "yaakcli ./src/index.js" "build": "yaakcli ./src/index.js"
}, },
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.1.6", "@yaakapp/api": "^0.1.9",
"@types/node": "^20.14.9",
"@xmldom/xmldom": "^0.8.10", "@xmldom/xmldom": "^0.8.10",
"typescript": "^5.5.2",
"xpath": "^0.0.34" "xpath": "^0.0.34"
},
"devDependencies": {
"@types/node": "^20.14.9",
"typescript": "^5.5.2"
} }
} }

View File

@@ -1,9 +1,9 @@
import { DOMParser } from '@xmldom/xmldom'; import { DOMParser } from '@xmldom/xmldom';
import { YaakContext } from '@yaakapp/api'; import { Context } from '@yaakapp/api';
import xpath from 'xpath'; import xpath from 'xpath';
export function pluginHookResponseFilter( export function pluginHookResponseFilter(
_ctx: YaakContext, _ctx: Context,
{ filter, body }: { filter: string; body: string }, { filter, body }: { filter: string; body: string },
) { ) {
const doc = new DOMParser().parseFromString(body, 'text/xml'); const doc = new DOMParser().parseFromString(body, 'text/xml');

View File

@@ -8,7 +8,7 @@
"name": "importer-curl", "name": "importer-curl",
"version": "0.0.1", "version": "0.0.1",
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.1.6", "@yaakapp/api": "^0.1.9",
"shell-quote": "^1.8.1" "shell-quote": "^1.8.1"
}, },
"devDependencies": { "devDependencies": {
@@ -709,9 +709,9 @@
} }
}, },
"node_modules/@yaakapp/api": { "node_modules/@yaakapp/api": {
"version": "0.1.6", "version": "0.1.9",
"resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.6.tgz", "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.9.tgz",
"integrity": "sha512-5lYXKcOVmLzVUrkfU4JOCbz+CBV5Dm/cALoZvfbelvZWOVu3sTrBxS9cbNVQQq2B6WwLInSevk7pMq58GqIj5Q==", "integrity": "sha512-5mgBoNplXUnNIUpLgGPCjcf6p/BcsU485cH3/MnIzcXIaMfFpZVVwHq5vf9cm+NDcr5hwYmPyIbwmBf9uVoV2Q==",
"dependencies": { "dependencies": {
"@types/node": "^22.0.0" "@types/node": "^22.0.0"
} }

View File

@@ -1,11 +1,12 @@
{ {
"name": "importer-curl", "name": "importer-curl",
"private": true,
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"build": "yaakcli ./src/index.js" "build": "yaakcli ./src/index.js"
}, },
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.1.6", "@yaakapp/api": "^0.1.9",
"shell-quote": "^1.8.1" "shell-quote": "^1.8.1"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -1,4 +1,4 @@
import { Environment, Folder, HttpRequest, HttpUrlParameter, Model, Workspace, YaakContext } from '@yaakapp/api'; import { Environment, Folder, HttpRequest, HttpUrlParameter, Model, Workspace, Context } from '@yaakapp/api';
import { ControlOperator, parse, ParseEntry } from 'shell-quote'; import { ControlOperator, parse, ParseEntry } from 'shell-quote';
type AtLeast<T, K extends keyof T> = Partial<T> & Pick<T, K>; type AtLeast<T, K extends keyof T> = Partial<T> & Pick<T, K>;
@@ -32,7 +32,7 @@ type Pair = string | boolean;
type PairsByName = Record<string, Pair[]>; type PairsByName = Record<string, Pair[]>;
export function pluginHookImport(ctx: YaakContext, rawData: string) { export function pluginHookImport(ctx: Context, rawData: string) {
if (!rawData.match(/^\s*curl /)) { if (!rawData.match(/^\s*curl /)) {
return null; return null;
} }

View File

@@ -8,7 +8,7 @@
"name": "importer-insomnia", "name": "importer-insomnia",
"version": "0.0.1", "version": "0.0.1",
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.1.6", "@yaakapp/api": "^0.1.9",
"yaml": "^2.4.2" "yaml": "^2.4.2"
}, },
"devDependencies": { "devDependencies": {
@@ -26,9 +26,9 @@
} }
}, },
"node_modules/@yaakapp/api": { "node_modules/@yaakapp/api": {
"version": "0.1.6", "version": "0.1.9",
"resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.6.tgz", "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.9.tgz",
"integrity": "sha512-5lYXKcOVmLzVUrkfU4JOCbz+CBV5Dm/cALoZvfbelvZWOVu3sTrBxS9cbNVQQq2B6WwLInSevk7pMq58GqIj5Q==", "integrity": "sha512-5mgBoNplXUnNIUpLgGPCjcf6p/BcsU485cH3/MnIzcXIaMfFpZVVwHq5vf9cm+NDcr5hwYmPyIbwmBf9uVoV2Q==",
"dependencies": { "dependencies": {
"@types/node": "^22.0.0" "@types/node": "^22.0.0"
} }

View File

@@ -1,11 +1,12 @@
{ {
"name": "importer-insomnia", "name": "importer-insomnia",
"private": true,
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"build": "yaakcli ./src/index.js" "build": "yaakcli ./src/index.js"
}, },
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.1.6", "@yaakapp/api": "^0.1.9",
"yaml": "^2.4.2" "yaml": "^2.4.2"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -1,4 +1,4 @@
import { Environment, Folder, GrpcRequest, HttpRequest, Workspace, YaakContext } from '@yaakapp/api'; import { Environment, Folder, GrpcRequest, HttpRequest, Workspace, Context } from '@yaakapp/api';
import YAML from 'yaml'; import YAML from 'yaml';
type AtLeast<T, K extends keyof T> = Partial<T> & Pick<T, K>; type AtLeast<T, K extends keyof T> = Partial<T> & Pick<T, K>;
@@ -11,7 +11,7 @@ export interface ExportResources {
folders: AtLeast<Folder, 'name' | 'id' | 'model' | 'workspaceId'>[]; folders: AtLeast<Folder, 'name' | 'id' | 'model' | 'workspaceId'>[];
} }
export function pluginHookImport(ctx: YaakContext, contents: string) { export function pluginHookImport(ctx: Context, contents: string) {
let parsed: any; let parsed: any;
try { try {

View File

@@ -8,7 +8,7 @@
"name": "importer-openapi", "name": "importer-openapi",
"version": "0.0.1", "version": "0.0.1",
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.1.6", "@yaakapp/api": "^0.1.9",
"openapi-to-postmanv2": "^4.23.1", "openapi-to-postmanv2": "^4.23.1",
"yaml": "^2.4.2" "yaml": "^2.4.2"
}, },
@@ -56,9 +56,9 @@
} }
}, },
"node_modules/@yaakapp/api": { "node_modules/@yaakapp/api": {
"version": "0.1.6", "version": "0.1.9",
"resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.6.tgz", "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.9.tgz",
"integrity": "sha512-5lYXKcOVmLzVUrkfU4JOCbz+CBV5Dm/cALoZvfbelvZWOVu3sTrBxS9cbNVQQq2B6WwLInSevk7pMq58GqIj5Q==", "integrity": "sha512-5mgBoNplXUnNIUpLgGPCjcf6p/BcsU485cH3/MnIzcXIaMfFpZVVwHq5vf9cm+NDcr5hwYmPyIbwmBf9uVoV2Q==",
"dependencies": { "dependencies": {
"@types/node": "^22.0.0" "@types/node": "^22.0.0"
} }

View File

@@ -1,11 +1,12 @@
{ {
"name": "importer-openapi", "name": "importer-openapi",
"private": true,
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"build": "yaakcli ./src/index.js" "build": "yaakcli ./src/index.js"
}, },
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.1.6", "@yaakapp/api": "^0.1.9",
"openapi-to-postmanv2": "^4.23.1", "openapi-to-postmanv2": "^4.23.1",
"yaml": "^2.4.2" "yaml": "^2.4.2"
}, },

View File

@@ -1,4 +1,4 @@
import { YaakContext } from '@yaakapp/api'; import { Context } from '@yaakapp/api';
import { convert } from 'openapi-to-postmanv2'; import { convert } from 'openapi-to-postmanv2';
import { pluginHookImport as pluginHookImportPostman } from '../../importer-postman/src/index'; import { pluginHookImport as pluginHookImportPostman } from '../../importer-postman/src/index';
import { Folder, HttpRequest, Workspace, Environment } from '../../../types/models'; import { Folder, HttpRequest, Workspace, Environment } from '../../../types/models';
@@ -13,7 +13,7 @@ interface ExportResources {
} }
export async function pluginHookImport( export async function pluginHookImport(
ctx: YaakContext, ctx: Context,
contents: string, contents: string,
): Promise<{ resources: ExportResources } | undefined> { ): Promise<{ resources: ExportResources } | undefined> {
let postmanCollection; let postmanCollection;

View File

@@ -8,7 +8,7 @@
"name": "importer-postman", "name": "importer-postman",
"version": "0.0.1", "version": "0.0.1",
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.1.6" "@yaakapp/api": "^0.1.9"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.14.9", "@types/node": "^20.14.9",
@@ -663,9 +663,9 @@
} }
}, },
"node_modules/@yaakapp/api": { "node_modules/@yaakapp/api": {
"version": "0.1.6", "version": "0.1.9",
"resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.6.tgz", "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.9.tgz",
"integrity": "sha512-5lYXKcOVmLzVUrkfU4JOCbz+CBV5Dm/cALoZvfbelvZWOVu3sTrBxS9cbNVQQq2B6WwLInSevk7pMq58GqIj5Q==", "integrity": "sha512-5mgBoNplXUnNIUpLgGPCjcf6p/BcsU485cH3/MnIzcXIaMfFpZVVwHq5vf9cm+NDcr5hwYmPyIbwmBf9uVoV2Q==",
"dependencies": { "dependencies": {
"@types/node": "^22.0.0" "@types/node": "^22.0.0"
} }

View File

@@ -1,12 +1,13 @@
{ {
"name": "importer-postman", "name": "importer-postman",
"private": true,
"version": "0.0.1", "version": "0.0.1",
"main": "./build/index.js", "main": "./build/index.js",
"scripts": { "scripts": {
"build": "yaakcli ./src/index.js" "build": "yaakcli ./src/index.js"
}, },
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.1.6" "@yaakapp/api": "^0.1.9"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.14.9", "@types/node": "^20.14.9",

View File

@@ -1,4 +1,4 @@
import { Environment, Folder, HttpRequest, HttpRequestHeader, Model, Workspace, YaakContext } from '@yaakapp/api'; import { Environment, Folder, HttpRequest, HttpRequestHeader, Model, Workspace, Context } from '@yaakapp/api';
const POSTMAN_2_1_0_SCHEMA = 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json'; const POSTMAN_2_1_0_SCHEMA = 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json';
const POSTMAN_2_0_0_SCHEMA = 'https://schema.getpostman.com/json/collection/v2.0.0/collection.json'; const POSTMAN_2_0_0_SCHEMA = 'https://schema.getpostman.com/json/collection/v2.0.0/collection.json';
@@ -14,7 +14,7 @@ interface ExportResources {
} }
export function pluginHookImport( export function pluginHookImport(
_ctx: YaakContext, _ctx: Context,
contents: string, contents: string,
): { resources: ExportResources } | undefined { ): { resources: ExportResources } | undefined {
const root = parseJSONToRecord(contents); const root = parseJSONToRecord(contents);

View File

@@ -8,7 +8,7 @@
"name": "importer-yaak", "name": "importer-yaak",
"version": "0.0.1", "version": "0.0.1",
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.1.6" "@yaakapp/api": "^0.1.9"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.14.9", "@types/node": "^20.14.9",
@@ -394,9 +394,9 @@
} }
}, },
"node_modules/@yaakapp/api": { "node_modules/@yaakapp/api": {
"version": "0.1.6", "version": "0.1.9",
"resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.6.tgz", "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.9.tgz",
"integrity": "sha512-5lYXKcOVmLzVUrkfU4JOCbz+CBV5Dm/cALoZvfbelvZWOVu3sTrBxS9cbNVQQq2B6WwLInSevk7pMq58GqIj5Q==", "integrity": "sha512-5mgBoNplXUnNIUpLgGPCjcf6p/BcsU485cH3/MnIzcXIaMfFpZVVwHq5vf9cm+NDcr5hwYmPyIbwmBf9uVoV2Q==",
"dependencies": { "dependencies": {
"@types/node": "^22.0.0" "@types/node": "^22.0.0"
} }

View File

@@ -1,11 +1,12 @@
{ {
"name": "importer-yaak", "name": "importer-yaak",
"private": true,
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"build": "yaakcli ./src/index.js" "build": "yaakcli ./src/index.js"
}, },
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.1.6" "@yaakapp/api": "^0.1.9"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.14.9", "@types/node": "^20.14.9",

View File

@@ -1,6 +1,6 @@
import { YaakContext } from '@yaakapp/api'; import { Context } from '@yaakapp/api';
export function pluginHookImport(_ctx: YaakContext, contents: string) { export function pluginHookImport(_ctx: Context, contents: string) {
let parsed; let parsed;
try { try {
parsed = JSON.parse(contents); parsed = JSON.parse(contents);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,20 @@
{
"name": "template-function-response",
"private": true,
"version": "0.0.1",
"scripts": {
"build": "yaakcli src/index.ts"
},
"dependencies": {
"@yaakapp/api": "^0.1.9",
"jsonpath-plus": "^9.0.0",
"xpath": "^0.0.34",
"@xmldom/xmldom": "^0.8.10"
},
"devDependencies": {
"@types/jsonpath": "^0.2.4",
"@types/node": "^20.14.9",
"typescript": "^5.5.2",
"vitest": "^1.4.0"
}
}

View File

@@ -0,0 +1,110 @@
import { DOMParser } from '@xmldom/xmldom';
import { CallTemplateFunctionArgs, Context, Plugin } from '@yaakapp/api';
import { JSONPath } from 'jsonpath-plus';
import { readFileSync } from 'node:fs';
import xpath from 'xpath';
export const plugin: Plugin = {
templateFunctions: [{
name: 'Response',
args: [
{
type: 'http_request',
name: 'request',
label: 'Request',
},
{
type: 'text',
name: 'path',
label: 'JSONPath or XPath',
placeholder: '$.books[0].id or /books[0]/id'
},
{
type: 'select',
name: 'behavior',
label: 'Sending Behavior',
defaultValue: 'smart',
options: [
{ name: 'When no responses', value: 'smart' },
{ name: 'Always', value: 'always' },
{ name: 'Never', value: 'never' },
],
},
],
async onRender(ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
if (!args.values.request || !args.values.path) {
return null;
}
const httpRequest = await ctx.httpRequest.getById({ id: args.values.request ?? 'n/a' });
if (httpRequest == null) {
return null;
}
const renderedHttpRequest = await ctx.httpRequest.render({ httpRequest });
const responses = await ctx.httpResponse.find({ requestId: httpRequest.id, limit: 1 });
if (args.values.behavior === 'never' && responses.length === 0) {
return null;
}
const response = (args.values.behavior === 'always' || responses[0] == null)
? await ctx.httpRequest.send({ httpRequest: renderedHttpRequest })
: responses[0];
if (response.bodyPath == null) {
return null;
}
let body;
try {
body = readFileSync(response.bodyPath, 'utf-8');
} catch (_) {
return null;
}
try {
return filterJSONPath(body, args.values.path);
} catch (err) {
// Probably not JSON, try XPath
}
try {
return filterXPath(body, args.values.path);
} catch (err) {
// Probably not XML
}
return null; // Bail out
},
}],
};
function filterJSONPath(body: string, path: string): string {
const parsed = JSON.parse(body);
const items = JSONPath({ path, json: parsed })[0];
if (items == null) {
return '';
}
if (
Object.prototype.toString.call(items) === '[object Array]' ||
Object.prototype.toString.call(items) === '[object Object]'
) {
return JSON.stringify(items);
} else {
return String(items);
}
}
function filterXPath(body: string, path: string): string {
const doc = new DOMParser().parseFromString(body, 'text/xml');
const items = xpath.select(path, doc, false);
if (Array.isArray(items)) {
return String(items[0] ?? '');
} else {
// Not sure what cases this happens in (?)
return String(items);
}
}

View File

@@ -0,0 +1,177 @@
import { describe, expect, test } from 'vitest';
import { pluginHookExport } from '../src';
const ctx = {};
describe('exporter-curl', () => {
test('Exports GET with params', () => {
expect(
pluginHookExport(ctx, {
url: 'https://yaak.app',
urlParameters: [
{ name: 'a', value: 'aaa' },
{ name: 'b', value: 'bbb', enabled: true },
{ name: 'c', value: 'ccc', enabled: false },
],
}),
).toEqual(
[`curl 'https://yaak.app'`, `--url-query 'a=aaa'`, `--url-query 'b=bbb'`].join(` \\\n `),
);
});
test('Exports POST with url form data', () => {
expect(
pluginHookExport(ctx, {
url: 'https://yaak.app',
method: 'POST',
bodyType: 'application/x-www-form-urlencoded',
body: {
form: [
{ name: 'a', value: 'aaa' },
{ name: 'b', value: 'bbb', enabled: true },
{ name: 'c', value: 'ccc', enabled: false },
],
},
}),
).toEqual(
[`curl -X POST 'https://yaak.app'`, `--data 'a=aaa'`, `--data 'b=bbb'`].join(` \\\n `),
);
});
test('Exports PUT with multipart form', () => {
expect(
pluginHookExport(ctx, {
url: 'https://yaak.app',
method: 'PUT',
bodyType: 'multipart/form-data',
body: {
form: [
{ name: 'a', value: 'aaa' },
{ name: 'b', value: 'bbb', enabled: true },
{ name: 'c', value: 'ccc', enabled: false },
{ name: 'f', file: '/foo/bar.png', contentType: 'image/png' },
],
},
}),
).toEqual(
[
`curl -X PUT 'https://yaak.app'`,
`--form 'a=aaa'`,
`--form 'b=bbb'`,
`--form f=@/foo/bar.png;type=image/png`,
].join(` \\\n `),
);
});
test('Exports JSON body', () => {
expect(
pluginHookExport(ctx, {
url: 'https://yaak.app',
method: 'POST',
bodyType: 'application/json',
body: {
text: `{"foo":"bar's"}`,
},
headers: [{ name: 'Content-Type', value: 'application/json' }],
}),
).toEqual(
[
`curl -X POST 'https://yaak.app'`,
`--header 'Content-Type: application/json'`,
`--data-raw $'{"foo":"bar\\'s"}'`,
].join(` \\\n `),
);
});
test('Exports multi-line JSON body', () => {
expect(
pluginHookExport(ctx, {
url: 'https://yaak.app',
method: 'POST',
bodyType: 'application/json',
body: {
text: `{"foo":"bar",\n"baz":"qux"}`,
},
headers: [{ name: 'Content-Type', value: 'application/json' }],
}),
).toEqual(
[
`curl -X POST 'https://yaak.app'`,
`--header 'Content-Type: application/json'`,
`--data-raw $'{"foo":"bar",\n"baz":"qux"}'`,
].join(` \\\n `),
);
});
test('Exports headers', () => {
expect(
pluginHookExport(ctx, {
headers: [
{ name: 'a', value: 'aaa' },
{ name: 'b', value: 'bbb', enabled: true },
{ name: 'c', value: 'ccc', enabled: false },
],
}),
).toEqual([`curl`, `--header 'a: aaa'`, `--header 'b: bbb'`].join(` \\\n `));
});
test('Basic auth', () => {
expect(
pluginHookExport(ctx, {
url: 'https://yaak.app',
authenticationType: 'basic',
authentication: {
username: 'user',
password: 'pass',
},
}),
).toEqual([`curl 'https://yaak.app'`, `--user 'user:pass'`].join(` \\\n `));
});
test('Broken basic auth', () => {
expect(
pluginHookExport(ctx, {
url: 'https://yaak.app',
authenticationType: 'basic',
authentication: {},
}),
).toEqual([`curl 'https://yaak.app'`, `--user ':'`].join(` \\\n `));
});
test('Digest auth', () => {
expect(
pluginHookExport(ctx, {
url: 'https://yaak.app',
authenticationType: 'digest',
authentication: {
username: 'user',
password: 'pass',
},
}),
).toEqual([`curl 'https://yaak.app'`, `--digest --user 'user:pass'`].join(` \\\n `));
});
test('Bearer auth', () => {
expect(
pluginHookExport(ctx, {
url: 'https://yaak.app',
authenticationType: 'bearer',
authentication: {
token: 'tok',
},
}),
).toEqual([`curl 'https://yaak.app'`, `--header 'Authorization: Bearer tok'`].join(` \\\n `));
});
test('Broken bearer auth', () => {
expect(
pluginHookExport(ctx, {
url: 'https://yaak.app',
authenticationType: 'bearer',
authentication: {
username: 'user',
password: 'pass',
},
}),
).toEqual([`curl 'https://yaak.app'`, `--header 'Authorization: Bearer '`].join(` \\\n `));
});
});