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

@@ -1,8 +1,8 @@
import { YaakContext } from '@yaakapp/api';
import jp from 'jsonpath';
import { Context } from '@yaakapp/api';
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 filtered = jp.query(parsed, args.filter);
const filtered = JSONPath({ path: args.filter, json: parsed });
return JSON.stringify(filtered, null, 2);
}