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-xml",
"displayName": "XML Template Functions",
"description": "Template functions for working with XML data",
"private": true,
"version": "0.1.0",
"private": true,
"description": "Template functions for working with XML data",
"main": "build/index.js",
"types": "src/index.ts",
"scripts": {

View File

@@ -1,53 +1,53 @@
/* oxlint-disable no-base-to-string */
import { DOMParser } from '@xmldom/xmldom';
import type { CallTemplateFunctionArgs, Context, PluginDefinition } from '@yaakapp/api';
import xpath from 'xpath';
import { DOMParser } from "@xmldom/xmldom";
import type { CallTemplateFunctionArgs, Context, PluginDefinition } from "@yaakapp/api";
import xpath from "xpath";
const RETURN_FIRST = 'first';
const RETURN_ALL = 'all';
const RETURN_JOIN = 'join';
const RETURN_FIRST = "first";
const RETURN_ALL = "all";
const RETURN_JOIN = "join";
export const plugin: PluginDefinition = {
templateFunctions: [
{
name: 'xml.xpath',
description: 'Filter XML-formatted text using XPath syntax',
previewArgs: ['query'],
name: "xml.xpath",
description: "Filter XML-formatted text using XPath syntax",
previewArgs: ["query"],
args: [
{
type: 'text',
name: 'input',
label: 'Input',
type: "text",
name: "input",
label: "Input",
multiLine: true,
placeholder: '<foo></foo>',
placeholder: "<foo></foo>",
},
{
type: 'h_stack',
type: "h_stack",
inputs: [
{
type: 'select',
name: 'result',
label: 'Return Format',
type: "select",
name: "result",
label: "Return Format",
defaultValue: RETURN_FIRST,
options: [
{ label: 'First result', value: RETURN_FIRST },
{ label: 'All results', value: RETURN_ALL },
{ label: 'Join with separator', value: RETURN_JOIN },
{ label: "First result", value: RETURN_FIRST },
{ label: "All results", value: RETURN_ALL },
{ label: "Join with separator", value: RETURN_JOIN },
],
},
{
name: 'join',
type: 'text',
label: 'Separator',
name: "join",
type: "text",
label: "Separator",
optional: true,
defaultValue: ', ',
defaultValue: ", ",
dynamic(_ctx, args) {
return { hidden: args.values.result !== RETURN_JOIN };
},
},
],
},
{ type: 'text', name: 'query', label: 'Query', placeholder: '//foo' },
{ type: "text", name: "query", label: "Query", placeholder: "//foo" },
],
async onRender(_ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
try {
@@ -62,7 +62,7 @@ export const plugin: PluginDefinition = {
],
};
export type XPathResult = 'first' | 'join' | 'all';
export type XPathResult = "first" | "join" | "all";
export function filterXPath(
body: string,
path: string,
@@ -70,17 +70,17 @@ export function filterXPath(
join: string | null,
): string {
// oxlint-disable-next-line no-explicit-any
const doc: any = new DOMParser().parseFromString(body, 'text/xml');
const doc: any = new DOMParser().parseFromString(body, "text/xml");
const items = xpath.select(path, doc, false);
if (!Array.isArray(items)) {
return String(items);
}
if (!Array.isArray(items) || result === 'first') {
return items[0] != null ? String(items[0].firstChild ?? '') : '';
if (!Array.isArray(items) || result === "first") {
return items[0] != null ? String(items[0].firstChild ?? "") : "";
}
if (result === 'join') {
return items.map((item) => String(item.firstChild ?? '')).join(join ?? '');
if (result === "join") {
return items.map((item) => String(item.firstChild ?? "")).join(join ?? "");
}
// Not sure what cases this happens in (?)
return String(items);