mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-22 01:19:13 +01:00
Add new plugins
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "exporter-curl",
|
||||
"name": "@yaakapp/exporter-curl",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "filter-jsonpath",
|
||||
"name": "@yaakapp/filter-jsonpath",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "filter-xpath",
|
||||
"name": "@yaakapp/filter-xpath",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "importer-curl",
|
||||
"name": "@yaakapp/importer-curl",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
@@ -8,5 +8,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"shell-quote": "^1.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/shell-quote": "^1.7.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "importer-insomnia",
|
||||
"name": "@yaakapp/importer-insomnia",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "importer-openapi",
|
||||
"name": "@yaakapp/importer-openapi",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
@@ -9,5 +9,8 @@
|
||||
"dependencies": {
|
||||
"openapi-to-postmanv2": "^4.23.1",
|
||||
"yaml": "^2.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/openapi-to-postmanv2": "^3.2.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "importer-postman",
|
||||
"name": "@yaakapp/importer-postman",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"main": "./build/index.js",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "importer-yaak",
|
||||
"name": "@yaakapp/importer-yaak",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
|
||||
54
src-tauri/vendored/plugins/template-function-file/build/index.js
generated
Normal file
54
src-tauri/vendored/plugins/template-function-file/build/index.js
generated
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
plugin: () => plugin
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
var import_node_fs = __toESM(require("node:fs"));
|
||||
var plugin = {
|
||||
templateFunctions: [{
|
||||
name: "fs.readFile",
|
||||
args: [{ title: "Select File", type: "file", name: "path", label: "File" }],
|
||||
async onRender(_ctx, args) {
|
||||
if (!args.values.path) return null;
|
||||
try {
|
||||
return import_node_fs.default.promises.readFile(args.values.path, "utf-8");
|
||||
} catch (err) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}]
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
plugin
|
||||
});
|
||||
9
src-tauri/vendored/plugins/template-function-file/package.json
generated
Normal file
9
src-tauri/vendored/plugins/template-function-file/package.json
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "@yaakapp/template-function-file",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
"build": "yaakcli build ./src/index.ts",
|
||||
"dev": "yaakcli dev ./src/index.js"
|
||||
}
|
||||
}
|
||||
48
src-tauri/vendored/plugins/template-function-hash/build/index.js
generated
Normal file
48
src-tauri/vendored/plugins/template-function-hash/build/index.js
generated
Normal file
@@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
plugin: () => plugin
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
var import_node_crypto = require("node:crypto");
|
||||
var algorithms = ["md5", "sha1", "sha256", "sha512"];
|
||||
var plugin = {
|
||||
templateFunctions: algorithms.map((algorithm) => ({
|
||||
name: `hash.${algorithm}`,
|
||||
args: [
|
||||
{
|
||||
name: "input",
|
||||
label: "Input",
|
||||
placeholder: "input text",
|
||||
type: "text"
|
||||
}
|
||||
],
|
||||
async onRender(_ctx, args) {
|
||||
if (!args.values.input) return "";
|
||||
return (0, import_node_crypto.createHash)(algorithm).update(args.values.input, "utf-8").digest("hex");
|
||||
}
|
||||
}))
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
plugin
|
||||
});
|
||||
9
src-tauri/vendored/plugins/template-function-hash/package.json
generated
Executable file
9
src-tauri/vendored/plugins/template-function-hash/package.json
generated
Executable file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "@yaakapp/template-function-hash",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
"build": "yaakcli build ./src/index.ts",
|
||||
"dev": "yaakcli dev ./src/index.js"
|
||||
}
|
||||
}
|
||||
53
src-tauri/vendored/plugins/template-function-prompt/build/index.js
generated
Normal file
53
src-tauri/vendored/plugins/template-function-prompt/build/index.js
generated
Normal file
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
plugin: () => plugin
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
var plugin = {
|
||||
templateFunctions: [{
|
||||
name: "prompt.text",
|
||||
args: [
|
||||
{ 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: "placeholder", label: "Placeholder", optional: true }
|
||||
],
|
||||
async onRender(ctx, args) {
|
||||
console.log("PROMPT", args);
|
||||
if (args.purpose !== "send") return null;
|
||||
const value = await ctx.prompt.text({
|
||||
id: `prompt-${args.values.label}`,
|
||||
label: args.values.label ?? "",
|
||||
title: args.values.title ?? "",
|
||||
defaultValue: args.values.defaultValue,
|
||||
placeholder: args.values.placeholder
|
||||
});
|
||||
console.log("VALUE", value);
|
||||
return value;
|
||||
}
|
||||
}]
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
plugin
|
||||
});
|
||||
9
src-tauri/vendored/plugins/template-function-prompt/package.json
generated
Normal file
9
src-tauri/vendored/plugins/template-function-prompt/package.json
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "@yaakapp/template-function-prompt",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
"build": "yaakcli build ./src/index.ts",
|
||||
"dev": "yaakcli dev ./src/index.js"
|
||||
}
|
||||
}
|
||||
@@ -27,12 +27,18 @@ var plugin = {
|
||||
templateFunctions: [
|
||||
{
|
||||
name: "request.body",
|
||||
args: [],
|
||||
args: [{
|
||||
name: "requestId",
|
||||
label: "Http Request",
|
||||
type: "http_request"
|
||||
}],
|
||||
async onRender(ctx, args) {
|
||||
const httpRequest = await ctx.httpRequest.getById({ id: args.values.request ?? "n/a" });
|
||||
const httpRequest = await ctx.httpRequest.getById({ id: args.values.requestId ?? "n/a" });
|
||||
if (httpRequest == null) return null;
|
||||
const rendered = await ctx.httpRequest.render({ httpRequest, purpose: args.purpose });
|
||||
return rendered.body.text ?? "";
|
||||
return String(await ctx.templates.render({
|
||||
data: httpRequest.body?.text ?? "",
|
||||
purpose: args.purpose
|
||||
}));
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -52,8 +58,11 @@ var plugin = {
|
||||
async onRender(ctx, args) {
|
||||
const httpRequest = await ctx.httpRequest.getById({ id: args.values.requestId ?? "n/a" });
|
||||
if (httpRequest == null) return null;
|
||||
const rendered = await ctx.httpRequest.render({ httpRequest, purpose: args.purpose });
|
||||
return rendered.headers.find((h) => h.name.toLowerCase() === args.values.header?.toLowerCase())?.value ?? "";
|
||||
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
|
||||
}));
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
{
|
||||
"name": "template-function-request",
|
||||
"name": "@yaakapp/template-function-request",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
"build": "yaakcli build ./src/index.ts",
|
||||
"dev": "yaakcli dev ./src/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"jsonpath-plus": "^9.0.0",
|
||||
"xpath": "^0.0.34",
|
||||
"@xmldom/xmldom": "^0.8.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jsonpath": "^0.2.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8818,73 +8818,91 @@ var SafeScript = import_vm.default.Script;
|
||||
// src/index.ts
|
||||
var import_node_fs = require("node:fs");
|
||||
var import_xpath = __toESM(require_xpath());
|
||||
var behaviorArg = {
|
||||
type: "select",
|
||||
name: "behavior",
|
||||
label: "Sending Behavior",
|
||||
defaultValue: "smart",
|
||||
options: [
|
||||
{ label: "When no responses", value: "smart" },
|
||||
{ label: "Always", value: "always" }
|
||||
]
|
||||
};
|
||||
var requestArg = {
|
||||
type: "http_request",
|
||||
name: "request",
|
||||
label: "Request"
|
||||
};
|
||||
var plugin = {
|
||||
templateFunctions: [{
|
||||
name: "response",
|
||||
args: [
|
||||
{
|
||||
type: "http_request",
|
||||
name: "request",
|
||||
label: "Request"
|
||||
},
|
||||
{
|
||||
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" }
|
||||
]
|
||||
templateFunctions: [
|
||||
{
|
||||
name: "response.header",
|
||||
args: [
|
||||
requestArg,
|
||||
{
|
||||
type: "text",
|
||||
name: "header",
|
||||
label: "Header Name",
|
||||
placeholder: "Content-Type"
|
||||
},
|
||||
behaviorArg
|
||||
],
|
||||
async onRender(ctx, args) {
|
||||
if (!args.values.request || !args.values.header) return null;
|
||||
const response = await getResponse(ctx, {
|
||||
requestId: args.values.request,
|
||||
purpose: args.purpose,
|
||||
behavior: args.values.behavior ?? null
|
||||
});
|
||||
if (response == null) return null;
|
||||
const header = response.headers.find(
|
||||
(h) => h.name.toLowerCase() === String(args.values.header ?? "").toLowerCase()
|
||||
);
|
||||
return header?.value ?? null;
|
||||
}
|
||||
],
|
||||
async onRender(ctx, args) {
|
||||
if (!args.values.request || !args.values.path) {
|
||||
},
|
||||
{
|
||||
name: "response.body.path",
|
||||
aliases: ["response"],
|
||||
args: [
|
||||
requestArg,
|
||||
{
|
||||
type: "text",
|
||||
name: "path",
|
||||
label: "JSONPath or XPath",
|
||||
placeholder: "$.books[0].id or /books[0]/id"
|
||||
},
|
||||
behaviorArg
|
||||
],
|
||||
async onRender(ctx, args) {
|
||||
if (!args.values.request || !args.values.path) 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 = (0, import_node_fs.readFileSync)(response.bodyPath, "utf-8");
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return filterJSONPath(body, args.values.path);
|
||||
} catch (err) {
|
||||
}
|
||||
try {
|
||||
return filterXPath(body, args.values.path);
|
||||
} catch (err) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
const httpRequest = await ctx.httpRequest.getById({ id: args.values.request ?? "n/a" });
|
||||
if (httpRequest == null) {
|
||||
return null;
|
||||
}
|
||||
const responses = await ctx.httpResponse.find({ requestId: httpRequest.id, limit: 1 });
|
||||
if (args.values.behavior === "never" && responses.length === 0) {
|
||||
return null;
|
||||
}
|
||||
let response = responses[0] ?? null;
|
||||
let behavior = args.values.behavior === "always" && args.purpose === "preview" ? "smart" : args.values.behavior;
|
||||
if (behavior === "smart" && response == null || behavior === "always") {
|
||||
const renderedHttpRequest = await ctx.httpRequest.render({ httpRequest, purpose: args.purpose });
|
||||
response = await ctx.httpRequest.send({ httpRequest: renderedHttpRequest });
|
||||
}
|
||||
if (response == null) {
|
||||
return null;
|
||||
}
|
||||
if (response.bodyPath == null) {
|
||||
return null;
|
||||
}
|
||||
let body;
|
||||
try {
|
||||
body = (0, import_node_fs.readFileSync)(response.bodyPath, "utf-8");
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return filterJSONPath(body, args.values.path);
|
||||
} catch (err) {
|
||||
}
|
||||
try {
|
||||
return filterXPath(body, args.values.path);
|
||||
} catch (err) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}]
|
||||
]
|
||||
};
|
||||
function filterJSONPath(body, path) {
|
||||
const parsed = JSON.parse(body);
|
||||
@@ -8907,6 +8925,24 @@ function filterXPath(body, path) {
|
||||
return String(items);
|
||||
}
|
||||
}
|
||||
async function getResponse(ctx, { requestId, behavior, purpose }) {
|
||||
if (!requestId) return null;
|
||||
const httpRequest = await ctx.httpRequest.getById({ id: requestId ?? "n/a" });
|
||||
if (httpRequest == null) {
|
||||
return null;
|
||||
}
|
||||
const responses = await ctx.httpResponse.find({ requestId: httpRequest.id, limit: 1 });
|
||||
if (behavior === "never" && responses.length === 0) {
|
||||
return null;
|
||||
}
|
||||
let response = responses[0] ?? null;
|
||||
let finalBehavior = behavior === "always" && purpose === "preview" ? "smart" : behavior;
|
||||
if (finalBehavior === "smart" && response == null || finalBehavior === "always") {
|
||||
const renderedHttpRequest = await ctx.httpRequest.render({ httpRequest, purpose });
|
||||
response = await ctx.httpRequest.send({ httpRequest: renderedHttpRequest });
|
||||
}
|
||||
return response;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
plugin
|
||||
|
||||
Reference in New Issue
Block a user