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

View File

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

View File

@@ -1,14 +1,17 @@
{
"name": "filter-xpath",
"private": true,
"version": "0.0.1",
"scripts": {
"build": "yaakcli ./src/index.js"
},
"dependencies": {
"@yaakapp/api": "^0.1.6",
"@types/node": "^20.14.9",
"@yaakapp/api": "^0.1.9",
"@xmldom/xmldom": "^0.8.10",
"typescript": "^5.5.2",
"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 { YaakContext } from '@yaakapp/api';
import { Context } from '@yaakapp/api';
import xpath from 'xpath';
export function pluginHookResponseFilter(
_ctx: YaakContext,
_ctx: Context,
{ filter, body }: { filter: string; body: string },
) {
const doc = new DOMParser().parseFromString(body, 'text/xml');