Fix plugins

This commit is contained in:
Gregory Schier committed 2024-06-13 07:03:50 -07:00
1 parent 641fe86cf7
commit 33763b6d2f
26 files changed
+793 -72

No files matched your search

+1 -1
View File
@@ -10,6 +10,6 @@ export default defineConfig({
},
emptyOutDir: true,
sourcemap: true,
outDir: resolve(__dirname, 'build'),
outDir: resolve(__dirname, '../../src-tauri/plugins/exporter-curl'),
},
});
+1 -1
View File
@@ -10,6 +10,6 @@ export default defineConfig({
},
emptyOutDir: true,
sourcemap: true,
outDir: resolve(__dirname, 'build'),
outDir: resolve(__dirname, '../../src-tauri/plugins/filter-jsonpath'),
},
});
+1 -1
View File
@@ -10,6 +10,6 @@ export default defineConfig({
},
emptyOutDir: true,
sourcemap: true,
outDir: resolve(__dirname, 'build'),
outDir: resolve(__dirname, '../../src-tauri/plugins/filter-xpath'),
},
});
+1 -1
View File
@@ -10,6 +10,6 @@ export default defineConfig({
},
emptyOutDir: true,
sourcemap: true,
outDir: resolve(__dirname, 'build'),
outDir: resolve(__dirname, '../../src-tauri/plugins/importer-curl'),
},
});
+1 -1
View File
@@ -10,6 +10,6 @@ export default defineConfig({
},
emptyOutDir: true,
sourcemap: true,
outDir: resolve(__dirname, 'build'),
outDir: resolve(__dirname, '../../src-tauri/plugins/importer-insomnia'),
},
});
+1 -1
View File
@@ -10,6 +10,6 @@ export default defineConfig({
},
emptyOutDir: true,
sourcemap: true,
outDir: resolve(__dirname, 'build'),
outDir: resolve(__dirname, '../../src-tauri/plugins/importer-postman'),
},
});
+1 -1
View File
@@ -10,6 +10,6 @@ export default defineConfig({
},
emptyOutDir: true,
sourcemap: true,
outDir: resolve(__dirname, 'build'),
outDir: resolve(__dirname, '../../src-tauri/plugins/importer-yaak'),
},
});
+25 -24
View File
@@ -1,36 +1,37 @@
const o = `\\
`;
function d(n) {
var h, f, r, u, l, s;
const t = ["curl"];
n.method && t.push("-X", n.method), n.url && t.push(i(n.url)), t.push(o);
for (const a of (n.urlParameters ?? []).filter(p))
t.push("--url-query", i(`${a.name}=${a.value}`)), t.push(o);
for (const a of (n.headers ?? []).filter(p))
t.push("--header", i(`${a.name}: ${a.value}`)), t.push(o);
if (Array.isArray((h = n.body) == null ? void 0 : h.form)) {
const a = n.bodyType === "multipart/form-data" ? "--form" : "--data";
for (const e of (((f = n.body) == null ? void 0 : f.form) ?? []).filter(p)) {
function y(p, t) {
var f, r, u, l, s, c;
const n = ["curl"];
t.method && n.push("-X", t.method), t.url && n.push(i(t.url)), n.push(o);
for (const a of (t.urlParameters ?? []).filter(h))
n.push("--url-query", i(`${a.name}=${a.value}`)), n.push(o);
for (const a of (t.headers ?? []).filter(h))
n.push("--header", i(`${a.name}: ${a.value}`)), n.push(o);
if (Array.isArray((f = t.body) == null ? void 0 : f.form)) {
const a = t.bodyType === "multipart/form-data" ? "--form" : "--data";
for (const e of (((r = t.body) == null ? void 0 : r.form) ?? []).filter(h)) {
if (e.file) {
let c = `${e.name}=@${e.file}`;
c += e.contentType ? `;type=${e.contentType}` : "", t.push(a, c);
let d = `${e.name}=@${e.file}`;
d += e.contentType ? `;type=${e.contentType}` : "", n.push(a, d);
} else
t.push(a, i(`${e.name}=${e.value}`));
t.push(o);
n.push(a, i(`${e.name}=${e.value}`));
n.push(o);
}
} else
typeof ((r = n.body) == null ? void 0 : r.text) == "string" && (t.push("--data-raw", `$${i(n.body.text)}`), t.push(o));
return (n.authenticationType === "basic" || n.authenticationType === "digest") && (n.authenticationType === "digest" && t.push("--digest"), t.push(
typeof ((u = t.body) == null ? void 0 : u.text) == "string" && (n.push("--data-raw", `$${i(t.body.text)}`), n.push(o));
return (t.authenticationType === "basic" || t.authenticationType === "digest") && (t.authenticationType === "digest" && n.push("--digest"), n.push(
"--user",
i(`${((u = n.authentication) == null ? void 0 : u.username) ?? ""}:${((l = n.authentication) == null ? void 0 : l.password) ?? ""}`)
), t.push(o)), n.authenticationType === "bearer" && (t.push("--header", i(`Authorization: Bearer ${((s = n.authentication) == null ? void 0 : s.token) ?? ""}`)), t.push(o)), t[t.length - 1] === o && t.splice(t.length - 1, 1), t.join(" ");
i(`${((l = t.authentication) == null ? void 0 : l.username) ?? ""}:${((s = t.authentication) == null ? void 0 : s.password) ?? ""}`)
), n.push(o)), t.authenticationType === "bearer" && (n.push("--header", i(`Authorization: Bearer ${((c = t.authentication) == null ? void 0 : c.token) ?? ""}`)), n.push(o)), n[n.length - 1] === o && n.splice(n.length - 1, 1), n.join(" ");
}
function i(n) {
return `'${n.replace(/'/g, "\\'")}'`;
function i(p) {
return `'${p.replace(/'/g, "\\'")}'`;
}
function p(n) {
return n.enabled !== !1 && !!n.name;
function h(p) {
return p.enabled !== !1 && !!p.name;
}
export {
d as pluginHookExport
y as pluginHookExport
};
//# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../plugins/exporter-curl/src/index.ts"],"sourcesContent":["import { HttpRequest } from '../../../src-web/lib/models';\n\nconst NEWLINE = '\\\\\\n ';\n\nexport function pluginHookExport(_: any, request: Partial<HttpRequest>) {\n const xs = ['curl'];\n\n // Add method and URL all on first line\n if (request.method) xs.push('-X', request.method);\n if (request.url) xs.push(quote(request.url));\n\n xs.push(NEWLINE);\n\n // Add URL params\n for (const p of (request.urlParameters ?? []).filter(onlyEnabled)) {\n xs.push('--url-query', quote(`${p.name}=${p.value}`));\n xs.push(NEWLINE);\n }\n\n // Add headers\n for (const h of (request.headers ?? []).filter(onlyEnabled)) {\n xs.push('--header', quote(`${h.name}: ${h.value}`));\n xs.push(NEWLINE);\n }\n\n // Add form params\n if (Array.isArray(request.body?.form)) {\n const flag = request.bodyType === 'multipart/form-data' ? '--form' : '--data';\n for (const p of (request.body?.form ?? []).filter(onlyEnabled)) {\n if (p.file) {\n let v = `${p.name}=@${p.file}`;\n v += p.contentType ? `;type=${p.contentType}` : '';\n xs.push(flag, v);\n } else {\n xs.push(flag, quote(`${p.name}=${p.value}`));\n }\n xs.push(NEWLINE);\n }\n } else if (typeof request.body?.text === 'string') {\n // --data-raw $'...' to do special ANSI C quoting\n xs.push('--data-raw', `$${quote(request.body.text)}`);\n xs.push(NEWLINE);\n }\n\n // Add basic/digest authentication\n if (request.authenticationType === 'basic' || request.authenticationType === 'digest') {\n if (request.authenticationType === 'digest') xs.push('--digest');\n xs.push(\n '--user',\n quote(`${request.authentication?.username ?? ''}:${request.authentication?.password ?? ''}`),\n );\n xs.push(NEWLINE);\n }\n\n // Add bearer authentication\n if (request.authenticationType === 'bearer') {\n xs.push('--header', quote(`Authorization: Bearer ${request.authentication?.token ?? ''}`));\n xs.push(NEWLINE);\n }\n\n // Remove trailing newline\n if (xs[xs.length - 1] === NEWLINE) {\n xs.splice(xs.length - 1, 1);\n }\n\n return xs.join(' ');\n}\n\nfunction quote(arg: string): string {\n const escaped = arg.replace(/'/g, \"\\\\'\");\n return `'${escaped}'`;\n}\n\nfunction onlyEnabled(v: { name?: string; enabled?: boolean }): boolean {\n return v.enabled !== false && !!v.name;\n}\n"],"names":["NEWLINE","pluginHookExport","_","request","_a","_b","_c","_d","_e","_f","xs","quote","p","onlyEnabled","h","flag","v","arg"],"mappings":"AAEA,MAAMA,IAAU;AAAA;AAEA,SAAAC,EAAiBC,GAAQC,GAA+B;AAFxE,MAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC;AAGQ,QAAAC,IAAK,CAAC,MAAM;AAGlB,EAAIP,EAAQ,UAAWO,EAAA,KAAK,MAAMP,EAAQ,MAAM,GAC5CA,EAAQ,OAAKO,EAAG,KAAKC,EAAMR,EAAQ,GAAG,CAAC,GAE3CO,EAAG,KAAKV,CAAO;AAGf,aAAWY,MAAMT,EAAQ,iBAAiB,IAAI,OAAOU,CAAW;AAC3D,IAAAH,EAAA,KAAK,eAAeC,EAAM,GAAGC,EAAE,IAAI,IAAIA,EAAE,KAAK,EAAE,CAAC,GACpDF,EAAG,KAAKV,CAAO;AAIjB,aAAWc,MAAMX,EAAQ,WAAW,IAAI,OAAOU,CAAW;AACrD,IAAAH,EAAA,KAAK,YAAYC,EAAM,GAAGG,EAAE,IAAI,KAAKA,EAAE,KAAK,EAAE,CAAC,GAClDJ,EAAG,KAAKV,CAAO;AAIjB,MAAI,MAAM,SAAQI,IAAAD,EAAQ,SAAR,gBAAAC,EAAc,IAAI,GAAG;AACrC,UAAMW,IAAOZ,EAAQ,aAAa,wBAAwB,WAAW;AAC1D,eAAAS,QAAMP,IAAAF,EAAQ,SAAR,gBAAAE,EAAc,SAAQ,CAAI,GAAA,OAAOQ,CAAW,GAAG;AAC9D,UAAID,EAAE,MAAM;AACV,YAAII,IAAI,GAAGJ,EAAE,IAAI,KAAKA,EAAE,IAAI;AAC5B,QAAAI,KAAKJ,EAAE,cAAc,SAASA,EAAE,WAAW,KAAK,IAC7CF,EAAA,KAAKK,GAAMC,CAAC;AAAA,MAAA;AAEZ,QAAAN,EAAA,KAAKK,GAAMJ,EAAM,GAAGC,EAAE,IAAI,IAAIA,EAAE,KAAK,EAAE,CAAC;AAE7C,MAAAF,EAAG,KAAKV,CAAO;AAAA,IACjB;AAAA,EACS;AAAA,IAAA,SAAOM,IAAAH,EAAQ,SAAR,gBAAAG,EAAc,SAAS,aAEpCI,EAAA,KAAK,cAAc,IAAIC,EAAMR,EAAQ,KAAK,IAAI,CAAC,EAAE,GACpDO,EAAG,KAAKV,CAAO;AAIjB,UAAIG,EAAQ,uBAAuB,WAAWA,EAAQ,uBAAuB,cACvEA,EAAQ,uBAAuB,YAAUO,EAAG,KAAK,UAAU,GAC5DA,EAAA;AAAA,IACD;AAAA,IACAC,EAAM,KAAGJ,IAAAJ,EAAQ,mBAAR,gBAAAI,EAAwB,aAAY,EAAE,MAAIC,IAAAL,EAAQ,mBAAR,gBAAAK,EAAwB,aAAY,EAAE,EAAE;AAAA,EAAA,GAE7FE,EAAG,KAAKV,CAAO,IAIbG,EAAQ,uBAAuB,aAC9BO,EAAA,KAAK,YAAYC,EAAM,2BAAyBF,IAAAN,EAAQ,mBAAR,gBAAAM,EAAwB,UAAS,EAAE,EAAE,CAAC,GACzFC,EAAG,KAAKV,CAAO,IAIbU,EAAGA,EAAG,SAAS,CAAC,MAAMV,KACxBU,EAAG,OAAOA,EAAG,SAAS,GAAG,CAAC,GAGrBA,EAAG,KAAK,GAAG;AACpB;AAEA,SAASC,EAAMM,GAAqB;AAElC,SAAO,IADSA,EAAI,QAAQ,MAAM,KAAK,CACrB;AACpB;AAEA,SAASJ,EAAYG,GAAkD;AACrE,SAAOA,EAAE,YAAY,MAAS,CAAC,CAACA,EAAE;AACpC;"}
+22 -21
View File
@@ -1,15 +1,15 @@
var Xe = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function Nt(le) {
return le && le.__esModule && Object.prototype.hasOwnProperty.call(le, "default") ? le.default : le;
function Nt(ce) {
return ce && ce.__esModule && Object.prototype.hasOwnProperty.call(ce, "default") ? ce.default : ce;
}
function Be(le) {
throw new Error('Could not dynamically require "' + le + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
function Be(ce) {
throw new Error('Could not dynamically require "' + ce + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
}
var Ve = { exports: {} };
/*! jsonpath 1.1.1 */
(function(le, Ne) {
(function(ce, Ne) {
(function(T) {
le.exports = T();
ce.exports = T();
})(function() {
return function T(L, B, v) {
function y(E, d) {
@@ -1131,7 +1131,7 @@ var Ve = { exports: {} };
function Ze() {
var e = [], t;
for (t = i, O("["); !_("]"); )
_(",") ? (N(), e.push(null)) : (e.push(ce()), _("]") || O(","));
_(",") ? (N(), e.push(null)) : (e.push(le()), _("]") || O(","));
return N(), n.markEnd(n.createArrayExpression(e), t);
}
function _e(e, t) {
@@ -1145,11 +1145,11 @@ var Ve = { exports: {} };
function et() {
var e, t, u, l, C, x;
if (e = i, x = i, e.type === y.Identifier)
return u = De(), e.value === "get" && !_(":") ? (t = De(), O("("), O(")"), l = _e([]), n.markEnd(n.createProperty("get", t, l), x)) : e.value === "set" && !_(":") ? (t = De(), O("("), e = i, e.type !== y.Identifier ? (O(")"), G(e, a.UnexpectedToken, e.value), l = _e([])) : (C = [ye()], O(")"), l = _e(C, e)), n.markEnd(n.createProperty("set", t, l), x)) : (O(":"), l = ce(), n.markEnd(n.createProperty("init", u, l), x));
return u = De(), e.value === "get" && !_(":") ? (t = De(), O("("), O(")"), l = _e([]), n.markEnd(n.createProperty("get", t, l), x)) : e.value === "set" && !_(":") ? (t = De(), O("("), e = i, e.type !== y.Identifier ? (O(")"), G(e, a.UnexpectedToken, e.value), l = _e([])) : (C = [ye()], O(")"), l = _e(C, e)), n.markEnd(n.createProperty("set", t, l), x)) : (O(":"), l = le(), n.markEnd(n.createProperty("init", u, l), x));
if (e.type === y.EOF || e.type === y.Punctuator)
pe(e);
else
return t = De(), O(":"), l = ce(), n.markEnd(n.createProperty("init", t, l), x);
return t = De(), O(":"), l = le(), n.markEnd(n.createProperty("init", t, l), x);
}
function tt() {
var e = [], t, u, l, C, x = {}, j = String, W;
@@ -1184,7 +1184,7 @@ var Ve = { exports: {} };
function je() {
var e = [];
if (O("("), !_(")"))
for (; r < h && (e.push(ce()), !_(")")); )
for (; r < h && (e.push(le()), !_(")")); )
O(",");
return O(")"), e;
}
@@ -1300,17 +1300,17 @@ var Ve = { exports: {} };
}
function st() {
var e, t, u, l, C;
return C = i, e = at(), _("?") && (N(), t = p.allowIn, p.allowIn = !0, u = ce(), p.allowIn = t, O(":"), l = ce(), e = n.createConditionalExpression(e, u, l), n.markEnd(e, C)), e;
return C = i, e = at(), _("?") && (N(), t = p.allowIn, p.allowIn = !0, u = le(), p.allowIn = t, O(":"), l = le(), e = n.createConditionalExpression(e, u, l), n.markEnd(e, C)), e;
}
function ce() {
function le() {
var e, t, u, l, C;
return e = i, C = i, l = t = st(), Ye() && (be(t) || G({}, a.InvalidLHSInAssignment), c && t.type === E.Identifier && J(t.name) && G(e, a.StrictLHSAssignment), e = N(), u = ce(), l = n.markEnd(n.createAssignmentExpression(e.value, t, u), C)), l;
return e = i, C = i, l = t = st(), Ye() && (be(t) || G({}, a.InvalidLHSInAssignment), c && t.type === E.Identifier && J(t.name) && G(e, a.StrictLHSAssignment), e = N(), u = le(), l = n.markEnd(n.createAssignmentExpression(e.value, t, u), C)), l;
}
function te() {
var e, t = i;
if (e = ce(), _(",")) {
if (e = le(), _(",")) {
for (e = n.createSequenceExpression([e]); r < h && _(","); )
N(), e.expressions.push(ce());
N(), e.expressions.push(le());
n.markEnd(e, t);
}
return e;
@@ -1330,7 +1330,7 @@ var Ve = { exports: {} };
}
function lt(e) {
var t = null, u, l;
return l = i, u = ye(), c && J(u.name) && G({}, a.StrictVarName), e === "const" ? (O("="), t = ce()) : _("=") && (N(), t = ce()), n.markEnd(n.createVariableDeclarator(u, t), l);
return l = i, u = ye(), c && J(u.name) && G({}, a.StrictVarName), e === "const" ? (O("="), t = le()) : _("=") && (N(), t = le()), n.markEnd(n.createVariableDeclarator(u, t), l);
}
function Te(e) {
var t = [];
@@ -3176,16 +3176,17 @@ Expecting ` + se.join(", ") + ", got '" + (this.terminals_[w] || w) + "'" : ie =
})(Ve);
var Pt = Ve.exports;
const Lt = /* @__PURE__ */ Nt(Pt);
function Rt(le, Ne) {
let T;
function Rt(ce, Ne, T) {
let L;
try {
T = JSON.parse(Ne);
L = JSON.parse(T);
} catch {
return;
}
const L = Lt.query(T, le);
return { filtered: JSON.stringify(L, null, 2) };
const B = Lt.query(L, Ne);
return { filtered: JSON.stringify(B, null, 2) };
}
export {
Rt as pluginHookResponseFilter
};
//# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../plugins/filter-jsonpath/node_modules/jsonpath/jsonpath.js","../../../plugins/filter-jsonpath/src/index.js"],"sourcesContent":["/*! jsonpath 1.1.1 */\n\n(function(f){if(typeof exports===\"object\"&&typeof module!==\"undefined\"){module.exports=f()}else if(typeof define===\"function\"&&define.amd){define([],f)}else{var g;if(typeof window!==\"undefined\"){g=window}else if(typeof global!==\"undefined\"){g=global}else if(typeof self!==\"undefined\"){g=self}else{g=this}g.jsonpath = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({\"./aesprim\":[function(require,module,exports){\n/*\n Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>\n Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>\n Copyright (C) 2013 Mathias Bynens <mathias@qiwi.be>\n Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>\n Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be>\n Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>\n Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com>\n Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>\n Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>\n Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY\n DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*jslint bitwise:true plusplus:true */\n/*global esprima:true, define:true, exports:true, window: true,\nthrowErrorTolerant: true,\nthrowError: true, generateStatement: true, peek: true,\nparseAssignmentExpression: true, parseBlock: true, parseExpression: true,\nparseFunctionDeclaration: true, parseFunctionExpression: true,\nparseFunctionSourceElements: true, parseVariableIdentifier: true,\nparseLeftHandSideExpression: true,\nparseUnaryExpression: true,\nparseStatement: true, parseSourceElement: true */\n\n(function (root, factory) {\n 'use strict';\n\n // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js,\n // Rhino, and plain browser loading.\n\n /* istanbul ignore next */\n if (typeof define === 'function' && define.amd) {\n define(['exports'], factory);\n } else if (typeof exports !== 'undefined') {\n factory(exports);\n } else {\n factory((root.esprima = {}));\n }\n}(this, function (exports) {\n 'use strict';\n\n var Token,\n TokenName,\n FnExprTokens,\n Syntax,\n PropertyKind,\n Messages,\n Regex,\n SyntaxTreeDelegate,\n source,\n strict,\n index,\n lineNumber,\n lineStart,\n length,\n delegate,\n lookahead,\n state,\n extra;\n\n Token = {\n BooleanLiteral: 1,\n EOF: 2,\n Identifier: 3,\n Keyword: 4,\n NullLiteral: 5,\n NumericLiteral: 6,\n Punctuator: 7,\n StringLiteral: 8,\n RegularExpression: 9\n };\n\n TokenName = {};\n TokenName[Token.BooleanLiteral] = 'Boolean';\n TokenName[Token.EOF] = '<end>';\n TokenName[Token.Identifier] = 'Identifier';\n TokenName[Token.Keyword] = 'Keyword';\n TokenName[Token.NullLiteral] = 'Null';\n TokenName[Token.NumericLiteral] = 'Numeric';\n TokenName[Token.Punctuator] = 'Punctuator';\n TokenName[Token.StringLiteral] = 'String';\n TokenName[Token.RegulaLine truncated
+4 -3
View File
@@ -6116,10 +6116,11 @@ Tr.__DOMHandler = Dr;
Tr.normalizeLineEndings = Rt;
Tr.DOMParser = _t;
var Cu = Tr.DOMParser;
function yu(t, u) {
const n = new Cu().parseFromString(u, "text/xml");
return { filtered: `${Qt.select(t, n)}` };
function yu(t, u, n) {
const s = new Cu().parseFromString(n, "text/xml");
return { filtered: `${Qt.select(u, s)}` };
}
export {
yu as pluginHookResponseFilter
};
//# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../plugins/filter-xpath/node_modules/xpath/xpath.js","../../../plugins/filter-xpath/node_modules/@xmldom/xmldom/lib/conventions.js","../../../plugins/filter-xpath/node_modules/@xmldom/xmldom/lib/dom.js","../../../plugins/filter-xpath/node_modules/@xmldom/xmldom/lib/entities.js","../../../plugins/filter-xpath/node_modules/@xmldom/xmldom/lib/sax.js","../../../plugins/filter-xpath/node_modules/@xmldom/xmldom/lib/dom-parser.js","../../../plugins/filter-xpath/node_modules/@xmldom/xmldom/lib/index.js","../../../plugins/filter-xpath/src/index.js"],"sourcesContent":["/*\r\n * xpath.js\r\n *\r\n * An XPath 1.0 library for JavaScript.\r\n *\r\n * Cameron McCormack <cam (at) mcc.id.au>\r\n *\r\n * This work is licensed under the MIT License.\r\n *\r\n * Revision 20: April 26, 2011\r\n * Fixed a typo resulting in FIRST_ORDERED_NODE_TYPE results being wrong,\r\n * thanks to <shi_a009 (at) hotmail.com>.\r\n *\r\n * Revision 19: November 29, 2005\r\n * Nodesets now store their nodes in a height balanced tree, increasing\r\n * performance for the common case of selecting nodes in document order,\r\n * thanks to Sébastien Cramatte <contact (at) zeninteractif.com>.\r\n * AVL tree code adapted from Raimund Neumann <rnova (at) gmx.net>.\r\n *\r\n * Revision 18: October 27, 2005\r\n * DOM 3 XPath support. Caveats:\r\n * - namespace prefixes aren't resolved in XPathEvaluator.createExpression,\r\n * but in XPathExpression.evaluate.\r\n * - XPathResult.invalidIteratorState is not implemented.\r\n *\r\n * Revision 17: October 25, 2005\r\n * Some core XPath function fixes and a patch to avoid crashing certain\r\n * versions of MSXML in PathExpr.prototype.getOwnerElement, thanks to\r\n * Sébastien Cramatte <contact (at) zeninteractif.com>.\r\n *\r\n * Revision 16: September 22, 2005\r\n * Workarounds for some IE 5.5 deficiencies.\r\n * Fixed problem with prefix node tests on attribute nodes.\r\n *\r\n * Revision 15: May 21, 2005\r\n * Fixed problem with QName node tests on elements with an xmlns=\"...\".\r\n *\r\n * Revision 14: May 19, 2005\r\n * Fixed QName node tests on attribute node regression.\r\n *\r\n * Revision 13: May 3, 2005\r\n * Node tests are case insensitive now if working in an HTML DOM.\r\n *\r\n * Revision 12: April 26, 2005\r\n * Updated licence. Slight code changes to enable use of Dean\r\n * Edwards' script compression, http://dean.edwards.name/packer/ .\r\n *\r\n * Revision 11: April 23, 2005\r\n * Fixed bug with 'and' and 'or' operators, fix thanks to\r\n * Sandy McArthur <sandy (at) mcarthur.org>.\r\n *\r\n * Revision 10: April 15, 2005\r\n * Added support for a virtual root node, supposedly helpful for\r\n * implementing XForms. Fixed problem with QName node tests and\r\n * the parent axis.\r\n *\r\n * Revision 9: March 17, 2005\r\n * Namespace resolver tweaked so using the document node as the context\r\n * for namespace lookups is equivalent to using the document element.\r\n *\r\n * Revision 8: February 13, 2005\r\n * Handle implicit declaration of 'xmlns' namespace prefix.\r\n * Fixed bug when comparing nodesets.\r\n * Instance data can now be associated with a FunctionResolver, and\r\n * workaround for MSXML not supporting 'localName' and 'getElementById',\r\n * thanks to Grant Gongaware.\r\n * Fix a few problems when the context node is the root node.\r\n *\r\n * Revision 7: February 11, 2005\r\n * Default namespace resolver fix from Grant Gongaware\r\n * <grant (at) gongaware.com>.\r\n *\r\n * Revision 6: February 10, 2005\r\n * Fixed bug in 'number' function.\r\n *\r\n * Revision 5: February 9, 2005\r\n * Fixed bug where text nodes not getting converted to string values.\r\n *\r\n * Revision 4: January 21, 2005\r\n * Bug in 'name' function, fix thanks to Bill Edney.\r\n * Fixed incorrect processing of namespace nodes.\r\n * Fixed NamespaceResolver to resolve 'xml' namespace.\r\n * Implemented union '|' operator.\r\n *\r\n * Revision 3: January 14, 2005\r\n * Fixed bug with nodeset comparisons, bug lexing < and >.\r\n *\r\n * Revision 2: October 26, 2004\r\n * QName node test namespace handling fixed. Few other bug fixes.\r\n *\r\n * Revision 1: August 13, 2004\r\n * Bug fixes from William J. Edney <bedney (at) technicalpursuit.com>.\r\n * Added minimal licence.\r\n *\r\n * Initial version: June 14, 2004\r\n */\r\n\r\n// non-node wrapper\r\nvar xpath = (typeof exports === 'undefined') ? {} : exports;\r\n\r\n(function (exports) {\r\n \"use strict\";\r\n\r\n // namespace nodes are not part of the DOM spec, so we use a custom nodetype for them.\r\n // should NOT be used externally\r\n var NAMESPACE_NODE_NODETYPE = '__namespace';\r\n\r\n var isNil = function (x) {\r\n return x === null || x === undefined;\r\n };\r\n\r\n var isValidNodeType = function (nodeType) {\r\n return nodeType === NAMESPACE_NODE_NODETYPE ||\r\Line truncated
+298
View File
@@ -0,0 +1,298 @@
var j = "(?:" + [
"\\|\\|",
"\\&\\&",
";;",
"\\|\\&",
"\\<\\(",
"\\<\\<\\<",
">>",
">\\&",
"<\\&",
"[&;()|<>]"
].join("|") + ")", D = new RegExp("^" + j + "$"), _ = "|&;()<> \\t", M = '"((\\\\"|[^"])*?)"', Q = "'((\\\\'|[^'])*?)'", V = /^#$/, q = "'", G = '"', U = "$", R = "", z = 4294967296;
for (var L = 0; L < 4; L++)
R += (z * Math.random()).toString(16);
var J = new RegExp("^" + R);
function X(n, s) {
for (var t = s.lastIndex, r = [], l; l = s.exec(n); )
r.push(l), s.lastIndex === l.index && (s.lastIndex += 1);
return s.lastIndex = t, r;
}
function F(n, s, t) {
var r = typeof n == "function" ? n(t) : n[t];
return typeof r > "u" && t != "" ? r = "" : typeof r > "u" && (r = "$"), typeof r == "object" ? s + R + JSON.stringify(r) + R : s + r;
}
function K(n, s, t) {
t || (t = {});
var r = t.escape || "\\", l = "(\\" + r + `['"` + _ + `]|[^\\s'"` + _ + "])+", h = new RegExp([
"(" + j + ")",
// control chars
"(" + l + "|" + M + "|" + Q + ")+"
].join("|"), "g"), p = X(n, h);
if (p.length === 0)
return [];
s || (s = {});
var g = !1;
return p.map(function(d) {
var e = d[0];
if (!e || g)
return;
if (D.test(e))
return { op: e };
var c = !1, T = !1, m = "", O = !1, a;
function $() {
a += 1;
var x, f, C = e.charAt(a);
if (C === "{") {
if (a += 1, e.charAt(a) === "}")
throw new Error("Bad substitution: " + e.slice(a - 2, a + 1));
if (x = e.indexOf("}", a), x < 0)
throw new Error("Bad substitution: " + e.slice(a));
f = e.slice(a, x), a = x;
} else if (/[*@#?$!_-]/.test(C))
f = C, a += 1;
else {
var w = e.slice(a);
x = w.match(/[^\w\d_]/), x ? (f = w.slice(0, x.index), a += x.index - 1) : (f = w, a = e.length);
}
return F(s, "", f);
}
for (a = 0; a < e.length; a++) {
var u = e.charAt(a);
if (O = O || !c && (u === "*" || u === "?"), T)
m += u, T = !1;
else if (c)
u === c ? c = !1 : c == q ? m += u : u === r ? (a += 1, u = e.charAt(a), u === G || u === r || u === U ? m += u : m += r + u) : u === U ? m += $() : m += u;
else if (u === G || u === q)
c = u;
else {
if (D.test(u))
return { op: e };
if (V.test(u)) {
g = !0;
var b = { comment: n.slice(d.index + a + 1) };
return m.length ? [m, b] : [b];
} else
u === r ? T = !0 : u === U ? m += $() : m += u;
}
}
return O ? { op: "glob", pattern: m } : m;
}).reduce(function(d, e) {
return typeof e > "u" ? d : d.concat(e);
}, []);
}
var Y = function(s, t, r) {
var l = K(s, t, r);
return typeof t != "function" ? l : l.reduce(function(h, p) {
if (typeof p == "object")
return h.concat(p);
var g = p.split(RegExp("(" + R + ".*?" + R + ")", "g"));
return g.length === 1 ? h.concat(g[0]) : h.concat(g.filter(Boolean).map(function(d) {
return J.test(d) ? JSON.parse(d.split(R)[1]) : d;
}));
}, []);
}, Z = Y;
const ae = "curl", se = "cURL", ie = "cURL command line tool", H = ["d", "data", "data-raw", "data-urlencode", "data-binary", "data-ascii"], ee = [
["url"],
// Specify the URL explicitly
["user", "u"],
// Authentication
["digest"],
// Apply auth as digest
["header", "H"],
["cookie", "b"],
["get", "G"],
// Put the post data in the URL
["d", "data"],
// Add url encoded data
["data-raw"],
["data-urlencode"],
["data-binary"],
["data-ascii"],
["form", "F"],
// Add multipart data
["request", "X"],
// Request method
H
].flatMap((n) => n);
function oe(n, s) {
if (!s.match(/^\s*curl /))
return null;
const t = [], r = s.replace(/\ncurl/g, "; curl");
let l = [];
const p = Z(r).flatMap((e) => typeof e == "string" && e.startsWith("-") && !e.startsWith("--") && e.length > 2 ? [e.slice(0, 2), e.slice(2)] : e);
for (const e of p) {
if (typeof e == "string") {
e.startsWith("$") ? l.push(e.slice(1)) : l.push(e);
continue;
}
if ("comment" in e)
continue;
const { op: c } = e;
if (c === ";") {
t.push(l), l = [];
continue;
}
if (c != null && c.startsWith("$")) {
const T = c.slice(2, c.length - 1).replace(/\\'/g, "'");
l.push(T);
continue;
}
c === "glob" && l.push(e.pattern);
}
t.push(l);
const g = {
model: "workspace",
id: N("workspace"),
name: "Curl Import"
};
return {
resources: {
httpRequests: t.filter((e) => e[0] === "curl").map((e) => te(e, g.id)),
workspaces: [g]
}
};
}
function te(n, s) {
const t = {}, r = [];
for (let i = 1; i < n.length; i++) {
let o = n[i];
if (typeof o == "string" && (o = o.trim()), typeof o == "string" && o.match(/^-{1,2}[\w-]+/)) {
const E = o[0] === "-" && o[1] !== "-";
let v = o.replace(/^-{1,2}/, "");
if (!ee.includes(v))
continue;
let y;
const S = n[i + 1];
E && v.length > 1 ? (y = v.slice(1), v = v.slice(0, 1)) : typeof S == "string" && !S.startsWith("-") ? (y = S, i++) : y = !0, t[v] = t[v] || [], t[v].push(y);
} else
o && r.push(o);
}
let l, h;
const p = A(t, r[0] || "", ["url"]), [g, d] = W(p, "?");
l = (d == null ? void 0 : d.split("&").map((i) => {
const o = W(i, "=");
return { name: o[0] ?? "", value: o[1] ?? "", enabled: !0 };
})) ?? [], h = g ?? p;
const [e, c] = A(t, "", ["u", "user"]).split(/:(.*)$/), T = A(t, !1, ["digest"]), m = e ? T ? "digest" : "basic" : null, O = e ? {
username: e.trim(),
password: (c ?? "").trim()
} : {}, a = [
...t.header || [],
...t.H || []
].map((i) => {
const [o, E] = i.split(/:(.*)$/);
return E ? {
name: (o ?? "").trim(),
value: E.trim(),
enabled: !0
} : {
name: (o ?? "").trim().replace(/;$/, ""),
value: "",
enabled: !0
};
}), $ = [
...t.cookie || [],
...t.b || []
].map((i) => {
const o = i.split("=", 1)[0], E = i.replace(`${o}=`, "");
return `${o}=${E}`;
}).join("; "), u = a.find((i) => i.name.toLowerCase() === "cookie");
$ && u ? u.value += `; ${$}` : $ && a.push({
name: "Cookie",
value: $,
enabled: !0
});
const b = ne(t), x = a.find((i) => i.name.toLowerCase() === "content-type"), f = x ? x.value.split(";")[0] : null, C = [
...t.form || [],
...t.F || []
].map((i) => {
const o = i.split("="), E = o[0] ?? "", v = o[1] ?? "", y = {
name: E,
enabled: !0
};
return v.indexOf("@") === 0 ? y.file = v.slice(1) : y.value = v, y;
});
let w = {}, I = null;
const B = A(t, !1, ["G", "get"]);
b.length > 0 && B ? l.push(...b) : b.length > 0 && (f == null || f === "application/x-www-form-urlencoded") ? (I = f ?? "application/x-www-form-urlencoded", w = {
form: b.map((i) => ({
...i,
name: decodeURIComponent(i.name || ""),
value: decodeURIComponent(i.value || "")
}))
}, a.push({
name: "Content-Type",
value: "application/x-www-form-urlencoded",
enabled: !0
})) : b.length > 0 ? (I = f === "application/json" || f === "text/xml" || f === "text/plain" ? f : "other", w = {
text: b.map(({ name: i, value: o }) => i && o ? `${i}=${o}` : i || o).join("&")
}) : C.length && (I = f ?? "multipart/form-data", w = {
form: C
}, f == null && a.push({
name: "Content-Type",
value: "multipart/form-data",
enabled: !0
}));
let P = A(t, "", ["X", "request"]).toUpperCase();
return P === "" && w && (P = "text" in w || "form" in w ? "POST" : "GET"), {
id: N("http_request"),
model: "http_request",
workspaceId: s,
name: "",
urlParameters: l,
url: h,
method: P,
headers: a,
authentication: O,
authenticationType: m,
body: w,
bodyType: I,
folderId: null,
sortPriority: 0
};
}
const ne = (n) => {
let s = [];
for (const t of H) {
const r = n[t];
if (!(!r || r.length === 0))
for (const l of r) {
if (typeof l != "string")
continue;
const [h, p] = l.split("=");
l.startsWith("@") ? s.push({
name: h ?? "",
value: "",
filePath: l.slice(1),
enabled: !0
}) : s.push({
name: h ?? "",
value: t === "data-urlencode" ? encodeURIComponent(p ?? "") : p ?? "",
enabled: !0
});
}
}
return s;
}, A = (n, s, t) => {
for (const r of t)
if (n[r] && n[r].length)
return n[r][0];
return s;
};
function W(n, s) {
const t = n.indexOf(s);
return t > -1 ? [n.slice(0, t), n.slice(t + 1)] : [n];
}
const k = {};
function N(n) {
return k[n] = (k[n] ?? -1) + 1, `GENERATE_ID::${n.toUpperCase()}_${k[n]}`;
}
export {
ie as description,
ae as id,
te as importCommand,
se as name,
oe as pluginHookImport
};
//# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../plugins/importer-curl/node_modules/shell-quote/parse.js","../../../plugins/importer-curl/node_modules/shell-quote/index.js","../../../plugins/importer-curl/src/index.ts"],"sourcesContent":["'use strict';\n\n// '<(' is process substitution operator and\n// can be parsed the same as control operator\nvar CONTROL = '(?:' + [\n\t'\\\\|\\\\|',\n\t'\\\\&\\\\&',\n\t';;',\n\t'\\\\|\\\\&',\n\t'\\\\<\\\\(',\n\t'\\\\<\\\\<\\\\<',\n\t'>>',\n\t'>\\\\&',\n\t'<\\\\&',\n\t'[&;()|<>]'\n].join('|') + ')';\nvar controlRE = new RegExp('^' + CONTROL + '$');\nvar META = '|&;()<> \\\\t';\nvar SINGLE_QUOTE = '\"((\\\\\\\\\"|[^\"])*?)\"';\nvar DOUBLE_QUOTE = '\\'((\\\\\\\\\\'|[^\\'])*?)\\'';\nvar hash = /^#$/;\n\nvar SQ = \"'\";\nvar DQ = '\"';\nvar DS = '$';\n\nvar TOKEN = '';\nvar mult = 0x100000000; // Math.pow(16, 8);\nfor (var i = 0; i < 4; i++) {\n\tTOKEN += (mult * Math.random()).toString(16);\n}\nvar startsWithToken = new RegExp('^' + TOKEN);\n\nfunction matchAll(s, r) {\n\tvar origIndex = r.lastIndex;\n\n\tvar matches = [];\n\tvar matchObj;\n\n\twhile ((matchObj = r.exec(s))) {\n\t\tmatches.push(matchObj);\n\t\tif (r.lastIndex === matchObj.index) {\n\t\t\tr.lastIndex += 1;\n\t\t}\n\t}\n\n\tr.lastIndex = origIndex;\n\n\treturn matches;\n}\n\nfunction getVar(env, pre, key) {\n\tvar r = typeof env === 'function' ? env(key) : env[key];\n\tif (typeof r === 'undefined' && key != '') {\n\t\tr = '';\n\t} else if (typeof r === 'undefined') {\n\t\tr = '$';\n\t}\n\n\tif (typeof r === 'object') {\n\t\treturn pre + TOKEN + JSON.stringify(r) + TOKEN;\n\t}\n\treturn pre + r;\n}\n\nfunction parseInternal(string, env, opts) {\n\tif (!opts) {\n\t\topts = {};\n\t}\n\tvar BS = opts.escape || '\\\\';\n\tvar BAREWORD = '(\\\\' + BS + '[\\'\"' + META + ']|[^\\\\s\\'\"' + META + '])+';\n\n\tvar chunker = new RegExp([\n\t\t'(' + CONTROL + ')', // control chars\n\t\t'(' + BAREWORD + '|' + SINGLE_QUOTE + '|' + DOUBLE_QUOTE + ')+'\n\t].join('|'), 'g');\n\n\tvar matches = matchAll(string, chunker);\n\n\tif (matches.length === 0) {\n\t\treturn [];\n\t}\n\tif (!env) {\n\t\tenv = {};\n\t}\n\n\tvar commented = false;\n\n\treturn matches.map(function (match) {\n\t\tvar s = match[0];\n\t\tif (!s || commented) {\n\t\t\treturn void undefined;\n\t\t}\n\t\tif (controlRE.test(s)) {\n\t\t\treturn { op: s };\n\t\t}\n\n\t\t// Hand-written scanner/parser for Bash quoting rules:\n\t\t//\n\t\t// 1. inside single quotes, all characters are printed literally.\n\t\t// 2. inside double quotes, all characters are printed literally\n\t\t// except variables prefixed by '$' and backslashes followed by\n\t\t// either a double quote or another backslash.\n\t\t// 3. outside of any quotes, backslashes are treated as escape\n\t\t// characters and not printed (unless they are themselves escaped)\n\t\t// 4. quote context can switch mid-token if there is no whitespace\n\t\t// between the two quote contexts (e.g. all'one'\"token\" parses as\n\t\t// \"allonetoken\")\n\t\tvar quote = false;\n\t\tvar esc = false;\n\t\tvar out = '';\n\t\tvar isGlob = false;\n\t\tvar i;\n\n\t\tfunction parseEnvVar() {\n\t\t\ti += 1;\n\t\t\tvar varend;\n\t\t\tvar varname;\n\t\t\tvar char = s.charAt(i);\n\n\t\t\tif (char === '{') {\n\t\t\t\ti += 1;\n\t\t\t\tif (s.charAt(i) === '}') {\n\t\t\t\t\tthrow new Error('Bad substitution: ' + s.slice(i - 2, i + 1));\n\t\t\t\t}\n\t\t\t\tvarend = s.indexOf('}', i);\n\t\t\t\tif (varend < 0) {\n\t\t\t\t\tthrow new Error('Bad substitution: ' + s.slice(i));\n\t\t\t\t}\n\t\t\t\tvarname = s.slice(i, varend);\n\t\t\t\ti = varend;\n\t\t\t} else if ((/[*@#?$!_-]/).test(char)) {\n\t\t\t\tvarname = char;\n\t\t\t\ti += 1;\n\t\t\t} else {\n\t\t\t\tvar slicedFromI = s.slice(i);\n\t\t\t\tvarend = slicedFromI.match(/[^\\w\\d_]/);\n\t\t\t\tif (!varend) {\n\t\t\t\t\tvarname = slicedFromI;\n\t\t\t\t\ti = s.length;\n\t\t\t\t} else {\n\t\t\t\t\tvarname = slicedFromI.slice(0, varend.index);\n\t\t\t\t\ti += varend.index - 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn getVar(env, '', varname);\n\t\t}\n\n\t\tfor (i = 0; i < s.length; i++) {\n\t\t\tvar c = s.charAt(i);\n\t\t\tisGlob = isGlob || (!quote && (c === '*' || c === '?'));\n\t\t\tif (esc) {\n\t\t\t\tout += c;\n\t\t\t\tesc = false;\n\t\t\t} else if (quote) {\n\t\t\t\tif (c === quote) {\n\t\t\t\t\tquote = false;\n\t\t\t\t} else if (quote == SQ) {\n\t\t\t\t\tout += c;\n\t\t\t\t} else { // Double quote\n\t\t\t\t\tif (c === BS) {\n\t\t\t\t\t\ti += 1;\n\t\t\t\t\t\tc = s.charAt(i);\n\t\t\t\t\t\tif (c === DQ || c === BS || c === DS) {\n\t\t\t\t\t\t\tout += c;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tout += BS + c;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (c === DS) {\n\t\t\t\t\t\tout += parseEnvVar();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tout += c;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (c === DQ || c === SQ) {\n\t\t\t\tquote = c;\n\t\t\t} else if (controlRE.test(c)) {\n\t\t\t\treturn { op: s };\n\t\t\t} else if (hash.test(c)) {\n\t\t\t\tcommented = true;\n\t\t\t\tvar commentObj = { comment: strLine truncated
@@ -0,0 +1,184 @@
function O(e, o) {
let n;
try {
n = JSON.parse(o);
} catch {
}
try {
n = n ?? YAML.parse(o);
} catch (a) {
console.log("FAILED", a);
}
if (!f(n) || !Array.isArray(n.resources))
return;
const t = {
workspaces: [],
httpRequests: [],
grpcRequests: [],
environments: [],
folders: []
}, i = n.resources.filter(_);
for (const a of i) {
const s = n.resources.find(
(l) => y(l) && l.parentId === a._id
);
t.workspaces.push({
id: p(a._id),
createdAt: new Date(i.created ?? Date.now()).toISOString().replace("Z", ""),
updatedAt: new Date(i.updated ?? Date.now()).toISOString().replace("Z", ""),
model: "workspace",
name: a.name,
variables: s ? h(s.data) : []
});
const d = n.resources.filter(
(l) => y(l) && l.parentId === (s == null ? void 0 : s._id)
);
t.environments.push(
...d.map((l) => b(l, a._id))
);
const c = (l) => {
const w = n.resources.filter((u) => u.parentId === l);
let r = 0;
for (const u of w)
D(u) ? (t.folders.push(I(u, a._id)), c(u._id)) : v(u) ? t.httpRequests.push(
g(u, a._id, r++)
) : q(u) && t.grpcRequests.push(
S(u, a._id, r++)
);
};
c(a._id);
}
return t.httpRequests = t.httpRequests.filter(Boolean), t.grpcRequests = t.grpcRequests.filter(Boolean), t.environments = t.environments.filter(Boolean), t.workspaces = t.workspaces.filter(Boolean), { resources: t };
}
function b(e, o) {
return {
id: p(e._id),
createdAt: new Date(e.created ?? Date.now()).toISOString().replace("Z", ""),
updatedAt: new Date(e.updated ?? Date.now()).toISOString().replace("Z", ""),
workspaceId: p(o),
model: "environment",
name: e.name,
variables: Object.entries(e.data).map(([n, t]) => ({
enabled: !0,
name: n,
value: `${t}`
}))
};
}
function I(e, o) {
return {
id: p(e._id),
createdAt: new Date(e.created ?? Date.now()).toISOString().replace("Z", ""),
updatedAt: new Date(e.updated ?? Date.now()).toISOString().replace("Z", ""),
folderId: e.parentId === o ? null : p(e.parentId),
workspaceId: p(o),
model: "folder",
name: e.name
};
}
function S(e, o, n = 0) {
var s;
const t = e.protoMethodName.split("/").filter((d) => d !== ""), i = t[0] ?? null, a = t[1] ?? null;
return {
id: p(e._id),
createdAt: new Date(e.created ?? Date.now()).toISOString().replace("Z", ""),
updatedAt: new Date(e.updated ?? Date.now()).toISOString().replace("Z", ""),
workspaceId: p(o),
folderId: e.parentId === o ? null : p(e.parentId),
model: "grpc_request",
sortPriority: n,
name: e.name,
url: m(e.url),
service: i,
method: a,
message: ((s = e.body) == null ? void 0 : s.text) ?? "",
metadata: (e.metadata ?? []).map((d) => ({
enabled: !d.disabled,
name: d.name ?? "",
value: d.value ?? ""
})).filter(({ name: d, value: c }) => d !== "" || c !== "")
};
}
function g(e, o, n = 0) {
var d, c, l, w;
let t = null, i = {};
e.body.mimeType === "application/octet-stream" ? (t = "binary", i = { filePath: e.body.fileName ?? "" }) : ((d = e.body) == null ? void 0 : d.mimeType) === "application/x-www-form-urlencoded" ? (t = "application/x-www-form-urlencoded", i = {
form: (e.body.params ?? []).map((r) => ({
enabled: !r.disabled,
name: r.name ?? "",
value: r.value ?? ""
}))
}) : ((c = e.body) == null ? void 0 : c.mimeType) === "multipart/form-data" ? (t = "multipart/form-data", i = {
form: (e.body.params ?? []).map((r) => ({
enabled: !r.disabled,
name: r.name ?? "",
value: r.value ?? "",
file: r.fileName ?? null
}))
}) : ((l = e.body) == null ? void 0 : l.mimeType) === "application/graphql" ? (t = "graphql", i = { text: m(e.body.text ?? "") }) : ((w = e.body) == null ? void 0 : w.mimeType) === "application/json" && (t = "application/json", i = { text: m(e.body.text ?? "") });
let a = null, s = {};
return e.authentication.type === "bearer" ? (a = "bearer", s = {
token: m(e.authentication.token)
}) : e.authentication.type === "basic" && (a = "basic", s = {
username: m(e.authentication.username),
password: m(e.authentication.password)
}), {
id: p(e._id),
createdAt: new Date(e.created ?? Date.now()).toISOString().replace("Z", ""),
updatedAt: new Date(e.updated ?? Date.now()).toISOString().replace("Z", ""),
workspaceId: p(o),
folderId: e.parentId === o ? null : p(e.parentId),
model: "http_request",
sortPriority: n,
name: e.name,
url: m(e.url),
body: i,
bodyType: t,
authentication: s,
authenticationType: a,
method: e.method,
headers: (e.headers ?? []).map((r) => ({
enabled: !r.disabled,
name: r.name ?? "",
value: r.value ?? ""
})).filter(({ name: r, value: u }) => r !== "" || u !== "")
};
}
function h(e) {
return Object.entries(e).map(([o, n]) => ({
enabled: !0,
name: o,
value: `${n}`
}));
}
function m(e) {
return A(e) ? e.replaceAll(/{{\s*(_\.)?([^}]+)\s*}}/g, "${[$2]}") : e;
}
function _(e) {
return f(e) && e._type === "workspace";
}
function D(e) {
return f(e) && e._type === "request_group";
}
function v(e) {
return f(e) && e._type === "request";
}
function q(e) {
return f(e) && e._type === "grpc_request";
}
function y(e) {
return f(e) && e._type === "environment";
}
function f(e) {
return Object.prototype.toString.call(e) === "[object Object]";
}
function A(e) {
return Object.prototype.toString.call(e) === "[object String]";
}
function p(e) {
return e.startsWith("GENERATE_ID::") ? e : `GENERATE_ID::${e}`;
}
export {
O as pluginHookImport
};
//# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../plugins/importer-insomnia/src/index.ts"],"sourcesContent":["import {\n Environment,\n Folder,\n GrpcRequest,\n HttpRequest,\n Workspace,\n} from '../../../src-web/lib/models';\nimport '../../../src-web/plugin/runtime.d.ts';\n\ntype AtLeast<T, K extends keyof T> = Partial<T> & Pick<T, K>;\n\nexport interface ExportResources {\n workspaces: AtLeast<Workspace, 'name' | 'id' | 'model'>[];\n environments: AtLeast<Environment, 'name' | 'id' | 'model' | 'workspaceId'>[];\n httpRequests: AtLeast<HttpRequest, 'name' | 'id' | 'model' | 'workspaceId'>[];\n grpcRequests: AtLeast<GrpcRequest, 'name' | 'id' | 'model' | 'workspaceId'>[];\n folders: AtLeast<Folder, 'name' | 'id' | 'model' | 'workspaceId'>[];\n}\n\nexport function pluginHookImport(ctx: YaakContext, contents: string) {\n let parsed: any;\n\n try {\n parsed = JSON.parse(contents);\n } catch (e) {}\n\n try {\n parsed = parsed ?? YAML.parse(contents);\n } catch (e) {\n console.log('FAILED', e);\n }\n\n if (!isJSObject(parsed)) return;\n if (!Array.isArray(parsed.resources)) return;\n\n const resources: ExportResources = {\n workspaces: [],\n httpRequests: [],\n grpcRequests: [],\n environments: [],\n folders: [],\n };\n\n // Import workspaces\n const workspacesToImport = parsed.resources.filter(isWorkspace);\n for (const workspaceToImport of workspacesToImport) {\n const baseEnvironment = parsed.resources.find(\n (r: any) => isEnvironment(r) && r.parentId === workspaceToImport._id,\n );\n resources.workspaces.push({\n id: convertId(workspaceToImport._id),\n createdAt: new Date(workspacesToImport.created ?? Date.now()).toISOString().replace('Z', ''),\n updatedAt: new Date(workspacesToImport.updated ?? Date.now()).toISOString().replace('Z', ''),\n model: 'workspace',\n name: workspaceToImport.name,\n variables: baseEnvironment ? parseVariables(baseEnvironment.data) : [],\n });\n const environmentsToImport = parsed.resources.filter(\n (r: any) => isEnvironment(r) && r.parentId === baseEnvironment?._id,\n );\n resources.environments.push(\n ...environmentsToImport.map((r: any) => importEnvironment(r, workspaceToImport._id)),\n );\n\n const nextFolder = (parentId: string) => {\n const children = parsed.resources.filter((r: any) => r.parentId === parentId);\n let sortPriority = 0;\n for (const child of children) {\n if (isRequestGroup(child)) {\n resources.folders.push(importFolder(child, workspaceToImport._id));\n nextFolder(child._id);\n } else if (isHttpRequest(child)) {\n resources.httpRequests.push(\n importHttpRequest(child, workspaceToImport._id, sortPriority++),\n );\n } else if (isGrpcRequest(child)) {\n resources.grpcRequests.push(\n importGrpcRequest(child, workspaceToImport._id, sortPriority++),\n );\n }\n }\n };\n\n // Import folders\n nextFolder(workspaceToImport._id);\n }\n\n // Filter out any `null` values\n resources.httpRequests = resources.httpRequests.filter(Boolean);\n resources.grpcRequests = resources.grpcRequests.filter(Boolean);\n resources.environments = resources.environments.filter(Boolean);\n resources.workspaces = resources.workspaces.filter(Boolean);\n\n return { resources };\n}\n\nfunction importEnvironment(e: any, workspaceId: string): ExportResources['environments'][0] {\n return {\n id: convertId(e._id),\n createdAt: new Date(e.created ?? Date.now()).toISOString().replace('Z', ''),\n updatedAt: new Date(e.updated ?? Date.now()).toISOString().replace('Z', ''),\n workspaceId: convertId(workspaceId),\n model: 'environment',\n name: e.name,\n variables: Object.entries(e.data).map(([name, value]) => ({\n enabled: true,\n name,\n value: `${value}`,\n })),\n };\n}\n\nfunction importFolder(f: any, workspaceId: string): ExportResources['folders'][0] {\n return {\n id: convertId(f._id),\n createdAt: new Date(f.created ?? Date.now()).toISOString().replace('Z', ''),\n updatedAt: new Date(f.updated ?? Date.now()).toISOString().replace('Z', ''),\n folderId: f.parentId === workspaceId ? null : convertId(f.parentId),\n workspaceId: convertId(workspaceId),\n model: 'folder',\n name: f.name,\n };\n}\n\nfunction importGrpcRequest(\n r: any,\n workspaceId: string,\n sortPriority = 0,\n): ExportResources['grpcRequests'][0] {\n const parts = r.protoMethodName.split('/').filter((p: any) => p !== '');\n const service = parts[0] ?? null;\n const method = parts[1] ?? null;\n\n return {\n id: convertId(r._id),\n createdAt: new Date(r.created ?? Date.now()).toISOString().replace('Z', ''),\n updatedAt: new Date(r.updated ?? Date.now()).toISOString().replace('Z', ''),\n workspaceId: convertId(workspaceId),\n folderId: r.parentId === workspaceId ? null : convertId(r.parenLine truncated
@@ -0,0 +1,184 @@
const _ = "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", C = "https://schema.getpostman.com/json/collection/v2.0.0/collection.json", O = [C, _];
function v(e, t) {
var w;
console.log("CTX", e);
const a = q(t);
if (a == null)
return;
const s = i(a.info);
if (!O.includes(s.schema) || !Array.isArray(a.item))
return;
const u = k(a.auth), n = {
workspaces: [],
environments: [],
httpRequests: [],
folders: []
}, p = {
model: "workspace",
id: b("workspace"),
name: s.name || "Postman Import",
description: s.description || "",
variables: ((w = a.variable) == null ? void 0 : w.map((r) => ({
name: r.key,
value: r.value
}))) ?? []
};
n.workspaces.push(p);
const g = (r, d = null) => {
if (typeof r.name == "string" && Array.isArray(r.item)) {
const o = {
model: "folder",
workspaceId: p.id,
id: b("folder"),
name: r.name,
folderId: d
};
n.folders.push(o);
for (const l of r.item)
g(l, o.id);
} else if (typeof r.name == "string" && "request" in r) {
const o = i(r.request), l = j(o.body), A = k(o.auth), m = A.authenticationType == null ? u : A, S = {
model: "http_request",
id: b("http_request"),
workspaceId: p.id,
folderId: d,
name: r.name,
method: o.method || "GET",
url: typeof o.url == "string" ? o.url : i(o.url).raw,
body: l.body,
bodyType: l.bodyType,
authentication: m.authentication,
authenticationType: m.authenticationType,
headers: [
...l.headers,
...m.headers,
...f(o.header).map((y) => ({
name: y.key,
value: y.value,
enabled: !y.disabled
}))
]
};
n.httpRequests.push(S);
} else
console.log("Unknown item", r, d);
};
for (const r of a.item)
g(r);
return { resources: T(n) };
}
function k(e) {
const t = i(e);
return "basic" in t ? {
headers: [],
authenticationType: "basic",
authentication: {
username: t.basic.username || "",
password: t.basic.password || ""
}
} : "bearer" in t ? {
headers: [],
authenticationType: "bearer",
authentication: {
token: t.bearer.token || ""
}
} : { headers: [], authenticationType: null, authentication: {} };
}
function j(e) {
var a, s, c, u;
const t = i(e);
return "graphql" in t ? {
headers: [
{
name: "Content-Type",
value: "application/json",
enabled: !0
}
],
bodyType: "graphql",
body: {
text: JSON.stringify(
{ query: t.graphql.query, variables: q(t.graphql.variables) },
null,
2
)
}
} : "urlencoded" in t ? {
headers: [
{
name: "Content-Type",
value: "application/x-www-form-urlencoded",
enabled: !0
}
],
bodyType: "application/x-www-form-urlencoded",
body: {
form: f(t.urlencoded).map((n) => ({
enabled: !n.disabled,
name: n.key ?? "",
value: n.value ?? ""
}))
}
} : "formdata" in t ? {
headers: [
{
name: "Content-Type",
value: "multipart/form-data",
enabled: !0
}
],
bodyType: "multipart/form-data",
body: {
form: f(t.formdata).map(
(n) => n.src != null ? {
enabled: !n.disabled,
contentType: n.contentType ?? null,
name: n.key ?? "",
file: n.src ?? ""
} : {
enabled: !n.disabled,
name: n.key ?? "",
value: n.value ?? ""
}
)
}
} : "raw" in t ? {
headers: [
{
name: "Content-Type",
value: ((s = (a = t.options) == null ? void 0 : a.raw) == null ? void 0 : s.language) === "json" ? "application/json" : "",
enabled: !0
}
],
bodyType: ((u = (c = t.options) == null ? void 0 : c.raw) == null ? void 0 : u.language) === "json" ? "application/json" : "other",
body: {
text: t.raw ?? ""
}
} : { headers: [], bodyType: null, body: {} };
}
function q(e) {
try {
return i(JSON.parse(e));
} catch {
}
return null;
}
function i(e) {
return Object.prototype.toString.call(e) === "[object Object]" ? e : {};
}
function f(e) {
return Object.prototype.toString.call(e) === "[object Array]" ? e : [];
}
function T(e) {
return typeof e == "string" ? e.replace(/{{\s*(_\.)?([^}]+)\s*}}/g, "${[$2]}") : Array.isArray(e) && e != null ? e.map(T) : typeof e == "object" && e != null ? Object.fromEntries(
Object.entries(e).map(([t, a]) => [t, T(a)])
) : e;
}
const h = {};
function b(e) {
return h[e] = (h[e] ?? -1) + 1, `GENERATE_ID::${e.toUpperCase()}_${h[e]}`;
}
export {
v as pluginHookImport
};
//# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../plugins/importer-postman/src/index.ts"],"sourcesContent":["import { Environment, Folder, HttpRequest, Model, Workspace } from '../../../src-web/lib/models';\n\nconst POSTMAN_2_1_0_SCHEMA = 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json';\nconst POSTMAN_2_0_0_SCHEMA = 'https://schema.getpostman.com/json/collection/v2.0.0/collection.json';\nconst VALID_SCHEMAS = [POSTMAN_2_0_0_SCHEMA, POSTMAN_2_1_0_SCHEMA];\n\ntype AtLeast<T, K extends keyof T> = Partial<T> & Pick<T, K>;\n\ninterface ExportResources {\n workspaces: AtLeast<Workspace, 'name' | 'id' | 'model'>[];\n environments: AtLeast<Environment, 'name' | 'id' | 'model' | 'workspaceId'>[];\n httpRequests: AtLeast<HttpRequest, 'name' | 'id' | 'model' | 'workspaceId'>[];\n folders: AtLeast<Folder, 'name' | 'id' | 'model' | 'workspaceId'>[];\n}\n\nexport function pluginHookImport(\n ctx: any,\n contents: string,\n): { resources: ExportResources } | undefined {\n console.log('CTX', ctx);\n const root = parseJSONToRecord(contents);\n if (root == null) return;\n\n const info = toRecord(root.info);\n const isValidSchema = VALID_SCHEMAS.includes(info.schema);\n if (!isValidSchema || !Array.isArray(root.item)) {\n return;\n }\n\n const globalAuth = importAuth(root.auth);\n\n const exportResources: ExportResources = {\n workspaces: [],\n environments: [],\n httpRequests: [],\n folders: [],\n };\n\n const workspace: ExportResources['workspaces'][0] = {\n model: 'workspace',\n id: generateId('workspace'),\n name: info.name || 'Postman Import',\n description: info.description || '',\n variables:\n root.variable?.map((v: any) => ({\n name: v.key,\n value: v.value,\n })) ?? [],\n };\n exportResources.workspaces.push(workspace);\n\n const importItem = (v: Record<string, any>, folderId: string | null = null) => {\n if (typeof v.name === 'string' && Array.isArray(v.item)) {\n const folder: ExportResources['folders'][0] = {\n model: 'folder',\n workspaceId: workspace.id,\n id: generateId('folder'),\n name: v.name,\n folderId,\n };\n exportResources.folders.push(folder);\n for (const child of v.item) {\n importItem(child, folder.id);\n }\n } else if (typeof v.name === 'string' && 'request' in v) {\n const r = toRecord(v.request);\n const bodyPatch = importBody(r.body);\n const requestAuthPath = importAuth(r.auth);\n const authPatch = requestAuthPath.authenticationType == null ? globalAuth : requestAuthPath;\n const request: ExportResources['httpRequests'][0] = {\n model: 'http_request',\n id: generateId('http_request'),\n workspaceId: workspace.id,\n folderId,\n name: v.name,\n method: r.method || 'GET',\n url: typeof r.url === 'string' ? r.url : toRecord(r.url).raw,\n body: bodyPatch.body,\n bodyType: bodyPatch.bodyType,\n authentication: authPatch.authentication,\n authenticationType: authPatch.authenticationType,\n headers: [\n ...bodyPatch.headers,\n ...authPatch.headers,\n ...toArray(r.header).map((h) => {\n return {\n name: h.key,\n value: h.value,\n enabled: !h.disabled,\n };\n }),\n ],\n };\n exportResources.httpRequests.push(request);\n } else {\n console.log('Unknown item', v, folderId);\n }\n };\n\n for (const item of root.item) {\n importItem(item);\n }\n\n return { resources: convertTemplateSyntax(exportResources) };\n}\n\nfunction importAuth(\n rawAuth: any,\n): Pick<HttpRequest, 'authentication' | 'authenticationType' | 'headers'> {\n const auth = toRecord(rawAuth);\n if ('basic' in auth) {\n return {\n headers: [],\n authenticationType: 'basic',\n authentication: {\n username: auth.basic.username || '',\n password: auth.basic.password || '',\n },\n };\n } else if ('bearer' in auth) {\n return {\n headers: [],\n authenticationType: 'bearer',\n authentication: {\n token: auth.bearer.token || '',\n },\n };\n } else {\n // TODO: support other auth types\n return { headers: [], authenticationType: null, authentication: {} };\n }\n}\n\nfunction importBody(rawBody: any): Pick<HttpRequest, 'body' | 'bodyType' | 'headers'> {\n const body = toRecord(rawBody);\n if ('graphql' in body) {\n return {\n headers: [\n {\n name: 'Content-Type',\n value: 'application/json',\n enabled: true,\n },\n ],\n bodyType: 'graphql',\n body: {\n text: JSON.stringify(\n { query: body.graphql.query, variables: parseJSONToRecord(body.graphql.variables) },\n null,\n 2,\n ),\n },\n };\n } else if ('urlencoded' in body) {\n return {\n hLine truncated
+18
View File
@@ -0,0 +1,18 @@
function u(r, t) {
let e;
try {
e = JSON.parse(t);
} catch {
return;
}
if (!(!s(e) || !("yaakSchema" in e)))
return "requests" in e.resources && (e.resources.httpRequests = e.resources.requests, delete e.resources.requests), { resources: e.resources };
}
function s(r) {
return Object.prototype.toString.call(r) === "[object Object]";
}
export {
s as isJSObject,
u as pluginHookImport
};
//# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../plugins/importer-yaak/src/index.ts"],"sourcesContent":["export function pluginHookImport(ctx: any, contents: string) {\n let parsed;\n try {\n parsed = JSON.parse(contents);\n } catch (err) {\n return undefined;\n }\n\n if (!isJSObject(parsed)) {\n return undefined;\n }\n\n const isYaakExport = 'yaakSchema' in parsed;\n if (!isYaakExport) {\n return;\n }\n\n // Migrate v1 to v2 -- changes requests to httpRequests\n if ('requests' in parsed.resources) {\n parsed.resources.httpRequests = parsed.resources.requests;\n delete parsed.resources['requests'];\n }\n\n return { resources: parsed.resources }; // Should already be in the correct format\n}\n\nexport function isJSObject(obj: any) {\n return Object.prototype.toString.call(obj) === '[object Object]';\n}\n"],"names":["pluginHookImport","ctx","contents","parsed","isJSObject","obj"],"mappings":"AAAgB,SAAAA,EAAiBC,GAAUC,GAAkB;AACvD,MAAAC;AACA,MAAA;AACO,IAAAA,IAAA,KAAK,MAAMD,CAAQ;AAAA,UAChB;AACL;AAAA,EACT;AAOA,MALI,GAACE,EAAWD,CAAM,KAKlB,EADiB,gBAAgBA;AAMjC,WAAA,cAAcA,EAAO,cAChBA,EAAA,UAAU,eAAeA,EAAO,UAAU,UAC1C,OAAAA,EAAO,UAAU,WAGnB,EAAE,WAAWA,EAAO;AAC7B;AAEO,SAASC,EAAWC,GAAU;AACnC,SAAO,OAAO,UAAU,SAAS,KAAKA,CAAG,MAAM;AACjD;"}
+5 -5
View File
@@ -735,7 +735,7 @@ async fn cmd_filter_response(
};
let body = read_to_string(response.body_path.unwrap()).unwrap();
let filter_result = plugin::run_plugin_filter(plugin_name, filter, &body)
let filter_result = plugin::run_plugin_filter(&w.app_handle(), plugin_name, filter, &body)
.await
.expect("Failed to run filter");
Ok(filter_result.filtered)
@@ -758,7 +758,7 @@ async fn cmd_import_data(
read_to_string(file_path).unwrap_or_else(|_| panic!("Unable to read file {}", file_path));
let file_contents = file.as_str();
for plugin_name in plugins {
let v = run_plugin_import(plugin_name, file_contents)
let v = run_plugin_import(&w.app_handle(), plugin_name, file_contents)
.await
.map_err(|e| e.to_string())?;
if let Some(r) = v {
@@ -903,12 +903,12 @@ async fn cmd_request_to_curl(
.await
.map_err(|e| e.to_string())?;
let rendered = render_request(&request, &workspace, environment.as_ref());
Ok(run_plugin_export_curl(&rendered)?)
Ok(run_plugin_export_curl(&app, &rendered)?)
}
#[tauri::command]
async fn cmd_curl_to_request(command: &str, workspace_id: &str) -> Result<HttpRequest, String> {
let v = run_plugin_import("importer-curl", command)
async fn cmd_curl_to_request(app_handle: AppHandle, command: &str, workspace_id: &str) -> Result<HttpRequest, String> {
let v = run_plugin_import(&app_handle, "importer-curl", command)
.await
.map_err(|e| e.to_string());
match v {
+26 -7
View File
@@ -2,6 +2,8 @@ use std::path;
use log::error;
use serde::{Deserialize, Serialize};
use tauri::path::BaseDirectory;
use tauri::{AppHandle, Manager};
use crate::deno::run_plugin_deno_block;
use crate::models::{HttpRequest, WorkspaceExportResources};
@@ -17,12 +19,17 @@ pub struct ImportResult {
}
pub async fn run_plugin_filter(
app_handle: &AppHandle,
plugin_name: &str,
response_body: &str,
filter: &str,
) -> Option<FilterResult> {
let plugin_dir = path::Path::new("/Users/gschier/Workspace/yaak/plugins");
let plugin_index_file = plugin_dir.join(plugin_name).join("build/index.mjs");
let plugin_dir = app_handle
.path()
.resolve("plugins", BaseDirectory::Resource)
.expect("failed to resolve plugin directory resource")
.join(plugin_name);
let plugin_index_file = plugin_dir.join("index.mjs");
let result = run_plugin_deno_block(
plugin_index_file.to_str().unwrap(),
@@ -45,9 +52,16 @@ pub async fn run_plugin_filter(
Some(resources)
}
pub fn run_plugin_export_curl(request: &HttpRequest) -> Result<String, String> {
let plugin_dir = path::Path::new("/Users/gschier/Workspace/yaak/plugins");
let plugin_index_file = plugin_dir.join("exporter-curl").join("build/index.mjs");
pub fn run_plugin_export_curl(
app_handle: &AppHandle,
request: &HttpRequest,
) -> Result<String, String> {
let plugin_dir = app_handle
.path()
.resolve("plugins", BaseDirectory::Resource)
.expect("failed to resolve plugin directory resource")
.join("exporter-curl");
let plugin_index_file = plugin_dir.join("index.mjs");
let request_json = serde_json::to_value(request).map_err(|e| e.to_string())?;
let result = run_plugin_deno_block(
@@ -62,11 +76,16 @@ pub fn run_plugin_export_curl(request: &HttpRequest) -> Result<String, String> {
}
pub async fn run_plugin_import(
app_handle: &AppHandle,
plugin_name: &str,
file_contents: &str,
) -> Result<Option<ImportResult>, String> {
let plugin_dir = path::Path::new("/Users/gschier/Workspace/yaak/plugins");
let plugin_index_file = plugin_dir.join(plugin_name).join("build/index.mjs");
let plugin_dir = app_handle
.path()
.resolve("plugins", BaseDirectory::Resource)
.expect("failed to resolve plugin directory resource")
.join(plugin_name);
let plugin_index_file = plugin_dir.join("index.mjs");
let result = run_plugin_deno_block(
plugin_index_file.to_str().unwrap(),
+2 -1
View File
@@ -1,6 +1,6 @@
{
"productName": "yaak",
"version": "2024.6.3",
"version": "2024.6.4",
"identifier": "app.yaak.desktop",
"build": {
"beforeBuildCommand": "npm run build",
@@ -27,6 +27,7 @@
"desktop": {
"schemes": [
"yaak"
]
}
},
+2 -2
View File
@@ -59,7 +59,7 @@ export function ExportDataDialog({
const noneSelected = numSelected === 0;
return (
<VStack space={3} className="w-full mb-3 px-4">
<table className="w-full mb-auto min-w-full max-w-full divide-y">
<table className="w-full mb-auto min-w-full max-w-full divide-y divide-background-highlight-secondary">
<thead>
<tr>
<th className="w-6 min-w-0 py-2 text-left pl-1">
@@ -76,7 +76,7 @@ export function ExportDataDialog({
</th>
</tr>
</thead>
<tbody className="divide-y">
<tbody className="divide-y divide-background-highlight-secondary">
{workspaces.map((w) => (
<tr key={w.id}>
<td className="min-w-0 py-1 pl-1">
@@ -1,18 +1,25 @@
import { useMutation } from '@tanstack/react-query';
import { invoke } from '@tauri-apps/api/core';
import { InlineCode } from '../components/core/InlineCode';
import { minPromiseMillis } from '../lib/minPromiseMillis';
import { useAlert } from './useAlert';
import { useAppInfo } from './useAppInfo';
export function useCheckForUpdates() {
const alert = useAlert();
const appInfo = useAppInfo();
return useMutation({
mutationFn: async () => {
const hasUpdate: boolean = await minPromiseMillis(invoke('cmd_check_for_updates'), 500);
if (!hasUpdate) {
alert({
id: 'no-updates',
title: 'No Updates',
body: 'You are currently up to date',
title: 'No Update Available',
body: (
<>
You are currently on the latest version <InlineCode>{appInfo?.version}</InlineCode>
</>
),
});
}
},