diff --git a/airbyte-webapp/src/components/connectorBuilder/Builder/BuilderConfigView.module.scss b/airbyte-webapp/src/components/connectorBuilder/Builder/BuilderConfigView.module.scss index ff2cbdd5450d..cc9c077f755b 100644 --- a/airbyte-webapp/src/components/connectorBuilder/Builder/BuilderConfigView.module.scss +++ b/airbyte-webapp/src/components/connectorBuilder/Builder/BuilderConfigView.module.scss @@ -5,6 +5,7 @@ display: flex; flex-direction: column; gap: variables.$spacing-md; + height: 100%; } .heading { diff --git a/airbyte-webapp/src/components/connectorBuilder/Builder/BuilderOptional.tsx b/airbyte-webapp/src/components/connectorBuilder/Builder/BuilderOptional.tsx index 639f5358726b..ce2067db6c82 100644 --- a/airbyte-webapp/src/components/connectorBuilder/Builder/BuilderOptional.tsx +++ b/airbyte-webapp/src/components/connectorBuilder/Builder/BuilderOptional.tsx @@ -11,6 +11,7 @@ export const BuilderOptional: React.FC> = ({ ch return (
- - - - - - - - - - - - - + {selectedTab === "configuration" ? ( + <> + + + + + + + + + + + + + + + ) : ( + + + + )} ); }; + +const StreamTab = ({ + selected, + label, + onSelect, + showErrorIndicator, +}: { + selected: boolean; + label: string; + onSelect: () => void; + showErrorIndicator?: boolean; +}) => ( + +); + +const SchemaEditor = ({ streamFieldPath }: { streamFieldPath: (fieldPath: string) => string }) => { + const [field, meta, helpers] = useField(streamFieldPath("schema")); + + return ( + <> + { + helpers.setValue(val); + }} + /> + {meta.error && } + + ); +}; diff --git a/airbyte-webapp/src/components/connectorBuilder/types.ts b/airbyte-webapp/src/components/connectorBuilder/types.ts index 02cbb50f3702..bc7c00db4564 100644 --- a/airbyte-webapp/src/components/connectorBuilder/types.ts +++ b/airbyte-webapp/src/components/connectorBuilder/types.ts @@ -66,6 +66,7 @@ export interface BuilderStream { }; paginator?: BuilderPaginator; streamSlicer?: SimpleRetrieverStreamSlicer; + schema?: string; } export const DEFAULT_BUILDER_FORM_VALUES: BuilderFormValues = { @@ -274,6 +275,20 @@ export const builderFormValidationSchema = yup.object().shape({ requestHeaders: yup.array().of(yup.array().of(yup.string())), requestBody: yup.array().of(yup.array().of(yup.string())), }), + schema: yup.string().test({ + test: (val: string | undefined) => { + if (!val) { + return true; + } + try { + JSON.parse(val); + return true; + } catch { + return false; + } + }, + message: "connectorBuilder.invalidSchema", + }), paginator: yup .object() .shape({ @@ -394,12 +409,24 @@ function builderFormAuthenticatorToAuthenticator( return globalSettings.authenticator as HttpRequesterAuthenticator; } +function parseSchemaString(schema?: string) { + if (!schema) { + return undefined; + } + try { + return { type: "InlineSchemaLoader", schema: JSON.parse(schema) }; + } catch { + return undefined; + } +} + export const convertToManifest = (values: BuilderFormValues): ConnectorManifest => { const manifestStreams: DeclarativeStream[] = values.streams.map((stream) => { return { type: "DeclarativeStream", name: stream.name, primary_key: stream.primaryKey, + schema_loader: parseSchemaString(stream.schema), retriever: { type: "SimpleRetriever", name: stream.name, diff --git a/airbyte-webapp/src/locales/en.json b/airbyte-webapp/src/locales/en.json index c7e27fd1815a..16fcf517dda0 100644 --- a/airbyte-webapp/src/locales/en.json +++ b/airbyte-webapp/src/locales/en.json @@ -718,6 +718,9 @@ "connectorBuilder.setInUserInput": "This setting is configured as part of the user inputs in the testing panel", "connectorBuilder.optionalFieldsLabel": "Optional fields", "connectorBuilder.duplicateFieldID": "Make sure no field ID is used multiple times", + "connectorBuilder.streamConfiguration": "Configuration", + "connectorBuilder.streamSchema": "Schema", + "connectorBuilder.invalidSchema": "Invalid JSON - please fix schema to have it applied", "connectorBuilder.copyToPaginationTitle": "Copy pagination settings to...", "connectorBuilder.copyFromPaginationTitle": "Import pagination settings from...", "connectorBuilder.copyToSlicerTitle": "Copy slicing settings to...",