snapshot of https://github.com/mountain-loop/yaak.git (main, 2026-09-23; blobs > 131072B omitted)
Some checks failed
Lint and Test / Lint/Test (push) Has been cancelled
Generate Sponsors README / deploy (push) Has been skipped

This commit is contained in:
upstream-mirror
2026-09-23 17:39:41 +05:00
commit 906fb231cc
1544 changed files with 164131 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
{
"name": "@yaak/filter-xpath",
"displayName": "XPath Filter",
"version": "0.1.0",
"private": true,
"description": "Filter response XML data using XPath expressions",
"scripts": {
"build": "yaakcli build",
"dev": "yaakcli dev"
},
"dependencies": {
"@xmldom/xmldom": "^0.9.12",
"xpath": "^0.0.34"
}
}

View File

@@ -0,0 +1,28 @@
/* oxlint-disable no-base-to-string */
import { DOMParser } from "@xmldom/xmldom";
import type { PluginDefinition } from "@yaakapp/api";
import xpath from "xpath";
export const plugin: PluginDefinition = {
filter: {
name: "XPath",
description: "Filter XPath",
onFilter(_ctx, args) {
// oxlint-disable-next-line no-explicit-any
const doc: any = new DOMParser().parseFromString(args.payload, "text/xml");
try {
const result = xpath.select(args.filter, doc, false);
if (Array.isArray(result)) {
return { content: result.map((r) => String(r)).join("\n") };
}
// Not sure what cases this happens in (?)
return { content: String(result) };
} catch (err) {
return {
content: "",
error: `Invalid filter: ${err instanceof Error ? err.message : String(err)}`,
};
}
},
},
};

View File

@@ -0,0 +1,3 @@
{
"extends": "../../tsconfig.json"
}