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

Support dekaf materializations #1357

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions src/api/connectors.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { supabaseClient } from 'context/GlobalProviders';
import {
CONNECTOR_WITH_TAG_QUERY,
ConnectorWithTagDetailQuery,
CONNECTOR_WITH_TAG_QUERY,
} from 'hooks/connectors/shared';
import {
CONNECTOR_DETAILS,
CONNECTOR_NAME,
CONNECTOR_RECOMMENDED,
TABLES,
defaultTableFilter,
handleFailure,
handleSuccess,
supabaseRetry,
CONNECTOR_DETAILS,
TABLES,
} from 'services/supabase';
import { SortDirection } from 'types';
import { requiredConnectorColumnsExist } from 'utils/connector-utils';
Expand Down Expand Up @@ -57,14 +57,14 @@ export interface ConnectorTag_Base {
export interface ConnectorsQuery_DetailsForm {
id: string;
image_name: string;
logo_url: string;
image: string;
connector_tags: ConnectorTag_Base[];
}

const DETAILS_FORM_QUERY = `
id,
image_name,
logo_url:logo_url->>en-US::text,
image:logo_url->>en-US::text,
connector_tags !inner(
id,
connector_id,
Expand Down
18 changes: 12 additions & 6 deletions src/components/capture/useCaptureDraftUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
useEndpointConfigStore_setEncryptedEndpointConfig,
useEndpointConfigStore_setPreviousEndpointConfig,
} from 'stores/EndpointConfig/hooks';
import { isDekafConnector } from 'utils/connector-utils';

import { modifyExistingCaptureDraftSpec } from 'utils/workflow-utils';

Expand All @@ -38,8 +39,10 @@ function useDiscoverDraftUpdate(options?: {
const persistedDraftId = useEditorStore_persistedDraftId();
const setDraftId = useEditorStore_setId();

const imagePath = useDetailsFormStore(
(state) => state.details.data.connectorImage.imagePath
const imagePath = useDetailsFormStore((state) =>
isDekafConnector(state.details.data.connectorImage)
? undefined
: state.details.data.connectorImage.imagePath
);

const setEncryptedEndpointConfig =
Expand Down Expand Up @@ -67,10 +70,13 @@ function useDiscoverDraftUpdate(options?: {
// Doing a rediscovery with no new changes

if (
(!draftId && persistedDraftId && !options?.initiateDiscovery) ||
(persistedDraftId &&
!options?.initiateDiscovery &&
!options?.initiateRediscovery)
imagePath &&
((!draftId &&
persistedDraftId &&
!options?.initiateDiscovery) ||
(persistedDraftId &&
!options?.initiateDiscovery &&
!options?.initiateRediscovery))
) {
const existingDraftSpecResponse =
await getDraftSpecsByCatalogName(
Expand Down
36 changes: 26 additions & 10 deletions src/components/materialization/useGenerateCatalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,25 @@ import {
} from 'stores/Binding/hooks';
import { useDetailsFormStore } from 'stores/DetailsForm/Store';
import {
useEndpointConfig_serverUpdateRequired,
useEndpointConfigStore_encryptedEndpointConfig_data,
useEndpointConfigStore_endpointConfig_data,
useEndpointConfigStore_endpointSchema,
useEndpointConfigStore_errorsExist,
useEndpointConfigStore_setEncryptedEndpointConfig,
useEndpointConfigStore_setPreviousEndpointConfig,
useEndpointConfig_serverUpdateRequired,
} from 'stores/EndpointConfig/hooks';
import {
useFormStateStore_setFormState,
useFormStateStore_updateStatus,
} from 'stores/FormState/hooks';
import { FormStatus } from 'stores/FormState/types';
import { useSourceCaptureStore_sourceCaptureDefinition } from 'stores/SourceCapture/hooks';
import { DekafConfig } from 'types';
import { isDekafConnector } from 'utils/connector-utils';
import { encryptEndpointConfig } from 'utils/sops-utils';
import { generateTaskSpec } from 'utils/workflow-utils';
import { ConnectorConfig } from '../../../deps/flow/flow';

const ENTITY_TYPE = 'materialization';

Expand All @@ -63,8 +66,17 @@ function useGenerateCatalog() {
const imageConnectorId = useDetailsFormStore(
(state) => state.details.data.connectorImage.connectorId
);
const imagePath = useDetailsFormStore(
(state) => state.details.data.connectorImage.imagePath
const endpointConfig: ConnectorConfig | DekafConfig = useDetailsFormStore(
(state) =>
isDekafConnector(state.details.data.connectorImage)
? {
config: {},
variant: state.details.data.connectorImage.variant,
}
: {
config: {},
image: state.details.data.connectorImage.imagePath,
}
);
const setDraftedEntityName = useDetailsFormStore(
(state) => state.setDraftedEntityName
Expand Down Expand Up @@ -209,12 +221,11 @@ function useGenerateCatalog() {
{ overrideJsonFormDefaults: true }
);

endpointConfig.config = encryptedEndpointConfig.data;

const draftSpec = generateTaskSpec(
ENTITY_TYPE,
{
image: imagePath,
config: encryptedEndpointConfig.data,
},
endpointConfig,
resourceConfigs,
resourceConfigServerUpdateRequired,
bindings,
Expand Down Expand Up @@ -279,8 +290,13 @@ function useGenerateCatalog() {
// Update all the store state
setCatalogName(processedEntityName);
setEncryptedEndpointConfig({
data: draftSpecsResponse.data[0].spec.endpoint.connector
.config,
data: Object.hasOwn(
draftSpecsResponse.data[0].spec.endpoint,
'dekaf'
)
? draftSpecsResponse.data[0].spec.endpoint.dekaf.config
: draftSpecsResponse.data[0].spec.endpoint.connector
.config,
});
setPreviousEndpointConfig({ data: endpointConfigData });

Expand Down Expand Up @@ -314,14 +330,14 @@ function useGenerateCatalog() {
bindings,
callFailed,
detailsFormsErrorsExist,
endpointConfig,
endpointConfigData,
endpointConfigErrorsExist,
endpointSchema,
fullSourceConfigs,
fullSourceErrorsExist,
imageConnectorId,
imageConnectorTagId,
imagePath,
persistedDraftId,
prefillBindingDependentState,
processedEntityName,
Expand Down
18 changes: 0 additions & 18 deletions src/components/shared/Entity/DetailsForm/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,19 @@ import { useEditorStore_isSaving } from 'components/editor/Store/hooks';
import AlertBox from 'components/shared/AlertBox';
import { Props } from 'components/shared/Entity/DetailsForm/types';
import { CONNECTOR_IMAGE_SCOPE } from 'forms/renderers/Connectors';
import { ConnectorWithTagDetailQuery } from 'hooks/connectors/shared';
import { FormattedMessage, useIntl } from 'react-intl';
import defaultRenderers from 'services/jsonforms/defaultRenderers';
import { defaultOptions, showValidation } from 'services/jsonforms/shared';
import { useDetailsFormStore } from 'stores/DetailsForm/Store';
import { Details } from 'stores/DetailsForm/types';
import {
useFormStateStore_displayValidation,
useFormStateStore_isActive,
useFormStateStore_messagePrefix,
} from 'stores/FormState/hooks';
import { evaluateConnectorVersions } from 'utils/workflow-utils';
import useFormFields from './useFormFields';

export const CONFIG_EDITOR_ID = 'endpointConfigEditor';

export const getConnectorImageDetails = (
connector: ConnectorWithTagDetailQuery,
options?: { connectorId: string; existingImageTag: string }
): Details['data']['connectorImage'] => {
const connectorTag = evaluateConnectorVersions(connector, options);

return {
connectorId: connector.id,
id: connectorTag.id,
imageName: connector.image_name,
imagePath: `${connector.image_name}${connectorTag.image_tag}`,
iconPath: connector.image,
};
};

function DetailsFormForm({ connectorTags, entityType, readOnly }: Props) {
const intl = useIntl();

Expand Down
24 changes: 10 additions & 14 deletions src/components/shared/Entity/DetailsForm/useConnectorField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import useGlobalSearchParams, {
} from 'hooks/searchParams/useGlobalSearchParams';
import { useCallback, useEffect, useMemo } from 'react';
import { useIntl } from 'react-intl';
import { useDetailsFormStore } from 'stores/DetailsForm/Store';
import { useDetailsForm_changed_connectorId } from 'stores/DetailsForm/hooks';
import { useDetailsFormStore } from 'stores/DetailsForm/Store';
import { Details } from 'stores/DetailsForm/types';
import { EntityWithCreateWorkflow } from 'types';
import { getConnectorMetadata } from 'utils/connector-utils';
import { hasLength } from 'utils/misc-utils';
import {
ConnectorVersionEvaluationOptions,
evaluateConnectorVersions,
} from 'utils/workflow-utils';
import { MAC_ADDR_RE } from 'validation';
import useEntityCreateNavigate from '../hooks/useEntityCreateNavigate';
import { getConnectorImageDetails } from './Form';

export default function useConnectorField(
connectorTags: ConnectorWithTagDetailQuery[],
Expand All @@ -33,8 +33,8 @@ export default function useConnectorField(
const originalConnectorImage = useDetailsFormStore(
(state) => state.details.data.connectorImage
);
const connectorImagePath = useDetailsFormStore(
(state) => state.details.data.connectorImage.imagePath
const connectorImageTag = useDetailsFormStore(
(state) => state.details.data.connectorImage.imageTag
);
const connectorIdChanged = useDetailsForm_changed_connectorId();
const setDetails_connector = useDetailsFormStore(
Expand All @@ -53,7 +53,7 @@ export default function useConnectorField(
connectorTag.connector_id === connectorId;

if (connectorLocated) {
setDetails_connector(getConnectorImageDetails(connector));
setDetails_connector(getConnectorMetadata(connector));
}

return connectorLocated;
Expand All @@ -66,29 +66,25 @@ export default function useConnectorField(
| undefined = useMemo(() => {
// This is rare but can happen so being safe.
// If you remove the connector id from the create URL
if (!connectorImagePath) {
if (!connectorImageTag) {
return undefined;
}

const imageTagStartIndex = connectorImagePath.indexOf(':');
return isEdit && hasLength(connectorId) && imageTagStartIndex > 0
return isEdit && hasLength(connectorId)
? {
connectorId,
existingImageTag: connectorImagePath.substring(
imageTagStartIndex,
connectorImagePath.length
),
existingImageTag: connectorImageTag,
}
: undefined;
}, [connectorId, connectorImagePath, isEdit]);
}, [connectorId, connectorImageTag, isEdit]);

const connectorsOneOf = useMemo(() => {
const response = [] as { title: string; const: Object }[];

if (connectorTags.length > 0) {
connectorTags.forEach((connector) => {
response.push({
const: getConnectorImageDetails(
const: getConnectorMetadata(
connector,
versionEvaluationOptions
),
Expand Down
10 changes: 10 additions & 0 deletions src/components/shared/Entity/EndpointConfig/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,16 @@ function EndpointConfig({
</Box>
) : null}

{canBeEmpty ? (
<Box sx={{ mb: 3 }}>
<AlertBox severity="info" short>
{intl.formatMessage({
id: 'workflows.alert.endpointConfigEmpty',
})}
</AlertBox>
</Box>
) : null}

<EndpointConfigForm readOnly={readOnly} />
</ErrorBoundryWrapper>
</WrapperWithHeader>
Expand Down
2 changes: 2 additions & 0 deletions src/lang/en-US/Workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ export const Workflows: Record<string, string> = {
'workflows.dataPlane.description': `Choose the data plane you would like to use.`,
'workflows.dataPlane.label': `Data Plane`,

'workflows.alert.endpointConfigEmpty': `This endpoint requires configuration of the external system only.`,

// Field Selection
'fieldSelection.header': `Field Selection`,
'fieldSelection.table.label': `Field Selection Editor`,
Expand Down
19 changes: 5 additions & 14 deletions src/stores/DetailsForm/Store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
getInitialHydrationData,
getStoreWithHydrationSettings,
} from 'stores/extensions/Hydration';
import { getConnectorMetadata } from 'utils/connector-utils';
import {
getDataPlaneScope,
parseDataPlaneName,
Expand All @@ -30,10 +31,7 @@ import {
import { defaultDataPlaneSuffix, isProduction } from 'utils/env-utils';
import { hasLength } from 'utils/misc-utils';
import { devtoolsOptions } from 'utils/store-utils';
import {
ConnectorVersionEvaluationOptions,
evaluateConnectorVersions,
} from 'utils/workflow-utils';
import { ConnectorVersionEvaluationOptions } from 'utils/workflow-utils';
import { NAME_RE } from 'validation';
import { create, StoreApi } from 'zustand';
import { devtools, NamedSet } from 'zustand/middleware';
Expand All @@ -48,20 +46,11 @@ const getConnectorImage = async (

if (!error && data && data.length > 0) {
const connector = data[0];
const { image_name, logo_url } = connector;

const options: ConnectorVersionEvaluationOptions | undefined =
existingImageTag ? { connectorId, existingImageTag } : undefined;

const connectorTag = evaluateConnectorVersions(connector, options);

return {
connectorId,
id: connectorTag.id,
imageName: image_name,
imagePath: `${image_name}${connectorTag.image_tag}`,
iconPath: logo_url,
};
return getConnectorMetadata(connector, options);
}

return null;
Expand Down Expand Up @@ -103,6 +92,7 @@ const initialDetails: Details = {
iconPath: '',
imageName: '',
imagePath: '',
imageTag: '',
},
entityName: '',
},
Expand Down Expand Up @@ -425,6 +415,7 @@ export const getInitialState = (
iconPath: '',
imageName: '',
imagePath: '',
imageTag: '',
connectorId,
});
get().setHydrationErrorsExist(true);
Expand Down
Loading
Loading