Skip to content

Commit

Permalink
Fix deps
Browse files Browse the repository at this point in the history
  • Loading branch information
gschier committed Oct 2, 2024
1 parent ae39276 commit 124a01f
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 45 deletions.
41 changes: 37 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"workspaces-run": "^1.0.2"
},
"dependencies": {
"@yaakapp/api": "^0.2.12"
"@yaakapp/api": "^0.2.15"
}
}
3 changes: 3 additions & 0 deletions plugins/importer-curl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
},
"dependencies": {
"shell-quote": "^1.8.1"
},
"devDependencies": {
"@types/shell-quote": "^1.7.5"
}
}
3 changes: 3 additions & 0 deletions plugins/importer-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
"dependencies": {
"openapi-to-postmanv2": "^4.23.1",
"yaml": "^2.4.2"
},
"devDependencies": {
"@types/openapi-to-postmanv2": "^3.2.4"
}
}
2 changes: 1 addition & 1 deletion plugins/importer-openapi/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Context } from '@yaakapp/api';
import { convert } from 'openapi-to-postmanv2';
import { pluginHookImport as pluginHookImportPostman } from '../../importer-postman/src/index';
import { Folder, HttpRequest, Workspace, Environment } from '../../../types/models';
import { Folder, HttpRequest, Workspace, Environment } from '@yaakapp/api';

type AtLeast<T, K extends keyof T> = Partial<T> & Pick<T, K>;

Expand Down
11 changes: 8 additions & 3 deletions plugins/template-function-file/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import fs from 'node:fs';
export const plugin: PluginDefinition = {
templateFunctions: [{
name: 'fs.readFile',
args: [{ type: 'file', name: 'path', label: 'File' }],
async onRender(ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
args: [{ title: 'Select File', type: 'file', name: 'path', label: 'File' }],
async onRender(_ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
if (!args.values.path) return null;
return fs.promises.readFile(args.values.path, 'utf-8');

try {
return fs.promises.readFile(args.values.path, 'utf-8');
} catch (err) {
return null;
}
},
}],
};
10 changes: 5 additions & 5 deletions plugins/template-function-prompt/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CallTemplateFunctionArgs, Context, PluginDefinition, ShowPromptRequest } from '@yaakapp/api';
import { CallTemplateFunctionArgs, Context, PluginDefinition } from '@yaakapp/api';

export const plugin: PluginDefinition = {
templateFunctions: [{
Expand All @@ -12,13 +12,13 @@ export const plugin: PluginDefinition = {
async onRender(ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
if (args.purpose !== 'send') return null;

return await ctx.prompt.show({
return await ctx.prompt.text({
id: `prompt-${args.values.label}`,
label: args.values.label,
title: args.values.title,
label: args.values.label ?? '',
title: args.values.title ?? '',
defaultValue: args.values.defaultValue,
placeholder: args.values.placeholder,
} as ShowPromptRequest);
});
},
}],
};
61 changes: 30 additions & 31 deletions plugins/template-function-response/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,47 @@
import { DOMParser } from '@xmldom/xmldom';
import { CallTemplateFunctionArgs, Context, HttpResponse, PluginDefinition, RenderPurpose } from '@yaakapp/api';
import {
CallTemplateFunctionArgs,
Context,
HttpResponse,
PluginDefinition,
RenderPurpose,
TemplateFunctionArg,
} from '@yaakapp/api';
import { JSONPath } from 'jsonpath-plus';
import { readFileSync } from 'node:fs';
import xpath from 'xpath';

const behaviorArg: TemplateFunctionArg = {
type: 'select',
name: 'behavior',
label: 'Sending Behavior',
defaultValue: 'smart',
options: [
{ label: 'When no responses', value: 'smart' },
{ label: 'Always', value: 'always' },
],
};

const requestArg: TemplateFunctionArg =
{
type: 'http_request',
name: 'request',
label: 'Request',
};

export const plugin: PluginDefinition = {
templateFunctions: [
{
name: 'response.header',
args: [
{
type: 'http_request',
name: 'request',
label: 'Request',
},
requestArg,
{
type: 'text',
name: 'header',
label: 'Header Name',
placeholder: 'Content-Type',
},
{
type: 'select',
name: 'behavior',
label: 'Sending Behavior',
defaultValue: 'smart',
options: [
{ name: 'When no responses', value: 'smart' },
{ name: 'Always', value: 'always' },
],
},
behaviorArg,
],
async onRender(ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
if (!args.values.request || !args.values.header) return null;
Expand All @@ -51,27 +63,14 @@ export const plugin: PluginDefinition = {
name: 'response.body.path',
aliases: ['response'],
args: [
{
type: 'http_request',
name: 'request',
label: 'Request',
},
requestArg,
{
type: 'text',
name: 'path',
label: 'JSONPath or XPath',
placeholder: '$.books[0].id or /books[0]/id',
},
{
type: 'select',
name: 'behavior',
label: 'Sending Behavior',
defaultValue: 'smart',
options: [
{ name: 'When no responses', value: 'smart' },
{ name: 'Always', value: 'always' },
],
},
behaviorArg,
],
async onRender(ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
if (!args.values.request || !args.values.path) return null;
Expand Down

0 comments on commit 124a01f

Please sign in to comment.