🔥 Remove disable response saving option
Doesn't work properly when it comes to keep tracking storage usage
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { safeStringify } from '@/features/variables'
|
||||
import {
|
||||
AnswerInput,
|
||||
ResultValues,
|
||||
ResultValuesInput,
|
||||
Variable,
|
||||
VariableWithUnknowValue,
|
||||
VariableWithValue,
|
||||
@@ -11,7 +11,7 @@ import { isDefined } from 'utils'
|
||||
|
||||
const answersContext = createContext<{
|
||||
resultId?: string
|
||||
resultValues: ResultValues
|
||||
resultValues: ResultValuesInput
|
||||
addAnswer: (
|
||||
existingVariables: Variable[]
|
||||
) => (
|
||||
@@ -35,7 +35,7 @@ export const AnswersProvider = ({
|
||||
onVariablesUpdated?: (variables: VariableWithValue[]) => void
|
||||
children: ReactNode
|
||||
}) => {
|
||||
const [resultValues, setResultValues] = useState<ResultValues>({
|
||||
const [resultValues, setResultValues] = useState<ResultValuesInput>({
|
||||
answers: [],
|
||||
variables: [],
|
||||
createdAt: new Date(),
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
Edge,
|
||||
Group,
|
||||
PublicTypebot,
|
||||
ResultValues,
|
||||
ResultValuesInput,
|
||||
Typebot,
|
||||
Variable,
|
||||
VariableWithUnknowValue,
|
||||
@@ -45,7 +45,7 @@ export type IntegrationState = {
|
||||
blockId: string
|
||||
isPreview: boolean
|
||||
variables: Variable[]
|
||||
resultValues: ResultValues
|
||||
resultValues: ResultValuesInput
|
||||
groups: Group[]
|
||||
resultId?: string
|
||||
parentTypebotIds: string[]
|
||||
|
||||
@@ -6,8 +6,6 @@ import {
|
||||
redirectOptionsSchema,
|
||||
} from './blocks'
|
||||
import { publicTypebotSchema } from './publicTypebot'
|
||||
import { ChatSession as ChatSessionPrisma } from 'db'
|
||||
import { schemaForType } from './utils'
|
||||
import { logSchema, resultSchema } from './result'
|
||||
import { typebotSchema } from './typebot'
|
||||
import {
|
||||
@@ -18,6 +16,7 @@ import {
|
||||
audioBubbleContentSchema,
|
||||
embedBubbleContentSchema,
|
||||
} from './blocks/bubbles'
|
||||
import { answerSchema } from './answer'
|
||||
|
||||
const typebotInSessionStateSchema = publicTypebotSchema.pick({
|
||||
id: true,
|
||||
@@ -31,6 +30,23 @@ const dynamicThemeSchema = z.object({
|
||||
guestAvatarUrl: z.string().optional(),
|
||||
})
|
||||
|
||||
const answerInSessionStateSchema = answerSchema.pick({
|
||||
content: true,
|
||||
blockId: true,
|
||||
variableId: true,
|
||||
})
|
||||
|
||||
const resultInSessionStateSchema = resultSchema
|
||||
.pick({
|
||||
variables: true,
|
||||
})
|
||||
.and(
|
||||
z.object({
|
||||
answers: z.array(answerInSessionStateSchema),
|
||||
id: z.string().optional(),
|
||||
})
|
||||
)
|
||||
|
||||
export const sessionStateSchema = z.object({
|
||||
typebot: typebotInSessionStateSchema,
|
||||
dynamicTheme: dynamicThemeSchema.optional(),
|
||||
@@ -39,10 +55,7 @@ export const sessionStateSchema = z.object({
|
||||
queue: z.array(z.object({ edgeId: z.string(), typebotId: z.string() })),
|
||||
}),
|
||||
currentTypebotId: z.string(),
|
||||
result: resultSchema
|
||||
.pick({ id: true, variables: true, hasStarted: true })
|
||||
.optional(),
|
||||
isPreview: z.boolean(),
|
||||
result: resultInSessionStateSchema,
|
||||
currentBlock: z
|
||||
.object({
|
||||
blockId: z.string(),
|
||||
@@ -51,14 +64,12 @@ export const sessionStateSchema = z.object({
|
||||
.optional(),
|
||||
})
|
||||
|
||||
const chatSessionSchema = schemaForType<ChatSessionPrisma>()(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date(),
|
||||
state: sessionStateSchema,
|
||||
})
|
||||
)
|
||||
const chatSessionSchema = z.object({
|
||||
id: z.string(),
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date(),
|
||||
state: sessionStateSchema,
|
||||
})
|
||||
|
||||
const textMessageSchema = z.object({
|
||||
type: z.enum([BubbleBlockType.TEXT]),
|
||||
@@ -234,6 +245,7 @@ export const chatReplySchema = z.object({
|
||||
export type ChatSession = z.infer<typeof chatSessionSchema>
|
||||
export type SessionState = z.infer<typeof sessionStateSchema>
|
||||
export type TypebotInSession = z.infer<typeof typebotInSessionStateSchema>
|
||||
export type ResultInSession = z.infer<typeof resultInSessionStateSchema>
|
||||
export type ChatReply = z.infer<typeof chatReplySchema>
|
||||
export type ChatMessage = z.infer<typeof chatMessageSchema>
|
||||
export type SendMessageInput = z.infer<typeof sendMessageInputSchema>
|
||||
|
||||
@@ -48,11 +48,16 @@ export type ResultWithAnswersInput = z.infer<
|
||||
>
|
||||
export type Log = z.infer<typeof logSchema>
|
||||
|
||||
export type ResultValues = Pick<
|
||||
export type ResultValuesInput = Pick<
|
||||
ResultWithAnswersInput,
|
||||
'answers' | 'createdAt' | 'variables'
|
||||
>
|
||||
|
||||
export type ResultValues = Pick<
|
||||
ResultWithAnswers,
|
||||
'answers' | 'createdAt' | 'variables'
|
||||
>
|
||||
|
||||
export type ResultHeaderCell = {
|
||||
id: string
|
||||
label: string
|
||||
|
||||
@@ -6,7 +6,6 @@ const generalSettings = z.object({
|
||||
isInputPrefillEnabled: z.boolean().optional(),
|
||||
isHideQueryParamsEnabled: z.boolean().optional(),
|
||||
isNewResultOnRefreshEnabled: z.boolean().optional(),
|
||||
isResultSavingEnabled: z.boolean().optional(),
|
||||
})
|
||||
|
||||
const typingEmulation = z.object({
|
||||
@@ -36,7 +35,6 @@ export const defaultSettings: Settings = {
|
||||
isNewResultOnRefreshEnabled: true,
|
||||
isInputPrefillEnabled: true,
|
||||
isHideQueryParamsEnabled: true,
|
||||
isResultSavingEnabled: true,
|
||||
},
|
||||
typingEmulation: { enabled: true, speed: 300, maxDelay: 1.5 },
|
||||
metadata: {
|
||||
|
||||
@@ -6,9 +6,9 @@ import {
|
||||
Answer,
|
||||
VariableWithValue,
|
||||
Typebot,
|
||||
ResultWithAnswersInput,
|
||||
ResultWithAnswers,
|
||||
InputBlockType,
|
||||
ResultInSession,
|
||||
} from 'models'
|
||||
import { isInputBlock, isDefined, byId, isNotEmpty } from './utils'
|
||||
|
||||
@@ -218,16 +218,16 @@ export const parseAnswers =
|
||||
createdAt,
|
||||
answers,
|
||||
variables: resultVariables,
|
||||
}: Pick<ResultWithAnswersInput, 'answers' | 'variables'> & {
|
||||
// TODO: remove once we are using 100% tRPC
|
||||
createdAt: Date | string
|
||||
}): {
|
||||
}: Omit<ResultInSession, 'hasStarted'> & { createdAt?: Date | string }): {
|
||||
[key: string]: string
|
||||
} => {
|
||||
const header = parseResultHeader(typebot, linkedTypebots)
|
||||
return {
|
||||
submittedAt:
|
||||
typeof createdAt === 'string' ? createdAt : createdAt.toISOString(),
|
||||
submittedAt: !createdAt
|
||||
? new Date().toISOString()
|
||||
: typeof createdAt === 'string'
|
||||
? createdAt
|
||||
: createdAt.toISOString(),
|
||||
...[...answers, ...resultVariables].reduce<{
|
||||
[key: string]: string
|
||||
}>((o, answerOrVariable) => {
|
||||
|
||||
Reference in New Issue
Block a user