mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-21 08:21:19 +02:00
Add new plugins
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "exporter-curl",
|
"name": "@yaakapp/exporter-curl",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "filter-jsonpath",
|
"name": "@yaakapp/filter-jsonpath",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "filter-xpath",
|
"name": "@yaakapp/filter-xpath",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "importer-curl",
|
"name": "@yaakapp/importer-curl",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -8,5 +8,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"shell-quote": "^1.8.1"
|
"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,
|
"private": true,
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "importer-openapi",
|
"name": "@yaakapp/importer-openapi",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -9,5 +9,8 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"openapi-to-postmanv2": "^4.23.1",
|
"openapi-to-postmanv2": "^4.23.1",
|
||||||
"yaml": "^2.4.2"
|
"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,
|
"private": true,
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"main": "./build/index.js",
|
"main": "./build/index.js",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "importer-yaak",
|
"name": "@yaakapp/importer-yaak",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"scripts": {
|
"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: [
|
templateFunctions: [
|
||||||
{
|
{
|
||||||
name: "request.body",
|
name: "request.body",
|
||||||
args: [],
|
args: [{
|
||||||
|
name: "requestId",
|
||||||
|
label: "Http Request",
|
||||||
|
type: "http_request"
|
||||||
|
}],
|
||||||
async onRender(ctx, args) {
|
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;
|
if (httpRequest == null) return null;
|
||||||
const rendered = await ctx.httpRequest.render({ httpRequest, purpose: args.purpose });
|
return String(await ctx.templates.render({
|
||||||
return rendered.body.text ?? "";
|
data: httpRequest.body?.text ?? "",
|
||||||
|
purpose: args.purpose
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -52,8 +58,11 @@ var plugin = {
|
|||||||
async onRender(ctx, args) {
|
async onRender(ctx, args) {
|
||||||
const httpRequest = await ctx.httpRequest.getById({ id: args.values.requestId ?? "n/a" });
|
const httpRequest = await ctx.httpRequest.getById({ id: args.values.requestId ?? "n/a" });
|
||||||
if (httpRequest == null) return null;
|
if (httpRequest == null) return null;
|
||||||
const rendered = await ctx.httpRequest.render({ httpRequest, purpose: args.purpose });
|
const header = httpRequest.headers.find((h) => h.name.toLowerCase() === args.values.header?.toLowerCase());
|
||||||
return rendered.headers.find((h) => h.name.toLowerCase() === args.values.header?.toLowerCase())?.value ?? "";
|
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,
|
"private": true,
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "yaakcli build ./src/index.ts",
|
"build": "yaakcli build ./src/index.ts",
|
||||||
"dev": "yaakcli dev ./src/index.js"
|
"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
|
// src/index.ts
|
||||||
var import_node_fs = require("node:fs");
|
var import_node_fs = require("node:fs");
|
||||||
var import_xpath = __toESM(require_xpath());
|
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 = {
|
var plugin = {
|
||||||
templateFunctions: [{
|
templateFunctions: [
|
||||||
name: "response",
|
{
|
||||||
args: [
|
name: "response.header",
|
||||||
{
|
args: [
|
||||||
type: "http_request",
|
requestArg,
|
||||||
name: "request",
|
{
|
||||||
label: "Request"
|
type: "text",
|
||||||
},
|
name: "header",
|
||||||
{
|
label: "Header Name",
|
||||||
type: "text",
|
placeholder: "Content-Type"
|
||||||
name: "path",
|
},
|
||||||
label: "JSONPath or XPath",
|
behaviorArg
|
||||||
placeholder: "$.books[0].id or /books[0]/id"
|
],
|
||||||
},
|
async onRender(ctx, args) {
|
||||||
{
|
if (!args.values.request || !args.values.header) return null;
|
||||||
type: "select",
|
const response = await getResponse(ctx, {
|
||||||
name: "behavior",
|
requestId: args.values.request,
|
||||||
label: "Sending Behavior",
|
purpose: args.purpose,
|
||||||
defaultValue: "smart",
|
behavior: args.values.behavior ?? null
|
||||||
options: [
|
});
|
||||||
{ name: "When no responses", value: "smart" },
|
if (response == null) return null;
|
||||||
{ name: "Always", value: "always" }
|
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;
|
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) {
|
function filterJSONPath(body, path) {
|
||||||
const parsed = JSON.parse(body);
|
const parsed = JSON.parse(body);
|
||||||
@@ -8907,6 +8925,24 @@ function filterXPath(body, path) {
|
|||||||
return String(items);
|
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:
|
// Annotate the CommonJS export names for ESM import in node:
|
||||||
0 && (module.exports = {
|
0 && (module.exports = {
|
||||||
plugin
|
plugin
|
||||||
|
|||||||
@@ -18,11 +18,12 @@ export function useActiveWorkspaceChangedToast() {
|
|||||||
if (id === null) return;
|
if (id === null) return;
|
||||||
|
|
||||||
toast.show({
|
toast.show({
|
||||||
id: 'workspace-changed',
|
id: `workspace-changed-${activeWorkspace.id}`,
|
||||||
timeout: 3000,
|
timeout: 3000,
|
||||||
message: (
|
message: (
|
||||||
<>
|
<>
|
||||||
Switched workspace to <InlineCode>{activeWorkspace.name}</InlineCode>
|
Activated workspace{' '}
|
||||||
|
<InlineCode className="whitespace-nowrap">{activeWorkspace.name}</InlineCode>
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user