mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-07-07 05:15:20 +02:00
Tweak plugins
This commit is contained in:
Generated
+13
-11
@@ -9,7 +9,7 @@
|
|||||||
"plugins/*"
|
"plugins/*"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@yaakapp/api": "^0.2.15"
|
"@yaakapp/api": "^0.2.16"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^22.7.4",
|
"@types/node": "^22.7.4",
|
||||||
@@ -1003,9 +1003,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@yaakapp/api": {
|
"node_modules/@yaakapp/api": {
|
||||||
"version": "0.2.15",
|
"version": "0.2.16",
|
||||||
"resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.2.15.tgz",
|
"resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.2.16.tgz",
|
||||||
"integrity": "sha512-SW5S3Ca00Qo8Z/IhzCWrSQU0CZHHHCZwuDZtJkjTbfVL5Lv0DAaZsORNEIaeHyuqeQU9xRoi+Wr/WHoA3bG6+A==",
|
"integrity": "sha512-rooweCKOMsqbTdSlb4vxe3wL19PpkVualZrtWvRelnUhIPgcJR8EMVNn/K2tZfLGKOXnthZi9xgFBeARnOyuSw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "^22.5.4"
|
"@types/node": "^22.5.4"
|
||||||
}
|
}
|
||||||
@@ -1042,8 +1042,8 @@
|
|||||||
"resolved": "plugins/importer-yaak",
|
"resolved": "plugins/importer-yaak",
|
||||||
"link": true
|
"link": true
|
||||||
},
|
},
|
||||||
"node_modules/@yaakapp/template-function-file": {
|
"node_modules/@yaakapp/template-function-fs": {
|
||||||
"resolved": "plugins/template-function-file",
|
"resolved": "plugins/template-function-fs",
|
||||||
"link": true
|
"link": true
|
||||||
},
|
},
|
||||||
"node_modules/@yaakapp/template-function-hash": {
|
"node_modules/@yaakapp/template-function-hash": {
|
||||||
@@ -1054,10 +1054,6 @@
|
|||||||
"resolved": "plugins/template-function-prompt",
|
"resolved": "plugins/template-function-prompt",
|
||||||
"link": true
|
"link": true
|
||||||
},
|
},
|
||||||
"node_modules/@yaakapp/template-function-request": {
|
|
||||||
"resolved": "plugins/template-function-request",
|
|
||||||
"link": true
|
|
||||||
},
|
|
||||||
"node_modules/aggregate-error": {
|
"node_modules/aggregate-error": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz",
|
||||||
@@ -6702,6 +6698,11 @@
|
|||||||
},
|
},
|
||||||
"plugins/template-function-file": {
|
"plugins/template-function-file": {
|
||||||
"name": "@yaakapp/template-function-file",
|
"name": "@yaakapp/template-function-file",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"extraneous": true
|
||||||
|
},
|
||||||
|
"plugins/template-function-fs": {
|
||||||
|
"name": "@yaakapp/template-function-fs",
|
||||||
"version": "0.0.1"
|
"version": "0.0.1"
|
||||||
},
|
},
|
||||||
"plugins/template-function-hash": {
|
"plugins/template-function-hash": {
|
||||||
@@ -6714,7 +6715,8 @@
|
|||||||
},
|
},
|
||||||
"plugins/template-function-request": {
|
"plugins/template-function-request": {
|
||||||
"name": "@yaakapp/template-function-request",
|
"name": "@yaakapp/template-function-request",
|
||||||
"version": "0.0.1"
|
"version": "0.0.1",
|
||||||
|
"extraneous": true
|
||||||
},
|
},
|
||||||
"plugins/template-function-response": {
|
"plugins/template-function-response": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
|
|||||||
+1
-1
@@ -19,6 +19,6 @@
|
|||||||
"workspaces-run": "^1.0.2"
|
"workspaces-run": "^1.0.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@yaakapp/api": "^0.2.15"
|
"@yaakapp/api": "^0.2.16"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "@yaakapp/template-function-file",
|
"name": "@yaakapp/template-function-fs",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -3,9 +3,9 @@ import { CallTemplateFunctionArgs, Context, PluginDefinition } from '@yaakapp/ap
|
|||||||
export const plugin: PluginDefinition = {
|
export const plugin: PluginDefinition = {
|
||||||
templateFunctions: [{
|
templateFunctions: [{
|
||||||
name: 'prompt.text',
|
name: 'prompt.text',
|
||||||
|
description: 'Prompt the user for input when sending a request',
|
||||||
args: [
|
args: [
|
||||||
{ type: 'text', name: 'title', label: 'Title' },
|
{ type: 'text', name: 'title', label: 'Title' },
|
||||||
{ type: 'text', name: 'label', label: 'Label', optional: true },
|
|
||||||
{ type: 'text', name: 'defaultValue', label: 'Default Value', optional: true },
|
{ type: 'text', name: 'defaultValue', label: 'Default Value', optional: true },
|
||||||
{ type: 'text', name: 'placeholder', label: 'Placeholder', optional: true },
|
{ type: 'text', name: 'placeholder', label: 'Placeholder', optional: true },
|
||||||
],
|
],
|
||||||
@@ -14,7 +14,7 @@ export const plugin: PluginDefinition = {
|
|||||||
|
|
||||||
return await ctx.prompt.text({
|
return await ctx.prompt.text({
|
||||||
id: `prompt-${args.values.label}`,
|
id: `prompt-${args.values.label}`,
|
||||||
label: args.values.label ?? '',
|
label: args.values.title ?? '',
|
||||||
title: args.values.title ?? '',
|
title: args.values.title ?? '',
|
||||||
defaultValue: args.values.defaultValue,
|
defaultValue: args.values.defaultValue,
|
||||||
placeholder: args.values.placeholder,
|
placeholder: args.values.placeholder,
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@yaakapp/template-function-request",
|
|
||||||
"private": true,
|
|
||||||
"version": "0.0.1",
|
|
||||||
"scripts": {
|
|
||||||
"build": "yaakcli build ./src/index.ts",
|
|
||||||
"dev": "yaakcli dev ./src/index.js"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
import { CallTemplateFunctionArgs, Context, PluginDefinition } from '@yaakapp/api';
|
|
||||||
|
|
||||||
export const plugin: PluginDefinition = {
|
|
||||||
templateFunctions: [
|
|
||||||
{
|
|
||||||
name: 'request.body',
|
|
||||||
args: [{
|
|
||||||
name: 'requestId',
|
|
||||||
label: 'Http Request',
|
|
||||||
type: 'http_request',
|
|
||||||
}],
|
|
||||||
async onRender(ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
|
|
||||||
const httpRequest = await ctx.httpRequest.getById({ id: args.values.requestId ?? 'n/a' });
|
|
||||||
if (httpRequest == null) return null;
|
|
||||||
return String(await ctx.templates.render({
|
|
||||||
data: httpRequest.body?.text ?? '',
|
|
||||||
purpose: args.purpose,
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'request.header',
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
name: 'requestId',
|
|
||||||
label: 'Http Request',
|
|
||||||
type: 'http_request',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'header',
|
|
||||||
label: 'Header Name',
|
|
||||||
type: 'text',
|
|
||||||
}],
|
|
||||||
async onRender(ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
|
|
||||||
const httpRequest = await ctx.httpRequest.getById({ id: args.values.requestId ?? 'n/a' });
|
|
||||||
if (httpRequest == null) return null;
|
|
||||||
const header = httpRequest.headers.find(h => h.name.toLowerCase() === args.values.header?.toLowerCase());
|
|
||||||
return String(await ctx.templates.render({
|
|
||||||
data: header?.value ?? '',
|
|
||||||
purpose: args.purpose,
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
@@ -61,6 +61,7 @@ export const plugin: PluginDefinition = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'response.body.path',
|
name: 'response.body.path',
|
||||||
|
description: 'Access a field of the response body using JsonPath or XPath',
|
||||||
aliases: ['response'],
|
aliases: ['response'],
|
||||||
args: [
|
args: [
|
||||||
requestArg,
|
requestArg,
|
||||||
@@ -108,6 +109,38 @@ export const plugin: PluginDefinition = {
|
|||||||
return null; // Bail out
|
return null; // Bail out
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'response.body.raw',
|
||||||
|
description: 'Access the entire response body, as text',
|
||||||
|
aliases: ['response'],
|
||||||
|
args: [
|
||||||
|
requestArg,
|
||||||
|
behaviorArg,
|
||||||
|
],
|
||||||
|
async onRender(ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
|
||||||
|
if (!args.values.request) return null;
|
||||||
|
|
||||||
|
const response = await getResponse(ctx, {
|
||||||
|
requestId: args.values.request,
|
||||||
|
purpose: args.purpose,
|
||||||
|
behavior: args.values.behavior ?? null,
|
||||||
|
});
|
||||||
|
if (response == null) return null;
|
||||||
|
|
||||||
|
if (response.bodyPath == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
let body;
|
||||||
|
try {
|
||||||
|
body = readFileSync(response.bodyPath, 'utf-8');
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return body;
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user