import FormStepTypes, { ClassifierOptionTypes, OptionTypes, RatingTypes, MapperStyleTypes, EntityValueOptionTypes, EntityValueDataTypes, ApiSelectorOptionTypes, ApiSelectorParamTypes } from '../constants/FormStepTypes'; import IconTypes from '../constants/IconTypes'; import { Condition } from './Condition'; import { EurekaDraft } from './Draft/Draft'; import { ErkValue } from './ErkValue'; import * as GSteps from './GenericFormSteps'; import { Time } from './Time'; export type FormStep = Title | TimePicker | Rating | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector | Collapsible | EntityValuePicker | ApiSelector | Mapper; export interface Title extends GSteps.GBaseStep { type: FormStepTypes.TITLE; title?: EurekaDraft; description?: EurekaDraft; size?: 1 | 2 | 3 | 4; } export interface TimePicker extends GSteps.GTimePicker { type: FormStepTypes.TIMEPICKER; defaultValue?: Time; } export interface CheckBox extends GSteps.GCheckBox { type: FormStepTypes.CHECKBOX; steps?: string[]; uncheckedSteps?: string[]; maxSize?: number; defaultValue?: boolean; } export interface Rating extends GSteps.GBaseStep { type: FormStepTypes.RATING; label: string; description: string; required: boolean; ratingType: RatingTypes; nestedSteps: string[][] | null; } export interface FileUpload extends GSteps.GBaseStep { type: FormStepTypes.FILEUPLOAD; label: string; description: string | null; required: boolean; } export interface Separator extends GSteps.GSeparator { type: FormStepTypes.SEPARATOR; } export interface TextArea extends GSteps.GTextArea { type: FormStepTypes.TEXTAREA; } export interface TextInput extends GSteps.GTextInput { type: FormStepTypes.TEXTINPUT; } export interface DatePicker extends GSteps.GDatePicker { type: FormStepTypes.DATEPICKER; } export interface Collapsible extends GSteps.GBaseStep { type: FormStepTypes.COLLAPSIBLE; label: string; steps: string[]; defaultValue?: boolean; } export interface FormSelector extends GSteps.GBaseStep { type: FormStepTypes.SELECTOR; label: string; description: string; required: boolean; searchable: boolean; options: FormSelectorOption[]; size: 1 | 2 | 3 | 4; maxSize?: number; defaultValue?: string; } export type FormSelectorOption = DefaultFormSelectorOption | NestedStepOption; interface DefaultFormSelectorOption { label: string; value: string; type: OptionTypes.DEFAULT; condition?: Condition; } export interface NestedStepOption { label: string; value: string; type: OptionTypes.NESTED; steps: string[]; condition?: Condition; } export interface ClassifierSelector extends GSteps.GBaseStep { type: FormStepTypes.CLASSIFIER_SELECTOR; idClassifier: string | null; label: string; description: string; searchable: boolean; options: Record; required: boolean; size: 1 | 2 | 3 | 4; maxSize?: number; } export type FormClassifierSelectorOption = DefaultClassifierOption | NestedStepClassifierOption | HideValueOption; interface DefaultClassifierOption { type: ClassifierOptionTypes.DEFAULT; idClassifier: string; condition?: Condition; } interface NestedStepClassifierOption { type: ClassifierOptionTypes.NESTED; idClassifier: string; steps: string[]; condition?: Condition; } interface HideValueOption { type: ClassifierOptionTypes.HIDE; idClassifier: string; } export interface EntityValuePicker extends GSteps.GSmartSelect { type: FormStepTypes.ENTITYVALUEPICKER; idEntity: string; icon: string | null; filters: EntityValuePickerFilter[]; path: EntityValuePickerPath[]; options: Record; maxSize?: number; dialogs?: EntityValuePickerDialog[]; } export type FormEntityValuePickerOption = DefaultEntityValuePickerOption | NestedEntityValuePickerOption | HideFormEntityValuePickerOption; export interface EntityValuePickerDialog { type: 'WARNING' | 'INFO'; message: EurekaDraft; condition?: Condition; } interface DefaultEntityValuePickerOption { type: EntityValueOptionTypes.DEFAULT; condition?: Condition; } interface NestedEntityValuePickerOption { type: EntityValueOptionTypes.NESTED; steps: string[]; condition?: Condition; } interface HideFormEntityValuePickerOption { type: EntityValueOptionTypes.HIDE; } export type EntityValuePickerPath = StepEntityValuePickerPath | ValueEntityValuePickerPath; export interface StepEntityValuePickerPath { idEntity: string; type: EntityValueDataTypes.STEP; idStep: string; any: boolean; } export interface ValueEntityValuePickerPath { idEntity: string; type: EntityValueDataTypes.VALUE; idEntityValue: string | null; } export type EntityValuePickerFilter = StepEntityValuePickerFilter | ValueEntityValuePickerFilter | CurrentAgentEntityValuePickerFilter | IntegrationEntityValuePickerFilter; export interface StepEntityValuePickerFilter { idProperty: string; type: EntityValueDataTypes.STEP; idStep: string; any: boolean; required: boolean; } export interface ValueEntityValuePickerFilter { idProperty: string; type: EntityValueDataTypes.VALUE; value: any; } export interface CurrentAgentEntityValuePickerFilter { idProperty: string; type: EntityValueDataTypes.CURRENT_AGENT; } export interface IntegrationEntityValuePickerFilter { idProperty: string; type: EntityValueDataTypes.INTEGRATION; idIntegration: string; values?: Record; } export interface ApiSelector extends GSteps.GSmartSelect { type: FormStepTypes.API_SELECTOR; icon?: IconTypes; url: string; pathParams: ApiSelectorParam[]; queryParams: ApiSelectorParam[]; /** Headers? Body, etc?? */ labelAttribute: string; idAttribute: string; /** Only has maxSize if level === 0 */ maxSize?: number; options: Record; defaultValue?: any; } export type ApiSelectorOption = DefaultApiSelectorOption | NestedApiSelectorOption | HideApiSelectorOption; interface DefaultApiSelectorOption { type: ApiSelectorOptionTypes.DEFAULT; condition?: Condition; } interface NestedApiSelectorOption { type: ApiSelectorOptionTypes.NESTED; steps: string[]; condition?: Condition; } interface HideApiSelectorOption { type: ApiSelectorOptionTypes.HIDE; idOption: string; } export type ApiSelectorParam = StepApiSelectorParam | ValueApiSelectorParam; export interface StepApiSelectorParam { type: ApiSelectorParamTypes.STEP; key: string; idStep: string; required: boolean; } export interface ValueApiSelectorParam { type: ApiSelectorParamTypes.VALUE; key: string; value: string; } export interface Mapper extends GSteps.GBaseStep { type: FormStepTypes.MAPPER; style: { type: MapperStyleTypes; size?: number; }; label: string; description: string | null; addBtnLabel: string; rootSteps: string[]; steps: Record; required: boolean; unitLabel: string; creatable?: boolean; deletable?: boolean; max?: number; } export {};