Skip to content

Commit 315d263

Browse files
committed
chore: address copilot suggestions
1 parent 6013083 commit 315d263

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

packages/backend/src/apps/toolbox/actions/for-each/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const tableRowsSchema = z.array(
2323
const tableSchema = z.object({
2424
rows: tableRowsSchema,
2525
columns: tableColumnsSchema,
26-
inputSource: z.enum(FOR_EACH_TABLE_SOURCES as [string, ...string[]]),
26+
inputSource: z.enum(FOR_EACH_TABLE_SOURCES),
2727
})
2828

2929
const baseDataOutSchema = z.object({

packages/backend/src/apps/toolbox/common/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ export const FOR_EACH_TABLE_SOURCES = [
1818
FOR_EACH_INPUT_SOURCE.TILES,
1919
FOR_EACH_INPUT_SOURCE.M365_EXCEL,
2020
FOR_EACH_INPUT_SOURCE.FORMSG_TABLE,
21-
]
21+
] as const

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IJSONObject, IJSONValue } from '@plumber/types'
1+
import { IJSONObject } from '@plumber/types'
22

33
import { z } from 'zod'
44

@@ -25,13 +25,15 @@ const FormSgTableFieldSchema = z.object({
2525
answer: z.string().transform((val) => JSON.parse(val) as IJSONObject),
2626
})
2727

28-
const FormSgFieldsSchema = z.record(z.any()).transform((fields) => {
28+
const FormSgFieldSchema = z.object({
29+
fieldType: z.string(),
30+
answer: z.union([z.string(), z.record(z.any())]).optional(),
31+
})
32+
33+
const FormSgFieldsSchema = z.record(FormSgFieldSchema).transform((fields) => {
2934
const tableField = Object.values(fields).find(
30-
(field: IJSONValue) =>
31-
typeof field === 'object' &&
32-
field !== null &&
33-
(field as IJSONObject).fieldType === 'table',
34-
) as IJSONObject | undefined
35+
(field) => field?.fieldType === 'table',
36+
) as z.infer<typeof FormSgFieldSchema> | undefined
3537

3638
if (!tableField) {
3739
return {

0 commit comments

Comments
 (0)