Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

refactor(frontend/builder): delete the unused barrels and helpers from the InputRenderer module (#15784)

Reinier van der Leer18f79e05083b
diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/array/context/array-item-context.tsx b/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/array/context/array-item-context.tsx
index d4da5b9ea4..527ea9e8f5 100644
--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/array/context/array-item-context.tsx
+++ b/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/array/context/array-item-context.tsx
@@ -1,4 +1,4 @@
-import React, { createContext, useContext } from "react";
+import { createContext, useContext } from "react";
interface ArrayItemContextValue {
isArrayItem: boolean;
@@ -10,24 +10,8 @@ const ArrayItemContext = createContext<ArrayItemContextValue>({
arrayItemHandleId: "",
});
-export const ArrayItemProvider: React.FC<{
- children: React.ReactNode;
- arrayItemHandleId: string;
-}> = ({ children, arrayItemHandleId }) => {
- return (
- <ArrayItemContext.Provider value={{ isArrayItem: true, arrayItemHandleId }}>
- {children}
- </ArrayItemContext.Provider>
- );
-};
-
export const useIsArrayItem = (): boolean => {
// here this will be true if field is inside an array
const context = useContext(ArrayItemContext);
return context.isArrayItem;
};
-
-export const useArrayItemHandleId = (): string => {
- const context = useContext(ArrayItemContext);
- return context.arrayItemHandleId;
-};
diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/array/helpers.ts b/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/array/helpers.ts
deleted file mode 100644
index 96e74e1381..0000000000
--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/array/helpers.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export const generateArrayItemHandleId = (id: string) => {
- return `array-item-${id}`;
-};
diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/array/index.ts b/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/array/index.ts
index eb496d3d6d..946a7b9277 100644
--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/array/index.ts
+++ b/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/array/index.ts
@@ -1,7 +1,3 @@
export { default as ArrayFieldTemplate } from "./ArrayFieldTemplate";
export { default as ArrayFieldItemTemplate } from "./ArrayFieldItemTemplate";
export { default as ArraySchemaField } from "./ArraySchemaField";
-export {
- ArrayItemProvider,
- useIsArrayItem,
-} from "./context/array-item-context";
diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/index.ts b/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/index.ts
deleted file mode 100644
index cfd0a86fa4..0000000000
--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export * from "./array";
-export * from "./object";
-export * from "./standard";
-export * from "./standard/widgets";
-export * from "./standard/buttons";
diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/standard/buttons/index.ts b/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/standard/buttons/index.ts
index f083306249..423093d350 100644
--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/standard/buttons/index.ts
+++ b/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/standard/buttons/index.ts
@@ -1,8 +1,2 @@
export { default as AddButton } from "./AddButton";
-export {
- default as IconButton,
- CopyButton,
- RemoveButton,
- MoveUpButton,
- MoveDownButton,
-} from "./IconButton";
+export { default as IconButton, CopyButton, RemoveButton } from "./IconButton";
diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/standard/errors/ErrorList.tsx b/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/standard/errors/ErrorList.tsx
deleted file mode 100644
index 39175ef13e..0000000000
--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/standard/errors/ErrorList.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import { ErrorListProps, TranslatableString } from "@rjsf/utils";
-import { AlertCircle } from "lucide-react";
-
-import {
- Alert,
- AlertDescription,
- AlertTitle,
-} from "@/components/molecules/Alert/Alert";
-
-export default function ErrorList(props: ErrorListProps) {
- const { errors, registry } = props;
- const { translateString } = registry;
- return (
- <Alert variant="error" className="mb-2">
- <AlertCircle className="h-4 w-4" />
- <AlertTitle>{translateString(TranslatableString.ErrorsLabel)}</AlertTitle>
- <AlertDescription className="flex flex-col gap-1">
- {errors.map((error, i: number) => {
- return <span key={i}>&#x2022; {error.stack}</span>;
- })}
- </AlertDescription>
- </Alert>
- );
-}
diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/standard/errors/index.ts b/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/standard/errors/index.ts
deleted file mode 100644
index ccecd3c8c6..0000000000
--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/standard/errors/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default as ErrorList } from "./ErrorList";
diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/standard/helpers.ts b/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/standard/helpers.ts
deleted file mode 100644
index 327a0e06b6..0000000000
--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/standard/helpers.ts
+++ /dev/null
@@ -1,76 +0,0 @@
-import { RJSFSchema } from "@rjsf/utils";
-
-export function parseFieldPath(
- rootSchema: RJSFSchema,
- id: string,
- additional: boolean,
- idSeparator: string = "_%_",
-): { path: string[]; typeHints: string[] } {
- const segments = id.split(idSeparator).filter(Boolean);
- const typeHints: string[] = [];
-
- let currentSchema = rootSchema;
-
- for (let i = 0; i < segments.length; i++) {
- const segment = segments[i];
- const isNumeric = /^\d+$/.test(segment);
-
- if (isNumeric) {
- typeHints.push("array");
- } else {
- if (additional) {
- typeHints.push("object-key");
- } else {
- typeHints.push("object-property");
- }
- currentSchema = (currentSchema.properties?.[segment] as RJSFSchema) || {};
- }
- }
-
- return { path: segments, typeHints };
-}
-
-// This helper work is simple - it just help us to convert rjsf id to our backend compatible id
-// Example : List[dict] = agpt_%_List_0_dict__title -> List_$_0_#_dict
-// We remove the prefix and suffix and then we split id by our custom delimiter (_%_)
-// then add _$_ delimiter for array and _#_ delimiter for object-key
-// and for normal property we add . delimiter
-
-export function getHandleId(
- rootSchema: RJSFSchema,
- id: string,
- additional: boolean,
- idSeparator: string = "_%_",
-): string {
- const idPrefix = "agpt_%_";
- const idSuffix = "__title";
-
- if (id.startsWith(idPrefix)) {
- id = id.slice(idPrefix.length);
- }
- if (id.endsWith(idSuffix)) {
- id = id.slice(0, -idSuffix.length);
- }
-
- const { path, typeHints } = parseFieldPath(
- rootSchema,
- id,
- additional,
- idSeparator,
- );
-
- return path
- .map((seg, i) => {
- const type = typeHints[i];
- if (type === "array") {
- return `_$_${seg}`;
- }
- if (type === "object-key") {
- return `_${seg}`; // we haven't added _#_ delimiter for object-key because it's already added in the id - check WrapIfAdditionalTemplate.tsx
- }
-
- return `.${seg}`;
- })
- .join("")
- .slice(1);
-}
diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/standard/widgets/TextInput/index.ts b/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/standard/widgets/TextInput/index.ts
index 102db07ade..e9ed72ed62 100644
--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/standard/widgets/TextInput/index.ts
+++ b/autogpt_platform/frontend/src/components/renderers/InputRenderer/base/standard/widgets/TextInput/index.ts
@@ -1,2 +1 @@
export { default } from "./TextWidget";
-export { InputExpanderModal } from "./TextInputExpanderModal";
diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/constants.ts b/autogpt_platform/frontend/src/components/renderers/InputRenderer/constants.ts
index 144d850a00..ec29661f41 100644
--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/constants.ts
+++ b/autogpt_platform/frontend/src/components/renderers/InputRenderer/constants.ts
@@ -1,8 +1,6 @@
export const ANY_OF_FLAG = "__anyOf";
-export const ARRAY_FLAG = "__array";
export const OBJECT_FLAG = "__object";
export const KEY_PAIR_FLAG = "__keyPair";
-export const TITLE_FLAG = "__title";
export const ARRAY_ITEM_FLAG = "__arrayItem";
export const ID_PREFIX = "agpt_@_";
export const ID_PREFIX_ARRAY = "agpt_%_";
diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/custom/MultiSelectField/index.ts b/autogpt_platform/frontend/src/components/renderers/InputRenderer/custom/MultiSelectField/index.ts
deleted file mode 100644
index 4d49ec7dbb..0000000000
--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/custom/MultiSelectField/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { MultiSelectField } from "./MultiSelectField";
diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/helpers.ts b/autogpt_platform/frontend/src/components/renderers/InputRenderer/helpers.ts
index 1a0b52c0b4..520a0c4936 100644
--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/helpers.ts
+++ b/autogpt_platform/frontend/src/components/renderers/InputRenderer/helpers.ts
@@ -164,14 +164,6 @@ export const getHandleId = <
return parentHandleId;
};
-export function isCredentialFieldSchema(schema: any): boolean {
- return (
- typeof schema === "object" &&
- schema !== null &&
- "credentials_provider" in schema
- );
-}
-
export function parseHandleIdToPath(handleId: string): PathSegment[] {
const cleanedId = cleanUpHandleId(handleId);
const segments: PathSegment[] = [];
diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/index.ts b/autogpt_platform/frontend/src/components/renderers/InputRenderer/index.ts
deleted file mode 100644
index c25af0b231..0000000000
--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export { FormRenderer } from "./FormRenderer";
-export { default as Form } from "./registry";
-export type { ExtendedFormContextType } from "./types";
diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/registry/index.ts b/autogpt_platform/frontend/src/components/renderers/InputRenderer/registry/index.ts
index 641c2a97d6..8c40f806cd 100644
--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/registry/index.ts
+++ b/autogpt_platform/frontend/src/components/renderers/InputRenderer/registry/index.ts
@@ -1,10 +1,2 @@
-export { default, generateForm } from "./Form";
-export {
- generateBaseFields,
- generateBaseTemplates,
- generateBaseWidgets,
-} from "../base/base-registry";
-export {
- generateCustomFields,
- findCustomFieldId,
-} from "../custom/custom-registry";
+export { default } from "./Form";
+export { findCustomFieldId } from "../custom/custom-registry";
diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/registry/types.ts b/autogpt_platform/frontend/src/components/renderers/InputRenderer/registry/types.ts
deleted file mode 100644
index cab84afcc3..0000000000
--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/registry/types.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { BlockUIType } from "@/app/(platform)/build/components/types";
-
-export type ExtraContext = {
- nodeId?: string;
- uiType?: BlockUIType;
- size?: "small" | "medium" | "large";
-};
diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/utils/rjsf-utils.ts b/autogpt_platform/frontend/src/components/renderers/InputRenderer/utils/rjsf-utils.ts
deleted file mode 100644
index 365058cebd..0000000000
--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/utils/rjsf-utils.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { type ClassValue, clsx } from "clsx";
-import { twMerge } from "tailwind-merge";
-
-export function cn(...inputs: ClassValue[]) {
- return twMerge(clsx(inputs));
-}
diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/utils/schema-utils.ts b/autogpt_platform/frontend/src/components/renderers/InputRenderer/utils/schema-utils.ts
index d481ad182d..b803ef5edd 100644
--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/utils/schema-utils.ts
+++ b/autogpt_platform/frontend/src/components/renderers/InputRenderer/utils/schema-utils.ts
@@ -42,10 +42,6 @@ export function isOptionalType(schema: RJSFSchema | undefined): {
type: nonNullType,
};
}
-export function isAnyOfSelector(name: string) {
- return name.includes("anyof_select");
-}
-
export function isMultiSelectSchema(schema: RJSFSchema | undefined): boolean {
if (typeof schema !== "object" || schema === null) {
return false;