mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-07-02 11:01:36 +02:00
b4a1c418bb
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>
76 lines
2.1 KiB
TypeScript
76 lines
2.1 KiB
TypeScript
import type {
|
|
CallPromptFormDynamicArgs,
|
|
Context,
|
|
DynamicAuthenticationArg,
|
|
DynamicPromptFormArg,
|
|
DynamicTemplateFunctionArg,
|
|
} from "@yaakapp/api";
|
|
import type {
|
|
CallHttpAuthenticationActionArgs,
|
|
CallTemplateFunctionArgs,
|
|
} from "@yaakapp-internal/plugins";
|
|
|
|
type AnyDynamicArg = DynamicTemplateFunctionArg | DynamicAuthenticationArg | DynamicPromptFormArg;
|
|
type AnyCallArgs =
|
|
| CallTemplateFunctionArgs
|
|
| CallHttpAuthenticationActionArgs
|
|
| CallPromptFormDynamicArgs;
|
|
|
|
export async function applyDynamicFormInput(
|
|
ctx: Context,
|
|
args: DynamicTemplateFunctionArg[],
|
|
callArgs: CallTemplateFunctionArgs,
|
|
): Promise<DynamicTemplateFunctionArg[]>;
|
|
|
|
export async function applyDynamicFormInput(
|
|
ctx: Context,
|
|
args: DynamicAuthenticationArg[],
|
|
callArgs: CallHttpAuthenticationActionArgs,
|
|
): Promise<DynamicAuthenticationArg[]>;
|
|
|
|
export async function applyDynamicFormInput(
|
|
ctx: Context,
|
|
args: DynamicPromptFormArg[],
|
|
callArgs: CallPromptFormDynamicArgs,
|
|
): Promise<DynamicPromptFormArg[]>;
|
|
|
|
export async function applyDynamicFormInput(
|
|
ctx: Context,
|
|
args: AnyDynamicArg[],
|
|
callArgs: AnyCallArgs,
|
|
): Promise<AnyDynamicArg[]> {
|
|
const resolvedArgs: AnyDynamicArg[] = [];
|
|
for (const { dynamic, ...arg } of args) {
|
|
const dynamicResult =
|
|
typeof dynamic === "function"
|
|
? await dynamic(
|
|
ctx,
|
|
callArgs as CallTemplateFunctionArgs &
|
|
CallHttpAuthenticationActionArgs &
|
|
CallPromptFormDynamicArgs,
|
|
)
|
|
: undefined;
|
|
|
|
const newArg = {
|
|
...arg,
|
|
...dynamicResult,
|
|
} as AnyDynamicArg;
|
|
|
|
if ("inputs" in newArg && Array.isArray(newArg.inputs)) {
|
|
try {
|
|
newArg.inputs = await applyDynamicFormInput(
|
|
ctx,
|
|
newArg.inputs as DynamicTemplateFunctionArg[],
|
|
callArgs as CallTemplateFunctionArgs &
|
|
CallHttpAuthenticationActionArgs &
|
|
CallPromptFormDynamicArgs,
|
|
);
|
|
} catch (e) {
|
|
console.error("Failed to apply dynamic form input", e);
|
|
}
|
|
}
|
|
resolvedArgs.push(newArg);
|
|
}
|
|
return resolvedArgs;
|
|
}
|