Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🪟🔧 Connector builder: use new lowcode manifest #20715

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { InfoBox } from "components/ui/InfoBox";
import { Modal, ModalBody } from "components/ui/Modal";
import { Tooltip } from "components/ui/Tooltip";

import { SourceDefinitionSpecificationDraft } from "core/domain/connector";
import { useConnectorBuilderState } from "services/connectorBuilder/ConnectorBuilderStateService";
import { ConnectorForm } from "views/Connector/ConnectorForm";

Expand All @@ -35,6 +36,17 @@ export const ConfigMenu: React.FC<ConfigMenuProps> = ({ className }) => {
setIsOpen(false);
};

const connectorDefinitionSpecification: SourceDefinitionSpecificationDraft | undefined = useMemo(
() =>
jsonManifest.spec
? {
documentationUrl: jsonManifest.spec.documentation_url,
connectionSpecification: jsonManifest.spec.connection_specification,
}
: undefined,
[jsonManifest]
);

return (
<>
<Tooltip
Expand All @@ -58,7 +70,7 @@ export const ConfigMenu: React.FC<ConfigMenuProps> = ({ className }) => {
<FormattedMessage id="connectorBuilder.inputsNoSpecYAMLTooltip" />
)}
</Tooltip>
{isOpen && jsonManifest.spec && (
{isOpen && connectorDefinitionSpecification && (
<Modal
size="lg"
onClose={() => setIsOpen(false)}
Expand Down Expand Up @@ -87,7 +99,7 @@ export const ConfigMenu: React.FC<ConfigMenuProps> = ({ className }) => {
formType="source"
bodyClassName={styles.formContent}
footerClassName={styles.inputFormModalFooter}
selectedConnectorDefinitionSpecification={jsonManifest.spec}
selectedConnectorDefinitionSpecification={connectorDefinitionSpecification}
formValues={formValues}
onSubmit={async (values) => {
setConfigString(JSON.stringify(values.connectionConfiguration, null, 2) ?? "");
Expand Down
22 changes: 15 additions & 7 deletions airbyte-webapp/src/components/connectorBuilder/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import * as yup from "yup";

import { ConnectorManifest, DeclarativeStream } from "core/request/ConnectorManifest";
import {
ConnectorManifest,
DeclarativeStream,
InterpolatedRequestOptionsProvider,
} from "core/request/ConnectorManifest";

export interface BuilderFormValues {
global: {
Expand Down Expand Up @@ -45,36 +49,40 @@ export const builderFormValidationSchema = yup.object().shape({
export const convertToManifest = (values: BuilderFormValues): ConnectorManifest => {
const manifestStreams: DeclarativeStream[] = values.streams.map((stream) => {
return {
type: "DeclarativeStream",
name: stream.name,
retriever: {
type: "SimpleRetriever",
name: stream.name,
requester: {
type: "HttpRequester",
name: stream.name,
url_base: values.global?.urlBase,
path: stream.urlPath,
request_options_provider: {
// TODO can't declar type here because the server will error out, but the types dictate it is needed. Fix here once server is fixed.
flash1293 marked this conversation as resolved.
Show resolved Hide resolved
// type: "InterpolatedRequestOptionsProvider",
request_parameters: Object.fromEntries(stream.requestOptions.requestParameters),
request_headers: Object.fromEntries(stream.requestOptions.requestHeaders),
request_body_data: Object.fromEntries(stream.requestOptions.requestBody),
},
// TODO: remove these empty "config" values once they are no longer required in the connector manifest JSON schema
config: {},
} as InterpolatedRequestOptionsProvider,
},
record_selector: {
type: "RecordSelector",
extractor: {
type: "DpathExtractor",
field_pointer: stream.fieldPointer,
config: {},
},
},
config: {},
},
config: {},
};
});

return {
version: "0.1.0",
type: "DeclarativeSource",
check: {
type: "CheckStream",
stream_names: [],
},
streams: manifestStreams,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useLocalStorage } from "react-use";

import { BuilderFormValues, convertToManifest } from "components/connectorBuilder/types";

import { PatchedConnectorManifest } from "core/domain/connectorBuilder/PatchedConnectorManifest";
import { StreamReadRequestBodyConfig, StreamsListReadStreamsItem } from "core/request/ConnectorBuilderClient";
import { ConnectorManifest } from "core/request/ConnectorManifest";

Expand All @@ -21,7 +20,9 @@ export const DEFAULT_BUILDER_FORM_VALUES: BuilderFormValues = {

const DEFAULT_JSON_MANIFEST_VALUES: ConnectorManifest = {
version: "0.1.0",
type: "DeclarativeSource",
check: {
type: "CheckStream",
stream_names: [],
},
streams: [],
Expand All @@ -32,7 +33,7 @@ export type BuilderView = "global" | number;

interface Context {
builderFormValues: BuilderFormValues;
jsonManifest: PatchedConnectorManifest;
jsonManifest: ConnectorManifest;
yamlManifest: string;
yamlEditorIsMounted: boolean;
yamlIsValid: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ paths: {}
components:
schemas:
ConnectorManifest:
$ref: "../../../../airbyte-cdk/python/airbyte_cdk/sources/declarative/config_component_schema.json"
$ref: "../../../../airbyte-cdk/python/airbyte_cdk/sources/declarative/declarative_component_schema.yaml"