2
0

🚧 Use TS project references

This commit is contained in:
Baptiste Arnaud
2024-08-28 18:09:35 +02:00
parent 0c7d2afd51
commit fdd6cc6fee
627 changed files with 3043 additions and 1696 deletions

View File

@@ -1,5 +1,5 @@
import { isDefined } from '@typebot.io/lib'
import { Variable, VariableWithValue } from '../schemas'
import { Variable, VariableWithValue } from './types'
export const filterNonSessionVariablesWithValues = (
variables: Variable[]

View File

@@ -5,7 +5,6 @@
"private": true,
"dependencies": {
"@typebot.io/lib": "workspace:*",
"@typebot.io/tsconfig": "workspace:*",
"isolated-vm": "5.0.1"
}
}

View File

@@ -0,0 +1,14 @@
{
"extends": "../tsconfig/base.json",
"include": [
"**/*.ts"
],
"compilerOptions": {
"outDir": "dist"
},
"references": [
{
"path": "../lib"
}
]
}

View File

@@ -12,3 +12,13 @@ export type VariableWithValue = Omit<Variable, 'value'> & {
export type VariableWithUnknowValue = Omit<Variable, 'value'> & {
value?: unknown
}
export type SetVariableHistoryItem = {
resultId: string
index: number
blockId: string
variableId: string
value: string | (string | null)[] | null
}
export type SessionState = any

View File

@@ -1,6 +1,10 @@
import { safeStringify } from '@typebot.io/lib/safeStringify'
import { Variable, VariableWithUnknowValue } from './types'
import { SessionState, SetVariableHistoryItem } from '../schemas'
import {
SessionState,
SetVariableHistoryItem,
Variable,
VariableWithUnknowValue,
} from './types'
type Props = {
state: SessionState
@@ -26,16 +30,17 @@ export const updateVariablesInSession = ({
updatedState: {
...state,
currentSetVariableHistoryIndex: setVariableHistoryIndex,
typebotsQueue: state.typebotsQueue.map((typebotInQueue, index: number) =>
index === 0
? {
...typebotInQueue,
typebot: {
...typebotInQueue.typebot,
variables: updatedVariables,
},
}
: typebotInQueue
typebotsQueue: state.typebotsQueue.map(
(typebotInQueue: any, index: number) =>
index === 0
? {
...typebotInQueue,
typebot: {
...typebotInQueue.typebot,
variables: updatedVariables,
},
}
: typebotInQueue
),
previewMetadata: state.typebotsQueue[0].resultId
? state.previewMetadata
@@ -89,10 +94,11 @@ const updateTypebotVariables = ({
return {
updatedVariables: [
...state.typebotsQueue[0].typebot.variables.filter((existingVariable) =>
serializedNewVariables.every(
(newVariable) => existingVariable.id !== newVariable.id
)
...state.typebotsQueue[0].typebot.variables.filter(
(existingVariable: any) =>
serializedNewVariables.every(
(newVariable) => existingVariable.id !== newVariable.id
)
),
...serializedNewVariables,
],