2
0

(bot) Improve variables parsing and predictability

This commit is contained in:
Baptiste Arnaud
2022-10-15 09:35:27 +02:00
parent b87ba4023d
commit 3dc3ab201d
6 changed files with 73 additions and 50 deletions

View File

@ -3,10 +3,21 @@ import { z } from 'zod'
export const variableSchema = z.object({
id: z.string(),
name: z.string(),
value: z.string().or(z.number()).optional(),
value: z.string().optional().nullable(),
})
/**
* Variable when retrieved from the database
*/
export type VariableWithValue = Omit<Variable, 'value'> & {
value: string
}
/**
* Variable when computed or retrieved from a block
*/
export type VariableWithUnknowValue = Omit<VariableWithValue, 'value'> & {
value: unknown
}
export type Variable = z.infer<typeof variableSchema>