2
0

refactor(graph): ♻️ Add Edges table in Typebot

This commit is contained in:
Baptiste Arnaud
2022-01-19 18:54:49 +01:00
parent ab34f95cce
commit 8bbd8977b2
59 changed files with 1118 additions and 991 deletions

View File

@ -1,5 +1,5 @@
import { PublicTypebot as PublicTypebotFromPrisma } from 'db'
import { Block, ChoiceItem, Settings, Step, Theme } from './typebot'
import { Block, ChoiceItem, Edge, Settings, Step, Theme } from './typebot'
import { Variable } from './typebot/variable'
import { Table } from './utils'
@ -17,6 +17,7 @@ export type PublicTypebot = Omit<
steps: Table<Step>
choiceItems: Table<ChoiceItem>
variables: Table<Variable>
edges: Table<Edge>
theme: Theme
settings: Settings
}

View File

@ -1,4 +1,3 @@
import { Target } from '.'
import { StepBase } from './steps'
export type InputStep =
@ -66,7 +65,7 @@ export type ChoiceItem = {
id: string
stepId: string
content?: string
target?: Target
edgeId?: string
}
type OptionBase = { variableId?: string }

View File

@ -1,4 +1,4 @@
import { StepBase, Target } from '.'
import { StepBase } from '.'
import { Table } from '../..'
export type LogicStep = SetVariableStep | ConditionStep
@ -32,8 +32,8 @@ export enum ComparisonOperators {
export type ConditionStep = StepBase & {
type: LogicStepType.CONDITION
options: ConditionOptions
trueTarget?: Target
falseTarget?: Target
trueEdgeId?: string
falseEdgeId?: string
}
export type ConditionOptions = {

View File

@ -36,11 +36,9 @@ export type StepOptions =
| LogicStepOptions
| IntegrationStepOptions
export type StepBase = { id: string; blockId: string; target?: Target }
export type StepBase = { id: string; blockId: string; edgeId?: string }
export type StartStep = StepBase & {
type: 'start'
label: string
}
export type Target = { blockId: string; stepId?: string }

View File

@ -14,6 +14,7 @@ export type Typebot = Omit<
steps: Table<Step>
choiceItems: Table<ChoiceItem>
variables: Table<Variable>
edges: Table<Edge>
theme: Theme
settings: Settings
}
@ -27,3 +28,16 @@ export type Block = {
}
stepIds: string[]
}
export type Source = {
blockId: string
stepId: string
nodeId?: string
conditionType?: 'true' | 'false'
}
export type Target = { blockId: string; stepId?: string }
export type Edge = {
id: string
from: Source
to: Target
}