2
0

♻️ Re-organize workspace folders

This commit is contained in:
Baptiste Arnaud
2023-03-15 08:35:16 +01:00
parent 25c367901f
commit cbc8194f19
987 changed files with 2716 additions and 2770 deletions

View File

@@ -0,0 +1,55 @@
import { z } from 'zod'
import { ItemType } from '../../items/enums'
import { itemBaseSchema } from '../../items/baseSchemas'
import { blockBaseSchema } from '../baseSchemas'
import { LogicBlockType } from './enums'
export enum LogicalOperator {
OR = 'OR',
AND = 'AND',
}
export enum ComparisonOperators {
EQUAL = 'Equal to',
NOT_EQUAL = 'Not equal',
CONTAINS = 'Contains',
GREATER = 'Greater than',
LESS = 'Less than',
IS_SET = 'Is set',
}
const comparisonSchema = z.object({
id: z.string(),
variableId: z.string().optional(),
comparisonOperator: z.nativeEnum(ComparisonOperators).optional(),
value: z.string().optional(),
})
const conditionContentSchema = z.object({
logicalOperator: z.nativeEnum(LogicalOperator),
comparisons: z.array(comparisonSchema),
})
export const conditionItemSchema = itemBaseSchema.merge(
z.object({
type: z.literal(ItemType.CONDITION),
content: conditionContentSchema,
})
)
export const conditionBlockSchema = blockBaseSchema.merge(
z.object({
type: z.enum([LogicBlockType.CONDITION]),
items: z.array(conditionItemSchema),
})
)
export const defaultConditionContent: ConditionContent = {
comparisons: [],
logicalOperator: LogicalOperator.AND,
}
export type ConditionItem = z.infer<typeof conditionItemSchema>
export type Comparison = z.infer<typeof comparisonSchema>
export type ConditionBlock = z.infer<typeof conditionBlockSchema>
export type ConditionContent = z.infer<typeof conditionContentSchema>

View File

@@ -0,0 +1,9 @@
export enum LogicBlockType {
SET_VARIABLE = 'Set variable',
CONDITION = 'Condition',
REDIRECT = 'Redirect',
SCRIPT = 'Code',
TYPEBOT_LINK = 'Typebot link',
WAIT = 'Wait',
JUMP = 'Jump',
}

View File

@@ -0,0 +1,7 @@
export * from './script'
export * from './condition'
export * from './enums'
export * from './redirect'
export * from './setVariable'
export * from './typebotLink'
export * from './wait'

View File

@@ -0,0 +1,17 @@
import { z } from 'zod'
import { blockBaseSchema } from '../baseSchemas'
import { LogicBlockType } from './enums'
export const jumpOptionsSchema = z.object({
groupId: z.string().optional(),
blockId: z.string().optional(),
})
export const jumpBlockSchema = blockBaseSchema.merge(
z.object({
type: z.enum([LogicBlockType.JUMP]),
options: jumpOptionsSchema,
})
)
export type JumpBlock = z.infer<typeof jumpBlockSchema>

View File

@@ -0,0 +1,20 @@
import { z } from 'zod'
import { blockBaseSchema } from '../baseSchemas'
import { LogicBlockType } from './enums'
export const redirectOptionsSchema = z.object({
url: z.string().optional(),
isNewTab: z.boolean(),
})
export const redirectBlockSchema = blockBaseSchema.merge(
z.object({
type: z.enum([LogicBlockType.REDIRECT]),
options: redirectOptionsSchema,
})
)
export const defaultRedirectOptions: RedirectOptions = { isNewTab: false }
export type RedirectBlock = z.infer<typeof redirectBlockSchema>
export type RedirectOptions = z.infer<typeof redirectOptionsSchema>

View File

@@ -0,0 +1,21 @@
import { z } from 'zod'
import { blockBaseSchema } from '../baseSchemas'
import { LogicBlockType } from './enums'
export const scriptOptionsSchema = z.object({
name: z.string(),
content: z.string().optional(),
shouldExecuteInParentContext: z.boolean().optional(),
})
export const scriptBlockSchema = blockBaseSchema.merge(
z.object({
type: z.enum([LogicBlockType.SCRIPT]),
options: scriptOptionsSchema,
})
)
export const defaultScriptOptions: ScriptOptions = { name: 'Script' }
export type ScriptBlock = z.infer<typeof scriptBlockSchema>
export type ScriptOptions = z.infer<typeof scriptOptionsSchema>

View File

@@ -0,0 +1,21 @@
import { z } from 'zod'
import { blockBaseSchema } from '../baseSchemas'
import { LogicBlockType } from './enums'
export const setVariableOptionsSchema = z.object({
variableId: z.string().optional(),
expressionToEvaluate: z.string().optional(),
isCode: z.boolean().optional(),
})
export const setVariableBlockSchema = blockBaseSchema.merge(
z.object({
type: z.enum([LogicBlockType.SET_VARIABLE]),
options: setVariableOptionsSchema,
})
)
export const defaultSetVariablesOptions: SetVariableOptions = {}
export type SetVariableBlock = z.infer<typeof setVariableBlockSchema>
export type SetVariableOptions = z.infer<typeof setVariableOptionsSchema>

View File

@@ -0,0 +1,20 @@
import { z } from 'zod'
import { blockBaseSchema } from '../baseSchemas'
import { LogicBlockType } from './enums'
export const typebotLinkOptionsSchema = z.object({
typebotId: z.string().optional(),
groupId: z.string().optional(),
})
export const typebotLinkBlockSchema = blockBaseSchema.merge(
z.object({
type: z.enum([LogicBlockType.TYPEBOT_LINK]),
options: typebotLinkOptionsSchema,
})
)
export const defaultTypebotLinkOptions: TypebotLinkOptions = {}
export type TypebotLinkBlock = z.infer<typeof typebotLinkBlockSchema>
export type TypebotLinkOptions = z.infer<typeof typebotLinkOptionsSchema>

View File

@@ -0,0 +1,19 @@
import { z } from 'zod'
import { blockBaseSchema } from '../baseSchemas'
import { LogicBlockType } from './enums'
export const waitOptionsSchema = z.object({
secondsToWaitFor: z.string().optional(),
})
export const waitBlockSchema = blockBaseSchema.merge(
z.object({
type: z.enum([LogicBlockType.WAIT]),
options: waitOptionsSchema,
})
)
export const defaultWaitOptions: WaitOptions = {}
export type WaitBlock = z.infer<typeof waitBlockSchema>
export type WaitOptions = z.infer<typeof waitOptionsSchema>