mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-16 14:06:49 +01:00
gRPC request actions and "copy as gRPCurl" (#232)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { CallTemplateFunctionArgs, Context, PluginDefinition } from '@yaakapp/api';
|
||||
import type { CallTemplateFunctionArgs, Context, PluginDefinition } from '@yaakapp/api';
|
||||
|
||||
export const plugin: PluginDefinition = {
|
||||
templateFunctions: [
|
||||
@@ -7,7 +7,7 @@ export const plugin: PluginDefinition = {
|
||||
description: 'Encode a value to base64',
|
||||
args: [{ label: 'Plain Text', type: 'text', name: 'value', multiLine: true }],
|
||||
async onRender(_ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
|
||||
return Buffer.from(args.values.value ?? '').toString('base64');
|
||||
return Buffer.from(String(args.values.value ?? '')).toString('base64');
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -15,7 +15,7 @@ export const plugin: PluginDefinition = {
|
||||
description: 'Decode a value from base64',
|
||||
args: [{ label: 'Encoded Value', type: 'text', name: 'value', multiLine: true }],
|
||||
async onRender(_ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
|
||||
return Buffer.from(args.values.value ?? '', 'base64').toString('utf-8');
|
||||
return Buffer.from(String(args.values.value ?? ''), 'base64').toString('utf-8');
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -23,7 +23,7 @@ export const plugin: PluginDefinition = {
|
||||
description: 'Encode a value for use in a URL (percent-encoding)',
|
||||
args: [{ label: 'Plain Text', type: 'text', name: 'value', multiLine: true }],
|
||||
async onRender(_ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
|
||||
return encodeURIComponent(args.values.value ?? '');
|
||||
return encodeURIComponent(String(args.values.value ?? ''));
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -32,7 +32,7 @@ export const plugin: PluginDefinition = {
|
||||
args: [{ label: 'Encoded Value', type: 'text', name: 'value', multiLine: true }],
|
||||
async onRender(_ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
|
||||
try {
|
||||
return decodeURIComponent(args.values.value ?? '');
|
||||
return decodeURIComponent(String(args.values.value ?? ''));
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user