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: Add manual schema #20862

Merged
merged 113 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
d2ed762
improve some types
Dec 5, 2022
f474a1c
Merge remote-tracking branch 'upstream/master' into chore-improve-con…
Dec 5, 2022
5b0521f
improve further
Dec 5, 2022
af659fd
Merge remote-tracking branch 'upstream/master' into chore-improve-con…
Dec 6, 2022
1cd3bbb
clean up a bit more
Dec 6, 2022
807c436
refactor loading state
Dec 6, 2022
6c76e0f
Merge remote-tracking branch 'upstream/master' into flash1293/connect…
Dec 6, 2022
05c3107
move loading state up
Dec 6, 2022
eee4303
remove isLoading references
Dec 6, 2022
7d6f977
remove unused props and make fetch connector error work
Dec 6, 2022
0fe11f0
remove special component for name
Dec 6, 2022
34d4814
remove top level state for unifinished flows
Dec 6, 2022
67d62c5
Merge remote-tracking branch 'upstream/master' into flash1293/connect…
Dec 6, 2022
afea882
Merge branch 'flash1293/connector-form-name-override' into flash1293/…
Dec 6, 2022
c7e7475
Merge branch 'master' into flash1293/connector-form-loading-state
Dec 6, 2022
cc7f65f
Merge branch 'chore-improve-connector-form-types' into flash1293/conn…
Dec 6, 2022
a1c6cbd
start removing uiwidget
Dec 6, 2022
9be8337
Update airbyte-webapp/src/views/Connector/ConnectorCard/ConnectorCard…
Dec 6, 2022
37cee8f
Merge remote-tracking branch 'upstream/master' into flash1293/connect…
Dec 6, 2022
5686241
Merge branch 'flash1293/connector-form-loading-state' of github.com:a…
Dec 6, 2022
7b73364
remove undefined option for selected id
Dec 6, 2022
7058d26
Merge branch 'flash1293/connector-form-loading-state' into flash1293/…
Dec 6, 2022
dd7e82a
Merge branch 'flash1293/connector-form-name-override' into flash1293/…
Dec 6, 2022
6d4c7d3
Merge remote-tracking branch 'upstream/master' into flash1293/connect…
Dec 7, 2022
d624792
Merge branch 'flash1293/connector-form-loading-state' into flash1293/…
Dec 7, 2022
36cf941
Merge branch 'flash1293/connector-form-name-override' into flash1293/…
Dec 7, 2022
b7a6322
Merge remote-tracking branch 'upstream/master' into flash1293/connect…
Dec 7, 2022
72b602a
Merge branch 'flash1293/connector-form-loading-state' into flash1293/…
Dec 7, 2022
5e47a4a
Merge branch 'flash1293/connector-form-name-override' into flash1293/…
Dec 7, 2022
6c71028
Merge remote-tracking branch 'origin/master' into flash1293/connector…
Dec 8, 2022
809625f
remove unused prop
Dec 8, 2022
10446eb
Merge branch 'flash1293/connector-form-loading-state' into flash1293/…
Dec 8, 2022
4a7a885
Merge branch 'flash1293/connector-form-name-override' into flash1293/…
Dec 8, 2022
2024b60
Merge branch 'flash1293/connector-form-unifinished-flows' into flash1…
Dec 8, 2022
ee30092
fix types
Dec 8, 2022
d91df38
remove uiwidget state
Dec 8, 2022
93fe558
Merge remote-tracking branch 'origin/master' into flash1293/connector…
Dec 9, 2022
cbc023a
Merge branch 'flash1293/connector-form-name-override' into flash1293/…
Dec 9, 2022
ec54d38
Merge branch 'flash1293/connector-form-unifinished-flows' into flash1…
Dec 9, 2022
47152ea
clean up
Dec 9, 2022
6ec0e10
adjust comment
Dec 9, 2022
1aa7829
handle errors in a nice way
Dec 9, 2022
7b90088
do not respect default on oneOf fields
Dec 9, 2022
fbefbdd
rename to formblock
Dec 9, 2022
6b3e5e2
reduce re-renders
Dec 9, 2022
9aa3f80
Merge remote-tracking branch 'origin/master' into flash1293/connector…
Dec 12, 2022
c765003
Merge branch 'flash1293/connector-form-unifinished-flows' into flash1…
Dec 12, 2022
5cd77ec
pass error to secure inputs
Dec 12, 2022
5dfbc22
Merge remote-tracking branch 'origin/master' into flash1293/connector…
Dec 13, 2022
a6aa741
simplify and improve styling
Dec 13, 2022
95717d2
align top
Dec 13, 2022
40d162d
Merge branch 'flash1293/connector-form-unifinished-flows' into flash1…
Dec 13, 2022
b9384ee
Merge remote-tracking branch 'origin/master' into flash1293/connector…
Dec 13, 2022
582a5f2
code review
Dec 13, 2022
18d6ce8
remove comment
Dec 13, 2022
60c1f1c
Merge branch 'master' into flash1293/connector-form-remove-ui-widget-…
Dec 14, 2022
9cb595d
Merge remote-tracking branch 'origin/master' into flash1293/connector…
Dec 15, 2022
fe74a45
review comments
Dec 15, 2022
5c00ad0
rename file
Dec 15, 2022
bd0dffc
be strict about boolean values
Dec 15, 2022
1ff8c13
add example
Dec 15, 2022
c6ee526
track form error in error boundary
Dec 15, 2022
05bbd6f
Merge branch 'flash1293/connector-form-remove-ui-widget-state' of git…
Dec 15, 2022
fff4703
Merge remote-tracking branch 'origin/master' into flash1293/connector…
Dec 16, 2022
94ba866
review comments
Dec 16, 2022
97bb0a7
handle unexpected cases better
Dec 16, 2022
633b9b2
Merge branch 'master' into flash1293/connector-form-remove-ui-widget-…
Dec 16, 2022
e47517f
Merge branch 'master' into flash1293/connector-form-remove-ui-widget-…
Dec 16, 2022
e931956
Merge remote-tracking branch 'origin/master' into feature/connector-b…
Dec 16, 2022
6889f66
enrich error with connector id
Dec 19, 2022
7b60406
Merge branch 'flash1293/connector-form-remove-ui-widget-state' into f…
Dec 19, 2022
d5e56eb
Merge branch 'master' into flash1293/connector-form-remove-ui-widget-…
Dec 19, 2022
35a74ba
Merge branch 'flash1293/connector-form-remove-ui-widget-state' into f…
Dec 19, 2022
02c8096
🪟🎉 Add copy stream button (#20577)
Dec 19, 2022
526adfc
rename prop
Dec 20, 2022
7d49233
🪟🎉 Connector builder: Integrate connector form for test input (#20385)
Dec 20, 2022
c5da764
Merge remote-tracking branch 'origin/master' into flash1293/connector…
Dec 20, 2022
6c0bf9d
Merge branch 'flash1293/connector-form-remove-ui-widget-state' into f…
Dec 20, 2022
477977f
use request_body_json instead of request_body_data
lmossman Dec 20, 2022
200cfe7
:window: :art: Move `Add` button into the line of Connector Builder k…
lmossman Dec 21, 2022
c7fd310
🪟🎉 Connector builder: Allow defining inputs (#20431)
Dec 22, 2022
e0e3796
fix merge conflict with dropdown prop being renamed to control
Dec 22, 2022
e23a6d8
[Connector Builder] Add paginator (#20698)
lmossman Dec 22, 2022
610e668
[Connector Builder] Add stream slicer (#20748)
lmossman Dec 22, 2022
e68ff49
debounce form builder values update to reduce load
Dec 22, 2022
9ccf294
Merge branch 'master' into flash1293/connector-form-remove-ui-widget-…
Dec 22, 2022
ae9a229
Merge branch 'flash1293/connector-form-remove-ui-widget-state' into f…
Dec 22, 2022
a9e1d09
🪟🔧 Connector builder: use new lowcode manifest (#20715)
Dec 22, 2022
1965efe
add manual schema
Dec 23, 2022
c8f3920
make buttons not submit the form accidentally
Dec 23, 2022
e4f7bba
debounce validation as well
Dec 27, 2022
16c71ae
Merge branch 'master' into flash1293/connector-form-remove-ui-widget-…
Jan 2, 2023
54c070d
Merge branch 'flash1293/connector-form-remove-ui-widget-state' into f…
Jan 2, 2023
a8b9aae
Merge branch 'feature/connector-builder' into flash1293/add-manual-sc…
Jan 2, 2023
2e20fa6
akways show stream test button in error state if there are errors
Jan 2, 2023
65199d0
fix type of oauth input
Jan 2, 2023
92722e0
Merge branch 'master' into flash1293/connector-form-remove-ui-widget-…
Jan 3, 2023
718c233
Merge branch 'flash1293/connector-form-remove-ui-widget-state' into f…
Jan 3, 2023
c303a5d
Merge branch 'feature/connector-builder' into flash1293/add-manual-sc…
Jan 3, 2023
6a8be0b
Merge remote-tracking branch 'origin/master' into feature/connector-b…
Jan 3, 2023
753241d
Merge branch 'feature/connector-builder' into flash1293/add-manual-sc…
Jan 3, 2023
16ce351
add validation schema for add stream form
lmossman Jan 3, 2023
25d6586
validate all views on test click
lmossman Jan 3, 2023
64a5eb9
add type to prevent console warning
lmossman Jan 4, 2023
1db62dd
Merge branch 'feature/connector-builder' into flash1293/add-manual-sc…
Jan 4, 2023
2a3776f
Merge remote-tracking branch 'origin/master' into flash1293/add-manua…
Jan 4, 2023
abb9c0b
improve error indicator
Jan 4, 2023
08e6d99
make schema editor take up full height (#21000)
lmossman Jan 4, 2023
12db741
Merge branch 'flash1293/add-manual-schema' of github.com:airbytehq/ai…
Jan 4, 2023
7088b2c
prevent resizing card when error message is shown or hidden
lmossman Jan 4, 2023
5423192
Merge remote-tracking branch 'origin/master' into flash1293/add-manua…
Jan 5, 2023
daae429
Revert "improve error indicator"
Jan 5, 2023
4a7ffc6
Merge remote-tracking branch 'origin/master' into flash1293/add-manua…
Jan 5, 2023
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 @@ -5,6 +5,7 @@
display: flex;
flex-direction: column;
gap: variables.$spacing-md;
height: 100%;
}

.heading {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const BuilderOptional: React.FC<React.PropsWithChildren<unknown>> = ({ ch
return (
<div className={styles.wrapper}>
<button
type="button"
onClick={() => {
setIsOpen(!isOpen);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ $controlButtonWidth: 24px;
.controls {
display: flex;
justify-content: center;
gap: variables.$spacing-sm;
align-items: center;
gap: variables.$spacing-md;
}

.controlButton {
Expand All @@ -33,6 +34,33 @@ $controlButtonWidth: 24px;
}
}

.tab {
background: none;
border: none;
padding: variables.$spacing-md;
border-bottom: variables.$border-thick solid transparent;
color: colors.$grey-400;
cursor: pointer;
display: flex;
gap: variables.$spacing-md;
align-items: center;
}

.selectedTab {
color: colors.$black;
border-bottom-color: colors.$yellow-900;
}

.errorMessage {
// hardcode height to prevent resizing when error message is hidden
height: 16px;
color: colors.$red;
}

.schemaEditor {
height: 100%;
}

.multiStreams {
padding-right: 50px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { faTrashCan, faCopy } from "@fortawesome/free-regular-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import classNames from "classnames";
import { useField } from "formik";
import { useIntl } from "react-intl";
import { useState } from "react";
import { FormattedMessage, useIntl } from "react-intl";

import Indicator from "components/Indicator";
import { CodeEditor } from "components/ui/CodeEditor";
import { Text } from "components/ui/Text";

import { useConfirmationModalService } from "hooks/services/ConfirmationModal";
import { BuilderView, useConnectorBuilderState } from "services/connectorBuilder/ConnectorBuilderStateService";
Expand All @@ -26,6 +31,7 @@ interface StreamConfigViewProps {
export const StreamConfigView: React.FC<StreamConfigViewProps> = ({ streamNum, hasMultipleStreams }) => {
const { formatMessage } = useIntl();
const [field, , helpers] = useField<BuilderStream[]>("streams");
const [selectedTab, setSelectedTab] = useState<"configuration" | "schema">("configuration");
const { openConfirmationModal, closeConfirmationModal } = useConfirmationModalService();
const { setSelectedView, setTestStreamIndex } = useConnectorBuilderState();

Expand All @@ -49,6 +55,9 @@ export const StreamConfigView: React.FC<StreamConfigViewProps> = ({ streamNum, h
});
};

const [, meta] = useField<string | undefined>(streamFieldPath("schema"));
const hasSchemaErrors = Boolean(meta.error);

return (
<BuilderConfigView
heading={formatMessage({ id: "connectorBuilder.stream" })}
Expand All @@ -57,6 +66,17 @@ export const StreamConfigView: React.FC<StreamConfigViewProps> = ({ streamNum, h
{/* Not using intl for the labels and tooltips in this component in order to keep maintainence simple */}
<BuilderTitle path={streamFieldPath("name")} label="Stream Name" size="md" />
<div className={styles.controls}>
<StreamTab
label={formatMessage({ id: "connectorBuilder.streamConfiguration" })}
selected={selectedTab === "configuration"}
onSelect={() => setSelectedTab("configuration")}
/>
<StreamTab
label={formatMessage({ id: "connectorBuilder.streamSchema" })}
selected={selectedTab === "schema"}
onSelect={() => setSelectedTab("schema")}
showErrorIndicator={hasSchemaErrors}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't need to be done in this PR, but it would be nice if clicking the Test or Download Config buttons would cause the schema view to be focused if it has any errors. Currently it auto-focuses the Stream view, but it doesn't open the Schema tab automatically

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restructured this a bit and I think I found an acceptable way to handle this and the comment about showing an error indicator for the configuration tab. It's always selecting the view that has errors if there is one by default.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we also show this error indicator on the configuration tab if there are any errors in there? Maybe not necessary since we already show it on the sidebar

/>
<AddStreamButton
onAddStream={(addedStreamNum) => {
setSelectedView(addedStreamNum);
Expand All @@ -73,53 +93,96 @@ export const StreamConfigView: React.FC<StreamConfigViewProps> = ({ streamNum, h
<FontAwesomeIcon icon={faTrashCan} />
</button>
</div>
<BuilderCard>
<BuilderField
type="string"
path={streamFieldPath("urlPath")}
label="Path URL"
tooltip="Path of the endpoint that this stream represents."
/>
<BuilderField
type="enum"
path={streamFieldPath("httpMethod")}
options={["GET", "POST"]}
label="HTTP Method"
tooltip="HTTP method to use for requests sent to the API"
/>
<BuilderField
type="array"
path={streamFieldPath("fieldPointer")}
label="Record selector"
tooltip="Pointer into the response that should be extracted as the final record"
/>
<BuilderField
type="array"
path={streamFieldPath("primaryKey")}
label="Primary key"
tooltip="Pointer into the response that should be used as the primary key when deduplicating records in the destination"
optional
/>
</BuilderCard>
<PaginationSection streamFieldPath={streamFieldPath} currentStreamIndex={streamNum} />
<StreamSlicerSection streamFieldPath={streamFieldPath} currentStreamIndex={streamNum} />
<BuilderCard>
<KeyValueListField
path={streamFieldPath("requestOptions.requestParameters")}
label="Request Parameters"
tooltip="Parameters to attach to API requests"
/>
<KeyValueListField
path={streamFieldPath("requestOptions.requestHeaders")}
label="Request Headers"
tooltip="Headers to attach to API requests"
/>
<KeyValueListField
path={streamFieldPath("requestOptions.requestBody")}
label="Request Body"
tooltip="Body to attach to API requests as url-encoded form values"
/>
</BuilderCard>
{selectedTab === "configuration" ? (
<>
<BuilderCard>
<BuilderField
type="string"
path={streamFieldPath("urlPath")}
label="Path URL"
tooltip="Path of the endpoint that this stream represents."
/>
<BuilderField
type="enum"
path={streamFieldPath("httpMethod")}
options={["GET", "POST"]}
label="HTTP Method"
tooltip="HTTP method to use for requests sent to the API"
/>
<BuilderField
type="array"
path={streamFieldPath("fieldPointer")}
label="Record selector"
tooltip="Pointer into the response that should be extracted as the final record"
/>
<BuilderField
type="array"
path={streamFieldPath("primaryKey")}
label="Primary key"
tooltip="Pointer into the response that should be used as the primary key when deduplicating records in the destination"
optional
/>
</BuilderCard>
<PaginationSection streamFieldPath={streamFieldPath} currentStreamIndex={streamNum} />
<StreamSlicerSection streamFieldPath={streamFieldPath} currentStreamIndex={streamNum} />
<BuilderCard>
<KeyValueListField
path={streamFieldPath("requestOptions.requestParameters")}
label="Request Parameters"
tooltip="Parameters to attach to API requests"
/>
<KeyValueListField
path={streamFieldPath("requestOptions.requestHeaders")}
label="Request Headers"
tooltip="Headers to attach to API requests"
/>
<KeyValueListField
path={streamFieldPath("requestOptions.requestBody")}
label="Request Body"
tooltip="Body to attach to API requests as url-encoded form values"
/>
</BuilderCard>
</>
) : (
<BuilderCard className={styles.schemaEditor}>
<SchemaEditor streamFieldPath={streamFieldPath} />
</BuilderCard>
)}
</BuilderConfigView>
);
};

const StreamTab = ({
selected,
label,
onSelect,
showErrorIndicator,
}: {
selected: boolean;
label: string;
onSelect: () => void;
showErrorIndicator?: boolean;
}) => (
<button type="button" className={classNames(styles.tab, { [styles.selectedTab]: selected })} onClick={onSelect}>
{label}
{showErrorIndicator && <Indicator />}
</button>
);

const SchemaEditor = ({ streamFieldPath }: { streamFieldPath: (fieldPath: string) => string }) => {
const [field, meta, helpers] = useField<string | undefined>(streamFieldPath("schema"));

return (
<>
<CodeEditor
value={field.value || ""}
language="json"
theme="airbyte-light"
onChange={(val: string | undefined) => {
helpers.setValue(val);
}}
/>
<Text className={styles.errorMessage}>{meta.error && <FormattedMessage id={meta.error} />}</Text>
</>
);
};
27 changes: 27 additions & 0 deletions airbyte-webapp/src/components/connectorBuilder/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export interface BuilderStream {
};
paginator?: BuilderPaginator;
streamSlicer?: SimpleRetrieverStreamSlicer;
schema?: string;
}

export const DEFAULT_BUILDER_FORM_VALUES: BuilderFormValues = {
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions airbyte-webapp/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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...",
Expand Down