Skip to content

Commit

Permalink
NEOS-359:Handle null in transformers (#680)
Browse files Browse the repository at this point in the history
  • Loading branch information
evisdrenova authored Nov 28, 2023
1 parent 5d5508c commit a95d935
Show file tree
Hide file tree
Showing 40 changed files with 762 additions and 415 deletions.
3 changes: 1 addition & 2 deletions backend/sql/postgresql/models/transformers.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ type TransformStringConfig struct {
PreserveLength bool `json:"preserveLength"`
}

type PassthroughConfig struct {
}
type PassthroughConfig struct{}

type NullConfig struct{}

Expand Down
12 changes: 11 additions & 1 deletion frontend/app/connections/[id]/components/MysqlForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,17 @@ export default function MysqlForm(props: Props) {
onClick={async () => {
setIsTesting(true);
try {
const resp = await checkMysqlConnection(form.getValues().db);
const val = {
host: form.getValues().db.host,
name: form.getValues().db.name,
user: form.getValues().db.user,
pass: form.getValues().db.pass,
port: form.getValues().db.port,
protocol: form.getValues().db.protocol // this is a little hacky but the sslMode doesn't get set in the form for some reason
? form.getValues().db.protocol
: defaultValues.db.protocol,
};
const resp = await checkMysqlConnection(val);
setCheckResp(resp);
setIsTesting(false);
} catch (err) {
Expand Down
14 changes: 12 additions & 2 deletions frontend/app/connections/[id]/components/PostgresForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export default function PostgresForm(props: Props) {
<FormControl>
<Select onValueChange={field.onChange} value={field.value}>
<SelectTrigger>
<SelectValue placeholder={defaultValues.db.sslMode ?? ''} />
<SelectValue placeholder={defaultValues.db.sslMode} />
</SelectTrigger>
<SelectContent>
{SSL_MODES.map((mode) => (
Expand All @@ -254,7 +254,17 @@ export default function PostgresForm(props: Props) {
onClick={async () => {
setIsTesting(true);
try {
const resp = await checkPostgresConnection(form.getValues().db);
const val = {
host: form.getValues().db.host,
name: form.getValues().db.name,
user: form.getValues().db.user,
pass: form.getValues().db.pass,
port: form.getValues().db.port,
sslMode: form.getValues().db.sslMode // this is a little hacky but the sslMode doesn't get set in the form for some reason
? form.getValues().db.sslMode
: defaultValues.db.sslMode,
};
const resp = await checkPostgresConnection(val);
setCheckResp(resp);
setIsTesting(false);
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function DataTableRowActions<TData>({
await removeConnection(connection.id);
toast({
title: 'Connection removed successfully!',
variant: 'destructive',
variant: 'success',
});
onDeleted();
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/new/connection/postgres/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default async function Postgres() {
<PageHeader
header="PostgreSQL"
description="Configure a PostgreSQL database as a connection"
leftIcon={<DiPostgresql className="w-[40px]" />}
leftIcon={<DiPostgresql className=" w-[40px] h-[40px]" />}
/>
}
containerClassName="px-12 md:px-24 lg:px-32"
Expand Down
68 changes: 34 additions & 34 deletions frontend/app/transformers/EditTransformerOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,79 +303,79 @@ export function handleTransformerMetadata(
const tEntries: Record<string, TransformerMetadata>[] = [
{
generate_email: {
name: 'Synthetic Email',
description: 'Generates a new synthetic email address.',
name: 'Generate Email',
description: 'Generates a new Generate email address.',
type: 'string',
},
},
{
generate_realistic_email: {
name: 'Realistic Synthetic Email',
description: 'Generates a new synthetic realistic email address.',
name: 'Generate Realistic Email',
description: 'Generates a new realistic email address.',
type: 'string',
},
},
{
transform_email: {
name: 'Anonymize Email',
description: 'Anonymizes an existing email address.',
name: 'Transform Email',
description: 'Transforms an existing email address.',
type: 'string',
},
},
{
generate_bool: {
name: 'Synthetic Boolean',
name: 'Generate Boolean',
description: 'Generates a boolean value at random.',
type: 'bool',
},
},
{
generate_card_number: {
name: 'Synthetic Card Number',
description: 'Generates a synthetic card number.',
name: 'Generate Card Number',
description: 'Generates a card number.',
type: 'bool',
},
},
{
generate_city: {
name: 'Synthetic City',
name: 'Generate City',
description:
'Randomly selects a city from a list of predefined US cities.',
type: 'string',
},
},
{
generate_e164_number: {
name: 'Synthetic E164 Phone Number',
description: 'Generates a synthetic phone number in e164 format.',
name: 'Generate E164 Phone Number',
description: 'Generates a Generate phone number in e164 format.',
type: 'string',
},
},
{
generate_first_name: {
name: 'Synthetic First Name',
description: 'Generates a synthetic first name.',
name: 'Generate First Name',
description: 'Generates a Generate first name.',
type: 'string',
},
},
{
generate_float: {
name: 'Synthetic Float',
description: 'Generates a synthetic float value.',
name: 'Generate Float',
description: 'Generates a Generate float value.',
type: 'string',
},
},
{
generate_full_address: {
name: 'Synthetic Full Address',
name: 'Generate Full Address',
description:
'Randomly generates a street address in the format: {street_num} {street_addresss} {street_descriptor} {city}, {state} {zipcode}. For example, 123 Main Street Boston, Massachusetts 02169.',
type: 'string',
},
},
{
generate_full_name: {
name: 'Synthetic Full Name',
name: 'Generate Full Name',
description:
'Generates a new full name consisting of a first and last name.',
type: 'string',
Expand All @@ -391,23 +391,23 @@ export function handleTransformerMetadata(
},
{
generate_int64_phone: {
name: 'Synthetic Int64 Phone Number',
name: 'Generate Int64 Phone Number',
description:
'Generates a new phone number of type int64 with a default length of 10.',
type: 'int64',
},
},
{
generate_int: {
name: 'Synthetic Integer',
name: 'Generate Integer',
description:
'Generates a random integer value with a default length of 4 unless the Integer Length or Preserve Length paramters are defined. .',
type: 'int64',
},
},
{
generate_last_name: {
name: 'Synthetic Last Name',
name: 'Generate Last Name',
description: 'Generates a new last name.',
type: 'string',
},
Expand Down Expand Up @@ -447,20 +447,20 @@ export function handleTransformerMetadata(
generate_string_phone: {
name: 'String Phone',
description:
'Generates a synthetic phone number and returns it as a string',
'Generates a Generate phone number and returns it as a string',
type: 'string',
},
},
{
generate_string: {
name: 'Synthetic String',
name: 'Generate String',
description:
'Creates a randomly ordered alphanumeric string with a default length of 10 unless the String Length parameter are defined.',
type: 'string',
},
},
{
generate_unix_timestamp: {
generate_unixtimestamp: {
name: 'Unix Timestamp',
description: 'Randomly generates a Unix timestamp.',
type: 'int64',
Expand All @@ -475,7 +475,7 @@ export function handleTransformerMetadata(
},
},
{
generate_utc_timestamp: {
generate_utctimestamp: {
name: 'UTC Timestamp',
description: 'Randomly generates a UTC timestamp.',
type: 'time',
Expand All @@ -499,65 +499,65 @@ export function handleTransformerMetadata(
{
transform_e164_phone: {
name: 'Transform E164 Phone',
description: 'Anonymizes an existing E164 formatted phone number.',
description: 'Transforms an existing E164 formatted phone number.',
type: 'string',
},
},
{
transform_first_name: {
name: 'Transform First Name',
description: 'Anonymizes an existing first name.',
description: 'Transforms an existing first name.',
type: 'string',
},
},
{
transform_float: {
name: 'Transform Float',
description: 'Anonymizes an existing float value.',
description: 'Transforms an existing float value.',
type: 'string',
},
},
{
transform_full_name: {
name: 'Transform Full Name',
description: 'Anonymizes an existing full name.',
description: 'Transforms an existing full name.',
type: 'string',
},
},
{
transform_int_phone: {
name: 'Transform Integer Phone Number',
description:
'Anonymizes an existing phone number that is typed as an integer.',
'Transforms an existing phone number that is typed as an integer.',
type: 'string',
},
},
{
transform_int: {
name: 'Transform Integer ',
description: 'Anonymizes an existing integer value.',
description: 'Transforms an existing integer value.',
type: 'string',
},
},
{
transform_last_name: {
name: 'Transform Last Name ',
description: 'Anonymizes an existing last name.',
description: 'Transforms an existing last name.',
type: 'string',
},
},
{
transform_phone: {
name: 'Transform String Phone Number ',
description:
'Anonymizes an existing phone number that is typed as a string.',
'Transforms an existing phone number that is typed as a string.',
type: 'string',
},
},
{
transform_string: {
name: 'Transform String',
description: 'Anonymizes an existing string value.',
description: 'Transforms an existing string value.',
type: 'string',
},
},
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/jobs/SchemaTable/TransformerSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default function TransformerSelect(props: Props): ReactElement {
</Button>
</PopoverTrigger>
<PopoverContent
className="w-[250px] p-0"
className="w-[300px] p-0"
side="left"
avoidCollisions={false}
>
Expand Down
1 change: 0 additions & 1 deletion frontend/components/jobs/SchemaTable/schema-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export function SchemaTable(props: JobTableProps): ReactElement {
<div>
<VirtualizedSchemaTable
data={tableData}
// transformers={systemTransformers?.transformers}
transformers={mergedTransformers}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/yup-validations/transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export function ToTransformerConfigOptions(
value: val.source,
config: new TransformerConfig({
config: {
case: 'generateEmailConfig',
case: 'transformEmailConfig',
value: new TransformEmail({
preserveDomain: te.value.preserveDomain,
preserveLength: te.value.preserveLength,
Expand Down
55 changes: 0 additions & 55 deletions worker/internal/benthos/transformers/email/email_utils.go

This file was deleted.

Loading

0 comments on commit a95d935

Please sign in to comment.