@@ -99,7 +99,6 @@
|
|||||||
"@playwright/test": "1.41.2",
|
"@playwright/test": "1.41.2",
|
||||||
"@typebot.io/forge": "workspace:*",
|
"@typebot.io/forge": "workspace:*",
|
||||||
"@typebot.io/forge-repository": "workspace:*",
|
"@typebot.io/forge-repository": "workspace:*",
|
||||||
"@typebot.io/forge-schemas": "workspace:*",
|
|
||||||
"@typebot.io/lib": "workspace:*",
|
"@typebot.io/lib": "workspace:*",
|
||||||
"@typebot.io/prisma": "workspace:*",
|
"@typebot.io/prisma": "workspace:*",
|
||||||
"@typebot.io/radar": "workspace:*",
|
"@typebot.io/radar": "workspace:*",
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/const
|
|||||||
import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integrations/constants'
|
import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integrations/constants'
|
||||||
import { LogicBlockType } from '@typebot.io/schemas/features/blocks/logic/constants'
|
import { LogicBlockType } from '@typebot.io/schemas/features/blocks/logic/constants'
|
||||||
import { BlockV6 } from '@typebot.io/schemas'
|
import { BlockV6 } from '@typebot.io/schemas'
|
||||||
import { enabledBlocks } from '@typebot.io/forge-repository'
|
|
||||||
import { BlockCardLayout } from './BlockCardLayout'
|
import { BlockCardLayout } from './BlockCardLayout'
|
||||||
import { ForgedBlockCard } from '@/features/forge/ForgedBlockCard'
|
import { ForgedBlockCard } from '@/features/forge/ForgedBlockCard'
|
||||||
|
import { isForgedBlockType } from '@typebot.io/schemas/features/blocks/forged/helpers'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
type: BlockV6['type']
|
type: BlockV6['type']
|
||||||
@@ -30,13 +30,8 @@ export const BlockCard = (
|
|||||||
const { t } = useTranslate()
|
const { t } = useTranslate()
|
||||||
const { workspace } = useWorkspace()
|
const { workspace } = useWorkspace()
|
||||||
|
|
||||||
if (enabledBlocks.includes(props.type as (typeof enabledBlocks)[number])) {
|
if (isForgedBlockType(props.type)) {
|
||||||
return (
|
return <ForgedBlockCard type={props.type} onMouseDown={props.onMouseDown} />
|
||||||
<ForgedBlockCard
|
|
||||||
type={props.type as (typeof enabledBlocks)[number]}
|
|
||||||
onMouseDown={props.onMouseDown}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
switch (props.type) {
|
switch (props.type) {
|
||||||
case BubbleBlockType.EMBED:
|
case BubbleBlockType.EMBED:
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/const
|
|||||||
import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integrations/constants'
|
import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integrations/constants'
|
||||||
import { LogicBlockType } from '@typebot.io/schemas/features/blocks/logic/constants'
|
import { LogicBlockType } from '@typebot.io/schemas/features/blocks/logic/constants'
|
||||||
import { BlockV6 } from '@typebot.io/schemas'
|
import { BlockV6 } from '@typebot.io/schemas'
|
||||||
import { enabledBlocks } from '@typebot.io/forge-repository'
|
|
||||||
import { useDebouncedCallback } from 'use-debounce'
|
import { useDebouncedCallback } from 'use-debounce'
|
||||||
|
import { forgedBlockIds } from '@typebot.io/forge-repository/constants'
|
||||||
|
|
||||||
// Integration blocks migrated to forged blocks
|
// Integration blocks migrated to forged blocks
|
||||||
const legacyIntegrationBlocks = [
|
const legacyIntegrationBlocks = [
|
||||||
@@ -174,7 +174,7 @@ export const BlocksSideBar = () => {
|
|||||||
</Text>
|
</Text>
|
||||||
<SimpleGrid columns={2} spacing="3">
|
<SimpleGrid columns={2} spacing="3">
|
||||||
{Object.values(IntegrationBlockType)
|
{Object.values(IntegrationBlockType)
|
||||||
.concat(enabledBlocks as any)
|
.concat(forgedBlockIds as any)
|
||||||
.filter((type) => !legacyIntegrationBlocks.includes(type))
|
.filter((type) => !legacyIntegrationBlocks.includes(type))
|
||||||
.map((type) => (
|
.map((type) => (
|
||||||
<BlockCard
|
<BlockCard
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ForgedBlock } from '@typebot.io/forge-schemas'
|
import { ForgedBlock } from '@typebot.io/forge-repository/types'
|
||||||
import { BlockV6 } from '@typebot.io/schemas'
|
import { BlockV6 } from '@typebot.io/schemas'
|
||||||
import { BlockIcon } from '../editor/components/BlockIcon'
|
import { BlockIcon } from '../editor/components/BlockIcon'
|
||||||
import { BlockLabel } from '../editor/components/BlockLabel'
|
import { BlockLabel } from '../editor/components/BlockLabel'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useColorMode } from '@chakra-ui/react'
|
import { useColorMode } from '@chakra-ui/react'
|
||||||
import { ForgedBlock } from '@typebot.io/forge-schemas'
|
import { ForgedBlock } from '@typebot.io/forge-repository/types'
|
||||||
import { useForgedBlock } from './hooks/useForgedBlock'
|
import { useForgedBlock } from './hooks/useForgedBlock'
|
||||||
|
|
||||||
export const ForgedBlockIcon = ({
|
export const ForgedBlockIcon = ({
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ForgedBlock } from '@typebot.io/forge-schemas'
|
import { ForgedBlock } from '@typebot.io/forge-repository/types'
|
||||||
import { useForgedBlock } from './hooks/useForgedBlock'
|
import { useForgedBlock } from './hooks/useForgedBlock'
|
||||||
import { Text } from '@chakra-ui/react'
|
import { Text } from '@chakra-ui/react'
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import { TRPCError } from '@trpc/server'
|
|||||||
import { encrypt } from '@typebot.io/lib/api/encryption/encrypt'
|
import { encrypt } from '@typebot.io/lib/api/encryption/encrypt'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
import { isWriteWorkspaceForbidden } from '@/features/workspace/helpers/isWriteWorkspaceForbidden'
|
import { isWriteWorkspaceForbidden } from '@/features/workspace/helpers/isWriteWorkspaceForbidden'
|
||||||
import { forgedCredentialsSchemas } from '@typebot.io/forge-schemas'
|
import { forgedCredentialsSchemas } from '@typebot.io/forge-repository/credentials'
|
||||||
|
import { isDefined } from '@typebot.io/lib'
|
||||||
|
|
||||||
const inputShape = {
|
const inputShape = {
|
||||||
data: true,
|
data: true,
|
||||||
@@ -20,7 +21,9 @@ export const createCredentials = authenticatedProcedure
|
|||||||
'type',
|
'type',
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
forgedCredentialsSchemas.map((i) => i.pick(inputShape))
|
Object.values(forgedCredentialsSchemas)
|
||||||
|
.filter(isDefined)
|
||||||
|
.map((i) => i.pick(inputShape))
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ import { authenticatedProcedure } from '@/helpers/server/trpc'
|
|||||||
import { TRPCError } from '@trpc/server'
|
import { TRPCError } from '@trpc/server'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
import { isReadWorkspaceFobidden } from '@/features/workspace/helpers/isReadWorkspaceFobidden'
|
import { isReadWorkspaceFobidden } from '@/features/workspace/helpers/isReadWorkspaceFobidden'
|
||||||
import { enabledBlocks } from '@typebot.io/forge-repository'
|
import { forgedBlockIds } from '@typebot.io/forge-repository/constants'
|
||||||
|
|
||||||
export const listCredentials = authenticatedProcedure
|
export const listCredentials = authenticatedProcedure
|
||||||
.input(
|
.input(
|
||||||
z.object({
|
z.object({
|
||||||
workspaceId: z.string(),
|
workspaceId: z.string(),
|
||||||
type: z.enum(enabledBlocks),
|
type: z.enum(forgedBlockIds),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.query(async ({ input: { workspaceId, type }, ctx: { user } }) => {
|
.query(async ({ input: { workspaceId, type }, ctx: { user } }) => {
|
||||||
|
|||||||
@@ -3,13 +3,14 @@ import { authenticatedProcedure } from '@/helpers/server/trpc'
|
|||||||
import { TRPCError } from '@trpc/server'
|
import { TRPCError } from '@trpc/server'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
import { isReadWorkspaceFobidden } from '@/features/workspace/helpers/isReadWorkspaceFobidden'
|
import { isReadWorkspaceFobidden } from '@/features/workspace/helpers/isReadWorkspaceFobidden'
|
||||||
import { forgedBlocks } from '@typebot.io/forge-schemas'
|
import { forgedBlocks } from '@typebot.io/forge-repository/definitions'
|
||||||
|
import { forgedBlockIds } from '@typebot.io/forge-repository/constants'
|
||||||
import { decrypt } from '@typebot.io/lib/api/encryption/decrypt'
|
import { decrypt } from '@typebot.io/lib/api/encryption/decrypt'
|
||||||
|
|
||||||
export const fetchSelectItems = authenticatedProcedure
|
export const fetchSelectItems = authenticatedProcedure
|
||||||
.input(
|
.input(
|
||||||
z.object({
|
z.object({
|
||||||
integrationId: z.string(),
|
integrationId: z.enum(forgedBlockIds),
|
||||||
fetcherId: z.string(),
|
fetcherId: z.string(),
|
||||||
options: z.any(),
|
options: z.any(),
|
||||||
workspaceId: z.string(),
|
workspaceId: z.string(),
|
||||||
@@ -55,7 +56,7 @@ export const fetchSelectItems = authenticatedProcedure
|
|||||||
|
|
||||||
const credentialsData = await decrypt(credentials.data, credentials.iv)
|
const credentialsData = await decrypt(credentials.data, credentials.iv)
|
||||||
|
|
||||||
const blockDef = forgedBlocks.find((b) => b.id === integrationId)
|
const blockDef = forgedBlocks[integrationId]
|
||||||
|
|
||||||
const fetchers = (blockDef?.fetchers ?? []).concat(
|
const fetchers = (blockDef?.fetchers ?? []).concat(
|
||||||
blockDef?.actions.flatMap((action) => action.fetchers ?? []) ?? []
|
blockDef?.actions.flatMap((action) => action.fetchers ?? []) ?? []
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ import {
|
|||||||
HStack,
|
HStack,
|
||||||
Stack,
|
Stack,
|
||||||
} from '@chakra-ui/react'
|
} from '@chakra-ui/react'
|
||||||
import { ForgedBlockDefinition, ForgedBlock } from '@typebot.io/forge-schemas'
|
import {
|
||||||
|
ForgedBlockDefinition,
|
||||||
|
ForgedBlock,
|
||||||
|
} from '@typebot.io/forge-repository/types'
|
||||||
import { ReactNode, useMemo } from 'react'
|
import { ReactNode, useMemo } from 'react'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { SetVariableLabel } from '@/components/SetVariableLabel'
|
|||||||
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
||||||
import { Stack, Text } from '@chakra-ui/react'
|
import { Stack, Text } from '@chakra-ui/react'
|
||||||
import { useForgedBlock } from '../hooks/useForgedBlock'
|
import { useForgedBlock } from '../hooks/useForgedBlock'
|
||||||
import { ForgedBlock } from '@typebot.io/forge-schemas'
|
import { ForgedBlock } from '@typebot.io/forge-repository/types'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
block: ForgedBlock
|
block: ForgedBlock
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { ForgedCredentialsModal } from './credentials/ForgedCredentialsModal'
|
|||||||
import { ZodObjectLayout } from './zodLayouts/ZodObjectLayout'
|
import { ZodObjectLayout } from './zodLayouts/ZodObjectLayout'
|
||||||
import { ZodActionDiscriminatedUnion } from './zodLayouts/ZodActionDiscriminatedUnion'
|
import { ZodActionDiscriminatedUnion } from './zodLayouts/ZodActionDiscriminatedUnion'
|
||||||
import { useForgedBlock } from '../hooks/useForgedBlock'
|
import { useForgedBlock } from '../hooks/useForgedBlock'
|
||||||
import { ForgedBlock } from '@typebot.io/forge-schemas'
|
import { ForgedBlock } from '@typebot.io/forge-repository/types'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
block: ForgedBlock
|
block: ForgedBlock
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { RepeatIcon, ChevronRightIcon } from '@/components/icons'
|
|||||||
import { useDebouncedCallback } from 'use-debounce'
|
import { useDebouncedCallback } from 'use-debounce'
|
||||||
import { useForgedBlock } from '@/features/forge/hooks/useForgedBlock'
|
import { useForgedBlock } from '@/features/forge/hooks/useForgedBlock'
|
||||||
import { ForgedBlockIcon } from '@/features/forge/ForgedBlockIcon'
|
import { ForgedBlockIcon } from '@/features/forge/ForgedBlockIcon'
|
||||||
import { ForgedBlock } from '@typebot.io/forge-schemas'
|
import { ForgedBlock } from '@typebot.io/forge-repository/types'
|
||||||
import { TurnableIntoParam } from '@typebot.io/forge'
|
import { TurnableIntoParam } from '@typebot.io/forge'
|
||||||
import { ZodObject } from 'zod'
|
import { ZodObject } from 'zod'
|
||||||
import { BlockV6 } from '@typebot.io/schemas'
|
import { BlockV6 } from '@typebot.io/schemas'
|
||||||
@@ -64,8 +64,8 @@ export const ForgedBlockTurnIntoMenu = ({ block, onTurnIntoClick }: Props) => {
|
|||||||
>
|
>
|
||||||
{actionDef.turnableInto.map((params) => (
|
{actionDef.turnableInto.map((params) => (
|
||||||
<TurnIntoMenuItem
|
<TurnIntoMenuItem
|
||||||
key={params.blockType}
|
key={params.blockId}
|
||||||
blockType={params.blockType}
|
blockType={params.blockId as ForgedBlock['type']}
|
||||||
onClick={(blockSchema) => onTurnIntoClick(params, blockSchema)}
|
onClick={(blockSchema) => onTurnIntoClick(params, blockSchema)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import React, { useCallback, useEffect, useState } from 'react'
|
|||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { trpc } from '@/lib/trpc'
|
import { trpc } from '@/lib/trpc'
|
||||||
import { useWorkspace } from '@/features/workspace/WorkspaceProvider'
|
import { useWorkspace } from '@/features/workspace/WorkspaceProvider'
|
||||||
import { ForgedBlockDefinition } from '@typebot.io/forge-schemas'
|
import { ForgedBlockDefinition } from '@typebot.io/forge-repository/types'
|
||||||
import { useToast } from '@/hooks/useToast'
|
import { useToast } from '@/hooks/useToast'
|
||||||
|
|
||||||
type Props = Omit<ButtonProps, 'type'> & {
|
type Props = Omit<ButtonProps, 'type'> & {
|
||||||
@@ -109,7 +109,7 @@ export const ForgedCredentialsDropdown = ({
|
|||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
Add {blockDef.auth.name}
|
Add {blockDef.auth?.name}
|
||||||
</Button>
|
</Button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ export const ForgedCredentialsDropdown = ({
|
|||||||
>
|
>
|
||||||
{currentCredential
|
{currentCredential
|
||||||
? currentCredential.name
|
? currentCredential.name
|
||||||
: `Select ${blockDef.auth.name}`}
|
: `Select ${blockDef.auth?.name}`}
|
||||||
</Text>
|
</Text>
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<MenuList>
|
<MenuList>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
} from '@chakra-ui/react'
|
} from '@chakra-ui/react'
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import { ZodObjectLayout } from '../zodLayouts/ZodObjectLayout'
|
import { ZodObjectLayout } from '../zodLayouts/ZodObjectLayout'
|
||||||
import { ForgedBlockDefinition } from '@typebot.io/forge-schemas'
|
import { ForgedBlockDefinition } from '@typebot.io/forge-repository/types'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
blockDef: ForgedBlockDefinition
|
blockDef: ForgedBlockDefinition
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ import { z } from '@typebot.io/forge/zod'
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { ZodObjectLayout } from './ZodObjectLayout'
|
import { ZodObjectLayout } from './ZodObjectLayout'
|
||||||
import { isDefined } from '@typebot.io/lib'
|
import { isDefined } from '@typebot.io/lib'
|
||||||
import { ForgedBlockDefinition, ForgedBlock } from '@typebot.io/forge-schemas'
|
import {
|
||||||
|
ForgedBlockDefinition,
|
||||||
|
ForgedBlock,
|
||||||
|
} from '@typebot.io/forge-repository/types'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
blockDef?: ForgedBlockDefinition
|
blockDef?: ForgedBlockDefinition
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ import { DropdownList } from '@/components/DropdownList'
|
|||||||
import { z } from '@typebot.io/forge/zod'
|
import { z } from '@typebot.io/forge/zod'
|
||||||
import { ZodObjectLayout } from './ZodObjectLayout'
|
import { ZodObjectLayout } from './ZodObjectLayout'
|
||||||
import { isDefined } from '@typebot.io/lib'
|
import { isDefined } from '@typebot.io/lib'
|
||||||
import { ForgedBlockDefinition, ForgedBlock } from '@typebot.io/forge-schemas'
|
import {
|
||||||
|
ForgedBlockDefinition,
|
||||||
|
ForgedBlock,
|
||||||
|
} from '@typebot.io/forge-repository/types'
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
export const ZodDiscriminatedUnionLayout = ({
|
export const ZodDiscriminatedUnionLayout = ({
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ import {
|
|||||||
} from '@chakra-ui/react'
|
} from '@chakra-ui/react'
|
||||||
import { VariableSearchInput } from '@/components/inputs/VariableSearchInput'
|
import { VariableSearchInput } from '@/components/inputs/VariableSearchInput'
|
||||||
import { DropdownList } from '@/components/DropdownList'
|
import { DropdownList } from '@/components/DropdownList'
|
||||||
import { ForgedBlockDefinition, ForgedBlock } from '@typebot.io/forge-schemas'
|
import {
|
||||||
|
ForgedBlockDefinition,
|
||||||
|
ForgedBlock,
|
||||||
|
} from '@typebot.io/forge-repository/types'
|
||||||
import { PrimitiveList } from '@/components/PrimitiveList'
|
import { PrimitiveList } from '@/components/PrimitiveList'
|
||||||
import { SwitchWithLabel } from '@/components/inputs/SwitchWithLabel'
|
import { SwitchWithLabel } from '@/components/inputs/SwitchWithLabel'
|
||||||
import { CodeEditor } from '@/components/inputs/CodeEditor'
|
import { CodeEditor } from '@/components/inputs/CodeEditor'
|
||||||
|
|||||||
@@ -14,7 +14,10 @@ import { ZodLayoutMetadata } from '@typebot.io/forge/zod'
|
|||||||
import { ReactNode } from 'react'
|
import { ReactNode } from 'react'
|
||||||
import { ZodTypeAny } from 'zod'
|
import { ZodTypeAny } from 'zod'
|
||||||
import { ZodFieldLayout } from './ZodFieldLayout'
|
import { ZodFieldLayout } from './ZodFieldLayout'
|
||||||
import { ForgedBlockDefinition, ForgedBlock } from '@typebot.io/forge-schemas'
|
import {
|
||||||
|
ForgedBlockDefinition,
|
||||||
|
ForgedBlock,
|
||||||
|
} from '@typebot.io/forge-repository/types'
|
||||||
import { getZodInnerSchema } from '../../helpers/getZodInnerSchema'
|
import { getZodInnerSchema } from '../../helpers/getZodInnerSchema'
|
||||||
|
|
||||||
export const ZodObjectLayout = ({
|
export const ZodObjectLayout = ({
|
||||||
|
|||||||
@@ -1,22 +1,16 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { forgedBlockSchemas, forgedBlocks } from '@typebot.io/forge-schemas'
|
import { forgedBlocks } from '@typebot.io/forge-repository/definitions'
|
||||||
import { enabledBlocks } from '@typebot.io/forge-repository'
|
import { forgedBlockSchemas } from '@typebot.io/forge-repository/schemas'
|
||||||
import { BlockV6 } from '@typebot.io/schemas'
|
import { BlockV6 } from '@typebot.io/schemas'
|
||||||
|
import { isForgedBlockType } from '@typebot.io/schemas/features/blocks/forged/helpers'
|
||||||
|
|
||||||
export const useForgedBlock = (blockType: BlockV6['type'], action?: string) =>
|
export const useForgedBlock = (blockType: BlockV6['type'], action?: string) =>
|
||||||
useMemo(() => {
|
useMemo(() => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
if (!isForgedBlockType(blockType)) return {}
|
||||||
if ((enabledBlocks as any).includes(blockType) === false) return {}
|
const blockDef = forgedBlocks[blockType]
|
||||||
const blockDef = forgedBlocks.find(
|
|
||||||
(b) => enabledBlocks.includes(b.id) && b.id === blockType
|
|
||||||
)
|
|
||||||
return {
|
return {
|
||||||
blockDef,
|
blockDef,
|
||||||
blockSchema: forgedBlockSchemas.find(
|
blockSchema: forgedBlockSchemas[blockType],
|
||||||
(b) =>
|
|
||||||
enabledBlocks.includes(b.shape.type.value) &&
|
|
||||||
b.shape.type.value === blockType
|
|
||||||
),
|
|
||||||
actionDef: action
|
actionDef: action
|
||||||
? blockDef?.actions.find((a) => a.name === action)
|
? blockDef?.actions.find((a) => a.name === action)
|
||||||
: undefined,
|
: undefined,
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ export const BlockNode = ({
|
|||||||
indices,
|
indices,
|
||||||
targetBlockSchema.parse({
|
targetBlockSchema.parse({
|
||||||
...block,
|
...block,
|
||||||
type: turnIntoParams.blockType,
|
type: turnIntoParams.blockId,
|
||||||
options: {
|
options: {
|
||||||
...convertedBlockOptions,
|
...convertedBlockOptions,
|
||||||
credentialsId: undefined,
|
credentialsId: undefined,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ForgedBlockDefinition } from '@typebot.io/forge-schemas'
|
import { ForgedBlockDefinition } from '@typebot.io/forge-repository/types'
|
||||||
import { BlockWithOptions } from '@typebot.io/schemas'
|
import { BlockWithOptions } from '@typebot.io/schemas'
|
||||||
import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants'
|
import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants'
|
||||||
import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integrations/constants'
|
import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integrations/constants'
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { forgedBlockSchemas } from '@typebot.io/forge-schemas'
|
|
||||||
import { enabledBlocks } from '@typebot.io/forge-repository'
|
|
||||||
import prisma from '@typebot.io/lib/prisma'
|
import prisma from '@typebot.io/lib/prisma'
|
||||||
import { Plan } from '@typebot.io/prisma'
|
import { Plan } from '@typebot.io/prisma'
|
||||||
import { Block, Typebot } from '@typebot.io/schemas'
|
import { Block, Typebot } from '@typebot.io/schemas'
|
||||||
@@ -51,25 +49,6 @@ const sanitizeBlock =
|
|||||||
async (block: Block): Promise<Block> => {
|
async (block: Block): Promise<Block> => {
|
||||||
if (!('options' in block) || !block.options) return block
|
if (!('options' in block) || !block.options) return block
|
||||||
|
|
||||||
if (enabledBlocks.includes(block.type as (typeof enabledBlocks)[number])) {
|
|
||||||
const schema = forgedBlockSchemas.find(
|
|
||||||
(s) => s.shape.type.value === block.type
|
|
||||||
)
|
|
||||||
if (!schema)
|
|
||||||
throw new Error(
|
|
||||||
`Integration block schema not found for block type ${block.type}`
|
|
||||||
)
|
|
||||||
return schema.parse({
|
|
||||||
...block,
|
|
||||||
options: {
|
|
||||||
...block.options,
|
|
||||||
credentialsId: await sanitizeCredentialsId(workspaceId)(
|
|
||||||
block.options.credentialsId
|
|
||||||
),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!('credentialsId' in block.options) || !block.options.credentialsId)
|
if (!('credentialsId' in block.options) || !block.options.credentialsId)
|
||||||
return block
|
return block
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -44,7 +44,6 @@
|
|||||||
"@typebot.io/env": "workspace:*",
|
"@typebot.io/env": "workspace:*",
|
||||||
"@typebot.io/forge": "workspace:*",
|
"@typebot.io/forge": "workspace:*",
|
||||||
"@typebot.io/forge-repository": "workspace:*",
|
"@typebot.io/forge-repository": "workspace:*",
|
||||||
"@typebot.io/forge-schemas": "workspace:*",
|
|
||||||
"@typebot.io/lib": "workspace:*",
|
"@typebot.io/lib": "workspace:*",
|
||||||
"@typebot.io/schemas": "workspace:*",
|
"@typebot.io/schemas": "workspace:*",
|
||||||
"@typebot.io/tsconfig": "workspace:*",
|
"@typebot.io/tsconfig": "workspace:*",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { StreamingTextResponse } from 'ai'
|
|||||||
import OpenAI from 'openai'
|
import OpenAI from 'openai'
|
||||||
import { NextResponse } from 'next/dist/server/web/spec-extension/response'
|
import { NextResponse } from 'next/dist/server/web/spec-extension/response'
|
||||||
import { getBlockById } from '@typebot.io/schemas/helpers'
|
import { getBlockById } from '@typebot.io/schemas/helpers'
|
||||||
import { forgedBlocks } from '@typebot.io/forge-schemas'
|
import { forgedBlocks } from '@typebot.io/forge-repository/definitions'
|
||||||
import { decryptV2 } from '@typebot.io/lib/api/encryption/decryptV2'
|
import { decryptV2 } from '@typebot.io/lib/api/encryption/decryptV2'
|
||||||
import { ReadOnlyVariableStore } from '@typebot.io/forge'
|
import { ReadOnlyVariableStore } from '@typebot.io/forge'
|
||||||
import {
|
import {
|
||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integrations/constants'
|
import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integrations/constants'
|
||||||
import { getChatCompletionStream } from '@typebot.io/bot-engine/blocks/integrations/legacy/openai/getChatCompletionStream'
|
import { getChatCompletionStream } from '@typebot.io/bot-engine/blocks/integrations/legacy/openai/getChatCompletionStream'
|
||||||
import { ChatCompletionOpenAIOptions } from '@typebot.io/schemas/features/blocks/integrations/openai/schema'
|
import { ChatCompletionOpenAIOptions } from '@typebot.io/schemas/features/blocks/integrations/openai/schema'
|
||||||
|
import { isForgedBlockType } from '@typebot.io/schemas/features/blocks/forged/helpers'
|
||||||
|
|
||||||
export const runtime = 'edge'
|
export const runtime = 'edge'
|
||||||
export const preferredRegion = 'lhr1'
|
export const preferredRegion = 'lhr1'
|
||||||
@@ -109,7 +110,13 @@ export async function POST(req: Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const blockDef = forgedBlocks.find((b) => b.id === block.type)
|
if (!isForgedBlockType(block.type))
|
||||||
|
return NextResponse.json(
|
||||||
|
{ message: 'Invalid forged block id' },
|
||||||
|
{ status: 400, headers: responseHeaders }
|
||||||
|
)
|
||||||
|
|
||||||
|
const blockDef = forgedBlocks[block.type]
|
||||||
const action = blockDef?.actions.find((a) => a.name === block.options?.action)
|
const action = blockDef?.actions.find((a) => a.name === block.options?.action)
|
||||||
|
|
||||||
if (!action || !action.run?.stream)
|
if (!action || !action.run?.stream)
|
||||||
|
|||||||
@@ -36,13 +36,14 @@ import { defaultPictureChoiceOptions } from '@typebot.io/schemas/features/blocks
|
|||||||
import { defaultFileInputOptions } from '@typebot.io/schemas/features/blocks/inputs/file/constants'
|
import { defaultFileInputOptions } from '@typebot.io/schemas/features/blocks/inputs/file/constants'
|
||||||
import { VisitedEdge } from '@typebot.io/prisma'
|
import { VisitedEdge } from '@typebot.io/prisma'
|
||||||
import { getBlockById } from '@typebot.io/schemas/helpers'
|
import { getBlockById } from '@typebot.io/schemas/helpers'
|
||||||
import { ForgedBlock, forgedBlocks } from '@typebot.io/forge-schemas'
|
import { ForgedBlock } from '@typebot.io/forge-repository/types'
|
||||||
import { enabledBlocks } from '@typebot.io/forge-repository'
|
import { forgedBlocks } from '@typebot.io/forge-repository/definitions'
|
||||||
import { resumeChatCompletion } from './blocks/integrations/legacy/openai/resumeChatCompletion'
|
import { resumeChatCompletion } from './blocks/integrations/legacy/openai/resumeChatCompletion'
|
||||||
import { env } from '@typebot.io/env'
|
import { env } from '@typebot.io/env'
|
||||||
import { downloadMedia } from './whatsapp/downloadMedia'
|
import { downloadMedia } from './whatsapp/downloadMedia'
|
||||||
import { uploadFileToBucket } from '@typebot.io/lib/s3/uploadFileToBucket'
|
import { uploadFileToBucket } from '@typebot.io/lib/s3/uploadFileToBucket'
|
||||||
import { isURL } from '@typebot.io/lib/validators/isURL'
|
import { isURL } from '@typebot.io/lib/validators/isURL'
|
||||||
|
import { isForgedBlockType } from '@typebot.io/schemas/features/blocks/forged/helpers'
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
version: 1 | 2
|
version: 1 | 2
|
||||||
@@ -111,14 +112,12 @@ export const continueBotFlow = async (
|
|||||||
response: JSON.parse(reply),
|
response: JSON.parse(reply),
|
||||||
})
|
})
|
||||||
if (result.newSessionState) newSessionState = result.newSessionState
|
if (result.newSessionState) newSessionState = result.newSessionState
|
||||||
} else if (
|
} else if (isForgedBlockType(block.type)) {
|
||||||
enabledBlocks.includes(block.type as (typeof enabledBlocks)[number])
|
|
||||||
) {
|
|
||||||
if (reply) {
|
if (reply) {
|
||||||
const options = (block as ForgedBlock).options
|
const options = (block as ForgedBlock).options
|
||||||
const action = forgedBlocks
|
const action = forgedBlocks[block.type].actions.find(
|
||||||
.find((b) => b.id === block.type)
|
(a) => a.name === options?.action
|
||||||
?.actions.find((a) => a.name === options?.action)
|
)
|
||||||
if (action) {
|
if (action) {
|
||||||
if (action.run?.stream?.getStreamVariableId) {
|
if (action.run?.stream?.getStreamVariableId) {
|
||||||
firstBubbleWasStreamed = true
|
firstBubbleWasStreamed = true
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { VariableStore, LogsStore } from '@typebot.io/forge'
|
import { VariableStore, LogsStore } from '@typebot.io/forge'
|
||||||
import { ForgedBlock, forgedBlocks } from '@typebot.io/forge-schemas'
|
import { forgedBlocks } from '@typebot.io/forge-repository/definitions'
|
||||||
|
import { ForgedBlock } from '@typebot.io/forge-repository/types'
|
||||||
import { decrypt } from '@typebot.io/lib/api/encryption/decrypt'
|
import { decrypt } from '@typebot.io/lib/api/encryption/decrypt'
|
||||||
import { isPlaneteScale } from '@typebot.io/lib/isPlanetScale'
|
import { isPlaneteScale } from '@typebot.io/lib/isPlanetScale'
|
||||||
import prisma from '@typebot.io/lib/prisma'
|
import prisma from '@typebot.io/lib/prisma'
|
||||||
@@ -23,7 +24,7 @@ export const executeForgedBlock = async (
|
|||||||
state: SessionState,
|
state: SessionState,
|
||||||
block: ForgedBlock
|
block: ForgedBlock
|
||||||
): Promise<ExecuteIntegrationResponse> => {
|
): Promise<ExecuteIntegrationResponse> => {
|
||||||
const blockDef = forgedBlocks.find((b) => b.id === block.type)
|
const blockDef = forgedBlocks[block.type]
|
||||||
if (!blockDef) return { outgoingEdgeId: block.outgoingEdgeId }
|
if (!blockDef) return { outgoingEdgeId: block.outgoingEdgeId }
|
||||||
const action = blockDef.actions.find((a) => a.name === block.options.action)
|
const action = blockDef.actions.find((a) => a.name === block.options.action)
|
||||||
const noCredentialsError = {
|
const noCredentialsError = {
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@typebot.io/forge": "workspace:*",
|
"@typebot.io/forge": "workspace:*",
|
||||||
"@typebot.io/forge-repository": "workspace:*",
|
"@typebot.io/forge-repository": "workspace:*",
|
||||||
"@typebot.io/forge-schemas": "workspace:*",
|
|
||||||
"@types/nodemailer": "6.4.8",
|
"@types/nodemailer": "6.4.8",
|
||||||
"@types/qs": "6.9.7"
|
"@types/qs": "6.9.7"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
"@rollup/plugin-babel": "6.0.3",
|
"@rollup/plugin-babel": "6.0.3",
|
||||||
"@rollup/plugin-node-resolve": "15.1.0",
|
"@rollup/plugin-node-resolve": "15.1.0",
|
||||||
"@rollup/plugin-terser": "0.4.3",
|
"@rollup/plugin-terser": "0.4.3",
|
||||||
"@rollup/plugin-typescript": "11.1.2",
|
|
||||||
"@typebot.io/bot-engine": "workspace:*",
|
"@typebot.io/bot-engine": "workspace:*",
|
||||||
"@typebot.io/env": "workspace:*",
|
"@typebot.io/env": "workspace:*",
|
||||||
"@typebot.io/lib": "workspace:*",
|
"@typebot.io/lib": "workspace:*",
|
||||||
|
|||||||
@@ -4,11 +4,15 @@ import { babel } from '@rollup/plugin-babel'
|
|||||||
import postcss from 'rollup-plugin-postcss'
|
import postcss from 'rollup-plugin-postcss'
|
||||||
import autoprefixer from 'autoprefixer'
|
import autoprefixer from 'autoprefixer'
|
||||||
import tailwindcss from 'tailwindcss'
|
import tailwindcss from 'tailwindcss'
|
||||||
import typescript from '@rollup/plugin-typescript'
|
|
||||||
import { typescriptPaths } from 'rollup-plugin-typescript-paths'
|
import { typescriptPaths } from 'rollup-plugin-typescript-paths'
|
||||||
|
import fs from 'fs'
|
||||||
|
|
||||||
const extensions = ['.ts', '.tsx']
|
const extensions = ['.ts', '.tsx']
|
||||||
|
|
||||||
|
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'))
|
||||||
|
const packageVersion = packageJson.version
|
||||||
|
const preamble = `// v${packageVersion}`
|
||||||
|
|
||||||
const indexConfig = {
|
const indexConfig = {
|
||||||
input: './src/index.ts',
|
input: './src/index.ts',
|
||||||
output: {
|
output: {
|
||||||
@@ -23,6 +27,7 @@ const indexConfig = {
|
|||||||
presets: ['solid', '@babel/preset-typescript'],
|
presets: ['solid', '@babel/preset-typescript'],
|
||||||
extensions,
|
extensions,
|
||||||
}),
|
}),
|
||||||
|
typescriptPaths({ preserveExtensions: true }),
|
||||||
postcss({
|
postcss({
|
||||||
plugins: [autoprefixer(), tailwindcss()],
|
plugins: [autoprefixer(), tailwindcss()],
|
||||||
extract: false,
|
extract: false,
|
||||||
@@ -31,9 +36,9 @@ const indexConfig = {
|
|||||||
minimize: true,
|
minimize: true,
|
||||||
inject: false,
|
inject: false,
|
||||||
}),
|
}),
|
||||||
typescript(),
|
terser({
|
||||||
typescriptPaths({ preserveExtensions: true }),
|
format: { preamble },
|
||||||
terser({ output: { comments: false } }),
|
}),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ import {
|
|||||||
} from '@/utils/storage'
|
} from '@/utils/storage'
|
||||||
import { setCssVariablesValue } from '@/utils/setCssVariablesValue'
|
import { setCssVariablesValue } from '@/utils/setCssVariablesValue'
|
||||||
import immutableCss from '../assets/immutable.css'
|
import immutableCss from '../assets/immutable.css'
|
||||||
import { Font, InputBlock } from '@typebot.io/schemas'
|
import { Font, InputBlock, StartFrom } from '@typebot.io/schemas'
|
||||||
import { StartFrom } from '@typebot.io/schemas'
|
|
||||||
import { defaultTheme } from '@typebot.io/schemas/features/typebot/theme/constants'
|
import { defaultTheme } from '@typebot.io/schemas/features/typebot/theme/constants'
|
||||||
import { clsx } from 'clsx'
|
import { clsx } from 'clsx'
|
||||||
import { HTTPError } from 'ky'
|
import { HTTPError } from 'ky'
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
"@rollup/plugin-babel": "6.0.3",
|
"@rollup/plugin-babel": "6.0.3",
|
||||||
"@rollup/plugin-node-resolve": "15.1.0",
|
"@rollup/plugin-node-resolve": "15.1.0",
|
||||||
"@rollup/plugin-terser": "0.4.3",
|
"@rollup/plugin-terser": "0.4.3",
|
||||||
"@rollup/plugin-typescript": "11.1.2",
|
|
||||||
"@typebot.io/js": "workspace:*",
|
"@typebot.io/js": "workspace:*",
|
||||||
"@typebot.io/lib": "workspace:*",
|
"@typebot.io/lib": "workspace:*",
|
||||||
"@typebot.io/prisma": "workspace:*",
|
"@typebot.io/prisma": "workspace:*",
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
import resolve from '@rollup/plugin-node-resolve'
|
import resolve from '@rollup/plugin-node-resolve'
|
||||||
import terser from '@rollup/plugin-terser'
|
import terser from '@rollup/plugin-terser'
|
||||||
import { babel } from '@rollup/plugin-babel'
|
import { babel } from '@rollup/plugin-babel'
|
||||||
import typescript from '@rollup/plugin-typescript'
|
|
||||||
import { typescriptPaths } from 'rollup-plugin-typescript-paths'
|
import { typescriptPaths } from 'rollup-plugin-typescript-paths'
|
||||||
|
import fs from 'fs'
|
||||||
|
|
||||||
const extensions = ['.ts', '.tsx']
|
const extensions = ['.ts', '.tsx']
|
||||||
|
|
||||||
|
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'))
|
||||||
|
const packageVersion = packageJson.version
|
||||||
|
const preamble = `// v${packageVersion}`
|
||||||
|
|
||||||
const indexConfig = {
|
const indexConfig = {
|
||||||
input: './src/index.ts',
|
input: './src/index.ts',
|
||||||
output: {
|
output: {
|
||||||
@@ -21,9 +25,8 @@ const indexConfig = {
|
|||||||
presets: ['@babel/preset-react', '@babel/preset-typescript'],
|
presets: ['@babel/preset-react', '@babel/preset-typescript'],
|
||||||
extensions,
|
extensions,
|
||||||
}),
|
}),
|
||||||
typescript(),
|
|
||||||
typescriptPaths({ preserveExtensions: true }),
|
typescriptPaths({ preserveExtensions: true }),
|
||||||
terser({ output: { comments: false } }),
|
terser({ format: { preamble } }),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
"@rollup/plugin-babel": "6.0.3",
|
"@rollup/plugin-babel": "6.0.3",
|
||||||
"@rollup/plugin-node-resolve": "15.1.0",
|
"@rollup/plugin-node-resolve": "15.1.0",
|
||||||
"@rollup/plugin-terser": "0.4.3",
|
"@rollup/plugin-terser": "0.4.3",
|
||||||
"@rollup/plugin-typescript": "11.1.2",
|
|
||||||
"@typebot.io/js": "workspace:*",
|
"@typebot.io/js": "workspace:*",
|
||||||
"@typebot.io/lib": "workspace:*",
|
"@typebot.io/lib": "workspace:*",
|
||||||
"@typebot.io/prisma": "workspace:*",
|
"@typebot.io/prisma": "workspace:*",
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
import resolve from '@rollup/plugin-node-resolve'
|
import resolve from '@rollup/plugin-node-resolve'
|
||||||
import terser from '@rollup/plugin-terser'
|
import terser from '@rollup/plugin-terser'
|
||||||
import { babel } from '@rollup/plugin-babel'
|
import { babel } from '@rollup/plugin-babel'
|
||||||
import typescript from '@rollup/plugin-typescript'
|
|
||||||
import { typescriptPaths } from 'rollup-plugin-typescript-paths'
|
import { typescriptPaths } from 'rollup-plugin-typescript-paths'
|
||||||
|
import fs from 'fs'
|
||||||
|
|
||||||
const extensions = ['.ts', '.tsx']
|
const extensions = ['.ts', '.tsx']
|
||||||
|
|
||||||
|
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'))
|
||||||
|
const packageVersion = packageJson.version
|
||||||
|
const preamble = `// v${packageVersion}`
|
||||||
|
|
||||||
const indexConfig = {
|
const indexConfig = {
|
||||||
input: './src/index.ts',
|
input: './src/index.ts',
|
||||||
output: {
|
output: {
|
||||||
@@ -21,9 +25,8 @@ const indexConfig = {
|
|||||||
presets: ['@babel/preset-react', '@babel/preset-typescript'],
|
presets: ['@babel/preset-react', '@babel/preset-typescript'],
|
||||||
extensions,
|
extensions,
|
||||||
}),
|
}),
|
||||||
typescript(),
|
|
||||||
typescriptPaths({ preserveExtensions: true }),
|
typescriptPaths({ preserveExtensions: true }),
|
||||||
terser({ output: { comments: false } }),
|
terser({ format: { preamble } }),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,15 +90,15 @@ export const createChatMessage = createAction({
|
|||||||
options,
|
options,
|
||||||
turnableInto: [
|
turnableInto: [
|
||||||
{
|
{
|
||||||
blockType: 'mistral',
|
blockId: 'mistral',
|
||||||
transform: transformToChatCompletionOptions,
|
transform: transformToChatCompletionOptions,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
blockType: 'openai',
|
blockId: 'openai',
|
||||||
transform: transformToChatCompletionOptions,
|
transform: transformToChatCompletionOptions,
|
||||||
},
|
},
|
||||||
{ blockType: 'open-router', transform: transformToChatCompletionOptions },
|
{ blockId: 'open-router', transform: transformToChatCompletionOptions },
|
||||||
{ blockType: 'together-ai', transform: transformToChatCompletionOptions },
|
{ blockId: 'together-ai', transform: transformToChatCompletionOptions },
|
||||||
],
|
],
|
||||||
getSetVariableIds: ({ responseMapping }) =>
|
getSetVariableIds: ({ responseMapping }) =>
|
||||||
responseMapping?.map((res) => res.variableId).filter(isDefined) ?? [],
|
responseMapping?.map((res) => res.variableId).filter(isDefined) ?? [],
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { AnthropicLogo } from './logo'
|
|||||||
import { auth } from './auth'
|
import { auth } from './auth'
|
||||||
import { createChatMessage } from './actions/createChatMessage'
|
import { createChatMessage } from './actions/createChatMessage'
|
||||||
|
|
||||||
export const anthropic = createBlock({
|
export const anthropicBlock = createBlock({
|
||||||
id: 'anthropic',
|
id: 'anthropic',
|
||||||
name: 'Anthropic',
|
name: 'Anthropic',
|
||||||
tags: ['ai', 'chat', 'completion', 'claude', 'anthropic'],
|
tags: ['ai', 'chat', 'completion', 'claude', 'anthropic'],
|
||||||
|
|||||||
6
packages/forge/blocks/anthropic/schemas.ts
Normal file
6
packages/forge/blocks/anthropic/schemas.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// Do not edit this file manually
|
||||||
|
import { parseBlockCredentials, parseBlockSchema } from '@typebot.io/forge'
|
||||||
|
import { anthropicBlock } from '.'
|
||||||
|
|
||||||
|
export const anthropicBlockSchema = parseBlockSchema(anthropicBlock)
|
||||||
|
export const anthropicCredentialsSchema = parseBlockCredentials(anthropicBlock)
|
||||||
@@ -3,7 +3,7 @@ import { CalComLogo } from './logo'
|
|||||||
import { bookEvent } from './actions/bookEvent'
|
import { bookEvent } from './actions/bookEvent'
|
||||||
import { baseOptions } from './baseOptions'
|
import { baseOptions } from './baseOptions'
|
||||||
|
|
||||||
export const calCom = createBlock({
|
export const calComBlock = createBlock({
|
||||||
id: 'cal-com',
|
id: 'cal-com',
|
||||||
name: 'Cal.com',
|
name: 'Cal.com',
|
||||||
tags: ['calendar', 'scheduling', 'meetings'],
|
tags: ['calendar', 'scheduling', 'meetings'],
|
||||||
|
|||||||
6
packages/forge/blocks/calCom/schemas.ts
Normal file
6
packages/forge/blocks/calCom/schemas.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// Do not edit this file manually
|
||||||
|
import { parseBlockCredentials, parseBlockSchema } from '@typebot.io/forge'
|
||||||
|
import { calComBlock } from '.'
|
||||||
|
|
||||||
|
export const calComBlockSchema = parseBlockSchema(calComBlock)
|
||||||
|
export const calComCredentialsSchema = parseBlockCredentials(calComBlock)
|
||||||
@@ -3,7 +3,7 @@ import { ChatNodeLogo } from './logo'
|
|||||||
import { auth } from './auth'
|
import { auth } from './auth'
|
||||||
import { sendMessage } from './actions/sendMessage'
|
import { sendMessage } from './actions/sendMessage'
|
||||||
|
|
||||||
export const chatNode = createBlock({
|
export const chatNodeBlock = createBlock({
|
||||||
id: 'chat-node',
|
id: 'chat-node',
|
||||||
name: 'ChatNode',
|
name: 'ChatNode',
|
||||||
tags: ['ai', 'openai', 'document', 'url'],
|
tags: ['ai', 'openai', 'document', 'url'],
|
||||||
|
|||||||
6
packages/forge/blocks/chatNode/schemas.ts
Normal file
6
packages/forge/blocks/chatNode/schemas.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// Do not edit this file manually
|
||||||
|
import { parseBlockCredentials, parseBlockSchema } from '@typebot.io/forge'
|
||||||
|
import { chatNodeBlock } from '.'
|
||||||
|
|
||||||
|
export const chatNodeBlockSchema = parseBlockSchema(chatNodeBlock)
|
||||||
|
export const chatNodeCredentialsSchema = parseBlockCredentials(chatNodeBlock)
|
||||||
@@ -3,7 +3,7 @@ import { DifyAiLogo } from './logo'
|
|||||||
import { auth } from './auth'
|
import { auth } from './auth'
|
||||||
import { createChatMessage } from './actions/createChatMessage'
|
import { createChatMessage } from './actions/createChatMessage'
|
||||||
|
|
||||||
export const difyAi = createBlock({
|
export const difyAiBlock = createBlock({
|
||||||
id: 'dify-ai',
|
id: 'dify-ai',
|
||||||
name: 'Dify.AI',
|
name: 'Dify.AI',
|
||||||
tags: ['dify', 'ai', 'documents', 'files', 'knowledge base'],
|
tags: ['dify', 'ai', 'documents', 'files', 'knowledge base'],
|
||||||
|
|||||||
6
packages/forge/blocks/difyAi/schemas.ts
Normal file
6
packages/forge/blocks/difyAi/schemas.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// Do not edit this file manually
|
||||||
|
import { parseBlockCredentials, parseBlockSchema } from '@typebot.io/forge'
|
||||||
|
import { difyAiBlock } from '.'
|
||||||
|
|
||||||
|
export const difyAiBlockSchema = parseBlockSchema(difyAiBlock)
|
||||||
|
export const difyAiCredentialsSchema = parseBlockCredentials(difyAiBlock)
|
||||||
@@ -3,7 +3,7 @@ import { ElevenlabsLogo, ElevenlabsLogoDark } from './logo'
|
|||||||
import { auth } from './auth'
|
import { auth } from './auth'
|
||||||
import { convertTextToSpeech } from './actions/convertTextToSpeech'
|
import { convertTextToSpeech } from './actions/convertTextToSpeech'
|
||||||
|
|
||||||
export const elevenlabs = createBlock({
|
export const elevenlabsBlock = createBlock({
|
||||||
id: 'elevenlabs',
|
id: 'elevenlabs',
|
||||||
name: 'ElevenLabs',
|
name: 'ElevenLabs',
|
||||||
tags: ['ai', 'voice', 'generation'],
|
tags: ['ai', 'voice', 'generation'],
|
||||||
|
|||||||
7
packages/forge/blocks/elevenlabs/schemas.ts
Normal file
7
packages/forge/blocks/elevenlabs/schemas.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
// Do not edit this file manually
|
||||||
|
import { parseBlockCredentials, parseBlockSchema } from '@typebot.io/forge'
|
||||||
|
import { elevenlabsBlock } from '.'
|
||||||
|
|
||||||
|
export const elevenlabsBlockSchema = parseBlockSchema(elevenlabsBlock)
|
||||||
|
export const elevenlabsCredentialsSchema =
|
||||||
|
parseBlockCredentials(elevenlabsBlock)
|
||||||
@@ -69,14 +69,14 @@ export const createChatCompletion = createAction({
|
|||||||
options,
|
options,
|
||||||
turnableInto: [
|
turnableInto: [
|
||||||
{
|
{
|
||||||
blockType: 'openai',
|
blockId: 'openai',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
blockType: 'together-ai',
|
blockId: 'together-ai',
|
||||||
},
|
},
|
||||||
{ blockType: 'open-router' },
|
{ blockId: 'open-router' },
|
||||||
{
|
{
|
||||||
blockType: 'anthropic',
|
blockId: 'anthropic',
|
||||||
transform: (options) => ({
|
transform: (options) => ({
|
||||||
...options,
|
...options,
|
||||||
action: 'Create Chat Message',
|
action: 'Create Chat Message',
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { MistralLogo } from './logo'
|
|||||||
import { auth } from './auth'
|
import { auth } from './auth'
|
||||||
import { createChatCompletion } from './actions/createChatCompletion'
|
import { createChatCompletion } from './actions/createChatCompletion'
|
||||||
|
|
||||||
export const mistral = createBlock({
|
export const mistralBlock = createBlock({
|
||||||
id: 'mistral',
|
id: 'mistral',
|
||||||
name: 'Mistral',
|
name: 'Mistral',
|
||||||
tags: ['ai', 'chat', 'completion'],
|
tags: ['ai', 'chat', 'completion'],
|
||||||
|
|||||||
6
packages/forge/blocks/mistral/schemas.ts
Normal file
6
packages/forge/blocks/mistral/schemas.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// Do not edit this file manually
|
||||||
|
import { parseBlockCredentials, parseBlockSchema } from '@typebot.io/forge'
|
||||||
|
import { mistralBlock } from '.'
|
||||||
|
|
||||||
|
export const mistralBlockSchema = parseBlockSchema(mistralBlock)
|
||||||
|
export const mistralCredentialsSchema = parseBlockCredentials(mistralBlock)
|
||||||
@@ -14,14 +14,14 @@ export const createChatCompletion = createAction({
|
|||||||
auth,
|
auth,
|
||||||
turnableInto: [
|
turnableInto: [
|
||||||
{
|
{
|
||||||
blockType: 'openai',
|
blockId: 'openai',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
blockType: 'together-ai',
|
blockId: 'together-ai',
|
||||||
},
|
},
|
||||||
{ blockType: 'mistral' },
|
{ blockId: 'mistral' },
|
||||||
{
|
{
|
||||||
blockType: 'anthropic',
|
blockId: 'anthropic',
|
||||||
transform: (options) => ({
|
transform: (options) => ({
|
||||||
...options,
|
...options,
|
||||||
action: 'Create Chat Message',
|
action: 'Create Chat Message',
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { OpenRouterLogo } from './logo'
|
|||||||
import { auth } from './auth'
|
import { auth } from './auth'
|
||||||
import { createChatCompletion } from './actions/createChatCompletion'
|
import { createChatCompletion } from './actions/createChatCompletion'
|
||||||
|
|
||||||
export const openRouter = createBlock({
|
export const openRouterBlock = createBlock({
|
||||||
id: 'open-router',
|
id: 'open-router',
|
||||||
name: 'OpenRouter',
|
name: 'OpenRouter',
|
||||||
tags: ['ai', 'openai', 'chat', 'completion'],
|
tags: ['ai', 'openai', 'chat', 'completion'],
|
||||||
|
|||||||
7
packages/forge/blocks/openRouter/schemas.ts
Normal file
7
packages/forge/blocks/openRouter/schemas.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
// Do not edit this file manually
|
||||||
|
import { parseBlockCredentials, parseBlockSchema } from '@typebot.io/forge'
|
||||||
|
import { openRouterBlock } from '.'
|
||||||
|
|
||||||
|
export const openRouterBlockSchema = parseBlockSchema(openRouterBlock)
|
||||||
|
export const openRouterCredentialsSchema =
|
||||||
|
parseBlockCredentials(openRouterBlock)
|
||||||
@@ -21,14 +21,14 @@ export const createChatCompletion = createAction({
|
|||||||
getSetVariableIds: getChatCompletionSetVarIds,
|
getSetVariableIds: getChatCompletionSetVarIds,
|
||||||
turnableInto: [
|
turnableInto: [
|
||||||
{
|
{
|
||||||
blockType: 'open-router',
|
blockId: 'open-router',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
blockType: 'together-ai',
|
blockId: 'together-ai',
|
||||||
},
|
},
|
||||||
{ blockType: 'mistral' },
|
{ blockId: 'mistral' },
|
||||||
{
|
{
|
||||||
blockType: 'anthropic',
|
blockId: 'anthropic',
|
||||||
transform: (options) => ({
|
transform: (options) => ({
|
||||||
...options,
|
...options,
|
||||||
action: 'Create Chat Message',
|
action: 'Create Chat Message',
|
||||||
|
|||||||
6
packages/forge/blocks/openai/schemas.ts
Normal file
6
packages/forge/blocks/openai/schemas.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// Do not edit this file manually
|
||||||
|
import { parseBlockCredentials, parseBlockSchema } from '@typebot.io/forge'
|
||||||
|
import { openAIBlock } from '.'
|
||||||
|
|
||||||
|
export const openAIBlockSchema = parseBlockSchema(openAIBlock)
|
||||||
|
export const openAICredentialsSchema = parseBlockCredentials(openAIBlock)
|
||||||
@@ -2,7 +2,7 @@ import { createBlock } from '@typebot.io/forge'
|
|||||||
import { QrCodeLogo } from './logo'
|
import { QrCodeLogo } from './logo'
|
||||||
import { generateQrCode } from './actions/generateQrCodeImage'
|
import { generateQrCode } from './actions/generateQrCodeImage'
|
||||||
|
|
||||||
export const qrCode = createBlock({
|
export const qrCodeBlock = createBlock({
|
||||||
id: 'qr-code',
|
id: 'qr-code',
|
||||||
name: 'QR code',
|
name: 'QR code',
|
||||||
tags: [],
|
tags: [],
|
||||||
|
|||||||
6
packages/forge/blocks/qrcode/schemas.ts
Normal file
6
packages/forge/blocks/qrcode/schemas.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// Do not edit this file manually
|
||||||
|
import { parseBlockCredentials, parseBlockSchema } from '@typebot.io/forge'
|
||||||
|
import { qrCodeBlock } from '.'
|
||||||
|
|
||||||
|
export const qrCodeBlockSchema = parseBlockSchema(qrCodeBlock)
|
||||||
|
export const qrCodeCredentialsSchema = parseBlockCredentials(qrCodeBlock)
|
||||||
@@ -16,14 +16,14 @@ export const createChatCompletion = createAction({
|
|||||||
}),
|
}),
|
||||||
turnableInto: [
|
turnableInto: [
|
||||||
{
|
{
|
||||||
blockType: 'openai',
|
blockId: 'openai',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
blockType: 'open-router',
|
blockId: 'open-router',
|
||||||
},
|
},
|
||||||
{ blockType: 'mistral' },
|
{ blockId: 'mistral' },
|
||||||
{
|
{
|
||||||
blockType: 'anthropic',
|
blockId: 'anthropic',
|
||||||
transform: (options) => ({
|
transform: (options) => ({
|
||||||
...options,
|
...options,
|
||||||
action: 'Create Chat Message',
|
action: 'Create Chat Message',
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { TogetherAiLogo } from './logo'
|
|||||||
import { auth } from './auth'
|
import { auth } from './auth'
|
||||||
import { createChatCompletion } from './actions/createChatCompletion'
|
import { createChatCompletion } from './actions/createChatCompletion'
|
||||||
|
|
||||||
export const togetherAi = createBlock({
|
export const togetherAiBlock = createBlock({
|
||||||
id: 'together-ai',
|
id: 'together-ai',
|
||||||
name: 'Together',
|
name: 'Together',
|
||||||
fullName: 'Together AI',
|
fullName: 'Together AI',
|
||||||
|
|||||||
7
packages/forge/blocks/togetherAi/schemas.ts
Normal file
7
packages/forge/blocks/togetherAi/schemas.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
// Do not edit this file manually
|
||||||
|
import { parseBlockCredentials, parseBlockSchema } from '@typebot.io/forge'
|
||||||
|
import { togetherAiBlock } from '.'
|
||||||
|
|
||||||
|
export const togetherAiBlockSchema = parseBlockSchema(togetherAiBlock)
|
||||||
|
export const togetherAiCredentialsSchema =
|
||||||
|
parseBlockCredentials(togetherAiBlock)
|
||||||
@@ -5,7 +5,7 @@ import { searchDocuments } from './actions/searchDocuments'
|
|||||||
import { auth } from './auth'
|
import { auth } from './auth'
|
||||||
import { baseOptions } from './baseOptions'
|
import { baseOptions } from './baseOptions'
|
||||||
|
|
||||||
export const zemanticAi = createBlock({
|
export const zemanticAiBlock = createBlock({
|
||||||
id: 'zemantic-ai',
|
id: 'zemantic-ai',
|
||||||
name: 'Zemantic AI',
|
name: 'Zemantic AI',
|
||||||
tags: [],
|
tags: [],
|
||||||
|
|||||||
7
packages/forge/blocks/zemanticAi/schemas.ts
Normal file
7
packages/forge/blocks/zemanticAi/schemas.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
// Do not edit this file manually
|
||||||
|
import { parseBlockCredentials, parseBlockSchema } from '@typebot.io/forge'
|
||||||
|
import { zemanticAiBlock } from '.'
|
||||||
|
|
||||||
|
export const zemanticAiBlockSchema = parseBlockSchema(zemanticAiBlock)
|
||||||
|
export const zemanticAiCredentialsSchema =
|
||||||
|
parseBlockCredentials(zemanticAiBlock)
|
||||||
@@ -83,7 +83,7 @@ const main = async () => {
|
|||||||
await createIndexFile(newBlockPath, prompt)
|
await createIndexFile(newBlockPath, prompt)
|
||||||
await createLogoFile(newBlockPath, prompt)
|
await createLogoFile(newBlockPath, prompt)
|
||||||
if (prompt.auth !== 'none') await createAuthFile(newBlockPath, prompt)
|
if (prompt.auth !== 'none') await createAuthFile(newBlockPath, prompt)
|
||||||
await addNewIntegrationToRepository(prompt)
|
await createSchemasFile(newBlockPath, prompt)
|
||||||
s.stop('Creating files...')
|
s.stop('Creating files...')
|
||||||
s.start('Installing dependencies...')
|
s.start('Installing dependencies...')
|
||||||
await new Promise<void>((resolve, reject) => {
|
await new Promise<void>((resolve, reject) => {
|
||||||
@@ -138,7 +138,7 @@ const createIndexFile = async (
|
|||||||
import { ${capitalize(camelCaseId)}Logo } from './logo'
|
import { ${capitalize(camelCaseId)}Logo } from './logo'
|
||||||
${auth !== 'none' ? `import { auth } from './auth'` : ''}
|
${auth !== 'none' ? `import { auth } from './auth'` : ''}
|
||||||
|
|
||||||
export const ${camelCaseName} = createBlock({
|
export const ${camelCaseName}Block = createBlock({
|
||||||
id: '${id}',
|
id: '${id}',
|
||||||
name: '${name}',
|
name: '${name}',
|
||||||
tags: [],
|
tags: [],
|
||||||
@@ -175,51 +175,6 @@ const createPackageJson = async (path: string, { id }: { id: unknown }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const addNewIntegrationToRepository = async ({
|
|
||||||
camelCaseId,
|
|
||||||
id,
|
|
||||||
}: {
|
|
||||||
camelCaseId: string
|
|
||||||
id: string
|
|
||||||
}) => {
|
|
||||||
const schemasPath = join(process.cwd(), `../schemas`)
|
|
||||||
const packageJson = require(join(schemasPath, 'package.json'))
|
|
||||||
packageJson.devDependencies[`@typebot.io/${id}-block`] = 'workspace:*'
|
|
||||||
writeFileSync(
|
|
||||||
join(schemasPath, 'package.json'),
|
|
||||||
await prettier.format(JSON.stringify(packageJson, null, 2), {
|
|
||||||
parser: 'json',
|
|
||||||
...prettierRc,
|
|
||||||
})
|
|
||||||
)
|
|
||||||
const repoIndexFile = readFileSync(join(schemasPath, 'index.ts')).toString()
|
|
||||||
writeFileSync(
|
|
||||||
join(schemasPath, 'index.ts'),
|
|
||||||
await prettier.format(
|
|
||||||
repoIndexFile
|
|
||||||
.replace(
|
|
||||||
'] as BlockDefinition<(typeof enabledBlocks)[number], any, any>[]',
|
|
||||||
`${camelCaseId},] as BlockDefinition<(typeof enabledBlocks)[number], any, any>[]`
|
|
||||||
)
|
|
||||||
.replace(
|
|
||||||
'// Do not edit this file manually',
|
|
||||||
`// Do not edit this file manually\nimport {${camelCaseId}} from '@typebot.io/${id}-block'`
|
|
||||||
),
|
|
||||||
{ parser: 'typescript', ...prettierRc }
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
const repoPath = join(process.cwd(), `../repository`)
|
|
||||||
const enabledIndexFile = readFileSync(join(repoPath, 'index.ts')).toString()
|
|
||||||
writeFileSync(
|
|
||||||
join(repoPath, 'index.ts'),
|
|
||||||
await prettier.format(
|
|
||||||
enabledIndexFile.replace('] as const', `'${id}'] as const`),
|
|
||||||
{ parser: 'typescript', ...prettierRc }
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const createTsConfig = async (path: string) => {
|
const createTsConfig = async (path: string) => {
|
||||||
writeFileSync(
|
writeFileSync(
|
||||||
join(path, 'tsconfig.json'),
|
join(path, 'tsconfig.json'),
|
||||||
@@ -289,6 +244,27 @@ const createAuthFile = async (
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const createSchemasFile = async (
|
||||||
|
path: string,
|
||||||
|
{
|
||||||
|
id,
|
||||||
|
}: { id: string; name: string; auth: 'apiKey' | 'encryptedData' | 'none' }
|
||||||
|
) => {
|
||||||
|
const camelCaseName = camelize(id as string)
|
||||||
|
writeFileSync(
|
||||||
|
join(path, 'schemas.ts'),
|
||||||
|
await prettier.format(
|
||||||
|
`// Do not edit this file manually
|
||||||
|
import { parseBlockCredentials, parseBlockSchema } from '@typebot.io/forge'
|
||||||
|
import { ${camelCaseName}Block } from '.'
|
||||||
|
|
||||||
|
export const ${camelCaseName}BlockSchema = parseBlockSchema(${camelCaseName}Block)
|
||||||
|
export const ${camelCaseName}CredentialsSchema = parseBlockCredentials(${camelCaseName}Block)`,
|
||||||
|
{ parser: 'typescript', ...prettierRc }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
.then()
|
.then()
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ export const parseBlockCredentials = <
|
|||||||
>(
|
>(
|
||||||
blockDefinition: BlockDefinition<I, A, O>
|
blockDefinition: BlockDefinition<I, A, O>
|
||||||
) => {
|
) => {
|
||||||
if (!blockDefinition.auth) throw new Error('Block has no auth definition')
|
if (!blockDefinition.auth) return null
|
||||||
return z.object({
|
return z.object({
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
type: z.literal(blockDefinition.id),
|
type: z.literal(blockDefinition.id),
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@typebot.io/tsconfig": "workspace:*",
|
"@typebot.io/tsconfig": "workspace:*",
|
||||||
"@types/react": "18.2.15",
|
"@types/react": "18.2.15"
|
||||||
"@typebot.io/forge-repository": "workspace:*"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { SVGProps } from 'react'
|
import { SVGProps } from 'react'
|
||||||
import { z } from './zod'
|
import { z } from './zod'
|
||||||
import { ZodRawShape } from 'zod'
|
import { ZodRawShape } from 'zod'
|
||||||
import { enabledBlocks } from '@typebot.io/forge-repository'
|
|
||||||
|
|
||||||
export type VariableStore = {
|
export type VariableStore = {
|
||||||
get: (variableId: string) => string | (string | null)[] | null | undefined
|
get: (variableId: string) => string | (string | null)[] | null | undefined
|
||||||
@@ -34,7 +33,7 @@ export type FunctionToExecute = {
|
|||||||
export type ReadOnlyVariableStore = Omit<VariableStore, 'set'>
|
export type ReadOnlyVariableStore = Omit<VariableStore, 'set'>
|
||||||
|
|
||||||
export type TurnableIntoParam<T = {}> = {
|
export type TurnableIntoParam<T = {}> = {
|
||||||
blockType: (typeof enabledBlocks)[number]
|
blockId: string
|
||||||
/**
|
/**
|
||||||
* If defined will be used to convert the existing block options into the new block options.
|
* If defined will be used to convert the existing block options into the new block options.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// Do not edit this file manually
|
import { ForgedBlock } from './types'
|
||||||
export const enabledBlocks = [
|
|
||||||
|
export const forgedBlockIds = [
|
||||||
'openai',
|
'openai',
|
||||||
'zemantic-ai',
|
'zemantic-ai',
|
||||||
'cal-com',
|
'cal-com',
|
||||||
@@ -11,4 +12,4 @@ export const enabledBlocks = [
|
|||||||
'anthropic',
|
'anthropic',
|
||||||
'together-ai',
|
'together-ai',
|
||||||
'open-router',
|
'open-router',
|
||||||
] as const
|
] as const satisfies ForgedBlock['type'][]
|
||||||
36
packages/forge/repository/credentials.ts
Normal file
36
packages/forge/repository/credentials.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { anthropicBlock } from '@typebot.io/anthropic-block'
|
||||||
|
import { anthropicCredentialsSchema } from '@typebot.io/anthropic-block/schemas'
|
||||||
|
import { calComBlock } from '@typebot.io/cal-com-block'
|
||||||
|
import { calComCredentialsSchema } from '@typebot.io/cal-com-block/schemas'
|
||||||
|
import { chatNodeBlock } from '@typebot.io/chat-node-block'
|
||||||
|
import { chatNodeCredentialsSchema } from '@typebot.io/chat-node-block/schemas'
|
||||||
|
import { difyAiBlock } from '@typebot.io/dify-ai-block'
|
||||||
|
import { difyAiCredentialsSchema } from '@typebot.io/dify-ai-block/schemas'
|
||||||
|
import { elevenlabsBlock } from '@typebot.io/elevenlabs-block'
|
||||||
|
import { elevenlabsCredentialsSchema } from '@typebot.io/elevenlabs-block/schemas'
|
||||||
|
import { mistralBlock } from '@typebot.io/mistral-block'
|
||||||
|
import { mistralCredentialsSchema } from '@typebot.io/mistral-block/schemas'
|
||||||
|
import { openRouterBlock } from '@typebot.io/open-router-block'
|
||||||
|
import { openRouterCredentialsSchema } from '@typebot.io/open-router-block/schemas'
|
||||||
|
import { openAIBlock } from '@typebot.io/openai-block'
|
||||||
|
import { openAICredentialsSchema } from '@typebot.io/openai-block/schemas'
|
||||||
|
import { qrCodeBlock } from '@typebot.io/qrcode-block'
|
||||||
|
import { qrCodeCredentialsSchema } from '@typebot.io/qrcode-block/schemas'
|
||||||
|
import { togetherAiBlock } from '@typebot.io/together-ai-block'
|
||||||
|
import { togetherAiCredentialsSchema } from '@typebot.io/together-ai-block/schemas'
|
||||||
|
import { zemanticAiBlock } from '@typebot.io/zemantic-ai-block'
|
||||||
|
import { zemanticAiCredentialsSchema } from '@typebot.io/zemantic-ai-block/schemas'
|
||||||
|
|
||||||
|
export const forgedCredentialsSchemas = {
|
||||||
|
[openAIBlock.id]: openAICredentialsSchema,
|
||||||
|
[zemanticAiBlock.id]: zemanticAiCredentialsSchema,
|
||||||
|
[calComBlock.id]: calComCredentialsSchema,
|
||||||
|
[chatNodeBlock.id]: chatNodeCredentialsSchema,
|
||||||
|
[qrCodeBlock.id]: qrCodeCredentialsSchema,
|
||||||
|
[difyAiBlock.id]: difyAiCredentialsSchema,
|
||||||
|
[mistralBlock.id]: mistralCredentialsSchema,
|
||||||
|
[elevenlabsBlock.id]: elevenlabsCredentialsSchema,
|
||||||
|
[anthropicBlock.id]: anthropicCredentialsSchema,
|
||||||
|
[togetherAiBlock.id]: togetherAiCredentialsSchema,
|
||||||
|
[openRouterBlock.id]: openRouterCredentialsSchema,
|
||||||
|
}
|
||||||
26
packages/forge/repository/definitions.ts
Normal file
26
packages/forge/repository/definitions.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
// Do not edit this file manually
|
||||||
|
import { anthropicBlock } from '@typebot.io/anthropic-block'
|
||||||
|
import { openRouterBlock } from '@typebot.io/open-router-block'
|
||||||
|
import { togetherAiBlock } from '@typebot.io/together-ai-block'
|
||||||
|
import { elevenlabsBlock } from '@typebot.io/elevenlabs-block'
|
||||||
|
import { difyAiBlock } from '@typebot.io/dify-ai-block'
|
||||||
|
import { mistralBlock } from '@typebot.io/mistral-block'
|
||||||
|
import { qrCodeBlock } from '@typebot.io/qrcode-block'
|
||||||
|
import { chatNodeBlock } from '@typebot.io/chat-node-block'
|
||||||
|
import { calComBlock } from '@typebot.io/cal-com-block'
|
||||||
|
import { zemanticAiBlock } from '@typebot.io/zemantic-ai-block'
|
||||||
|
import { openAIBlock } from '@typebot.io/openai-block'
|
||||||
|
|
||||||
|
export const forgedBlocks = {
|
||||||
|
[openAIBlock.id]: openAIBlock,
|
||||||
|
[zemanticAiBlock.id]: zemanticAiBlock,
|
||||||
|
[calComBlock.id]: calComBlock,
|
||||||
|
[chatNodeBlock.id]: chatNodeBlock,
|
||||||
|
[qrCodeBlock.id]: qrCodeBlock,
|
||||||
|
[difyAiBlock.id]: difyAiBlock,
|
||||||
|
[mistralBlock.id]: mistralBlock,
|
||||||
|
[elevenlabsBlock.id]: elevenlabsBlock,
|
||||||
|
[anthropicBlock.id]: anthropicBlock,
|
||||||
|
[togetherAiBlock.id]: togetherAiBlock,
|
||||||
|
[openRouterBlock.id]: openRouterBlock,
|
||||||
|
} as const
|
||||||
@@ -2,8 +2,21 @@
|
|||||||
"name": "@typebot.io/forge-repository",
|
"name": "@typebot.io/forge-repository",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.ts",
|
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "Baptiste Arnaud",
|
"author": "Baptiste Arnaud",
|
||||||
"license": "ISC"
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"@typebot.io/forge": "workspace:*",
|
||||||
|
"@typebot.io/openai-block": "workspace:*",
|
||||||
|
"@typebot.io/zemantic-ai-block": "workspace:*",
|
||||||
|
"@typebot.io/cal-com-block": "workspace:*",
|
||||||
|
"@typebot.io/chat-node-block": "workspace:*",
|
||||||
|
"@typebot.io/qrcode-block": "workspace:*",
|
||||||
|
"@typebot.io/dify-ai-block": "workspace:*",
|
||||||
|
"@typebot.io/mistral-block": "workspace:*",
|
||||||
|
"@typebot.io/elevenlabs-block": "workspace:*",
|
||||||
|
"@typebot.io/anthropic-block": "workspace:*",
|
||||||
|
"@typebot.io/together-ai-block": "workspace:*",
|
||||||
|
"@typebot.io/open-router-block": "workspace:*"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
36
packages/forge/repository/schemas.ts
Normal file
36
packages/forge/repository/schemas.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { anthropicBlock } from '@typebot.io/anthropic-block'
|
||||||
|
import { anthropicBlockSchema } from '@typebot.io/anthropic-block/schemas'
|
||||||
|
import { calComBlock } from '@typebot.io/cal-com-block'
|
||||||
|
import { calComBlockSchema } from '@typebot.io/cal-com-block/schemas'
|
||||||
|
import { chatNodeBlock } from '@typebot.io/chat-node-block'
|
||||||
|
import { chatNodeBlockSchema } from '@typebot.io/chat-node-block/schemas'
|
||||||
|
import { difyAiBlock } from '@typebot.io/dify-ai-block'
|
||||||
|
import { difyAiBlockSchema } from '@typebot.io/dify-ai-block/schemas'
|
||||||
|
import { elevenlabsBlock } from '@typebot.io/elevenlabs-block'
|
||||||
|
import { elevenlabsBlockSchema } from '@typebot.io/elevenlabs-block/schemas'
|
||||||
|
import { mistralBlock } from '@typebot.io/mistral-block'
|
||||||
|
import { mistralBlockSchema } from '@typebot.io/mistral-block/schemas'
|
||||||
|
import { openRouterBlock } from '@typebot.io/open-router-block'
|
||||||
|
import { openRouterBlockSchema } from '@typebot.io/open-router-block/schemas'
|
||||||
|
import { openAIBlock } from '@typebot.io/openai-block'
|
||||||
|
import { openAIBlockSchema } from '@typebot.io/openai-block/schemas'
|
||||||
|
import { qrCodeBlock } from '@typebot.io/qrcode-block'
|
||||||
|
import { qrCodeBlockSchema } from '@typebot.io/qrcode-block/schemas'
|
||||||
|
import { togetherAiBlock } from '@typebot.io/together-ai-block'
|
||||||
|
import { togetherAiBlockSchema } from '@typebot.io/together-ai-block/schemas'
|
||||||
|
import { zemanticAiBlock } from '@typebot.io/zemantic-ai-block'
|
||||||
|
import { zemanticAiBlockSchema } from '@typebot.io/zemantic-ai-block/schemas'
|
||||||
|
|
||||||
|
export const forgedBlockSchemas = {
|
||||||
|
[openAIBlock.id]: openAIBlockSchema,
|
||||||
|
[zemanticAiBlock.id]: zemanticAiBlockSchema,
|
||||||
|
[calComBlock.id]: calComBlockSchema,
|
||||||
|
[chatNodeBlock.id]: chatNodeBlockSchema,
|
||||||
|
[qrCodeBlock.id]: qrCodeBlockSchema,
|
||||||
|
[difyAiBlock.id]: difyAiBlockSchema,
|
||||||
|
[mistralBlock.id]: mistralBlockSchema,
|
||||||
|
[elevenlabsBlock.id]: elevenlabsBlockSchema,
|
||||||
|
[anthropicBlock.id]: anthropicBlockSchema,
|
||||||
|
[togetherAiBlock.id]: togetherAiBlockSchema,
|
||||||
|
[openRouterBlock.id]: openRouterBlockSchema,
|
||||||
|
}
|
||||||
10
packages/forge/repository/types.ts
Normal file
10
packages/forge/repository/types.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { z } from '@typebot.io/forge/zod'
|
||||||
|
import { forgedBlocks } from './definitions'
|
||||||
|
import { forgedBlockSchemas } from './schemas'
|
||||||
|
|
||||||
|
export type ForgedBlock = z.infer<
|
||||||
|
(typeof forgedBlockSchemas)[keyof typeof forgedBlockSchemas]
|
||||||
|
>
|
||||||
|
|
||||||
|
export type ForgedBlockDefinition =
|
||||||
|
(typeof forgedBlocks)[keyof typeof forgedBlocks]
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
// Do not edit this file manually
|
|
||||||
import { anthropic } from '@typebot.io/anthropic-block'
|
|
||||||
import { openRouter } from '@typebot.io/open-router-block'
|
|
||||||
import { togetherAi } from '@typebot.io/together-ai-block'
|
|
||||||
import { elevenlabs } from '@typebot.io/elevenlabs-block'
|
|
||||||
import { difyAi } from '@typebot.io/dify-ai-block'
|
|
||||||
import { mistral } from '@typebot.io/mistral-block'
|
|
||||||
import { qrCode } from '@typebot.io/qrcode-block'
|
|
||||||
import { chatNode } from '@typebot.io/chat-node-block'
|
|
||||||
import { calCom } from '@typebot.io/cal-com-block'
|
|
||||||
import { zemanticAi } from '@typebot.io/zemantic-ai-block'
|
|
||||||
import { openAIBlock } from '@typebot.io/openai-block'
|
|
||||||
import {
|
|
||||||
BlockDefinition,
|
|
||||||
parseBlockCredentials,
|
|
||||||
parseBlockSchema,
|
|
||||||
} from '@typebot.io/forge'
|
|
||||||
import { enabledBlocks } from '@typebot.io/forge-repository'
|
|
||||||
import { z } from '@typebot.io/forge/zod'
|
|
||||||
|
|
||||||
export const forgedBlocks = [
|
|
||||||
openAIBlock,
|
|
||||||
zemanticAi,
|
|
||||||
calCom,
|
|
||||||
chatNode,
|
|
||||||
qrCode,
|
|
||||||
difyAi,
|
|
||||||
mistral,
|
|
||||||
elevenlabs,
|
|
||||||
anthropic,
|
|
||||||
togetherAi,
|
|
||||||
openRouter,
|
|
||||||
] as BlockDefinition<(typeof enabledBlocks)[number], any, any>[]
|
|
||||||
|
|
||||||
export type ForgedBlockDefinition = (typeof forgedBlocks)[number]
|
|
||||||
|
|
||||||
export const forgedBlockSchemas = forgedBlocks.map(parseBlockSchema)
|
|
||||||
export type ForgedBlock = z.infer<(typeof forgedBlockSchemas)[number]>
|
|
||||||
|
|
||||||
export const forgedCredentialsSchemas = forgedBlocks
|
|
||||||
.filter((b) => b.auth)
|
|
||||||
.map(parseBlockCredentials)
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@typebot.io/forge-schemas",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "",
|
|
||||||
"main": "index.ts",
|
|
||||||
"keywords": [],
|
|
||||||
"author": "Baptiste Arnaud",
|
|
||||||
"license": "ISC",
|
|
||||||
"devDependencies": {
|
|
||||||
"@typebot.io/forge": "workspace:*",
|
|
||||||
"@typebot.io/forge-repository": "workspace:*",
|
|
||||||
"@typebot.io/openai-block": "workspace:*",
|
|
||||||
"@typebot.io/zemantic-ai-block": "workspace:*",
|
|
||||||
"@typebot.io/cal-com-block": "workspace:*",
|
|
||||||
"@typebot.io/chat-node-block": "workspace:*",
|
|
||||||
"@typebot.io/qrcode-block": "workspace:*",
|
|
||||||
"@typebot.io/dify-ai-block": "workspace:*",
|
|
||||||
"@typebot.io/mistral-block": "workspace:*",
|
|
||||||
"@typebot.io/elevenlabs-block": "workspace:*",
|
|
||||||
"@typebot.io/anthropic-block": "workspace:*",
|
|
||||||
"@typebot.io/together-ai-block": "workspace:*",
|
|
||||||
"@typebot.io/open-router-block": "workspace:*"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,6 @@
|
|||||||
"@paralleldrive/cuid2": "2.2.1",
|
"@paralleldrive/cuid2": "2.2.1",
|
||||||
"@playwright/test": "1.36.0",
|
"@playwright/test": "1.36.0",
|
||||||
"@typebot.io/env": "workspace:*",
|
"@typebot.io/env": "workspace:*",
|
||||||
"@typebot.io/forge-repository": "workspace:*",
|
|
||||||
"@typebot.io/prisma": "workspace:*",
|
"@typebot.io/prisma": "workspace:*",
|
||||||
"@typebot.io/tsconfig": "workspace:*",
|
"@typebot.io/tsconfig": "workspace:*",
|
||||||
"@types/escape-html": "^1.0.4",
|
"@types/escape-html": "^1.0.4",
|
||||||
|
|||||||
9
packages/schemas/features/blocks/forged/helpers.ts
Normal file
9
packages/schemas/features/blocks/forged/helpers.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { forgedBlocks } from '@typebot.io/forge-repository/definitions'
|
||||||
|
import { ForgedBlock } from '@typebot.io/forge-repository/types'
|
||||||
|
import { Block } from '../schema'
|
||||||
|
|
||||||
|
export const isForgedBlock = (block: Block): block is ForgedBlock =>
|
||||||
|
block.type in forgedBlocks
|
||||||
|
export const isForgedBlockType = (
|
||||||
|
type: Block['type']
|
||||||
|
): type is ForgedBlock['type'] => type in forgedBlocks
|
||||||
@@ -6,7 +6,7 @@ import { bubbleBlockSchemas } from './bubbles/schema'
|
|||||||
import { LogicBlock, logicBlockSchemas } from './logic/schema'
|
import { LogicBlock, logicBlockSchemas } from './logic/schema'
|
||||||
import { InputBlock, inputBlockSchemas } from './inputs/schema'
|
import { InputBlock, inputBlockSchemas } from './inputs/schema'
|
||||||
import { IntegrationBlock, integrationBlockSchemas } from './integrations'
|
import { IntegrationBlock, integrationBlockSchemas } from './integrations'
|
||||||
import { enabledBlocks } from '@typebot.io/forge-repository'
|
import { forgedBlockSchemas } from '@typebot.io/forge-repository/schemas'
|
||||||
|
|
||||||
export type BlockWithOptions = Extract<Block, { options?: any }>
|
export type BlockWithOptions = Extract<Block, { options?: any }>
|
||||||
|
|
||||||
@@ -34,15 +34,8 @@ export const blockSchemaV6 = z
|
|||||||
...inputBlockSchemas.v6,
|
...inputBlockSchemas.v6,
|
||||||
...logicBlockSchemas.v6,
|
...logicBlockSchemas.v6,
|
||||||
...integrationBlockSchemas.v6,
|
...integrationBlockSchemas.v6,
|
||||||
|
...Object.values(forgedBlockSchemas),
|
||||||
])
|
])
|
||||||
.or(
|
|
||||||
blockBaseSchema.merge(
|
|
||||||
z.object({
|
|
||||||
type: z.enum(enabledBlocks),
|
|
||||||
options: z.any().optional(),
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.openapi({
|
.openapi({
|
||||||
title: 'Block',
|
title: 'Block',
|
||||||
ref: 'block',
|
ref: 'block',
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { enabledBlocks } from '@typebot.io/forge-repository'
|
import { forgedBlockIds } from '@typebot.io/forge-repository/constants'
|
||||||
import {
|
import {
|
||||||
Block,
|
Block,
|
||||||
InputBlock,
|
InputBlock,
|
||||||
@@ -62,9 +62,7 @@ export const isConditionBlock = (block: Block): block is ConditionBlock =>
|
|||||||
|
|
||||||
export const isIntegrationBlock = (block: Block): block is IntegrationBlock =>
|
export const isIntegrationBlock = (block: Block): block is IntegrationBlock =>
|
||||||
(
|
(
|
||||||
Object.values(IntegrationBlockType).concat(
|
Object.values(IntegrationBlockType).concat(forgedBlockIds as any[]) as any[]
|
||||||
enabledBlocks as readonly any[]
|
|
||||||
) as any[]
|
|
||||||
).includes(block.type)
|
).includes(block.type)
|
||||||
|
|
||||||
export const isWebhookBlock = (block: Block): block is HttpRequestBlock =>
|
export const isWebhookBlock = (block: Block): block is HttpRequestBlock =>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { Variable } from '@typebot.io/schemas'
|
|
||||||
import {
|
import {
|
||||||
defaultParseVariablesOptions,
|
defaultParseVariablesOptions,
|
||||||
parseVariables,
|
parseVariables,
|
||||||
ParseVariablesOptions,
|
ParseVariablesOptions,
|
||||||
} from './parseVariables'
|
} from './parseVariables'
|
||||||
import { parseGuessedTypeFromString } from './parseGuessedTypeFromString'
|
import { parseGuessedTypeFromString } from './parseGuessedTypeFromString'
|
||||||
|
import { Variable } from './types'
|
||||||
|
|
||||||
type DeepParseOptions = {
|
type DeepParseOptions = {
|
||||||
guessCorrectTypes?: boolean
|
guessCorrectTypes?: boolean
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { Variable } from '@typebot.io/schemas'
|
|
||||||
import { parseVariables } from './parseVariables'
|
import { parseVariables } from './parseVariables'
|
||||||
import { extractVariablesFromText } from './extractVariablesFromText'
|
import { extractVariablesFromText } from './extractVariablesFromText'
|
||||||
import { parseGuessedValueType } from './parseGuessedValueType'
|
import { parseGuessedValueType } from './parseGuessedValueType'
|
||||||
import { isDefined } from '@typebot.io/lib'
|
import { isDefined } from '@typebot.io/lib'
|
||||||
import { defaultTimeout } from '@typebot.io/schemas/features/blocks/integrations/webhook/constants'
|
|
||||||
import { safeStringify } from '@typebot.io/lib/safeStringify'
|
import { safeStringify } from '@typebot.io/lib/safeStringify'
|
||||||
|
import { Variable } from './types'
|
||||||
|
|
||||||
|
const defaultTimeout = 10
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
variables: Variable[]
|
variables: Variable[]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Variable } from '@typebot.io/schemas'
|
import { Variable } from './types'
|
||||||
|
|
||||||
export const extractVariablesFromText =
|
export const extractVariablesFromText =
|
||||||
(variables: Variable[]) =>
|
(variables: Variable[]) =>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Variable } from '@typebot.io/schemas'
|
import { Variable } from './types'
|
||||||
|
|
||||||
export const findUniqueVariableValue =
|
export const findUniqueVariableValue =
|
||||||
(variables: Variable[]) =>
|
(variables: Variable[]) =>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Result, Variable } from '@typebot.io/schemas'
|
import { Variable } from './types'
|
||||||
|
|
||||||
export const injectVariablesFromExistingResult = (
|
export const injectVariablesFromExistingResult = (
|
||||||
variables: Variable[],
|
variables: Variable[],
|
||||||
resultVariables: Result['variables']
|
resultVariables: any[]
|
||||||
): Variable[] =>
|
): Variable[] =>
|
||||||
variables.map((variable) => {
|
variables.map((variable) => {
|
||||||
const resultVariable = resultVariables.find(
|
const resultVariable = resultVariables.find(
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typebot.io/lib": "workspace:*",
|
"@typebot.io/lib": "workspace:*"
|
||||||
"@typebot.io/schemas": "workspace:*"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Variable } from '@typebot.io/schemas'
|
import { Variable } from './types'
|
||||||
|
|
||||||
export const parseGuessedValueType = (
|
export const parseGuessedValueType = (
|
||||||
value: Variable['value']
|
value: Variable['value']
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Variable } from '@typebot.io/schemas'
|
|
||||||
import { parseGuessedValueType } from './parseGuessedValueType'
|
import { parseGuessedValueType } from './parseGuessedValueType'
|
||||||
import { parseVariables } from './parseVariables'
|
import { parseVariables } from './parseVariables'
|
||||||
|
import { Variable } from './types'
|
||||||
|
|
||||||
export const parseVariableNumber =
|
export const parseVariableNumber =
|
||||||
(variables: Variable[]) =>
|
(variables: Variable[]) =>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { safeStringify } from '@typebot.io/lib/safeStringify'
|
import { safeStringify } from '@typebot.io/lib/safeStringify'
|
||||||
import { isDefined, isNotDefined } from '@typebot.io/lib/utils'
|
import { isDefined, isNotDefined } from '@typebot.io/lib/utils'
|
||||||
import { Variable, VariableWithValue } from '@typebot.io/schemas'
|
|
||||||
import { parseGuessedValueType } from './parseGuessedValueType'
|
import { parseGuessedValueType } from './parseGuessedValueType'
|
||||||
|
import { Variable, VariableWithValue } from './types'
|
||||||
|
|
||||||
export type ParseVariablesOptions = {
|
export type ParseVariablesOptions = {
|
||||||
fieldToParse?: 'value' | 'id'
|
fieldToParse?: 'value' | 'id'
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { safeStringify } from '@typebot.io/lib/safeStringify'
|
import { safeStringify } from '@typebot.io/lib/safeStringify'
|
||||||
import { StartChatInput, Variable } from '@typebot.io/schemas'
|
import { Variable } from './types'
|
||||||
|
|
||||||
export const prefillVariables = (
|
export const prefillVariables = (
|
||||||
variables: Variable[],
|
variables: Variable[],
|
||||||
prefilledVariables: NonNullable<StartChatInput['prefilledVariables']>
|
prefilledVariables: Record<string, any>
|
||||||
): Variable[] =>
|
): Variable[] =>
|
||||||
variables.map((variable) => {
|
variables.map((variable) => {
|
||||||
const prefilledVariable = prefilledVariables[variable.name]
|
const prefilledVariable = prefilledVariables[variable.name]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { isNotDefined } from '@typebot.io/lib/utils'
|
import { isNotDefined } from '@typebot.io/lib/utils'
|
||||||
import { Variable, VariableWithValue } from '@typebot.io/schemas'
|
import { Variable, VariableWithValue } from './types'
|
||||||
|
|
||||||
export const transformVariablesToList =
|
export const transformVariablesToList =
|
||||||
(variables: Variable[]) =>
|
(variables: Variable[]) =>
|
||||||
|
|||||||
13
packages/variables/types.ts
Normal file
13
packages/variables/types.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
export type Variable = {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
value?: string | (string | null)[] | null | undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
export type VariableWithValue = Pick<Variable, 'id' | 'name'> & {
|
||||||
|
value: string | (string | null)[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export type VariableWithUnknowValue = Pick<Variable, 'id' | 'name'> & {
|
||||||
|
value?: unknown
|
||||||
|
}
|
||||||
@@ -1,26 +1,22 @@
|
|||||||
import { safeStringify } from '@typebot.io/lib/safeStringify'
|
import { safeStringify } from '@typebot.io/lib/safeStringify'
|
||||||
import {
|
import { Variable, VariableWithUnknowValue } from './types'
|
||||||
SessionState,
|
|
||||||
VariableWithUnknowValue,
|
|
||||||
Variable,
|
|
||||||
} from '@typebot.io/schemas'
|
|
||||||
|
|
||||||
export const updateVariablesInSession =
|
export const updateVariablesInSession =
|
||||||
(state: SessionState) =>
|
(state: any) => (newVariables: VariableWithUnknowValue[]) => ({
|
||||||
(newVariables: VariableWithUnknowValue[]): SessionState => ({
|
|
||||||
...state,
|
...state,
|
||||||
typebotsQueue: state.typebotsQueue.map((typebotInQueue, index) =>
|
typebotsQueue: state.typebotsQueue.map(
|
||||||
index === 0
|
(typebotInQueue: { typebot: { variables: Variable[] } }, index: number) =>
|
||||||
? {
|
index === 0
|
||||||
...typebotInQueue,
|
? {
|
||||||
typebot: {
|
...typebotInQueue,
|
||||||
...typebotInQueue.typebot,
|
typebot: {
|
||||||
variables: updateTypebotVariables(typebotInQueue.typebot)(
|
...typebotInQueue.typebot,
|
||||||
newVariables
|
variables: updateTypebotVariables(typebotInQueue.typebot)(
|
||||||
),
|
newVariables
|
||||||
},
|
),
|
||||||
}
|
},
|
||||||
: typebotInQueue
|
}
|
||||||
|
: typebotInQueue
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
54
pnpm-lock.yaml
generated
54
pnpm-lock.yaml
generated
@@ -285,9 +285,6 @@ importers:
|
|||||||
'@typebot.io/forge-repository':
|
'@typebot.io/forge-repository':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../../packages/forge/repository
|
version: link:../../packages/forge/repository
|
||||||
'@typebot.io/forge-schemas':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../../packages/forge/schemas
|
|
||||||
'@typebot.io/lib':
|
'@typebot.io/lib':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../../packages/lib
|
version: link:../../packages/lib
|
||||||
@@ -569,9 +566,6 @@ importers:
|
|||||||
'@typebot.io/forge-repository':
|
'@typebot.io/forge-repository':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../../packages/forge/repository
|
version: link:../../packages/forge/repository
|
||||||
'@typebot.io/forge-schemas':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../../packages/forge/schemas
|
|
||||||
'@typebot.io/lib':
|
'@typebot.io/lib':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../../packages/lib
|
version: link:../../packages/lib
|
||||||
@@ -742,9 +736,6 @@ importers:
|
|||||||
'@typebot.io/forge-repository':
|
'@typebot.io/forge-repository':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../forge/repository
|
version: link:../forge/repository
|
||||||
'@typebot.io/forge-schemas':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../forge/schemas
|
|
||||||
'@types/nodemailer':
|
'@types/nodemailer':
|
||||||
specifier: 6.4.8
|
specifier: 6.4.8
|
||||||
version: 6.4.8
|
version: 6.4.8
|
||||||
@@ -963,9 +954,6 @@ importers:
|
|||||||
'@rollup/plugin-terser':
|
'@rollup/plugin-terser':
|
||||||
specifier: 0.4.3
|
specifier: 0.4.3
|
||||||
version: 0.4.3(rollup@3.26.2)
|
version: 0.4.3(rollup@3.26.2)
|
||||||
'@rollup/plugin-typescript':
|
|
||||||
specifier: 11.1.2
|
|
||||||
version: 11.1.2(rollup@3.26.2)(tslib@2.6.0)(typescript@5.3.2)
|
|
||||||
'@typebot.io/bot-engine':
|
'@typebot.io/bot-engine':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../../bot-engine
|
version: link:../../bot-engine
|
||||||
@@ -1045,9 +1033,6 @@ importers:
|
|||||||
'@rollup/plugin-terser':
|
'@rollup/plugin-terser':
|
||||||
specifier: 0.4.3
|
specifier: 0.4.3
|
||||||
version: 0.4.3(rollup@3.26.2)
|
version: 0.4.3(rollup@3.26.2)
|
||||||
'@rollup/plugin-typescript':
|
|
||||||
specifier: 11.1.2
|
|
||||||
version: 11.1.2(rollup@3.26.2)(tslib@2.6.0)(typescript@5.3.2)
|
|
||||||
'@typebot.io/js':
|
'@typebot.io/js':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../js
|
version: link:../js
|
||||||
@@ -1118,9 +1103,6 @@ importers:
|
|||||||
'@rollup/plugin-terser':
|
'@rollup/plugin-terser':
|
||||||
specifier: 0.4.3
|
specifier: 0.4.3
|
||||||
version: 0.4.3(rollup@3.26.2)
|
version: 0.4.3(rollup@3.26.2)
|
||||||
'@rollup/plugin-typescript':
|
|
||||||
specifier: 11.1.2
|
|
||||||
version: 11.1.2(rollup@3.26.2)(tslib@2.6.0)(typescript@5.3.2)
|
|
||||||
'@typebot.io/js':
|
'@typebot.io/js':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../js
|
version: link:../js
|
||||||
@@ -1488,9 +1470,6 @@ importers:
|
|||||||
specifier: 3.22.4
|
specifier: 3.22.4
|
||||||
version: 3.22.4
|
version: 3.22.4
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@typebot.io/forge-repository':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../repository
|
|
||||||
'@typebot.io/tsconfig':
|
'@typebot.io/tsconfig':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../../tsconfig
|
version: link:../../tsconfig
|
||||||
@@ -1498,9 +1477,7 @@ importers:
|
|||||||
specifier: 18.2.15
|
specifier: 18.2.15
|
||||||
version: 18.2.15
|
version: 18.2.15
|
||||||
|
|
||||||
packages/forge/repository: {}
|
packages/forge/repository:
|
||||||
|
|
||||||
packages/forge/schemas:
|
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@typebot.io/anthropic-block':
|
'@typebot.io/anthropic-block':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
@@ -1520,9 +1497,6 @@ importers:
|
|||||||
'@typebot.io/forge':
|
'@typebot.io/forge':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../core
|
version: link:../core
|
||||||
'@typebot.io/forge-repository':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../repository
|
|
||||||
'@typebot.io/mistral-block':
|
'@typebot.io/mistral-block':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../blocks/mistral
|
version: link:../blocks/mistral
|
||||||
@@ -1620,9 +1594,6 @@ importers:
|
|||||||
'@typebot.io/env':
|
'@typebot.io/env':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../env
|
version: link:../env
|
||||||
'@typebot.io/forge-repository':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../forge/repository
|
|
||||||
'@typebot.io/prisma':
|
'@typebot.io/prisma':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../prisma
|
version: link:../prisma
|
||||||
@@ -1886,9 +1857,6 @@ importers:
|
|||||||
'@typebot.io/lib':
|
'@typebot.io/lib':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../lib
|
version: link:../lib
|
||||||
'@typebot.io/schemas':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../schemas
|
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
@@ -8722,26 +8690,6 @@ packages:
|
|||||||
terser: 5.29.1
|
terser: 5.29.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@rollup/plugin-typescript@11.1.2(rollup@3.26.2)(tslib@2.6.0)(typescript@5.3.2):
|
|
||||||
resolution: {integrity: sha512-0ghSOCMcA7fl1JM+0gYRf+Q/HWyg+zg7/gDSc+fRLmlJWcW5K1I+CLRzaRhXf4Y3DRyPnnDo4M2ktw+a6JcDEg==}
|
|
||||||
engines: {node: '>=14.0.0'}
|
|
||||||
peerDependencies:
|
|
||||||
rollup: ^2.14.0||^3.0.0
|
|
||||||
tslib: '*'
|
|
||||||
typescript: '>=3.7.0'
|
|
||||||
peerDependenciesMeta:
|
|
||||||
rollup:
|
|
||||||
optional: true
|
|
||||||
tslib:
|
|
||||||
optional: true
|
|
||||||
dependencies:
|
|
||||||
'@rollup/pluginutils': 5.1.0(rollup@3.26.2)
|
|
||||||
resolve: 1.22.8
|
|
||||||
rollup: 3.26.2
|
|
||||||
tslib: 2.6.0
|
|
||||||
typescript: 5.3.2
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/@rollup/pluginutils@5.1.0(rollup@2.78.0):
|
/@rollup/pluginutils@5.1.0(rollup@2.78.0):
|
||||||
resolution: {integrity: sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==}
|
resolution: {integrity: sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==}
|
||||||
engines: {node: '>=14.0.0'}
|
engines: {node: '>=14.0.0'}
|
||||||
|
|||||||
Reference in New Issue
Block a user