diff --git a/CommonServer/Utils/StartServer.ts b/CommonServer/Utils/StartServer.ts index 6d8daab34b..dfb8064ddd 100644 --- a/CommonServer/Utils/StartServer.ts +++ b/CommonServer/Utils/StartServer.ts @@ -38,7 +38,6 @@ app.set('port', process.env['PORT']); app.set('view engine', 'ejs'); app.use(CookieParser()); - const jsonBodyParserMiddleware: RequestHandler = ExpressJson({ limit: '50mb', extended: true, diff --git a/CommonUI/src/Components/Button/Button.tsx b/CommonUI/src/Components/Button/Button.tsx index e5446caef8..48b3733ee4 100644 --- a/CommonUI/src/Components/Button/Button.tsx +++ b/CommonUI/src/Components/Button/Button.tsx @@ -86,7 +86,9 @@ const Button: FunctionComponent = ({ type HandleKeyboardFunction = (event: KeyboardEventProp) => void; - const handleKeyboard: HandleKeyboardFunction = (event: KeyboardEventProp): void => { + const handleKeyboard: HandleKeyboardFunction = ( + event: KeyboardEventProp + ): void => { if ( event.target instanceof HTMLBodyElement && event.key && diff --git a/CommonUI/src/Components/CategoryCheckbox/Index.tsx b/CommonUI/src/Components/CategoryCheckbox/Index.tsx index 8b9a6be5a6..eadce9f218 100644 --- a/CommonUI/src/Components/CategoryCheckbox/Index.tsx +++ b/CommonUI/src/Components/CategoryCheckbox/Index.tsx @@ -23,7 +23,6 @@ export interface CategoryCheckboxProps const CategoryCheckbox: FunctionComponent = ( props: CategoryCheckboxProps ): ReactElement => { - type SanitizeInitialValuesFunction = ( value?: Array ) => Array; diff --git a/CommonUI/src/Components/Detail/Detail.tsx b/CommonUI/src/Components/Detail/Detail.tsx index 7f5514ca53..303dfe395b 100644 --- a/CommonUI/src/Components/Detail/Detail.tsx +++ b/CommonUI/src/Components/Detail/Detail.tsx @@ -30,11 +30,11 @@ export interface ComponentProps { const Detail: (props: ComponentProps) => ReactElement = ( props: ComponentProps ): ReactElement => { - - type GetMarkdownViewerFunction = (text: string) => ReactElement | null; - const getMarkdownViewer: GetMarkdownViewerFunction = (text: string): ReactElement | null => { + const getMarkdownViewer: GetMarkdownViewerFunction = ( + text: string + ): ReactElement | null => { if (!text) { return null; } @@ -88,19 +88,25 @@ const Detail: (props: ComponentProps) => ReactElement = ( type GetColorFieldFunction = (color: Color) => ReactElement; - const getColorField: GetColorFieldFunction = (color: Color): ReactElement => { + const getColorField: GetColorFieldFunction = ( + color: Color + ): ReactElement => { return ; }; type GetUSDCentsFieldFunction = (usdCents: number) => ReactElement; - const getUSDCentsField: GetUSDCentsFieldFunction = (usdCents: number): ReactElement => { + const getUSDCentsField: GetUSDCentsFieldFunction = ( + usdCents: number + ): ReactElement => { return
{usdCents / 100} USD
; }; type GetMinutesFieldFunction = (minutes: number) => ReactElement; - const getMinutesField: GetMinutesFieldFunction = (minutes: number): ReactElement => { + const getMinutesField: GetMinutesFieldFunction = ( + minutes: number + ): ReactElement => { return (
{minutes} {minutes > 1 ? 'minutes' : 'minute'} @@ -110,7 +116,10 @@ const Detail: (props: ComponentProps) => ReactElement = ( type GetFieldFunction = (field: Field, index: number) => ReactElement; - const getField: GetFieldFunction = (field: Field, index: number): ReactElement => { + const getField: GetFieldFunction = ( + field: Field, + index: number + ): ReactElement => { const fieldKey: string = field.key; if (!props.item) { diff --git a/CommonUI/src/Components/Dropdown/Dropdown.tsx b/CommonUI/src/Components/Dropdown/Dropdown.tsx index 7d5a6a8210..7ce0dd6d2d 100644 --- a/CommonUI/src/Components/Dropdown/Dropdown.tsx +++ b/CommonUI/src/Components/Dropdown/Dropdown.tsx @@ -20,8 +20,8 @@ export interface ComponentProps { placeholder?: undefined | string; className?: undefined | string; onChange?: - | undefined - | ((value: DropdownValue | Array | null) => void); + | undefined + | ((value: DropdownValue | Array | null) => void); value?: DropdownOption | undefined; onFocus?: (() => void) | undefined; onBlur?: (() => void) | undefined; @@ -33,21 +33,19 @@ export interface ComponentProps { const Dropdown: FunctionComponent = ( props: ComponentProps ): ReactElement => { - - type GetDropdownOptionFromValueFunctionProps = undefined + type GetDropdownOptionFromValueFunctionProps = + | undefined | DropdownValue | DropdownOption | Array | Array; type GetDropdownOptionFromValueFunction = ( - value: - GetDropdownOptionFromValueFunctionProps + value: GetDropdownOptionFromValueFunctionProps ) => DropdownOption | Array; const getDropdownOptionFromValue: GetDropdownOptionFromValueFunction = ( - value: - GetDropdownOptionFromValueFunctionProps + value: GetDropdownOptionFromValueFunctionProps ): DropdownOption | Array => { if ( Array.isArray(value) && @@ -73,10 +71,10 @@ const Dropdown: FunctionComponent = ( | DropdownOption | undefined | Array = props.options.find( - (option: DropdownOption) => { - return option.value === item; - } - ) as DropdownOption | Array; + (option: DropdownOption) => { + return option.value === item; + } + ) as DropdownOption | Array; if (option) { options.push(option as DropdownOption); @@ -115,9 +113,10 @@ const Dropdown: FunctionComponent = ( return (
{ props.onClick && props.onClick(); props.onFocus && props.onFocus(); diff --git a/CommonUI/src/Components/List/ListBody.tsx b/CommonUI/src/Components/List/ListBody.tsx index 9e446889fb..c3b7dd39aa 100644 --- a/CommonUI/src/Components/List/ListBody.tsx +++ b/CommonUI/src/Components/List/ListBody.tsx @@ -20,10 +20,11 @@ export interface ComponentProps { const ListBody: FunctionComponent = ( props: ComponentProps ): ReactElement => { - type GetBodyFunction = (provided?: DroppableProvided) => ReactElement; - const getBody: GetBodyFunction = (provided?: DroppableProvided): ReactElement => { + const getBody: GetBodyFunction = ( + provided?: DroppableProvided + ): ReactElement => { return (
( ) => ReactElement = ( props: ComponentProps ): ReactElement => { - type GetRowFunction = ( model: TBaseModel, isSelected: boolean, @@ -123,9 +122,13 @@ const StaticModelList: ( ); }; - type GetBodyFunction = (provided?: DroppableProvided | undefined) => ReactElement; + type GetBodyFunction = ( + provided?: DroppableProvided | undefined + ) => ReactElement; - const getBody: GetBodyFunction = (provided?: DroppableProvided): ReactElement => { + const getBody: GetBodyFunction = ( + provided?: DroppableProvided + ): ReactElement => { return (
{props.list && diff --git a/CommonUI/src/Components/Workflow/DocumentationViewer.tsx b/CommonUI/src/Components/Workflow/DocumentationViewer.tsx index 9f3dfcdb48..8aede2f158 100644 --- a/CommonUI/src/Components/Workflow/DocumentationViewer.tsx +++ b/CommonUI/src/Components/Workflow/DocumentationViewer.tsx @@ -25,7 +25,9 @@ const DocumentationViewer: FunctionComponent = ( type PopulateWithEnvVarsFunction = (text: string) => string; - const populateWithEnvVars: PopulateWithEnvVarsFunction = (text: string): string => { + const populateWithEnvVars: PopulateWithEnvVarsFunction = ( + text: string + ): string => { text = text.replace('{{serverUrl}}', HOME_URL.toString()); text = text.replace('{{workflowId}}', props.workflowId.toString()); diff --git a/CommonUI/src/Components/Workflow/Utils.ts b/CommonUI/src/Components/Workflow/Utils.ts index 6efe23f918..8efd6a5d8e 100644 --- a/CommonUI/src/Components/Workflow/Utils.ts +++ b/CommonUI/src/Components/Workflow/Utils.ts @@ -31,8 +31,9 @@ export const loadComponentsAndCategories: LoadComponentsAndCategoriesFunction = ); initCategories.push({ name: new model().singularName || 'Model', - description: `Interact with ${new model().singularName - } in your workflow.`, + description: `Interact with ${ + new model().singularName + } in your workflow.`, icon: new model().icon || IconProp.Database, }); } @@ -48,218 +49,219 @@ type ComponentInputTypeToFormFieldTypeFunction = ( dropdownOptions?: Array | undefined; }; -export const componentInputTypeToFormFieldType: ComponentInputTypeToFormFieldTypeFunction = ( - componentInputType: ComponentInputType, - argValue: any -): { - fieldType: FormFieldSchemaType; - dropdownOptions?: Array | undefined; -} => { - // first priority. +export const componentInputTypeToFormFieldType: ComponentInputTypeToFormFieldTypeFunction = + ( + componentInputType: ComponentInputType, + argValue: any + ): { + fieldType: FormFieldSchemaType; + dropdownOptions?: Array | undefined; + } => { + // first priority. - if (componentInputType === ComponentInputType.BaseModel) { - return { - fieldType: FormFieldSchemaType.JSON, - }; - } + if (componentInputType === ComponentInputType.BaseModel) { + return { + fieldType: FormFieldSchemaType.JSON, + }; + } - if (componentInputType === ComponentInputType.BaseModelArray) { - return { - fieldType: FormFieldSchemaType.JSON, - }; - } + if (componentInputType === ComponentInputType.BaseModelArray) { + return { + fieldType: FormFieldSchemaType.JSON, + }; + } - if (componentInputType === ComponentInputType.JSON) { - return { - fieldType: FormFieldSchemaType.JSON, - }; - } + if (componentInputType === ComponentInputType.JSON) { + return { + fieldType: FormFieldSchemaType.JSON, + }; + } - if (componentInputType === ComponentInputType.JSONArray) { - return { - fieldType: FormFieldSchemaType.JSON, - }; - } + if (componentInputType === ComponentInputType.JSONArray) { + return { + fieldType: FormFieldSchemaType.JSON, + }; + } - if (componentInputType === ComponentInputType.Markdown) { - return { - fieldType: FormFieldSchemaType.Markdown, - }; - } + if (componentInputType === ComponentInputType.Markdown) { + return { + fieldType: FormFieldSchemaType.Markdown, + }; + } - if (componentInputType === ComponentInputType.JavaScript) { - return { - fieldType: FormFieldSchemaType.JavaScript, - }; - } + if (componentInputType === ComponentInputType.JavaScript) { + return { + fieldType: FormFieldSchemaType.JavaScript, + }; + } - if (componentInputType === ComponentInputType.Query) { - return { - fieldType: FormFieldSchemaType.JSON, - }; - } + if (componentInputType === ComponentInputType.Query) { + return { + fieldType: FormFieldSchemaType.JSON, + }; + } - if (componentInputType === ComponentInputType.Select) { - return { - fieldType: FormFieldSchemaType.JSON, - }; - } + if (componentInputType === ComponentInputType.Select) { + return { + fieldType: FormFieldSchemaType.JSON, + }; + } - if (componentInputType === ComponentInputType.StringDictionary) { - return { - fieldType: FormFieldSchemaType.JSON, - }; - } + if (componentInputType === ComponentInputType.StringDictionary) { + return { + fieldType: FormFieldSchemaType.JSON, + }; + } - if (componentInputType === ComponentInputType.LongText) { - return { - fieldType: FormFieldSchemaType.LongText, - }; - } + if (componentInputType === ComponentInputType.LongText) { + return { + fieldType: FormFieldSchemaType.LongText, + }; + } - // Second priority. + // Second priority. + + if ( + argValue && + typeof argValue === Typeof.String && + argValue.toString().includes('{{') + ) { + return { + fieldType: FormFieldSchemaType.Text, + dropdownOptions: [], + }; + } + + if (componentInputType === ComponentInputType.Boolean) { + return { + fieldType: FormFieldSchemaType.Toggle, + dropdownOptions: [], + }; + } + + if (componentInputType === ComponentInputType.HTML) { + return { + fieldType: FormFieldSchemaType.HTML, + dropdownOptions: [], + }; + } + + if (componentInputType === ComponentInputType.CronTab) { + return { + fieldType: FormFieldSchemaType.Dropdown, + dropdownOptions: [ + { + label: 'Every Minute', + value: '* * * * *', + }, + { + label: 'Every 30 minutes', + value: '*/30 * * * *', + }, + { + label: 'Every Hour', + value: '0 * * * *', + }, + { + label: 'Every Day', + value: '0 0 * * *', + }, + { + label: 'Every Week', + value: '0 0 * * 0', + }, + { + label: 'Every Month', + value: '0 0 1 * *', + }, + { + label: 'Every Three Months', + value: '0 0 1 */3 *', + }, + { + label: 'Every Six Months', + value: '0 0 1 */6 *', + }, + ], + }; + } + + if (componentInputType === ComponentInputType.Operator) { + return { + fieldType: FormFieldSchemaType.Dropdown, + dropdownOptions: [ + { + label: 'Equal To', + value: '==', + }, + { + label: 'Not Equal To', + value: '!=', + }, + { + label: 'Greater Than', + value: '>', + }, + { + label: 'Less Than', + value: '<', + }, + { + label: 'Greater Than or Equal', + value: '>=', + }, + { + label: 'Less Than or Equal', + value: '<=', + }, + ], + }; + } + + if (componentInputType === ComponentInputType.Date) { + return { + fieldType: FormFieldSchemaType.Date, + }; + } + + if (componentInputType === ComponentInputType.DateTime) { + return { + fieldType: FormFieldSchemaType.DateTime, + }; + } + + if (componentInputType === ComponentInputType.Decimal) { + return { + fieldType: FormFieldSchemaType.Number, + }; + } + + if (componentInputType === ComponentInputType.Email) { + return { + fieldType: FormFieldSchemaType.Email, + }; + } + + if (componentInputType === ComponentInputType.Number) { + return { + fieldType: FormFieldSchemaType.Number, + }; + } + + if (componentInputType === ComponentInputType.Password) { + return { + fieldType: FormFieldSchemaType.Password, + }; + } + + if (componentInputType === ComponentInputType.URL) { + return { + fieldType: FormFieldSchemaType.URL, + }; + } - if ( - argValue && - typeof argValue === Typeof.String && - argValue.toString().includes('{{') - ) { return { fieldType: FormFieldSchemaType.Text, dropdownOptions: [], }; - } - - if (componentInputType === ComponentInputType.Boolean) { - return { - fieldType: FormFieldSchemaType.Toggle, - dropdownOptions: [], - }; - } - - if (componentInputType === ComponentInputType.HTML) { - return { - fieldType: FormFieldSchemaType.HTML, - dropdownOptions: [], - }; - } - - if (componentInputType === ComponentInputType.CronTab) { - return { - fieldType: FormFieldSchemaType.Dropdown, - dropdownOptions: [ - { - label: 'Every Minute', - value: '* * * * *', - }, - { - label: 'Every 30 minutes', - value: '*/30 * * * *', - }, - { - label: 'Every Hour', - value: '0 * * * *', - }, - { - label: 'Every Day', - value: '0 0 * * *', - }, - { - label: 'Every Week', - value: '0 0 * * 0', - }, - { - label: 'Every Month', - value: '0 0 1 * *', - }, - { - label: 'Every Three Months', - value: '0 0 1 */3 *', - }, - { - label: 'Every Six Months', - value: '0 0 1 */6 *', - }, - ], - }; - } - - if (componentInputType === ComponentInputType.Operator) { - return { - fieldType: FormFieldSchemaType.Dropdown, - dropdownOptions: [ - { - label: 'Equal To', - value: '==', - }, - { - label: 'Not Equal To', - value: '!=', - }, - { - label: 'Greater Than', - value: '>', - }, - { - label: 'Less Than', - value: '<', - }, - { - label: 'Greater Than or Equal', - value: '>=', - }, - { - label: 'Less Than or Equal', - value: '<=', - }, - ], - }; - } - - if (componentInputType === ComponentInputType.Date) { - return { - fieldType: FormFieldSchemaType.Date, - }; - } - - if (componentInputType === ComponentInputType.DateTime) { - return { - fieldType: FormFieldSchemaType.DateTime, - }; - } - - if (componentInputType === ComponentInputType.Decimal) { - return { - fieldType: FormFieldSchemaType.Number, - }; - } - - if (componentInputType === ComponentInputType.Email) { - return { - fieldType: FormFieldSchemaType.Email, - }; - } - - if (componentInputType === ComponentInputType.Number) { - return { - fieldType: FormFieldSchemaType.Number, - }; - } - - if (componentInputType === ComponentInputType.Password) { - return { - fieldType: FormFieldSchemaType.Password, - }; - } - - if (componentInputType === ComponentInputType.URL) { - return { - fieldType: FormFieldSchemaType.URL, - }; - } - - return { - fieldType: FormFieldSchemaType.Text, - dropdownOptions: [], }; -}; diff --git a/CommonUI/src/Components/Workflow/Workflow.tsx b/CommonUI/src/Components/Workflow/Workflow.tsx index 2ee8475d16..1a8cefd8d0 100644 --- a/CommonUI/src/Components/Workflow/Workflow.tsx +++ b/CommonUI/src/Components/Workflow/Workflow.tsx @@ -42,26 +42,27 @@ import RunModal from './RunModal'; type GetPlaceholderTriggerNodeFunction = () => Node; -export const getPlaceholderTriggerNode: GetPlaceholderTriggerNodeFunction = (): Node => { - return { - id: ObjectID.generate().toString(), - type: 'node', - position: { x: 100, y: 100 }, - data: { - metadata: { - iconProp: IconProp.Bolt, - componentType: ComponentType.Trigger, - title: 'Trigger', - description: 'Please click here to add trigger', +export const getPlaceholderTriggerNode: GetPlaceholderTriggerNodeFunction = + (): Node => { + return { + id: ObjectID.generate().toString(), + type: 'node', + position: { x: 100, y: 100 }, + data: { + metadata: { + iconProp: IconProp.Bolt, + componentType: ComponentType.Trigger, + title: 'Trigger', + description: 'Please click here to add trigger', + }, + metadataId: '', + internalId: '', + nodeType: NodeType.PlaceholderNode, + id: '', + error: '', }, - metadataId: '', - internalId: '', - nodeType: NodeType.PlaceholderNode, - id: '', - error: '', - }, + }; }; -}; const nodeTypes: NodeTypes = { node: WorkflowComponent, @@ -340,7 +341,9 @@ const Workflow: FunctionComponent = (props: ComponentProps) => { type AddToGraphFunction = (componentMetadata: ComponentMetadata) => void; - const addToGraph: AddToGraphFunction = (componentMetadata: ComponentMetadata) => { + const addToGraph: AddToGraphFunction = ( + componentMetadata: ComponentMetadata + ) => { const metaDataId: string = componentMetadata.id; let hasFoundExistingId: boolean = true; diff --git a/CommonUI/src/Tests/Components/BasicForm.test.tsx b/CommonUI/src/Tests/Components/BasicForm.test.tsx index ac0e444d34..40a0ea86cc 100644 --- a/CommonUI/src/Tests/Components/BasicForm.test.tsx +++ b/CommonUI/src/Tests/Components/BasicForm.test.tsx @@ -63,7 +63,7 @@ describe('BasicForm test', () => { }); test('Should accept values and submit if valid', async () => { - const handleSubmit: jest.Mock = jest.fn(); + const handleSubmit: jest.Mock = jest.fn(); const onSubmitSuccessful: jest.Mock = jest.fn(); render( ComponentCategory; -const getComponentCategory: GetComponentCategoryFunction = (name?: string): ComponentCategory => { +const getComponentCategory: GetComponentCategoryFunction = ( + name?: string +): ComponentCategory => { return { name: name || faker.datatype.uuid(), description: `Description for ${name}`, diff --git a/TestServer/API/Main.ts b/TestServer/API/Main.ts index 8612c3cbb4..5f97256603 100644 --- a/TestServer/API/Main.ts +++ b/TestServer/API/Main.ts @@ -12,7 +12,6 @@ import Typeof from 'Common/Types/Typeof'; import { JSONValue } from 'Common/Types/JSON'; import logger from 'CommonServer/Utils/Logger'; - const router: ExpressRouter = Express.getRouter(); router.get(