import { FlowData } from '@easy-coder/sdk/flow';
import { VariableDefine } from '@easy-coder/sdk/variable';

export declare namespace EasyCoderEvent {
    interface Base<T extends string> {
        type: T;
    }
    interface Flow extends Base<'flow'> {
        id: string;
        resultSetting?: any;
        paramsSetting?: any;
    }
    interface Method extends Base<'method'> {
        eventPath: string[];
        resultSetting?: any;
        paramsSetting?: any;
    }
    interface SetGlobalVariable extends Base<'setGlobalVariable'> {
        id: string;
        value?: any;
    }
    interface OpenLink extends Base<'openLink'> {
        url: any;
        openInSelf?: boolean;
    }
    type Desc = Flow | Method | SetGlobalVariable | OpenLink;
    interface MethodDefine {
        params?: VariableDefine.Desc[];
        return?: VariableDefine.Desc;
        label: string;
    }
    type PathOrMethod = {
        type: 'path';
        label: string;
        children: Record<string, PathOrMethod>;
    } | (MethodDefine & {
        type: 'event';
    });
    interface EventFlow<T extends Record<string, any>> extends FlowData<T> {
        label: string;
        apiName: string;
    }
}
