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 UI: Fix datetime stream slicer #21161

Merged
merged 5 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -5,7 +5,6 @@ import { ControlLabels } from "components/LabeledControl";

import { RequestOption, SimpleRetrieverStreamSlicer } from "core/request/ConnectorManifest";

import { timeDeltaRegex } from "../types";
import { BuilderCard } from "./BuilderCard";
import { BuilderField } from "./BuilderField";
import { BuilderFieldWithInputs } from "./BuilderFieldWithInputs";
Expand Down Expand Up @@ -97,6 +96,12 @@ export const StreamSlicerSection: React.FC<StreamSlicerSectionProps> = ({ stream
label="Datetime format"
tooltip="Specify the format of the start and end time, e.g. %Y-%m-%d"
/>
<BuilderFieldWithInputs
type="string"
path={buildPath("cursor_granularity")}
label="Cursor granularity"
tooltip="Smallest increment the datetime format has (ISO 8601 duration) that will be used to ensure that the start of a slice does not overlap with the end of the previous one, e.g. for %Y-%m-%d the granularity should be P1D, for %Y-%m-%dT%H:%M:%SZ the granularity should be PT1S"
/>
<BuilderFieldWithInputs
type="string"
path={buildPath("start_datetime")}
Expand All @@ -113,8 +118,7 @@ export const StreamSlicerSection: React.FC<StreamSlicerSectionProps> = ({ stream
type="string"
path={buildPath("step")}
label="Step"
tooltip="Time interval for which to break up stream into slices, e.g. 1d"
pattern={timeDeltaRegex}
tooltip="Time interval (ISO 8601 duration) for which to break up stream into slices, e.g. P1D for daily slices"
/>
<BuilderFieldWithInputs
type="string"
Expand All @@ -127,7 +131,7 @@ export const StreamSlicerSection: React.FC<StreamSlicerSectionProps> = ({ stream
type="string"
path={buildPath("lookback_window")}
label="Lookback window"
tooltip="How many days before the start_datetime to read data for, e.g. 31d"
tooltip="Time interval (ISO 8601 duration) before the start_datetime to read data for, e.g. P1M for looking back one month"
optional
/>
<ToggleGroupField<RequestOption>
Expand Down
5 changes: 1 addition & 4 deletions airbyte-webapp/src/components/connectorBuilder/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,6 @@ const nonPathRequestOptionSchema = yup
.notRequired()
.default(undefined);

// eslint-disable-next-line no-useless-escape
export const timeDeltaRegex = /^(([\.\d]+?)y)?(([\.\d]+?)m)?(([\.\d]+?)w)?(([\.\d]+?)d)?$/;

const regularSlicerShape = {
cursor_field: yup.mixed().when("type", {
is: (val: string) => val !== "SubstreamSlicer" && val !== "CartesianProductStreamSlicer",
Expand All @@ -280,7 +277,7 @@ const regularSlicerShape = {
}),
step: yup.mixed().when("type", {
is: "DatetimeStreamSlicer",
then: yup.string().matches(timeDeltaRegex, "form.pattern.error").required("form.empty.error"),
then: yup.string().required("form.empty.error"),
otherwise: (schema) => schema.strip(),
}),
datetime_format: yup.mixed().when("type", {
Expand Down