mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-17 23:13:51 +01:00
Merge plugins repo into mono
This commit is contained in:
15
plugins/filter-jsonpath/package.json
Normal file
15
plugins/filter-jsonpath/package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "@yaakapp/filter-jsonpath",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
"build": "yaakcli build ./src/index.ts",
|
||||
"dev": "yaakcli dev ./src/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"jsonpath-plus": "^10.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jsonpath": "^0.2.4"
|
||||
}
|
||||
}
|
||||
14
plugins/filter-jsonpath/src/index.ts
Normal file
14
plugins/filter-jsonpath/src/index.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { PluginDefinition } from '@yaakapp/api';
|
||||
import { JSONPath } from 'jsonpath-plus';
|
||||
|
||||
export const plugin: PluginDefinition = {
|
||||
filter: {
|
||||
name: 'JSONPath',
|
||||
description: 'Filter JSONPath',
|
||||
onFilter(_ctx, args) {
|
||||
const parsed = JSON.parse(args.payload);
|
||||
const filtered = JSONPath({ path: args.filter, json: parsed });
|
||||
return { filtered: JSON.stringify(filtered, null, 2) };
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user