refactor: Remove any types
This commit is contained in:
parent
53a20ecccf
commit
e40628a069
14 changed files with 48 additions and 24 deletions
|
|
@ -111,7 +111,7 @@ export default function GenericNode({
|
|||
{validationStatus.params
|
||||
? validationStatus.params
|
||||
.split("\n")
|
||||
.map((line, index) => <div key={index}>{line}</div>)
|
||||
.map((line: string, index: number) => <div key={index}>{line}</div>)
|
||||
: ""}
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export default function AccordionComponent({
|
|||
open.length === 0 ? "" : getOpenAccordion()
|
||||
);
|
||||
|
||||
function getOpenAccordion() {
|
||||
function getOpenAccordion(): string {
|
||||
let value = "";
|
||||
open.forEach((el) => {
|
||||
if (el == trigger) {
|
||||
|
|
@ -28,7 +28,7 @@ export default function AccordionComponent({
|
|||
return value;
|
||||
}
|
||||
|
||||
function handleClick() {
|
||||
function handleClick(): void {
|
||||
value === "" ? setValue(keyValue) : setValue("");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export const EditFlowSettings: React.FC<InputProps> = ({
|
|||
setName,
|
||||
setDescription,
|
||||
updateFlow,
|
||||
}): JSX.Element => {
|
||||
}: InputProps): JSX.Element => {
|
||||
const [isMaxLength, setIsMaxLength] = useState(false);
|
||||
|
||||
const handleNameChange = (event: ChangeEvent<HTMLInputElement>) => {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import DOMPurify from "dompurify";
|
||||
import { SanitizedHTMLWrapperType } from "../../types/components";
|
||||
|
||||
const SanitizedHTMLWrapper = ({
|
||||
className,
|
||||
content,
|
||||
onClick,
|
||||
suppressWarning = false,
|
||||
}): JSX.Element => {
|
||||
}: SanitizedHTMLWrapperType): JSX.Element => {
|
||||
const sanitizedHTML = DOMPurify.sanitize(content);
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import { TabsContext } from "../../../contexts/tabsContext";
|
|||
import { validateNodes } from "../../../utils/reactflowUtils";
|
||||
import RadialProgressComponent from "../../RadialProgress";
|
||||
import IconComponent from "../../genericIconComponent";
|
||||
import { parsedDataType } from "../../../types/components";
|
||||
|
||||
export default function BuildTrigger({
|
||||
open,
|
||||
|
|
@ -30,7 +31,7 @@ export default function BuildTrigger({
|
|||
const eventClick = isBuilding ? "pointer-events-none" : "";
|
||||
const [progress, setProgress] = useState(0);
|
||||
|
||||
async function handleBuild(flow: FlowType) {
|
||||
async function handleBuild(flow: FlowType): Promise<void> {
|
||||
try {
|
||||
if (isBuilding) {
|
||||
return;
|
||||
|
|
@ -69,7 +70,7 @@ export default function BuildTrigger({
|
|||
const response = await postBuildInit(flow);
|
||||
const { flowId } = response.data;
|
||||
// Step 2: Use the session ID to establish an SSE connection using EventSource
|
||||
let validationResults = [];
|
||||
let validationResults: boolean[] = [];
|
||||
let finished = false;
|
||||
const apiUrl = `/api/v1/build/stream/${flowId}`;
|
||||
const eventSource = new EventSource(apiUrl);
|
||||
|
|
@ -124,10 +125,11 @@ export default function BuildTrigger({
|
|||
return validationResults.every((result) => result);
|
||||
}
|
||||
|
||||
function processStreamResult(parsedData) {
|
||||
function processStreamResult(parsedData: parsedDataType) {
|
||||
// Process each chunk of data here
|
||||
// Parse the chunk and update the context
|
||||
try {
|
||||
console.log(parsedData)
|
||||
updateSSEData({ [parsedData.id]: parsedData });
|
||||
} catch (err) {
|
||||
console.log("Error parsing stream data: ", err);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ export default function InputFileComponent({
|
|||
setMyValue(value);
|
||||
}, [value]);
|
||||
|
||||
const handleButtonClick = () => {
|
||||
const handleButtonClick = (): void => {
|
||||
// Create a file input element
|
||||
const input = document.createElement("input");
|
||||
input.type = "file";
|
||||
|
|
@ -49,7 +49,7 @@ export default function InputFileComponent({
|
|||
input.style.display = "none"; // Hidden from view
|
||||
input.multiple = false; // Allow only one file selection
|
||||
|
||||
input.onchange = (e: Event) => {
|
||||
input.onchange = (e: Event): void => {
|
||||
setLoading(true);
|
||||
|
||||
// Get the selected file
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export default function CommunityPage(): JSX.Element {
|
|||
const [examples, setExamples] = useState<FlowType[]>([]);
|
||||
|
||||
// Show community examples on screen
|
||||
function handleExamples() {
|
||||
function handleExamples(): void {
|
||||
setLoadingExamples(true);
|
||||
getExamples()
|
||||
.then((result) => {
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ export default function Page({ flow }: { flow: FlowType }): JSX.Element {
|
|||
event.preventDefault();
|
||||
}
|
||||
};
|
||||
const handleMouseMove = (event) => {
|
||||
const handleMouseMove = (event: MouseEvent) => {
|
||||
setPosition({ x: event.clientX, y: event.clientY });
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export default function ExtraSidebar(): JSX.Element {
|
|||
function onDragStart(
|
||||
event: React.DragEvent<any>,
|
||||
data: { type: string; node?: APIClassType }
|
||||
) {
|
||||
): void {
|
||||
//start drag event
|
||||
var crt = event.currentTarget.cloneNode(true);
|
||||
crt.style.position = "absolute";
|
||||
|
|
@ -65,7 +65,7 @@ export default function ExtraSidebar(): JSX.Element {
|
|||
<ShadTooltip content="Import" side="top">
|
||||
<button
|
||||
className="extra-side-bar-buttons"
|
||||
onClick={() => {
|
||||
onClick={(): void => {
|
||||
uploadFlow();
|
||||
}}
|
||||
>
|
||||
|
|
@ -76,7 +76,7 @@ export default function ExtraSidebar(): JSX.Element {
|
|||
<ShadTooltip content="Export" side="top">
|
||||
<button
|
||||
className={classNames("extra-side-bar-buttons")}
|
||||
onClick={(event) => {
|
||||
onClick={(event): void => {
|
||||
openPopUp(<ExportModal />);
|
||||
}}
|
||||
>
|
||||
|
|
@ -86,7 +86,7 @@ export default function ExtraSidebar(): JSX.Element {
|
|||
<ShadTooltip content="Code" side="top">
|
||||
<button
|
||||
className={classNames("extra-side-bar-buttons")}
|
||||
onClick={(event) => {
|
||||
onClick={(event): void => {
|
||||
openPopUp(<ApiModal flow={flows.find((f) => f.id === tabId)} />);
|
||||
}}
|
||||
>
|
||||
|
|
@ -97,7 +97,7 @@ export default function ExtraSidebar(): JSX.Element {
|
|||
<ShadTooltip content="Save" side="top">
|
||||
<button
|
||||
className="extra-side-bar-buttons"
|
||||
onClick={(event) => {
|
||||
onClick={(event): void => {
|
||||
saveFlow(flows.find((f) => f.id === tabId));
|
||||
setSuccessData({ title: "Changes saved successfully" });
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,9 @@ import IconComponent from "../../../../components/genericIconComponent";
|
|||
import { TabsContext } from "../../../../contexts/tabsContext";
|
||||
import EditNodeModal from "../../../../modals/EditNodeModal";
|
||||
import { classNames } from "../../../../utils/utils";
|
||||
import { nodeToolbarPropsType } from "../../../../types/components";
|
||||
|
||||
const NodeToolbarComponent = (props): JSX.Element => {
|
||||
const NodeToolbarComponent = (props: nodeToolbarPropsType): JSX.Element => {
|
||||
const [nodeLength, setNodeLength] = useState(
|
||||
Object.keys(props.data.node.template).filter(
|
||||
(t) =>
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ export type sendAllProps = {
|
|||
name: string;
|
||||
description: string;
|
||||
viewport: Viewport;
|
||||
inputs: any;
|
||||
inputs: { text: string; };
|
||||
|
||||
chatHistory: { message: string | object; isSend: boolean }[];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ReactElement, ReactNode } from "react";
|
||||
import { ReactElement, ReactNode, RefObject } from "react";
|
||||
import { APIClassType } from "../api";
|
||||
import { FlowStyleType, NodeDataType } from "../flow/index";
|
||||
import { typesContextType } from "../typesContext";
|
||||
|
|
@ -84,7 +84,7 @@ export type DisclosureComponentType = {
|
|||
openDisc: boolean;
|
||||
button: {
|
||||
title: string;
|
||||
Icon: any;
|
||||
Icon: React.Component;
|
||||
buttons?: {
|
||||
Icon: ReactElement;
|
||||
title: string;
|
||||
|
|
@ -431,7 +431,7 @@ export type nodeToolbarType = {
|
|||
value: void;
|
||||
};
|
||||
deleteNode: (idx: string) => void;
|
||||
openPopUp: (element) => JSX.Element;
|
||||
openPopUp: (element: JSX.Element) => JSX.Element;
|
||||
};
|
||||
|
||||
export type chatTriggerPropType = {
|
||||
|
|
@ -488,3 +488,23 @@ export type fileCardPropsType = {
|
|||
content: string;
|
||||
fileType: string;
|
||||
};
|
||||
|
||||
export type nodeToolbarPropsType = {
|
||||
data: NodeDataType;
|
||||
deleteNode: (idx: string) => void;
|
||||
openPopUp: (element: JSX.Element) => void;
|
||||
}
|
||||
|
||||
export type parsedDataType = {
|
||||
id: string;
|
||||
params: string;
|
||||
progress: number;
|
||||
valid: boolean;
|
||||
};
|
||||
|
||||
export type SanitizedHTMLWrapperType = {
|
||||
className: string;
|
||||
content: string;
|
||||
onClick: () => void;
|
||||
suppressWarning: boolean;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export type NodeDataType = {
|
|||
type: string;
|
||||
node?: APIClassType;
|
||||
id: string;
|
||||
value: any;
|
||||
value: null;
|
||||
};
|
||||
// FlowStyleType is the type of the style object that is used to style the
|
||||
// Flow card with an emoji and a color.
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
"noImplicitAny": true
|
||||
"noImplicitAny": false
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue