🚧 Use TS project references
This commit is contained in:
@@ -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[]
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@typebot.io/lib": "workspace:*",
|
||||
"@typebot.io/tsconfig": "workspace:*",
|
||||
"isolated-vm": "5.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
14
packages/variables/tsconfig.json
Normal file
14
packages/variables/tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"extends": "../tsconfig/base.json",
|
||||
"include": [
|
||||
"**/*.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"outDir": "dist"
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"path": "../lib"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user