package workoss:extension;
world extension {
import extension-http;
import platform;
import process;
use common.{env-vars,mime-type};
use process.{command};
/// 获取配置
import get-settings: func(key: option<string>) -> result<string, string>;
/// 下载文件
import download-file: func(url: string, file-path: string, file-type: download-file-type) -> result<_,string>;
/// 让下载后的文件变成可执行文件
import make-file-executable: func(file-path: string) -> result<_, string>;
///下载文件后缀 解压
enum download-file-type {
/// .gz
gzip,
/// .tar.gz
tar-gzip,
/// .zip
zip,
// uncompressed
uncompressed,
}
/// 输入
record plugin-input {
/// 输入body
body: option<list<u8>>,
/// 输入body类型
mime-type: mime-type,
/// env参数
envs: option<env-vars>,
}
/// 输出
record plugin-output {
///输出 body
body: option<list<u8>>,
/// 输出body类型
mime-type: mime-type,
}
/// 初始化插件
export init-plugin: func();
/// 执行插件
export run-plugin: func(input: plugin-input) -> result<plugin-output,string>;
}