Skip to content

Commit 042439d

Browse files
committed
fix: support tiles v2 nullable cells
1 parent 45b4a55 commit 042439d

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

packages/backend/src/apps/tiles/actions/find-multiple-rows/get-data-out-metadata.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { IDataOutMetadata, IExecutionStep } from '@plumber/types'
22

3+
import logger from '@/helpers/logger'
4+
35
import { dataOutSchema } from './schema'
46

57
async function getDataOutMetadata(
@@ -10,12 +12,20 @@ async function getDataOutMetadata(
1012
if (!rawDataOut) {
1113
return null
1214
}
13-
const dataOut = dataOutSchema.parse(rawDataOut)
15+
const dataOut = dataOutSchema.safeParse(rawDataOut)
16+
if (!dataOut.success) {
17+
logger.error({
18+
message: 'Invalid data out schema for tiles find multiple rows action',
19+
executionId: executionStep.executionId,
20+
action: 'find-multiple-rows',
21+
})
22+
return null
23+
}
1424

1525
const metadata: IDataOutMetadata = {
1626
data: {
1727
label: 'Row(s) found',
18-
displayedValue: `Preview ${dataOut.rowsFound} row(s)`,
28+
displayedValue: `Preview ${dataOut.data.rowsFound} row(s)`,
1929
type: 'table',
2030
order: 1,
2131
},

packages/backend/src/apps/tiles/actions/find-multiple-rows/schema.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import { z } from 'zod'
22

33
const tableRowOutputSchema = z.object({
44
rowId: z.string(),
5-
data: z.record(z.string(), z.string().or(z.number())),
5+
// for tiles v1, empty cells is either an empty string or wont even have their key returned
6+
// for tiles v2, empty cells return null
7+
data: z.record(z.string(), z.union([z.string(), z.number(), z.null()])),
68
})
79

810
export const dataOutSchema = z.object({

packages/frontend/src/components/VariablesList/schema.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { z } from 'zod'
33
const RowDataSchema = z.object({
44
rows: z.array(
55
z.object({
6-
data: z.record(z.string(), z.union([z.string(), z.number()])),
6+
// for tiles v1, empty cells is either an empty string or wont even have their key returned
7+
// for tiles v2, empty cells return null
8+
data: z.record(z.string(), z.union([z.string(), z.number(), z.null()])),
79
rowId: z.string().optional(), // only Tiles will have this
810
}),
911
),

packages/frontend/src/components/VariablesList/utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface RawColumn {
99
}
1010

1111
export interface RawRow {
12-
data: Record<string, string | number>
12+
data: Record<string, string | number | null>
1313
rowId?: string // only Tiles will have this
1414
}
1515

packages/frontend/src/helpers/variables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ const process = (
163163
*/
164164
const { columns, rows } = data
165165
const columnVariables = columns.map((column: RawColumn) => {
166-
const rowValues: (string | number)[] = []
166+
const rowValues: (string | number | null)[] = []
167167
rows.forEach((row: RawRow) => {
168168
/**
169169
* NOTE: do not push empty values as we do not want to cause any errors

0 commit comments

Comments
 (0)