Run oxfmt across repo, add format script and docs

Add .oxfmtignore to skip generated bindings and wasm-pack output.
Add npm format script, update DEVELOPMENT.md for Vite+ toolchain,
and format all non-generated files with oxfmt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Gregory Schier
2026-03-13 10:15:49 -07:00
parent 45262edfbd
commit b4a1c418bb
664 changed files with 13638 additions and 13492 deletions

View File

@@ -1,9 +1,9 @@
{
"name": "@yaak/template-function-prompt",
"displayName": "Prompt Template Functions",
"description": "Template functions for prompting for user input",
"private": true,
"version": "0.1.0",
"private": true,
"description": "Template functions for prompting for user input",
"scripts": {
"build": "yaakcli build",
"dev": "yaakcli dev"

View File

@@ -1,9 +1,9 @@
import type { CallTemplateFunctionArgs, Context, PluginDefinition } from '@yaakapp/api';
import slugify from 'slugify';
import type { CallTemplateFunctionArgs, Context, PluginDefinition } from "@yaakapp/api";
import slugify from "slugify";
const STORE_NONE = 'none';
const STORE_FOREVER = 'forever';
const STORE_EXPIRE = 'expire';
const STORE_NONE = "none";
const STORE_FOREVER = "forever";
const STORE_EXPIRE = "expire";
interface Saved {
value: string;
@@ -13,15 +13,15 @@ interface Saved {
export const plugin: PluginDefinition = {
templateFunctions: [
{
name: 'prompt.text',
description: 'Prompt the user for input when sending a request',
previewType: 'click',
previewArgs: ['label'],
name: "prompt.text",
description: "Prompt the user for input when sending a request",
previewType: "click",
previewArgs: ["label"],
args: [
{
type: 'text',
name: 'label',
label: 'Label',
type: "text",
name: "label",
label: "Label",
optional: true,
dynamic(_ctx, args) {
if (
@@ -33,45 +33,45 @@ export const plugin: PluginDefinition = {
},
},
{
type: 'select',
name: 'store',
label: 'Store Input',
type: "select",
name: "store",
label: "Store Input",
defaultValue: STORE_NONE,
options: [
{ label: 'Never', value: STORE_NONE },
{ label: 'Expire', value: STORE_EXPIRE },
{ label: 'Forever', value: STORE_FOREVER },
{ label: "Never", value: STORE_NONE },
{ label: "Expire", value: STORE_EXPIRE },
{ label: "Forever", value: STORE_FOREVER },
],
},
{
type: 'h_stack',
type: "h_stack",
dynamic(_ctx, args) {
return { hidden: args.values.store === STORE_NONE };
},
inputs: [
{
type: 'text',
name: 'namespace',
label: 'Namespace',
type: "text",
name: "namespace",
label: "Namespace",
// oxlint-disable-next-line no-template-curly-in-string -- Yaak template syntax
defaultValue: '${[ctx.workspace()]}',
defaultValue: "${[ctx.workspace()]}",
optional: true,
},
{
type: 'text',
name: 'key',
label: 'Key (defaults to Label)',
type: "text",
name: "key",
label: "Key (defaults to Label)",
optional: true,
dynamic(_ctx, args) {
return { placeholder: String(args.values.label || '') };
return { placeholder: String(args.values.label || "") };
},
},
{
type: 'text',
name: 'ttl',
label: 'TTL (seconds)',
placeholder: '0',
defaultValue: '0',
type: "text",
name: "ttl",
label: "TTL (seconds)",
placeholder: "0",
defaultValue: "0",
optional: true,
dynamic(_ctx, args) {
return { hidden: args.values.store !== STORE_EXPIRE };
@@ -80,49 +80,49 @@ export const plugin: PluginDefinition = {
],
},
{
type: 'banner',
color: 'info',
type: "banner",
color: "info",
inputs: [],
dynamic(_ctx, args) {
let key: string;
try {
key = buildKey(args);
} catch (err) {
return { color: 'danger', inputs: [{ type: 'markdown', content: String(err) }] };
return { color: "danger", inputs: [{ type: "markdown", content: String(err) }] };
}
return {
hidden: args.values.store === STORE_NONE,
inputs: [
{
type: 'markdown',
content: [`Value will be saved under: \`${key}\``].join('\n\n'),
type: "markdown",
content: [`Value will be saved under: \`${key}\``].join("\n\n"),
},
],
};
},
},
{
type: 'accordion',
label: 'Advanced',
type: "accordion",
label: "Advanced",
inputs: [
{
type: 'text',
name: 'title',
label: 'Prompt Title',
type: "text",
name: "title",
label: "Prompt Title",
optional: true,
placeholder: 'Enter Value',
placeholder: "Enter Value",
},
{ type: 'text', name: 'defaultValue', label: 'Default Value', optional: true },
{ type: 'text', name: 'placeholder', label: 'Input Placeholder', optional: true },
{ type: 'checkbox', name: 'password', label: 'Mask Value' },
{ type: "text", name: "defaultValue", label: "Default Value", optional: true },
{ type: "text", name: "placeholder", label: "Input Placeholder", optional: true },
{ type: "checkbox", name: "password", label: "Mask Value" },
],
},
],
async onRender(ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
if (args.purpose !== 'send') return null;
if (args.purpose !== "send") return null;
if (args.values.store !== STORE_NONE && !args.values.namespace) {
throw new Error('Namespace is required when storing values');
throw new Error("Namespace is required when storing values");
}
const existing = await maybeGetValue(ctx, args);
@@ -131,17 +131,17 @@ export const plugin: PluginDefinition = {
}
const value = await ctx.prompt.text({
id: `prompt-${args.values.label ?? 'none'}`,
label: String(args.values.label || 'Value'),
title: String(args.values.title ?? 'Enter Value'),
defaultValue: String(args.values.defaultValue ?? ''),
placeholder: String(args.values.placeholder ?? ''),
id: `prompt-${args.values.label ?? "none"}`,
label: String(args.values.label || "Value"),
title: String(args.values.title ?? "Enter Value"),
defaultValue: String(args.values.defaultValue ?? ""),
placeholder: String(args.values.placeholder ?? ""),
password: Boolean(args.values.password),
required: false,
});
if (value == null) {
throw new Error('Prompt cancelled');
throw new Error("Prompt cancelled");
}
if (args.values.store !== STORE_NONE) {
@@ -156,12 +156,12 @@ export const plugin: PluginDefinition = {
function buildKey(args: CallTemplateFunctionArgs) {
if (!args.values.key && !args.values.label) {
throw new Error('A label or key is required when storing values');
throw new Error("A label or key is required when storing values");
}
return [args.values.namespace, args.values.key || args.values.label]
.filter((v) => !!v)
.map((v) => slugify(String(v), { lower: true, trim: true }))
.join('.');
.join(".");
}
async function maybeGetValue(ctx: Context, args: CallTemplateFunctionArgs) {