From 124a01f377eda180af692ce4d6bbe35514ffbf27 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Wed, 2 Oct 2024 06:51:19 -0700 Subject: [PATCH] Fix deps --- package-lock.json | 41 +++++++++++-- package.json | 2 +- plugins/importer-curl/package.json | 3 + plugins/importer-openapi/package.json | 3 + plugins/importer-openapi/src/index.ts | 2 +- plugins/template-function-file/src/index.ts | 11 +++- plugins/template-function-prompt/src/index.ts | 10 +-- .../template-function-response/src/index.ts | 61 +++++++++---------- 8 files changed, 88 insertions(+), 45 deletions(-) diff --git a/package-lock.json b/package-lock.json index a980d60..b488ea6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "plugins/*" ], "dependencies": { - "@yaakapp/api": "^0.2.12" + "@yaakapp/api": "^0.2.15" }, "devDependencies": { "@types/node": "^22.7.4", @@ -885,6 +885,33 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/openapi-to-postmanv2": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@types/openapi-to-postmanv2/-/openapi-to-postmanv2-3.2.4.tgz", + "integrity": "sha512-5SMU3TY2gmQRs6Ri7WRlI7tF2QEK0K4GfL50ghAPOUv4NkxhG37Aq2qystytm9fcmUgHDfyrkwZyprRgp85mxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/postman-collection": "*" + } + }, + "node_modules/@types/postman-collection": { + "version": "3.5.10", + "resolved": "https://registry.npmjs.org/@types/postman-collection/-/postman-collection-3.5.10.tgz", + "integrity": "sha512-l8xAUZNW9MzKWyeWuPgQlnyvpX8beeLqXYZTixr55Figae8/0gFb5l5GcU1y+3yeDmbXdY57cGxdvu+4OGbMdg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/shell-quote": { + "version": "1.7.5", + "resolved": "https://registry.npmjs.org/@types/shell-quote/-/shell-quote-1.7.5.tgz", + "integrity": "sha512-+UE8GAGRPbJVQDdxi16dgadcBfQ+KG2vgZhV1+3A1XmHbmwcdwhCUwIdy+d3pAGrbvgRoVSjeI9vOWyq376Yzw==", + "dev": true, + "license": "MIT" + }, "node_modules/@vitest/expect": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-2.0.4.tgz", @@ -976,9 +1003,9 @@ } }, "node_modules/@yaakapp/api": { - "version": "0.2.12", - "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.2.12.tgz", - "integrity": "sha512-ROlGUrl98cUlQGHLNMOkEQfLlvryHj8oLcoBkxr5bnxtIS1LUK+Y/6+qYni8zVF9bOIyGD462DEsWcFR5vmDbA==", + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.2.15.tgz", + "integrity": "sha512-SW5S3Ca00Qo8Z/IhzCWrSQU0CZHHHCZwuDZtJkjTbfVL5Lv0DAaZsORNEIaeHyuqeQU9xRoi+Wr/WHoA3bG6+A==", "dependencies": { "@types/node": "^22.5.4" } @@ -6642,6 +6669,9 @@ "version": "0.0.1", "dependencies": { "shell-quote": "^1.8.1" + }, + "devDependencies": { + "@types/shell-quote": "^1.7.5" } }, "plugins/importer-insomnia": { @@ -6657,6 +6687,9 @@ "dependencies": { "openapi-to-postmanv2": "^4.23.1", "yaml": "^2.4.2" + }, + "devDependencies": { + "@types/openapi-to-postmanv2": "^3.2.4" } }, "plugins/importer-postman": { diff --git a/package.json b/package.json index e2ceac0..1633ca2 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,6 @@ "workspaces-run": "^1.0.2" }, "dependencies": { - "@yaakapp/api": "^0.2.12" + "@yaakapp/api": "^0.2.15" } } diff --git a/plugins/importer-curl/package.json b/plugins/importer-curl/package.json index f7f87d2..53ef8d3 100644 --- a/plugins/importer-curl/package.json +++ b/plugins/importer-curl/package.json @@ -8,5 +8,8 @@ }, "dependencies": { "shell-quote": "^1.8.1" + }, + "devDependencies": { + "@types/shell-quote": "^1.7.5" } } diff --git a/plugins/importer-openapi/package.json b/plugins/importer-openapi/package.json index ef7f71a..9ea28dd 100644 --- a/plugins/importer-openapi/package.json +++ b/plugins/importer-openapi/package.json @@ -9,5 +9,8 @@ "dependencies": { "openapi-to-postmanv2": "^4.23.1", "yaml": "^2.4.2" + }, + "devDependencies": { + "@types/openapi-to-postmanv2": "^3.2.4" } } diff --git a/plugins/importer-openapi/src/index.ts b/plugins/importer-openapi/src/index.ts index 6ff684b..87b8a11 100644 --- a/plugins/importer-openapi/src/index.ts +++ b/plugins/importer-openapi/src/index.ts @@ -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 = Partial & Pick; diff --git a/plugins/template-function-file/src/index.ts b/plugins/template-function-file/src/index.ts index 79b9b5c..472c1a0 100644 --- a/plugins/template-function-file/src/index.ts +++ b/plugins/template-function-file/src/index.ts @@ -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 { + args: [{ title: 'Select File', type: 'file', name: 'path', label: 'File' }], + async onRender(_ctx: Context, args: CallTemplateFunctionArgs): Promise { 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; + } }, }], }; diff --git a/plugins/template-function-prompt/src/index.ts b/plugins/template-function-prompt/src/index.ts index fc89c54..4941253 100644 --- a/plugins/template-function-prompt/src/index.ts +++ b/plugins/template-function-prompt/src/index.ts @@ -1,4 +1,4 @@ -import { CallTemplateFunctionArgs, Context, PluginDefinition, ShowPromptRequest } from '@yaakapp/api'; +import { CallTemplateFunctionArgs, Context, PluginDefinition } from '@yaakapp/api'; export const plugin: PluginDefinition = { templateFunctions: [{ @@ -12,13 +12,13 @@ export const plugin: PluginDefinition = { async onRender(ctx: Context, args: CallTemplateFunctionArgs): Promise { 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); + }); }, }], }; diff --git a/plugins/template-function-response/src/index.ts b/plugins/template-function-response/src/index.ts index ca640bb..ae5018a 100644 --- a/plugins/template-function-response/src/index.ts +++ b/plugins/template-function-response/src/index.ts @@ -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 { if (!args.values.request || !args.values.header) return null; @@ -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 { if (!args.values.request || !args.values.path) return null;