Skip to content

Commit

Permalink
more console, some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Jun 21, 2024
1 parent 5f83fc2 commit 8914f72
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
18 changes: 7 additions & 11 deletions ui/app/mirrors/create/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ const CDCCheck = (
) => {
const flowNameValid = flowNameSchema.safeParse(flowJobName);
if (!flowNameValid.success) {
const flowNameErr = flowNameValid.error.issues[0].message;
return flowNameErr;
return flowNameValid.error.issues[0].message;
}

const tableNameMapping = reformattedTableMapping(rows);
Expand Down Expand Up @@ -81,17 +80,16 @@ const validateCDCFields = (
)[],
config: CDCConfig
): string | undefined => {
let validationErr: string | undefined;
const tablesValidity = tableMappingSchema.safeParse(tableMapping);
if (!tablesValidity.success) {
validationErr = tablesValidity.error.issues[0].message;
return tablesValidity.error.issues[0].message;
}

console.log(config);
const configValidity = cdcSchema.safeParse(config);
if (!configValidity.success) {
validationErr = configValidity.error.issues[0].message;
return configValidity.error.issues[0].message;
}
return validationErr;
};

const validateQRepFields = (
Expand All @@ -101,12 +99,10 @@ const validateQRepFields = (
if (query.length < 5) {
return 'Query is invalid';
}
let validationErr: string | undefined;
const configValidity = qrepSchema.safeParse(config);
if (!configValidity.success) {
validationErr = configValidity.error.issues[0].message;
return configValidity.error.issues[0].message;
}
return validationErr;
};

interface TableMapping {
Expand Down Expand Up @@ -148,7 +144,7 @@ export const handleCreateCDC = async (
route: RouteCallback
) => {
const err = CDCCheck(flowJobName, rows, config, destinationType);
if (err != '') {
if (err) {
notifyErr(err);
return;
}
Expand Down Expand Up @@ -411,7 +407,7 @@ export const handleValidateCDC = async (
) => {
setLoading(true);
const err = CDCCheck(flowJobName, rows, config, destinationType);
if (err != '') {
if (err) {
notifyErr(err);
setLoading(false);
return;
Expand Down
16 changes: 8 additions & 8 deletions ui/app/mirrors/create/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ export const cdcSchema = z.object({
.string({
invalid_type_error: 'Publication name must be a string',
})
.max(255, 'Publication name must be less than 255 characters')
.max(255, 'Publication name must be less than 256 characters')
.optional(),
replicationSlotName: z
.string({
invalid_type_error: 'Replication slot name must be a string',
})
.max(255, 'Replication slot name must be less than 255 characters')
.max(255, 'Replication slot name must be less than 256 characters')
.optional(),
snapshotNumRowsPerPartition: z
.number({
Expand All @@ -80,13 +80,13 @@ export const cdcSchema = z.object({
.string({
invalid_type_error: 'Snapshot staging path must be a string',
})
.max(255, 'Snapshot staging path must be less than 255 characters')
.max(255, 'Snapshot staging path must be less than 256 characters')
.optional(),
cdcStagingPath: z
.string({
invalid_type_error: 'CDC staging path must be a string',
})
.max(255, 'CDC staging path must be less than 255 characters')
.max(255, 'CDC staging path must be less than 256 characters')
.optional(),
softDelete: z.boolean().optional(),
});
Expand All @@ -104,21 +104,21 @@ export const qrepSchema = z.object({
required_error: 'Destination table name is required',
})
.min(1, 'Destination table name must be non-empty')
.max(255, 'Destination table name must be less than 255 characters'),
.max(255, 'Destination table name must be less than 256 characters'),
watermarkTable: z
.string({
invalid_type_error: 'Watermark table must be a string',
required_error: 'Watermark table is required',
})
.min(1, 'Watermark table must be non-empty')
.max(255, 'Watermark table must be less than 255 characters'),
.max(255, 'Watermark table must be less than 256 characters'),
watermarkColumn: z
.string({
invalid_type_error: 'Watermark column must be a string',
required_error: 'Watermark column is required',
})
.min(1, 'Watermark column must be non-empty')
.max(255, 'Watermark column must be less than 255 characters'),
.max(255, 'Watermark column must be less than 256 characters'),
numRowsPerPartition: z
.number({
invalid_type_error: 'Rows per partition must be a number',
Expand All @@ -137,7 +137,7 @@ export const qrepSchema = z.object({
.string({
invalid_type_error: 'Staging path must be a string',
})
.max(255, 'Staging path must be less than 255 characters')
.max(255, 'Staging path must be less than 256 characters')
.optional(),
writeMode: z.object(
{
Expand Down

0 comments on commit 8914f72

Please sign in to comment.