mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix(lint): biome-format tool-factory and json-xml to green apps/api lint (#252)
Collapses the error_message line introduced in #251 plus the pre-existing preValidate blocks and the json-xml wrapped assignment that were already failing apps/api lint on main. Pure formatting, no logic change.
This commit is contained in:
@@ -80,9 +80,7 @@ export interface ToolRouteConfig<T> {
|
|||||||
* and validated settings; throw InputValidationError to reject with its
|
* and validated settings; throw InputValidationError to reject with its
|
||||||
* statusCode (default 400) before any job is enqueued (vs a worker 422).
|
* statusCode (default 400) before any job is enqueued (vs a worker 422).
|
||||||
*/
|
*/
|
||||||
preValidate?: (ctx: {
|
preValidate?: (ctx: { inputs: { filename: string; buffer: Buffer }[] }) => Promise<void> | void;
|
||||||
inputs: { filename: string; buffer: Buffer }[];
|
|
||||||
}) => Promise<void> | void;
|
|
||||||
/**
|
/**
|
||||||
* Per-position input kind overrides for mixed-input tools (e.g. video +
|
* Per-position input kind overrides for mixed-input tools (e.g. video +
|
||||||
* subtitle). Input i validates with kind inputKinds[Math.min(i, len-1)].
|
* subtitle). Input i validates with kind inputKinds[Math.min(i, len-1)].
|
||||||
@@ -121,9 +119,7 @@ export interface AnyToolRouteConfig {
|
|||||||
toolId: string;
|
toolId: string;
|
||||||
maxInputs?: number;
|
maxInputs?: number;
|
||||||
minInputs?: number;
|
minInputs?: number;
|
||||||
preValidate?: (ctx: {
|
preValidate?: (ctx: { inputs: { filename: string; buffer: Buffer }[] }) => Promise<void> | void;
|
||||||
inputs: { filename: string; buffer: Buffer }[];
|
|
||||||
}) => Promise<void> | void;
|
|
||||||
inputKinds?: ("video" | "audio" | "image" | "subtitle")[];
|
inputKinds?: ("video" | "audio" | "image" | "subtitle")[];
|
||||||
settingsSchema: z.ZodType<unknown, z.ZodTypeDef, unknown>;
|
settingsSchema: z.ZodType<unknown, z.ZodTypeDef, unknown>;
|
||||||
process: (
|
process: (
|
||||||
@@ -589,8 +585,7 @@ export function createToolRoute<T>(app: FastifyInstance, config: ToolRouteConfig
|
|||||||
category: TOOLS.find((t) => t.id === config.toolId)?.category ?? "unknown",
|
category: TOOLS.find((t) => t.id === config.toolId)?.category ?? "unknown",
|
||||||
is_ai_tool: getBundleForTool(config.toolId) !== null,
|
is_ai_tool: getBundleForTool(config.toolId) !== null,
|
||||||
error_code: err instanceof Error ? err.constructor.name : "UnknownError",
|
error_code: err instanceof Error ? err.constructor.name : "UnknownError",
|
||||||
error_message:
|
error_message: err instanceof Error ? err.message.slice(0, 200) : "Processing failed",
|
||||||
err instanceof Error ? err.message.slice(0, 200) : "Processing failed",
|
|
||||||
});
|
});
|
||||||
return reply.status(422).send({
|
return reply.status(422).send({
|
||||||
error: "Processing failed",
|
error: "Processing failed",
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ export function registerJsonXml(app: FastifyInstance) {
|
|||||||
}
|
}
|
||||||
// Wrap in a root element when the top level is an array or has multiple
|
// Wrap in a root element when the top level is an array or has multiple
|
||||||
// keys, so the XML is well-formed with a single root.
|
// keys, so the XML is well-formed with a single root.
|
||||||
const wrapped =
|
const wrapped = Array.isArray(data) || Object.keys(data).length !== 1 ? { root: data } : data;
|
||||||
Array.isArray(data) || Object.keys(data).length !== 1 ? { root: data } : data;
|
|
||||||
const builder = new XMLBuilder({ format: settings.pretty, ignoreAttributes: false });
|
const builder = new XMLBuilder({ format: settings.pretty, ignoreAttributes: false });
|
||||||
const xml = builder.build(wrapped) as string;
|
const xml = builder.build(wrapped) as string;
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user