mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-24 01:28:35 +02:00
Proper handling of boolean template function args
This commit is contained in:
1287
src-tauri/vendored/plugins/filter-jsonpath/build/index.js
generated
1287
src-tauri/vendored/plugins/filter-jsonpath/build/index.js
generated
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@
|
|||||||
"dev": "yaakcli dev ./src/index.js"
|
"dev": "yaakcli dev ./src/index.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"jsonpath-plus": "^9.0.0"
|
"jsonpath-plus": "^10.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jsonpath": "^0.2.4"
|
"@types/jsonpath": "^0.2.4"
|
||||||
|
|||||||
1769
src-tauri/vendored/plugins/template-function-json/build/index.js
generated
Normal file
1769
src-tauri/vendored/plugins/template-function-json/build/index.js
generated
Normal file
File diff suppressed because it is too large
Load Diff
15
src-tauri/vendored/plugins/template-function-json/package.json
generated
Executable file
15
src-tauri/vendored/plugins/template-function-json/package.json
generated
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "@yaakapp/template-function-json",
|
||||||
|
"private": true,
|
||||||
|
"version": "0.0.1",
|
||||||
|
"scripts": {
|
||||||
|
"build": "yaakcli build ./src/index.ts",
|
||||||
|
"dev": "yaakcli dev ./src/index.js"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"jsonpath-plus": "^10.3.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/jsonpath": "^0.2.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
417
src-tauri/vendored/plugins/template-function-uuid/build/index.js
generated
Normal file
417
src-tauri/vendored/plugins/template-function-uuid/build/index.js
generated
Normal file
@@ -0,0 +1,417 @@
|
|||||||
|
"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);
|
||||||
|
|
||||||
|
// node_modules/uuid/dist/esm/regex.js
|
||||||
|
var regex_default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
||||||
|
|
||||||
|
// node_modules/uuid/dist/esm/validate.js
|
||||||
|
function validate(uuid) {
|
||||||
|
return typeof uuid === "string" && regex_default.test(uuid);
|
||||||
|
}
|
||||||
|
var validate_default = validate;
|
||||||
|
|
||||||
|
// node_modules/uuid/dist/esm/parse.js
|
||||||
|
function parse(uuid) {
|
||||||
|
if (!validate_default(uuid)) {
|
||||||
|
throw TypeError("Invalid UUID");
|
||||||
|
}
|
||||||
|
let v;
|
||||||
|
return Uint8Array.of((v = parseInt(uuid.slice(0, 8), 16)) >>> 24, v >>> 16 & 255, v >>> 8 & 255, v & 255, (v = parseInt(uuid.slice(9, 13), 16)) >>> 8, v & 255, (v = parseInt(uuid.slice(14, 18), 16)) >>> 8, v & 255, (v = parseInt(uuid.slice(19, 23), 16)) >>> 8, v & 255, (v = parseInt(uuid.slice(24, 36), 16)) / 1099511627776 & 255, v / 4294967296 & 255, v >>> 24 & 255, v >>> 16 & 255, v >>> 8 & 255, v & 255);
|
||||||
|
}
|
||||||
|
var parse_default = parse;
|
||||||
|
|
||||||
|
// node_modules/uuid/dist/esm/stringify.js
|
||||||
|
var byteToHex = [];
|
||||||
|
for (let i = 0; i < 256; ++i) {
|
||||||
|
byteToHex.push((i + 256).toString(16).slice(1));
|
||||||
|
}
|
||||||
|
function unsafeStringify(arr, offset = 0) {
|
||||||
|
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
// node_modules/uuid/dist/esm/rng.js
|
||||||
|
var import_crypto = require("crypto");
|
||||||
|
var rnds8Pool = new Uint8Array(256);
|
||||||
|
var poolPtr = rnds8Pool.length;
|
||||||
|
function rng() {
|
||||||
|
if (poolPtr > rnds8Pool.length - 16) {
|
||||||
|
(0, import_crypto.randomFillSync)(rnds8Pool);
|
||||||
|
poolPtr = 0;
|
||||||
|
}
|
||||||
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
// node_modules/uuid/dist/esm/v1.js
|
||||||
|
var _state = {};
|
||||||
|
function v1(options, buf, offset) {
|
||||||
|
let bytes;
|
||||||
|
const isV6 = options?._v6 ?? false;
|
||||||
|
if (options) {
|
||||||
|
const optionsKeys = Object.keys(options);
|
||||||
|
if (optionsKeys.length === 1 && optionsKeys[0] === "_v6") {
|
||||||
|
options = void 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (options) {
|
||||||
|
bytes = v1Bytes(options.random ?? options.rng?.() ?? rng(), options.msecs, options.nsecs, options.clockseq, options.node, buf, offset);
|
||||||
|
} else {
|
||||||
|
const now = Date.now();
|
||||||
|
const rnds = rng();
|
||||||
|
updateV1State(_state, now, rnds);
|
||||||
|
bytes = v1Bytes(rnds, _state.msecs, _state.nsecs, isV6 ? void 0 : _state.clockseq, isV6 ? void 0 : _state.node, buf, offset);
|
||||||
|
}
|
||||||
|
return buf ?? unsafeStringify(bytes);
|
||||||
|
}
|
||||||
|
function updateV1State(state, now, rnds) {
|
||||||
|
state.msecs ??= -Infinity;
|
||||||
|
state.nsecs ??= 0;
|
||||||
|
if (now === state.msecs) {
|
||||||
|
state.nsecs++;
|
||||||
|
if (state.nsecs >= 1e4) {
|
||||||
|
state.node = void 0;
|
||||||
|
state.nsecs = 0;
|
||||||
|
}
|
||||||
|
} else if (now > state.msecs) {
|
||||||
|
state.nsecs = 0;
|
||||||
|
} else if (now < state.msecs) {
|
||||||
|
state.node = void 0;
|
||||||
|
}
|
||||||
|
if (!state.node) {
|
||||||
|
state.node = rnds.slice(10, 16);
|
||||||
|
state.node[0] |= 1;
|
||||||
|
state.clockseq = (rnds[8] << 8 | rnds[9]) & 16383;
|
||||||
|
}
|
||||||
|
state.msecs = now;
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
function v1Bytes(rnds, msecs, nsecs, clockseq, node, buf, offset = 0) {
|
||||||
|
if (rnds.length < 16) {
|
||||||
|
throw new Error("Random bytes length must be >= 16");
|
||||||
|
}
|
||||||
|
if (!buf) {
|
||||||
|
buf = new Uint8Array(16);
|
||||||
|
offset = 0;
|
||||||
|
} else {
|
||||||
|
if (offset < 0 || offset + 16 > buf.length) {
|
||||||
|
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msecs ??= Date.now();
|
||||||
|
nsecs ??= 0;
|
||||||
|
clockseq ??= (rnds[8] << 8 | rnds[9]) & 16383;
|
||||||
|
node ??= rnds.slice(10, 16);
|
||||||
|
msecs += 122192928e5;
|
||||||
|
const tl = ((msecs & 268435455) * 1e4 + nsecs) % 4294967296;
|
||||||
|
buf[offset++] = tl >>> 24 & 255;
|
||||||
|
buf[offset++] = tl >>> 16 & 255;
|
||||||
|
buf[offset++] = tl >>> 8 & 255;
|
||||||
|
buf[offset++] = tl & 255;
|
||||||
|
const tmh = msecs / 4294967296 * 1e4 & 268435455;
|
||||||
|
buf[offset++] = tmh >>> 8 & 255;
|
||||||
|
buf[offset++] = tmh & 255;
|
||||||
|
buf[offset++] = tmh >>> 24 & 15 | 16;
|
||||||
|
buf[offset++] = tmh >>> 16 & 255;
|
||||||
|
buf[offset++] = clockseq >>> 8 | 128;
|
||||||
|
buf[offset++] = clockseq & 255;
|
||||||
|
for (let n = 0; n < 6; ++n) {
|
||||||
|
buf[offset++] = node[n];
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
var v1_default = v1;
|
||||||
|
|
||||||
|
// node_modules/uuid/dist/esm/v1ToV6.js
|
||||||
|
function v1ToV6(uuid) {
|
||||||
|
const v1Bytes2 = typeof uuid === "string" ? parse_default(uuid) : uuid;
|
||||||
|
const v6Bytes = _v1ToV6(v1Bytes2);
|
||||||
|
return typeof uuid === "string" ? unsafeStringify(v6Bytes) : v6Bytes;
|
||||||
|
}
|
||||||
|
function _v1ToV6(v1Bytes2) {
|
||||||
|
return Uint8Array.of((v1Bytes2[6] & 15) << 4 | v1Bytes2[7] >> 4 & 15, (v1Bytes2[7] & 15) << 4 | (v1Bytes2[4] & 240) >> 4, (v1Bytes2[4] & 15) << 4 | (v1Bytes2[5] & 240) >> 4, (v1Bytes2[5] & 15) << 4 | (v1Bytes2[0] & 240) >> 4, (v1Bytes2[0] & 15) << 4 | (v1Bytes2[1] & 240) >> 4, (v1Bytes2[1] & 15) << 4 | (v1Bytes2[2] & 240) >> 4, 96 | v1Bytes2[2] & 15, v1Bytes2[3], v1Bytes2[8], v1Bytes2[9], v1Bytes2[10], v1Bytes2[11], v1Bytes2[12], v1Bytes2[13], v1Bytes2[14], v1Bytes2[15]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// node_modules/uuid/dist/esm/md5.js
|
||||||
|
var import_crypto2 = require("crypto");
|
||||||
|
function md5(bytes) {
|
||||||
|
if (Array.isArray(bytes)) {
|
||||||
|
bytes = Buffer.from(bytes);
|
||||||
|
} else if (typeof bytes === "string") {
|
||||||
|
bytes = Buffer.from(bytes, "utf8");
|
||||||
|
}
|
||||||
|
return (0, import_crypto2.createHash)("md5").update(bytes).digest();
|
||||||
|
}
|
||||||
|
var md5_default = md5;
|
||||||
|
|
||||||
|
// node_modules/uuid/dist/esm/v35.js
|
||||||
|
function stringToBytes(str) {
|
||||||
|
str = unescape(encodeURIComponent(str));
|
||||||
|
const bytes = new Uint8Array(str.length);
|
||||||
|
for (let i = 0; i < str.length; ++i) {
|
||||||
|
bytes[i] = str.charCodeAt(i);
|
||||||
|
}
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
var DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
|
||||||
|
var URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
|
||||||
|
function v35(version, hash, value, namespace, buf, offset) {
|
||||||
|
const valueBytes = typeof value === "string" ? stringToBytes(value) : value;
|
||||||
|
const namespaceBytes = typeof namespace === "string" ? parse_default(namespace) : namespace;
|
||||||
|
if (typeof namespace === "string") {
|
||||||
|
namespace = parse_default(namespace);
|
||||||
|
}
|
||||||
|
if (namespace?.length !== 16) {
|
||||||
|
throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");
|
||||||
|
}
|
||||||
|
let bytes = new Uint8Array(16 + valueBytes.length);
|
||||||
|
bytes.set(namespaceBytes);
|
||||||
|
bytes.set(valueBytes, namespaceBytes.length);
|
||||||
|
bytes = hash(bytes);
|
||||||
|
bytes[6] = bytes[6] & 15 | version;
|
||||||
|
bytes[8] = bytes[8] & 63 | 128;
|
||||||
|
if (buf) {
|
||||||
|
offset = offset || 0;
|
||||||
|
for (let i = 0; i < 16; ++i) {
|
||||||
|
buf[offset + i] = bytes[i];
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
return unsafeStringify(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
// node_modules/uuid/dist/esm/v3.js
|
||||||
|
function v3(value, namespace, buf, offset) {
|
||||||
|
return v35(48, md5_default, value, namespace, buf, offset);
|
||||||
|
}
|
||||||
|
v3.DNS = DNS;
|
||||||
|
v3.URL = URL;
|
||||||
|
var v3_default = v3;
|
||||||
|
|
||||||
|
// node_modules/uuid/dist/esm/native.js
|
||||||
|
var import_crypto3 = require("crypto");
|
||||||
|
var native_default = { randomUUID: import_crypto3.randomUUID };
|
||||||
|
|
||||||
|
// node_modules/uuid/dist/esm/v4.js
|
||||||
|
function v4(options, buf, offset) {
|
||||||
|
if (native_default.randomUUID && !buf && !options) {
|
||||||
|
return native_default.randomUUID();
|
||||||
|
}
|
||||||
|
options = options || {};
|
||||||
|
const rnds = options.random ?? options.rng?.() ?? rng();
|
||||||
|
if (rnds.length < 16) {
|
||||||
|
throw new Error("Random bytes length must be >= 16");
|
||||||
|
}
|
||||||
|
rnds[6] = rnds[6] & 15 | 64;
|
||||||
|
rnds[8] = rnds[8] & 63 | 128;
|
||||||
|
if (buf) {
|
||||||
|
offset = offset || 0;
|
||||||
|
if (offset < 0 || offset + 16 > buf.length) {
|
||||||
|
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
||||||
|
}
|
||||||
|
for (let i = 0; i < 16; ++i) {
|
||||||
|
buf[offset + i] = rnds[i];
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
return unsafeStringify(rnds);
|
||||||
|
}
|
||||||
|
var v4_default = v4;
|
||||||
|
|
||||||
|
// node_modules/uuid/dist/esm/sha1.js
|
||||||
|
var import_crypto4 = require("crypto");
|
||||||
|
function sha1(bytes) {
|
||||||
|
if (Array.isArray(bytes)) {
|
||||||
|
bytes = Buffer.from(bytes);
|
||||||
|
} else if (typeof bytes === "string") {
|
||||||
|
bytes = Buffer.from(bytes, "utf8");
|
||||||
|
}
|
||||||
|
return (0, import_crypto4.createHash)("sha1").update(bytes).digest();
|
||||||
|
}
|
||||||
|
var sha1_default = sha1;
|
||||||
|
|
||||||
|
// node_modules/uuid/dist/esm/v5.js
|
||||||
|
function v5(value, namespace, buf, offset) {
|
||||||
|
return v35(80, sha1_default, value, namespace, buf, offset);
|
||||||
|
}
|
||||||
|
v5.DNS = DNS;
|
||||||
|
v5.URL = URL;
|
||||||
|
var v5_default = v5;
|
||||||
|
|
||||||
|
// node_modules/uuid/dist/esm/v6.js
|
||||||
|
function v6(options, buf, offset) {
|
||||||
|
options ??= {};
|
||||||
|
offset ??= 0;
|
||||||
|
let bytes = v1_default({ ...options, _v6: true }, new Uint8Array(16));
|
||||||
|
bytes = v1ToV6(bytes);
|
||||||
|
if (buf) {
|
||||||
|
for (let i = 0; i < 16; i++) {
|
||||||
|
buf[offset + i] = bytes[i];
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
return unsafeStringify(bytes);
|
||||||
|
}
|
||||||
|
var v6_default = v6;
|
||||||
|
|
||||||
|
// node_modules/uuid/dist/esm/v7.js
|
||||||
|
var _state2 = {};
|
||||||
|
function v7(options, buf, offset) {
|
||||||
|
let bytes;
|
||||||
|
if (options) {
|
||||||
|
bytes = v7Bytes(options.random ?? options.rng?.() ?? rng(), options.msecs, options.seq, buf, offset);
|
||||||
|
} else {
|
||||||
|
const now = Date.now();
|
||||||
|
const rnds = rng();
|
||||||
|
updateV7State(_state2, now, rnds);
|
||||||
|
bytes = v7Bytes(rnds, _state2.msecs, _state2.seq, buf, offset);
|
||||||
|
}
|
||||||
|
return buf ?? unsafeStringify(bytes);
|
||||||
|
}
|
||||||
|
function updateV7State(state, now, rnds) {
|
||||||
|
state.msecs ??= -Infinity;
|
||||||
|
state.seq ??= 0;
|
||||||
|
if (now > state.msecs) {
|
||||||
|
state.seq = rnds[6] << 23 | rnds[7] << 16 | rnds[8] << 8 | rnds[9];
|
||||||
|
state.msecs = now;
|
||||||
|
} else {
|
||||||
|
state.seq = state.seq + 1 | 0;
|
||||||
|
if (state.seq === 0) {
|
||||||
|
state.msecs++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
function v7Bytes(rnds, msecs, seq, buf, offset = 0) {
|
||||||
|
if (rnds.length < 16) {
|
||||||
|
throw new Error("Random bytes length must be >= 16");
|
||||||
|
}
|
||||||
|
if (!buf) {
|
||||||
|
buf = new Uint8Array(16);
|
||||||
|
offset = 0;
|
||||||
|
} else {
|
||||||
|
if (offset < 0 || offset + 16 > buf.length) {
|
||||||
|
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msecs ??= Date.now();
|
||||||
|
seq ??= rnds[6] * 127 << 24 | rnds[7] << 16 | rnds[8] << 8 | rnds[9];
|
||||||
|
buf[offset++] = msecs / 1099511627776 & 255;
|
||||||
|
buf[offset++] = msecs / 4294967296 & 255;
|
||||||
|
buf[offset++] = msecs / 16777216 & 255;
|
||||||
|
buf[offset++] = msecs / 65536 & 255;
|
||||||
|
buf[offset++] = msecs / 256 & 255;
|
||||||
|
buf[offset++] = msecs & 255;
|
||||||
|
buf[offset++] = 112 | seq >>> 28 & 15;
|
||||||
|
buf[offset++] = seq >>> 20 & 255;
|
||||||
|
buf[offset++] = 128 | seq >>> 14 & 63;
|
||||||
|
buf[offset++] = seq >>> 6 & 255;
|
||||||
|
buf[offset++] = seq << 2 & 255 | rnds[10] & 3;
|
||||||
|
buf[offset++] = rnds[11];
|
||||||
|
buf[offset++] = rnds[12];
|
||||||
|
buf[offset++] = rnds[13];
|
||||||
|
buf[offset++] = rnds[14];
|
||||||
|
buf[offset++] = rnds[15];
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
var v7_default = v7;
|
||||||
|
|
||||||
|
// src/index.ts
|
||||||
|
var plugin = {
|
||||||
|
templateFunctions: [
|
||||||
|
{
|
||||||
|
name: "uuid.v1",
|
||||||
|
description: "Generate a UUID V1",
|
||||||
|
args: [],
|
||||||
|
async onRender(_ctx, _args) {
|
||||||
|
return v1_default();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "uuid.v3",
|
||||||
|
description: "Generate a UUID V3",
|
||||||
|
args: [
|
||||||
|
{ type: "text", name: "name", label: "Name" },
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
name: "namespace",
|
||||||
|
label: "Namespace UUID",
|
||||||
|
description: "A valid UUID to use as the namespace",
|
||||||
|
placeholder: "24ced880-3bf4-11f0-8329-cd053d577f0e"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
async onRender(_ctx, args) {
|
||||||
|
return v3_default(String(args.values.name), String(args.values.namespace));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "uuid.v4",
|
||||||
|
description: "Generate a UUID V4",
|
||||||
|
args: [],
|
||||||
|
async onRender(_ctx, _args) {
|
||||||
|
return v4_default();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "uuid.v5",
|
||||||
|
description: "Generate a UUID V5",
|
||||||
|
args: [
|
||||||
|
{ type: "text", name: "name", label: "Name" },
|
||||||
|
{ type: "text", name: "namespace", label: "Namespace" }
|
||||||
|
],
|
||||||
|
async onRender(_ctx, args) {
|
||||||
|
return v5_default(String(args.values.name), String(args.values.namespace));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "uuid.v6",
|
||||||
|
description: "Generate a UUID V6",
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
name: "timestamp",
|
||||||
|
label: "Timestamp",
|
||||||
|
optional: true,
|
||||||
|
description: "Can be any format that can be parsed by JavaScript new Date(...)",
|
||||||
|
placeholder: "2025-05-28T11:15:00Z"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
async onRender(_ctx, args) {
|
||||||
|
return v6_default({ msecs: new Date(String(args.values.timestamp)).getTime() });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "uuid.v7",
|
||||||
|
description: "Generate a UUID V7",
|
||||||
|
args: [],
|
||||||
|
async onRender(_ctx, _args) {
|
||||||
|
return v7_default();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
// Annotate the CommonJS export names for ESM import in node:
|
||||||
|
0 && (module.exports = {
|
||||||
|
plugin
|
||||||
|
});
|
||||||
12
src-tauri/vendored/plugins/template-function-uuid/package.json
generated
Normal file
12
src-tauri/vendored/plugins/template-function-uuid/package.json
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"name": "@yaakapp/template-function-uuid",
|
||||||
|
"private": true,
|
||||||
|
"version": "0.0.1",
|
||||||
|
"scripts": {
|
||||||
|
"build": "yaakcli build ./src/index.ts",
|
||||||
|
"dev": "yaakcli dev ./src/index.js"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"uuid": "^11.1.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
8380
src-tauri/vendored/plugins/template-function-xml/build/index.js
generated
Normal file
8380
src-tauri/vendored/plugins/template-function-xml/build/index.js
generated
Normal file
File diff suppressed because it is too large
Load Diff
13
src-tauri/vendored/plugins/template-function-xml/package.json
generated
Executable file
13
src-tauri/vendored/plugins/template-function-xml/package.json
generated
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "@yaakapp/template-function-xml",
|
||||||
|
"private": true,
|
||||||
|
"version": "0.0.1",
|
||||||
|
"scripts": {
|
||||||
|
"build": "yaakcli build ./src/index.ts",
|
||||||
|
"dev": "yaakcli dev ./src/index.js"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@xmldom/xmldom": "^0.8.10",
|
||||||
|
"xpath": "^0.0.34"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -840,7 +840,7 @@ pub struct CallTemplateFunctionResponse {
|
|||||||
#[ts(export, export_to = "gen_events.ts")]
|
#[ts(export, export_to = "gen_events.ts")]
|
||||||
pub struct CallTemplateFunctionArgs {
|
pub struct CallTemplateFunctionArgs {
|
||||||
pub purpose: RenderPurpose,
|
pub purpose: RenderPurpose,
|
||||||
pub values: HashMap<String, String>,
|
pub values: HashMap<String, serde_json::Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, TS)]
|
#[derive(Debug, Clone, Serialize, Deserialize, TS)]
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use crate::events::{
|
|||||||
GetHttpRequestActionsResponse, GetTemplateFunctionsResponse, ImportRequest, ImportResponse,
|
GetHttpRequestActionsResponse, GetTemplateFunctionsResponse, ImportRequest, ImportResponse,
|
||||||
InternalEvent, InternalEventPayload, JsonPrimitive, PluginWindowContext, RenderPurpose,
|
InternalEvent, InternalEventPayload, JsonPrimitive, PluginWindowContext, RenderPurpose,
|
||||||
};
|
};
|
||||||
|
use crate::native_template_functions::template_function_secure;
|
||||||
use crate::nodejs::start_nodejs_plugin_runtime;
|
use crate::nodejs::start_nodejs_plugin_runtime;
|
||||||
use crate::plugin_handle::PluginHandle;
|
use crate::plugin_handle::PluginHandle;
|
||||||
use crate::server_ws::PluginRuntimeServerWebsocket;
|
use crate::server_ws::PluginRuntimeServerWebsocket;
|
||||||
@@ -24,13 +25,12 @@ use tauri::path::BaseDirectory;
|
|||||||
use tauri::{AppHandle, Manager, Runtime, WebviewWindow};
|
use tauri::{AppHandle, Manager, Runtime, WebviewWindow};
|
||||||
use tokio::fs::read_dir;
|
use tokio::fs::read_dir;
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
use tokio::sync::{mpsc, Mutex};
|
use tokio::sync::{Mutex, mpsc};
|
||||||
use tokio::time::{timeout, Instant};
|
use tokio::time::{Instant, timeout};
|
||||||
use yaak_models::query_manager::QueryManagerExt;
|
use yaak_models::query_manager::QueryManagerExt;
|
||||||
use yaak_models::util::generate_id;
|
use yaak_models::util::generate_id;
|
||||||
use yaak_templates::error::Error::RenderError;
|
use yaak_templates::error::Error::RenderError;
|
||||||
use yaak_templates::error::Result as TemplateResult;
|
use yaak_templates::error::Result as TemplateResult;
|
||||||
use crate::native_template_functions::template_function_secure;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct PluginManager {
|
pub struct PluginManager {
|
||||||
@@ -160,8 +160,7 @@ impl PluginManager {
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let plugins =
|
let plugins = app_handle.db().list_plugins().unwrap_or_default();
|
||||||
app_handle.db().list_plugins().unwrap_or_default();
|
|
||||||
let installed_plugin_dirs: Vec<PluginCandidate> = plugins
|
let installed_plugin_dirs: Vec<PluginCandidate> = plugins
|
||||||
.iter()
|
.iter()
|
||||||
.map(|p| PluginCandidate {
|
.map(|p| PluginCandidate {
|
||||||
@@ -606,15 +605,12 @@ impl PluginManager {
|
|||||||
&self,
|
&self,
|
||||||
window_context: &PluginWindowContext,
|
window_context: &PluginWindowContext,
|
||||||
fn_name: &str,
|
fn_name: &str,
|
||||||
args: HashMap<String, String>,
|
values: HashMap<String, serde_json::Value>,
|
||||||
purpose: RenderPurpose,
|
purpose: RenderPurpose,
|
||||||
) -> TemplateResult<String> {
|
) -> TemplateResult<String> {
|
||||||
let req = CallTemplateFunctionRequest {
|
let req = CallTemplateFunctionRequest {
|
||||||
name: fn_name.to_string(),
|
name: fn_name.to_string(),
|
||||||
args: CallTemplateFunctionArgs {
|
args: CallTemplateFunctionArgs { purpose, values },
|
||||||
purpose,
|
|
||||||
values: args,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let events = self
|
let events = self
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ pub(crate) fn template_function_secure() -> TemplateFunction {
|
|||||||
|
|
||||||
pub fn template_function_secure_run<R: Runtime>(
|
pub fn template_function_secure_run<R: Runtime>(
|
||||||
app_handle: &AppHandle<R>,
|
app_handle: &AppHandle<R>,
|
||||||
args: HashMap<String, String>,
|
args: HashMap<String, serde_json::Value>,
|
||||||
window_context: &PluginWindowContext,
|
window_context: &PluginWindowContext,
|
||||||
) -> Result<String> {
|
) -> Result<String> {
|
||||||
match window_context.clone() {
|
match window_context.clone() {
|
||||||
@@ -43,9 +43,10 @@ pub fn template_function_secure_run<R: Runtime>(
|
|||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
let value = args.get("value").map(|v| v.to_owned()).unwrap_or_default();
|
let value = args.get("value").map(|v| v.to_owned()).unwrap_or_default();
|
||||||
if value.is_empty() {
|
let value = match value {
|
||||||
return Ok("".to_string());
|
serde_json::Value::String(s) => s,
|
||||||
}
|
_ => return Ok("".to_string()),
|
||||||
|
};
|
||||||
|
|
||||||
let value = match value.strip_prefix("YENC_") {
|
let value = match value.strip_prefix("YENC_") {
|
||||||
None => {
|
None => {
|
||||||
@@ -118,7 +119,7 @@ pub fn decrypt_secure_template_function<R: Runtime>(
|
|||||||
for a in args {
|
for a in args {
|
||||||
match a.clone().value {
|
match a.clone().value {
|
||||||
Val::Str { text } => {
|
Val::Str { text } => {
|
||||||
args_map.insert(a.name.to_string(), text);
|
args_map.insert(a.name.to_string(), serde_json::Value::String(text));
|
||||||
}
|
}
|
||||||
_ => continue,
|
_ => continue,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ impl<R: Runtime> PluginTemplateCallback<R> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<R: Runtime> TemplateCallback for PluginTemplateCallback<R> {
|
impl<R: Runtime> TemplateCallback for PluginTemplateCallback<R> {
|
||||||
async fn run(&self, fn_name: &str, args: HashMap<String, String>) -> Result<String> {
|
async fn run(&self, fn_name: &str, args: HashMap<String, serde_json::Value>) -> Result<String> {
|
||||||
// The beta named the function `Response` but was changed in stable.
|
// The beta named the function `Response` but was changed in stable.
|
||||||
// Keep this here for a while because there's no easy way to migrate
|
// Keep this here for a while because there's no easy way to migrate
|
||||||
let fn_name = if fn_name == "Response" { "response" } else { fn_name };
|
let fn_name = if fn_name == "Response" { "response" } else { fn_name };
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ pub trait TemplateCallback {
|
|||||||
fn run(
|
fn run(
|
||||||
&self,
|
&self,
|
||||||
fn_name: &str,
|
fn_name: &str,
|
||||||
args: HashMap<String, String>,
|
args: HashMap<String, serde_json::Value>,
|
||||||
) -> impl Future<Output = Result<String>> + Send;
|
) -> impl Future<Output = Result<String>> + Send;
|
||||||
|
|
||||||
fn transform_arg(&self, fn_name: &str, arg_name: &str, arg_value: &str) -> Result<String>;
|
fn transform_arg(&self, fn_name: &str, arg_name: &str, arg_value: &str) -> Result<String>;
|
||||||
@@ -107,9 +107,15 @@ async fn render_value<T: TemplateCallback>(
|
|||||||
None => return Err(VariableNotFound(name)),
|
None => return Err(VariableNotFound(name)),
|
||||||
},
|
},
|
||||||
Val::Fn { name, args } => {
|
Val::Fn { name, args } => {
|
||||||
let mut resolved_args: HashMap<String, String> = HashMap::new();
|
let mut resolved_args: HashMap<String, serde_json::Value> = HashMap::new();
|
||||||
for a in args {
|
for a in args {
|
||||||
let v = Box::pin(render_value(a.value, vars, cb, depth)).await?;
|
let v = match a.value.clone() {
|
||||||
|
Val::Bool { value } => serde_json::Value::Bool(value),
|
||||||
|
Val::Null => serde_json::Value::Null,
|
||||||
|
_ => serde_json::Value::String(
|
||||||
|
Box::pin(render_value(a.value, vars, cb, depth)).await?,
|
||||||
|
),
|
||||||
|
};
|
||||||
resolved_args.insert(a.name, v);
|
resolved_args.insert(a.name, v);
|
||||||
}
|
}
|
||||||
let result = cb.run(name.as_str(), resolved_args.clone()).await?;
|
let result = cb.run(name.as_str(), resolved_args.clone()).await?;
|
||||||
@@ -133,7 +139,11 @@ mod parse_and_render_tests {
|
|||||||
struct EmptyCB {}
|
struct EmptyCB {}
|
||||||
|
|
||||||
impl TemplateCallback for EmptyCB {
|
impl TemplateCallback for EmptyCB {
|
||||||
async fn run(&self, _fn_name: &str, _args: HashMap<String, String>) -> Result<String> {
|
async fn run(
|
||||||
|
&self,
|
||||||
|
_fn_name: &str,
|
||||||
|
_args: HashMap<String, serde_json::Value>,
|
||||||
|
) -> Result<String> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +246,11 @@ mod parse_and_render_tests {
|
|||||||
|
|
||||||
struct CB {}
|
struct CB {}
|
||||||
impl TemplateCallback for CB {
|
impl TemplateCallback for CB {
|
||||||
async fn run(&self, fn_name: &str, args: HashMap<String, String>) -> Result<String> {
|
async fn run(
|
||||||
|
&self,
|
||||||
|
fn_name: &str,
|
||||||
|
args: HashMap<String, serde_json::Value>,
|
||||||
|
) -> Result<String> {
|
||||||
Ok(format!("{fn_name}: {}, {:?} {:?}", args.len(), args.get("a"), args.get("b")))
|
Ok(format!("{fn_name}: {}, {:?} {:?}", args.len(), args.get("a"), args.get("b")))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +274,11 @@ mod parse_and_render_tests {
|
|||||||
let result = r#"BAR"#;
|
let result = r#"BAR"#;
|
||||||
struct CB {}
|
struct CB {}
|
||||||
impl TemplateCallback for CB {
|
impl TemplateCallback for CB {
|
||||||
async fn run(&self, fn_name: &str, args: HashMap<String, String>) -> Result<String> {
|
async fn run(
|
||||||
|
&self,
|
||||||
|
fn_name: &str,
|
||||||
|
args: HashMap<String, serde_json::Value>,
|
||||||
|
) -> Result<String> {
|
||||||
Ok(match fn_name {
|
Ok(match fn_name {
|
||||||
"secret" => "abc".to_string(),
|
"secret" => "abc".to_string(),
|
||||||
"upper" => args["foo"].to_string().to_uppercase(),
|
"upper" => args["foo"].to_string().to_uppercase(),
|
||||||
@@ -290,7 +308,7 @@ mod parse_and_render_tests {
|
|||||||
let result = r#"FOO 'BAR' BAZ"#;
|
let result = r#"FOO 'BAR' BAZ"#;
|
||||||
struct CB {}
|
struct CB {}
|
||||||
impl TemplateCallback for CB {
|
impl TemplateCallback for CB {
|
||||||
async fn run(&self, fn_name: &str, args: HashMap<String, String>) -> Result<String> {
|
async fn run(&self, fn_name: &str, args: HashMap<String, serde_json::Value>) -> Result<String> {
|
||||||
Ok(match fn_name {
|
Ok(match fn_name {
|
||||||
"upper" => args["foo"].to_string().to_uppercase(),
|
"upper" => args["foo"].to_string().to_uppercase(),
|
||||||
_ => "".to_string(),
|
_ => "".to_string(),
|
||||||
@@ -319,7 +337,7 @@ mod parse_and_render_tests {
|
|||||||
let result = r#"BAR"#;
|
let result = r#"BAR"#;
|
||||||
struct CB {}
|
struct CB {}
|
||||||
impl TemplateCallback for CB {
|
impl TemplateCallback for CB {
|
||||||
async fn run(&self, fn_name: &str, args: HashMap<String, String>) -> Result<String> {
|
async fn run(&self, fn_name: &str, args: HashMap<String, serde_json::Value>) -> Result<String> {
|
||||||
Ok(match fn_name {
|
Ok(match fn_name {
|
||||||
"secret" => "abc".to_string(),
|
"secret" => "abc".to_string(),
|
||||||
"upper" => args["foo"].to_string().to_uppercase(),
|
"upper" => args["foo"].to_string().to_uppercase(),
|
||||||
@@ -349,7 +367,7 @@ mod parse_and_render_tests {
|
|||||||
let result = r#"bar"#;
|
let result = r#"bar"#;
|
||||||
struct CB {}
|
struct CB {}
|
||||||
impl TemplateCallback for CB {
|
impl TemplateCallback for CB {
|
||||||
async fn run(&self, fn_name: &str, args: HashMap<String, String>) -> Result<String> {
|
async fn run(&self, fn_name: &str, args: HashMap<String, serde_json::Value>) -> Result<String> {
|
||||||
Ok(match fn_name {
|
Ok(match fn_name {
|
||||||
"no_op" => args["inner"].to_string(),
|
"no_op" => args["inner"].to_string(),
|
||||||
_ => "".to_string(),
|
_ => "".to_string(),
|
||||||
@@ -377,7 +395,7 @@ mod parse_and_render_tests {
|
|||||||
let result = r#"ABC"#;
|
let result = r#"ABC"#;
|
||||||
struct CB {}
|
struct CB {}
|
||||||
impl TemplateCallback for CB {
|
impl TemplateCallback for CB {
|
||||||
async fn run(&self, fn_name: &str, args: HashMap<String, String>) -> Result<String> {
|
async fn run(&self, fn_name: &str, args: HashMap<String, serde_json::Value>) -> Result<String> {
|
||||||
Ok(match fn_name {
|
Ok(match fn_name {
|
||||||
"secret" => "abc".to_string(),
|
"secret" => "abc".to_string(),
|
||||||
"upper" => args["foo"].to_string().to_uppercase(),
|
"upper" => args["foo"].to_string().to_uppercase(),
|
||||||
@@ -406,7 +424,7 @@ mod parse_and_render_tests {
|
|||||||
|
|
||||||
struct CB {}
|
struct CB {}
|
||||||
impl TemplateCallback for CB {
|
impl TemplateCallback for CB {
|
||||||
async fn run(&self, _fn_name: &str, _args: HashMap<String, String>) -> Result<String> {
|
async fn run(&self, _fn_name: &str, _args: HashMap<String, serde_json::Value>) -> Result<String> {
|
||||||
Err(RenderError("Failed to do it!".to_string()))
|
Err(RenderError("Failed to do it!".to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,7 +456,7 @@ mod render_json_value_raw_tests {
|
|||||||
struct EmptyCB {}
|
struct EmptyCB {}
|
||||||
|
|
||||||
impl TemplateCallback for EmptyCB {
|
impl TemplateCallback for EmptyCB {
|
||||||
async fn run(&self, _fn_name: &str, _args: HashMap<String, String>) -> Result<String> {
|
async fn run(&self, _fn_name: &str, _args: HashMap<String, serde_json::Value>) -> Result<String> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user