Task Writing Guide
Language:
Scripts are written in JavaScript.
TypeScript can be used and compiled to JavaScript.
Development Environment:
Simple scripts can be written and tested directly in the task's script editor.
Complex scripts or those requiring third-party libraries should be compiled before importing.
Templates are available for reference (Template Link).
Module Standard:
Scripts follow the ES module standard.
Export the task module using syntax like:
export default async function (files, params)
Function Type:
Task function is asynchronous.
await
syntax is supported within the function.
Function Parameters:
Two parameters:
files
andparams
files
: Type FileList (even for single input, it's a FileList with length 1)params
: An object containing task or workflow parameters, accessed via keys (e.g.,params.quality
)onProgressMsg: A callback function
(progressMsg: string) => void
Function Return:
Return a Promise of a processed FileList or File array.
If nothing is returned, the input
files
will be returned.
Error Handling:
Throw errors directly, e.g.,
throw new Error("The quality in the parameters is invalid.")
Important Notes:
Do not include sensitive/confidential data in scripts. Use environment variables for such data.
Optimize scripts to run within 5 minutes. Executions exceeding 5 minutes will fail.
Keep script size under 10MB.
Following these guidelines will help ensure your scripts are efficient, secure, and compatible with the FilesWorkflow platform.
Last updated