diff --git a/frontend/src/components/input-output/add-source/AddSource.jsx b/frontend/src/components/input-output/add-source/AddSource.jsx index 9cdd757b8b..e55c9b529b 100644 --- a/frontend/src/components/input-output/add-source/AddSource.jsx +++ b/frontend/src/components/input-output/add-source/AddSource.jsx @@ -1,3 +1,5 @@ +import { getDefaultFormState } from "@rjsf/utils"; +import validator from "@rjsf/validator-ajv8"; import { Typography } from "antd"; import PropTypes from "prop-types"; import { useEffect, useMemo, useState } from "react"; @@ -121,12 +123,22 @@ function AddSource({ axiosPrivate(requestOptions) .then((res) => { const data = res?.data; - setFormData(metadata || {}); + const jsonSchema = isLLMWPaidSchema + ? transformLlmWhispererJsonSchema(data?.json_schema || {}) + : data?.json_schema || {}; - if (isLLMWPaidSchema) { - setSpec(transformLlmWhispererJsonSchema(data?.json_schema || {})); + setSpec(jsonSchema); + + if (metadata && Object.keys(metadata).length > 0) { + setFormData(metadata); } else { - setSpec(data?.json_schema || {}); + const defaults = getDefaultFormState( + validator, + jsonSchema, + {}, + jsonSchema, + ); + setFormData(defaults || {}); } if (data?.oauth) { @@ -142,7 +154,7 @@ function AddSource({ .finally(() => { setIsLoading(false); }); - }, [selectedSourceId]); + }, [selectedSourceId, isLLMWPaidSchema]); useEffect(() => { if (editItemId?.length && metadata && Object.keys(metadata)?.length) { diff --git a/unstract/connectors/src/unstract/connectors/filesystems/sharepoint/sharepoint.py b/unstract/connectors/src/unstract/connectors/filesystems/sharepoint/sharepoint.py index 7491fbf7a7..3eacdac30d 100644 --- a/unstract/connectors/src/unstract/connectors/filesystems/sharepoint/sharepoint.py +++ b/unstract/connectors/src/unstract/connectors/filesystems/sharepoint/sharepoint.py @@ -170,9 +170,11 @@ def _get_onedrive_drive(self, ctx: Any) -> Any: if self.client_secret: if not self.user_email: error_msg = ( - "OneDrive client credentials require user email. Provide either \n" - "- user_email (e.g., user@company.onmicrosoft.com) \n" - "- OR use OAuth with access_token instead." + "No Site URL provided. " + "To access a SharePoint site, provide the Site URL " + "(e.g., https://contoso.sharepoint.com/sites/mysite). " + "To access OneDrive, provide the User Email " + "(e.g., user@company.onmicrosoft.com)." ) raise ConnectorError( error_msg, diff --git a/unstract/connectors/src/unstract/connectors/filesystems/sharepoint/static/json_schema.json b/unstract/connectors/src/unstract/connectors/filesystems/sharepoint/static/json_schema.json index f9555f5da2..d83f84c8ae 100644 --- a/unstract/connectors/src/unstract/connectors/filesystems/sharepoint/static/json_schema.json +++ b/unstract/connectors/src/unstract/connectors/filesystems/sharepoint/static/json_schema.json @@ -10,12 +10,6 @@ "default": "SharePoint / OneDrive Connector", "description": "A friendly name to identify this connector" }, - "is_personal": { - "type": "boolean", - "title": "Personal Account", - "default": false, - "description": "Enable for OneDrive Personal (consumer Microsoft accounts). Leave disabled for SharePoint or OneDrive for Business (work/school accounts)." - }, "site_url": { "type": "string", "title": "Site URL", @@ -27,7 +21,7 @@ }, "drive_id": { "type": "string", - "title": "Drive ID (Optional)", + "title": "Drive ID", "description": "Specific Drive/Document Library ID. Leave empty to use the default drive." }, "auth_type": {