// @flow import type { NunjucksParsedTagArg } from '../utils'; import type { Request } from '../../models/request'; import type { Response } from '../../models/response'; import type { PluginStore } from '../../plugins/context'; export type PluginArgumentValue = string | number | boolean; type DisplayName = string | ((args: Array) => string); type PluginArgumentBase = { displayName: DisplayName, description?: string, help?: string, hide?: (args: Array) => boolean, }; export type PluginArgumentEnumOption = { displayName: DisplayName, value: PluginArgumentValue, description?: string, placeholder?: string, }; export type PluginArgumentEnum = PluginArgumentBase & { type: 'enum', options: Array, defaultValue?: PluginArgumentValue, }; export type PluginArgumentModel = PluginArgumentBase & { type: 'model', model: string, defaultValue?: string, }; export type PluginArgumentString = PluginArgumentBase & { type: 'string', placeholder?: string, defaultValue?: string, }; export type PluginArgumentBoolean = PluginArgumentBase & { type: 'boolean', defaultValue?: boolean, }; export type PluginArgumentFile = PluginArgumentBase & { type: 'file', }; export type PluginArgumentNumber = PluginArgumentBase & { type: 'number', placeholder?: string, defaultValue?: number, }; export type PluginArgument = | PluginArgumentEnum | PluginArgumentModel | PluginArgumentString | PluginArgumentBoolean | PluginArgumentFile | PluginArgumentNumber; export type PluginTemplateTagContext = { util: { models: { request: { getById: (id: string) => Promise, }, response: { getLatestForRequestId: (id: string) => Promise, getBodyBuffer: (response: Response, fallback?: any) => Promise, }, }, }, }; export type PluginTemplateTagActionContext = { store: PluginStore, }; export type PluginTemplateTagAction = { name: string, icon?: string, run: (context: PluginTemplateTagActionContext) => Promise, }; export type PluginTemplateTag = { args: Array, name: string, displayName: DisplayName, disablePreview: () => boolean, description: string, actions: Array, run: (context: PluginTemplateTagContext, ...arg: Array) => Promise | any, deprecated?: boolean, validate?: (value: any) => ?string, priority?: number, };