2
0

(setVariable) Add Transcription system var (#1507)

Closes #1484
This commit is contained in:
Baptiste Arnaud
2024-05-15 14:24:55 +02:00
committed by GitHub
parent ec7ff8d9ca
commit 40f21203b5
102 changed files with 2911 additions and 986 deletions

View File

@@ -2,12 +2,12 @@ import { VariableStore, LogsStore } from '@typebot.io/forge'
import { forgedBlocks } from '@typebot.io/forge-repository/definitions'
import { ForgedBlock } from '@typebot.io/forge-repository/types'
import { decrypt } from '@typebot.io/lib/api/encryption/decrypt'
import { isPlaneteScale } from '@typebot.io/lib/isPlanetScale'
import {
SessionState,
ContinueChatResponse,
Block,
TypebotInSession,
SetVariableHistoryItem,
} from '@typebot.io/schemas'
import { deepParseVariables } from '@typebot.io/variables/deepParseVariables'
import {
@@ -73,6 +73,7 @@ export const executeForgedBlock = async (
}
let newSessionState = state
let setVariableHistory: SetVariableHistoryItem[] = []
const variables: VariableStore = {
get: (id: string) => {
@@ -86,9 +87,13 @@ export const executeForgedBlock = async (
(variable) => variable.id === id
)
if (!variable) return
newSessionState = updateVariablesInSession(newSessionState)([
{ ...variable, value },
])
const { newSetVariableHistory, updatedState } = updateVariablesInSession({
newVariables: [{ ...variable, value }],
state: newSessionState,
currentBlockId: block.id,
})
newSessionState = updatedState
setVariableHistory.push(...newSetVariableHistory)
},
parse: (text: string, params?: ParseVariablesOptions) =>
parseVariables(
@@ -159,6 +164,7 @@ export const executeForgedBlock = async (
},
}
: undefined,
newSetVariableHistory: setVariableHistory,
}
}