feat(inputs): ✨ Add Set variable step
This commit is contained in:
@ -1,14 +1,22 @@
|
||||
import { PublicTypebot as PublicTypebotFromPrisma } from 'db'
|
||||
import { Block, ChoiceItem, Settings, Step, Theme } from './typebot'
|
||||
import { Variable } from './typebot/variable'
|
||||
import { Table } from './utils'
|
||||
|
||||
export type PublicTypebot = Omit<
|
||||
PublicTypebotFromPrisma,
|
||||
'blocks' | 'startBlock' | 'theme' | 'settings' | 'steps'
|
||||
| 'blocks'
|
||||
| 'startBlock'
|
||||
| 'theme'
|
||||
| 'settings'
|
||||
| 'steps'
|
||||
| 'choiceItems'
|
||||
| 'variables'
|
||||
> & {
|
||||
blocks: Table<Block>
|
||||
steps: Table<Step>
|
||||
choiceItems: Table<ChoiceItem>
|
||||
variables: Table<Variable>
|
||||
theme: Theme
|
||||
settings: Settings
|
||||
}
|
||||
|
@ -2,3 +2,4 @@ export * from './typebot'
|
||||
export * from './steps'
|
||||
export * from './theme'
|
||||
export * from './settings'
|
||||
export * from './variable'
|
||||
|
@ -1,2 +1,3 @@
|
||||
export * from './steps'
|
||||
export * from './inputs'
|
||||
export * from './logic'
|
||||
|
@ -47,7 +47,7 @@ export type DateInputStep = StepBase & {
|
||||
|
||||
export type PhoneNumberInputStep = StepBase & {
|
||||
type: InputStepType.PHONE
|
||||
options?: InputTextOptionsBase
|
||||
options?: OptionBase & InputTextOptionsBase
|
||||
}
|
||||
|
||||
export type ChoiceInputStep = StepBase & {
|
||||
@ -55,12 +55,6 @@ export type ChoiceInputStep = StepBase & {
|
||||
options: ChoiceInputOptions
|
||||
}
|
||||
|
||||
export type ChoiceInputOptions = {
|
||||
itemIds: string[]
|
||||
isMultipleChoice?: boolean
|
||||
buttonLabel?: string
|
||||
}
|
||||
|
||||
export type ChoiceItem = {
|
||||
id: string
|
||||
stepId: string
|
||||
@ -68,26 +62,35 @@ export type ChoiceItem = {
|
||||
target?: Target
|
||||
}
|
||||
|
||||
export type DateInputOptions = {
|
||||
type OptionBase = { variableId?: string }
|
||||
type InputTextOptionsBase = {
|
||||
labels?: { placeholder?: string; button?: string }
|
||||
}
|
||||
|
||||
export type ChoiceInputOptions = OptionBase & {
|
||||
itemIds: string[]
|
||||
isMultipleChoice?: boolean
|
||||
buttonLabel?: string
|
||||
}
|
||||
|
||||
export type DateInputOptions = OptionBase & {
|
||||
labels?: { button?: string; from?: string; to?: string }
|
||||
hasTime?: boolean
|
||||
isRange?: boolean
|
||||
}
|
||||
|
||||
export type EmailInputOptions = InputTextOptionsBase
|
||||
export type EmailInputOptions = OptionBase & InputTextOptionsBase
|
||||
|
||||
export type UrlInputOptions = InputTextOptionsBase
|
||||
export type UrlInputOptions = OptionBase & InputTextOptionsBase
|
||||
|
||||
type InputTextOptionsBase = {
|
||||
labels?: { placeholder?: string; button?: string }
|
||||
}
|
||||
export type TextInputOptions = OptionBase &
|
||||
InputTextOptionsBase & {
|
||||
isLong?: boolean
|
||||
}
|
||||
|
||||
export type TextInputOptions = InputTextOptionsBase & {
|
||||
isLong?: boolean
|
||||
}
|
||||
|
||||
export type NumberInputOptions = InputTextOptionsBase & {
|
||||
min?: number
|
||||
max?: number
|
||||
step?: number
|
||||
}
|
||||
export type NumberInputOptions = OptionBase &
|
||||
InputTextOptionsBase & {
|
||||
min?: number
|
||||
max?: number
|
||||
step?: number
|
||||
}
|
||||
|
17
packages/models/src/typebot/steps/logic.ts
Normal file
17
packages/models/src/typebot/steps/logic.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { StepBase } from '.'
|
||||
|
||||
export type LogicStep = SetVariableStep
|
||||
|
||||
export enum LogicStepType {
|
||||
SET_VARIABLE = 'Set variable',
|
||||
}
|
||||
|
||||
export type SetVariableStep = StepBase & {
|
||||
type: LogicStepType.SET_VARIABLE
|
||||
options?: SetVariableOptions
|
||||
}
|
||||
|
||||
export type SetVariableOptions = {
|
||||
variableId?: string
|
||||
expressionToEvaluate?: string
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
import { InputStep, InputStepType } from './inputs'
|
||||
import { LogicStep, LogicStepType } from './logic'
|
||||
|
||||
export type Step = StartStep | BubbleStep | InputStep
|
||||
export type Step = StartStep | BubbleStep | InputStep | LogicStep
|
||||
|
||||
export type BubbleStep = TextStep
|
||||
|
||||
export type StepType = 'start' | BubbleStepType | InputStepType
|
||||
export type StepType = 'start' | BubbleStepType | InputStepType | LogicStepType
|
||||
|
||||
export enum BubbleStepType {
|
||||
TEXT = 'text',
|
||||
|
@ -4,14 +4,16 @@ import { Table } from '../utils'
|
||||
import { Settings } from './settings'
|
||||
import { Step } from './steps/steps'
|
||||
import { Theme } from './theme'
|
||||
import { Variable } from './variable'
|
||||
|
||||
export type Typebot = Omit<
|
||||
TypebotFromPrisma,
|
||||
'blocks' | 'theme' | 'settings' | 'steps'
|
||||
'blocks' | 'theme' | 'settings' | 'steps' | 'choiceItems' | 'variables'
|
||||
> & {
|
||||
blocks: Table<Block>
|
||||
steps: Table<Step>
|
||||
choiceItems: Table<ChoiceItem>
|
||||
variables: Table<Variable>
|
||||
theme: Theme
|
||||
settings: Settings
|
||||
}
|
||||
|
5
packages/models/src/typebot/variable.ts
Normal file
5
packages/models/src/typebot/variable.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export type Variable = {
|
||||
id: string
|
||||
name: string
|
||||
value?: string
|
||||
}
|
Reference in New Issue
Block a user