Iql Function
proxima:iqlFunction
可以让你的应用定义一个自定义的iql函数,该函数可以在任何可以配置iql的功能中使用。
Manifest示例
manifest.yml
modules:
proxima:iqlFunction:
- key: iql-function-key
name: myIqlFunction
function: iql-function-execute
function:
- key: iql-function-execute
handler: iql.executeIqlFunction
属性
属性 | 类型 | 是否必填 | 说明 |
---|---|---|---|
key | String | Yes | 模块的key,其他模块可以引用它。在Manifest文件中必须是唯一的。 规则: ^[a-zA-Z0-9_-]+$ |
name | String | Yes | iql函数的名称,用来在iql中使用 |
function | String | Yes | 对定义函数的function 模块的引用 |
函数定义
interface IPayload {
field: string;
operator: string;
arguments: any[];
}
export const executeIqlFunction = ({ payload }: { payload: IPayload }) => {
const { field, operator, arguments } = payload;
// 比如对于这个iql: status in myIqlFunction("arg1", "arg2")
// 在iql函数中获取的参数如下:
// field: status
// operator: in
// arguments: ["arg1", "arg2"]
// your code
return { iql }; // 返回一个新的iql
}
使用
可以直接在iql的输入中直接使用iql函数: