@@ -4,6 +4,10 @@ import { TextInputBlock } from './schema'
|
||||
export const defaultTextInputOptions = {
|
||||
isLong: false,
|
||||
labels: { button: defaultButtonLabel, placeholder: 'Type your answer...' },
|
||||
audioClip: {
|
||||
isEnabled: false,
|
||||
visibility: 'Auto',
|
||||
},
|
||||
attachments: {
|
||||
isEnabled: false,
|
||||
visibility: 'Auto',
|
||||
|
||||
@@ -17,6 +17,13 @@ export const textInputOptionsSchema = textInputOptionsBaseSchema
|
||||
.merge(
|
||||
z.object({
|
||||
isLong: z.boolean().optional(),
|
||||
audioClip: z
|
||||
.object({
|
||||
isEnabled: z.boolean().optional(),
|
||||
saveVariableId: z.string().optional(),
|
||||
visibility: z.enum(fileVisibilityOptions).optional(),
|
||||
})
|
||||
.optional(),
|
||||
attachments: z
|
||||
.object({
|
||||
isEnabled: z.boolean().optional(),
|
||||
|
||||
@@ -42,6 +42,14 @@ export const messageSchema = z.preprocess(
|
||||
'Can only be provided if current input block is a text input block that allows attachments'
|
||||
),
|
||||
}),
|
||||
z
|
||||
.object({
|
||||
type: z.literal('audio'),
|
||||
url: z.string(),
|
||||
})
|
||||
.describe(
|
||||
'Can only be provided if current input block is a text input that allows audio clips'
|
||||
),
|
||||
])
|
||||
)
|
||||
export type Message = z.infer<typeof messageSchema>
|
||||
|
||||
@@ -118,10 +118,11 @@ export const sessionStateSchema = z
|
||||
])
|
||||
.transform((state): SessionState => {
|
||||
if (state.version === '3') return state
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let migratedState: any = state
|
||||
if (!state.version) migratedState = migrateFromV1ToV2(state)
|
||||
return migrateFromV2ToV3(migratedState)
|
||||
})
|
||||
}) as z.ZodType<SessionState>
|
||||
|
||||
const migrateFromV1ToV2 = (
|
||||
state: z.infer<typeof sessionStateSchemaV1>
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
"@typebot.io/forge-repository": "workspace:*",
|
||||
"@typebot.io/prisma": "workspace:*",
|
||||
"@typebot.io/tsconfig": "workspace:*",
|
||||
"typescript": "5.4.5"
|
||||
"typescript": "5.4.5",
|
||||
"eslint": "8.44.0",
|
||||
"eslint-config-custom": "workspace:*"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user