diff --git a/packages/plugin-runtime-types/package.json b/packages/plugin-runtime-types/package.json index 7c6fb290..510732ec 100644 --- a/packages/plugin-runtime-types/package.json +++ b/packages/plugin-runtime-types/package.json @@ -1,6 +1,6 @@ { "name": "@yaakapp/api", - "version": "0.5.3", + "version": "0.6.0", "main": "lib/index.js", "typings": "./lib/index.d.ts", "files": [ diff --git a/packages/plugin-runtime-types/src/bindings/gen_events.ts b/packages/plugin-runtime-types/src/bindings/gen_events.ts index a67f9f66..4d762f6e 100644 --- a/packages/plugin-runtime-types/src/bindings/gen_events.ts +++ b/packages/plugin-runtime-types/src/bindings/gen_events.ts @@ -104,7 +104,11 @@ hideLabel?: boolean, /** * The default value */ -defaultValue?: string, disabled?: boolean, }; +defaultValue?: string, disabled?: boolean, +/** + * Longer description of the input, likely shown in a tooltip + */ +description?: string, }; export type FormInputCheckbox = { /** @@ -131,7 +135,11 @@ hideLabel?: boolean, /** * The default value */ -defaultValue?: string, disabled?: boolean, }; +defaultValue?: string, disabled?: boolean, +/** + * Longer description of the input, likely shown in a tooltip + */ +description?: string, }; export type FormInputEditor = { /** @@ -170,7 +178,11 @@ hideLabel?: boolean, /** * The default value */ -defaultValue?: string, disabled?: boolean, }; +defaultValue?: string, disabled?: boolean, +/** + * Longer description of the input, likely shown in a tooltip + */ +description?: string, }; export type FormInputFile = { /** @@ -205,7 +217,11 @@ hideLabel?: boolean, /** * The default value */ -defaultValue?: string, disabled?: boolean, }; +defaultValue?: string, disabled?: boolean, +/** + * Longer description of the input, likely shown in a tooltip + */ +description?: string, }; export type FormInputHttpRequest = { /** @@ -232,7 +248,11 @@ hideLabel?: boolean, /** * The default value */ -defaultValue?: string, disabled?: boolean, }; +defaultValue?: string, disabled?: boolean, +/** + * Longer description of the input, likely shown in a tooltip + */ +description?: string, }; export type FormInputMarkdown = { content: string, hidden?: boolean, }; @@ -265,7 +285,11 @@ hideLabel?: boolean, /** * The default value */ -defaultValue?: string, disabled?: boolean, }; +defaultValue?: string, disabled?: boolean, +/** + * Longer description of the input, likely shown in a tooltip + */ +description?: string, }; export type FormInputSelectOption = { label: string, value: string, }; @@ -306,7 +330,11 @@ hideLabel?: boolean, /** * The default value */ -defaultValue?: string, disabled?: boolean, }; +defaultValue?: string, disabled?: boolean, +/** + * Longer description of the input, likely shown in a tooltip + */ +description?: string, }; export type GenericCompletionOption = { label: string, detail?: string, info?: string, type?: CompletionOptionType, boost?: number, }; diff --git a/src-tauri/vendored/plugins/template-function-cookie/build/index.js b/src-tauri/vendored/plugins/template-function-cookie/build/index.js index c194983c..42696360 100644 --- a/src-tauri/vendored/plugins/template-function-cookie/build/index.js +++ b/src-tauri/vendored/plugins/template-function-cookie/build/index.js @@ -36,9 +36,6 @@ var plugin = { } ], async onRender(ctx, args) { - console.log("COOKIE", args.values.cookie_name); - const cookies = await ctx.cookies.listNames({}); - console.log("COOKIES", cookies); return ctx.cookies.getValue({ name: String(args.values.cookie_name) }); } } diff --git a/src-tauri/vendored/plugins/template-function-encode/build/index.js b/src-tauri/vendored/plugins/template-function-encode/build/index.js new file mode 100644 index 00000000..28195b7c --- /dev/null +++ b/src-tauri/vendored/plugins/template-function-encode/build/index.js @@ -0,0 +1,49 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/index.ts +var src_exports = {}; +__export(src_exports, { + plugin: () => plugin +}); +module.exports = __toCommonJS(src_exports); +var plugin = { + templateFunctions: [ + { + name: "base64.encode", + description: "Encode a value to base64", + args: [{ label: "Plain Text", type: "text", name: "value", multiLine: true }], + async onRender(_ctx, args) { + return Buffer.from(args.values.value ?? "").toString("base64"); + } + }, + { + name: "base64.decode", + description: "Decode a value from base64", + args: [{ label: "Encoded Value", type: "text", name: "value", multiLine: true }], + async onRender(_ctx, args) { + return Buffer.from(args.values.value ?? "", "base64").toString("utf-8"); + } + } + ] +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + plugin +}); diff --git a/src-tauri/vendored/plugins/template-function-encode/package.json b/src-tauri/vendored/plugins/template-function-encode/package.json new file mode 100644 index 00000000..4c261fdc --- /dev/null +++ b/src-tauri/vendored/plugins/template-function-encode/package.json @@ -0,0 +1,9 @@ +{ + "name": "@yaakapp/template-function-encode", + "private": true, + "version": "0.0.1", + "scripts": { + "build": "yaakcli build ./src/index.ts", + "dev": "yaakcli dev ./src/index.js" + } +} diff --git a/src-tauri/vendored/plugins/template-function-hash/build/index.js b/src-tauri/vendored/plugins/template-function-hash/build/index.js index 7fe4f9af..3f83a694 100644 --- a/src-tauri/vendored/plugins/template-function-hash/build/index.js +++ b/src-tauri/vendored/plugins/template-function-hash/build/index.js @@ -25,24 +25,76 @@ __export(src_exports, { module.exports = __toCommonJS(src_exports); var import_node_crypto = require("node:crypto"); var algorithms = ["md5", "sha1", "sha256", "sha512"]; -var plugin = { - templateFunctions: algorithms.map((algorithm) => ({ - name: `hash.${algorithm}`, - description: "Hash a value to its hexidecimal representation", - args: [ - { - name: "input", - label: "Input", - placeholder: "input text", - type: "text" - } - ], - async onRender(_ctx, args) { - if (!args.values.input) return ""; - return (0, import_node_crypto.createHash)(algorithm).update(args.values.input, "utf-8").digest("hex"); +var encodings = ["base64", "hex"]; +var hashFunctions = algorithms.map((algorithm) => ({ + name: `hash.${algorithm}`, + description: "Hash a value to its hexidecimal representation", + args: [ + { + type: "text", + name: "input", + label: "Input", + placeholder: "input text", + multiLine: true + }, + { + type: "select", + name: "encoding", + label: "Encoding", + defaultValue: "base64", + options: encodings.map((encoding) => ({ + label: capitalize(encoding), + value: encoding + })) } - })) + ], + async onRender(_ctx, args) { + const input = String(args.values.input); + const encoding = String(args.values.encoding); + return (0, import_node_crypto.createHash)(algorithm).update(input, "utf-8").digest(encoding); + } +})); +var hmacFunctions = algorithms.map((algorithm) => ({ + name: `hmac.${algorithm}`, + description: "Compute the HMAC of a value", + args: [ + { + type: "text", + name: "input", + label: "Input", + placeholder: "input text", + multiLine: true + }, + { + type: "text", + name: "key", + label: "Key", + password: true + }, + { + type: "select", + name: "encoding", + label: "Encoding", + defaultValue: "base64", + options: encodings.map((encoding) => ({ + value: encoding, + label: capitalize(encoding) + })) + } + ], + async onRender(_ctx, args) { + const input = String(args.values.input); + const key = String(args.values.key); + const encoding = String(args.values.encoding); + return (0, import_node_crypto.createHmac)(algorithm, key, {}).update(input).digest(encoding); + } +})); +var plugin = { + templateFunctions: [...hashFunctions, ...hmacFunctions] }; +function capitalize(str) { + return str.charAt(0).toUpperCase() + str.slice(1); +} // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { plugin diff --git a/src-tauri/vendored/plugins/template-function-regex/build/index.js b/src-tauri/vendored/plugins/template-function-regex/build/index.js new file mode 100644 index 00000000..f4597230 --- /dev/null +++ b/src-tauri/vendored/plugins/template-function-regex/build/index.js @@ -0,0 +1,52 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/index.ts +var src_exports = {}; +__export(src_exports, { + plugin: () => plugin +}); +module.exports = __toCommonJS(src_exports); +var plugin = { + templateFunctions: [{ + name: "regex.match", + description: "Extract", + args: [ + { + type: "text", + name: "regex", + label: "Regular Expression", + placeholder: "^w+=(?w*)$", + defaultValue: "^(.*)$", + description: "A JavaScript regular expression, evaluated using the Node.js RegExp engine. Capture groups or named groups can be used to extract values." + }, + { type: "text", name: "input", label: "Input Text", multiLine: true } + ], + async onRender(_ctx, args) { + if (!args.values.regex) return ""; + const regex = new RegExp(String(args.values.regex)); + const match = args.values.input?.match(regex); + return match?.groups ? Object.values(match.groups)[0] ?? "" : match?.[1] ?? match?.[0] ?? ""; + } + }] +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + plugin +}); diff --git a/src-tauri/vendored/plugins/template-function-regex/package.json b/src-tauri/vendored/plugins/template-function-regex/package.json new file mode 100644 index 00000000..de67316b --- /dev/null +++ b/src-tauri/vendored/plugins/template-function-regex/package.json @@ -0,0 +1,9 @@ +{ + "name": "@yaakapp/template-function-regex", + "private": true, + "version": "0.0.1", + "scripts": { + "build": "yaakcli build ./src/index.ts", + "dev": "yaakcli dev ./src/index.js" + } +} diff --git a/src-tauri/yaak-models/src/models.rs b/src-tauri/yaak-models/src/models.rs index 983eba4a..d9917ea4 100644 --- a/src-tauri/yaak-models/src/models.rs +++ b/src-tauri/yaak-models/src/models.rs @@ -401,7 +401,7 @@ impl UpsertModelInfo for WorkspaceMeta { #[derive(Debug, Clone, Serialize, Deserialize, TS)] #[ts(export, export_to = "gen_models.ts")] -enum CookieDomain { +pub enum CookieDomain { HostOnly(String), Suffix(String), NotPresent, @@ -410,7 +410,7 @@ enum CookieDomain { #[derive(Debug, Clone, Serialize, Deserialize, TS)] #[ts(export, export_to = "gen_models.ts")] -enum CookieExpires { +pub enum CookieExpires { AtUtc(String), SessionEnd, } diff --git a/src-tauri/yaak-plugins/bindings/gen_events.ts b/src-tauri/yaak-plugins/bindings/gen_events.ts index a67f9f66..4d762f6e 100644 --- a/src-tauri/yaak-plugins/bindings/gen_events.ts +++ b/src-tauri/yaak-plugins/bindings/gen_events.ts @@ -104,7 +104,11 @@ hideLabel?: boolean, /** * The default value */ -defaultValue?: string, disabled?: boolean, }; +defaultValue?: string, disabled?: boolean, +/** + * Longer description of the input, likely shown in a tooltip + */ +description?: string, }; export type FormInputCheckbox = { /** @@ -131,7 +135,11 @@ hideLabel?: boolean, /** * The default value */ -defaultValue?: string, disabled?: boolean, }; +defaultValue?: string, disabled?: boolean, +/** + * Longer description of the input, likely shown in a tooltip + */ +description?: string, }; export type FormInputEditor = { /** @@ -170,7 +178,11 @@ hideLabel?: boolean, /** * The default value */ -defaultValue?: string, disabled?: boolean, }; +defaultValue?: string, disabled?: boolean, +/** + * Longer description of the input, likely shown in a tooltip + */ +description?: string, }; export type FormInputFile = { /** @@ -205,7 +217,11 @@ hideLabel?: boolean, /** * The default value */ -defaultValue?: string, disabled?: boolean, }; +defaultValue?: string, disabled?: boolean, +/** + * Longer description of the input, likely shown in a tooltip + */ +description?: string, }; export type FormInputHttpRequest = { /** @@ -232,7 +248,11 @@ hideLabel?: boolean, /** * The default value */ -defaultValue?: string, disabled?: boolean, }; +defaultValue?: string, disabled?: boolean, +/** + * Longer description of the input, likely shown in a tooltip + */ +description?: string, }; export type FormInputMarkdown = { content: string, hidden?: boolean, }; @@ -265,7 +285,11 @@ hideLabel?: boolean, /** * The default value */ -defaultValue?: string, disabled?: boolean, }; +defaultValue?: string, disabled?: boolean, +/** + * Longer description of the input, likely shown in a tooltip + */ +description?: string, }; export type FormInputSelectOption = { label: string, value: string, }; @@ -306,7 +330,11 @@ hideLabel?: boolean, /** * The default value */ -defaultValue?: string, disabled?: boolean, }; +defaultValue?: string, disabled?: boolean, +/** + * Longer description of the input, likely shown in a tooltip + */ +description?: string, }; export type GenericCompletionOption = { label: string, detail?: string, info?: string, type?: CompletionOptionType, boost?: number, }; diff --git a/src-tauri/yaak-plugins/src/events.rs b/src-tauri/yaak-plugins/src/events.rs index 5e4ec454..faebabe5 100644 --- a/src-tauri/yaak-plugins/src/events.rs +++ b/src-tauri/yaak-plugins/src/events.rs @@ -594,6 +594,10 @@ pub struct FormInputBase { #[ts(optional)] pub disabled: Option, + + /// Longer description of the input, likely shown in a tooltip + #[ts(optional)] + pub description: Option, } #[derive(Debug, Clone, Default, Serialize, Deserialize, TS)] diff --git a/src-web/components/DynamicForm.tsx b/src-web/components/DynamicForm.tsx index ce4817b5..4db425ad 100644 --- a/src-web/components/DynamicForm.tsx +++ b/src-web/components/DynamicForm.tsx @@ -237,6 +237,7 @@ function TextArg({ defaultValue={value === DYNAMIC_FORM_NULL_ARG ? arg.defaultValue : value} required={!arg.optional} disabled={arg.disabled} + help={arg.description} type={arg.password ? 'password' : 'text'} label={arg.label ?? arg.name} size={INPUT_SIZE} @@ -278,6 +279,7 @@ function EditorArg({ htmlFor={id} required={!arg.optional} visuallyHidden={arg.hideLabel} + help={arg.description} tags={arg.language ? [capitalize(arg.language)] : undefined} > {arg.label} @@ -319,6 +321,7 @@ function SelectArg({