🚸 Loosen file import parsing strictness
This commit is contained in:
@@ -4,7 +4,6 @@ import {
|
|||||||
Fade,
|
Fade,
|
||||||
Flex,
|
Flex,
|
||||||
HStack,
|
HStack,
|
||||||
useColorMode,
|
|
||||||
useColorModeValue,
|
useColorModeValue,
|
||||||
VStack,
|
VStack,
|
||||||
} from '@chakra-ui/react'
|
} from '@chakra-ui/react'
|
||||||
@@ -20,7 +19,6 @@ import { useDrag } from '@use-gesture/react'
|
|||||||
import { ResizeHandle } from './ResizeHandle'
|
import { ResizeHandle } from './ResizeHandle'
|
||||||
|
|
||||||
export const PreviewDrawer = () => {
|
export const PreviewDrawer = () => {
|
||||||
const isDark = useColorMode().colorMode === 'dark'
|
|
||||||
const { save, isSavingLoading } = useTypebot()
|
const { save, isSavingLoading } = useTypebot()
|
||||||
const { setRightPanel } = useEditor()
|
const { setRightPanel } = useEditor()
|
||||||
const { setPreviewingBlock } = useGraph()
|
const { setPreviewingBlock } = useGraph()
|
||||||
@@ -69,7 +67,6 @@ export const PreviewDrawer = () => {
|
|||||||
<Fade in={isResizeHandleVisible}>
|
<Fade in={isResizeHandleVisible}>
|
||||||
<ResizeHandle
|
<ResizeHandle
|
||||||
{...useResizeHandleDrag()}
|
{...useResizeHandleDrag()}
|
||||||
isDark={isDark}
|
|
||||||
pos="absolute"
|
pos="absolute"
|
||||||
left="-7.5px"
|
left="-7.5px"
|
||||||
top={`calc(50% - ${headerHeight}px)`}
|
top={`calc(50% - ${headerHeight}px)`}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { FlexProps, Flex, useColorModeValue, Box } from '@chakra-ui/react'
|
import { FlexProps, Flex, useColorModeValue, Box } from '@chakra-ui/react'
|
||||||
|
|
||||||
export const ResizeHandle = (props: { isDark: boolean } & FlexProps) => {
|
export const ResizeHandle = (props: FlexProps) => {
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
w="15px"
|
w="15px"
|
||||||
|
|||||||
@@ -63,8 +63,10 @@ export const PublishButton = (props: ButtonProps) => {
|
|||||||
description: error.message,
|
description: error.message,
|
||||||
}),
|
}),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
|
refetchPublishedTypebot({
|
||||||
|
typebotId: typebot?.id as string,
|
||||||
|
})
|
||||||
if (!publishedTypebot) push(`/typebots/${query.typebotId}/share`)
|
if (!publishedTypebot) push(`/typebots/${query.typebotId}/share`)
|
||||||
refetchPublishedTypebot()
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -76,7 +78,6 @@ export const PublishButton = (props: ButtonProps) => {
|
|||||||
description: error.message,
|
description: error.message,
|
||||||
}),
|
}),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
if (!publishedTypebot) push(`/typebots/${query.typebotId}/share`)
|
|
||||||
refetchPublishedTypebot()
|
refetchPublishedTypebot()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { parseInvalidTypebot } from '@/features/typebot/helpers/parseInvalidTypebot'
|
import { parseInvalidTypebot } from '@/features/typebot/helpers/parseInvalidTypebot'
|
||||||
import { useToast } from '@/hooks/useToast'
|
import { useToast } from '@/hooks/useToast'
|
||||||
import { Button, ButtonProps, chakra } from '@chakra-ui/react'
|
import { Button, ButtonProps, chakra } from '@chakra-ui/react'
|
||||||
import { Typebot, typebotSchema } from '@typebot.io/schemas'
|
import { Typebot, typebotCreateSchema } from '@typebot.io/schemas'
|
||||||
import React, { ChangeEvent } from 'react'
|
import React, { ChangeEvent } from 'react'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -19,12 +19,9 @@ export const ImportTypebotFromFileButton = ({
|
|||||||
const file = e.target.files[0]
|
const file = e.target.files[0]
|
||||||
const fileContent = await readFile(file)
|
const fileContent = await readFile(file)
|
||||||
try {
|
try {
|
||||||
const typebot = typebotSchema
|
const typebot = typebotCreateSchema.parse(
|
||||||
.omit({
|
parseInvalidTypebot(JSON.parse(fileContent))
|
||||||
createdAt: true,
|
)
|
||||||
updatedAt: true,
|
|
||||||
})
|
|
||||||
.parse(parseInvalidTypebot(JSON.parse(fileContent)))
|
|
||||||
onNewTypebot(typebot as Typebot)
|
onNewTypebot(typebot as Typebot)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { Plan, WorkspaceRole } from '@typebot.io/prisma'
|
|||||||
import {
|
import {
|
||||||
defaultSettings,
|
defaultSettings,
|
||||||
defaultTheme,
|
defaultTheme,
|
||||||
|
typebotCreateSchema,
|
||||||
typebotSchema,
|
typebotSchema,
|
||||||
} from '@typebot.io/schemas'
|
} from '@typebot.io/schemas'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
@@ -31,22 +32,7 @@ export const createTypebot = authenticatedProcedure
|
|||||||
.input(
|
.input(
|
||||||
z.object({
|
z.object({
|
||||||
workspaceId: z.string(),
|
workspaceId: z.string(),
|
||||||
typebot: typebotSchema
|
typebot: typebotCreateSchema,
|
||||||
.pick({
|
|
||||||
name: true,
|
|
||||||
icon: true,
|
|
||||||
selectedThemeTemplateId: true,
|
|
||||||
groups: true,
|
|
||||||
theme: true,
|
|
||||||
settings: true,
|
|
||||||
folderId: true,
|
|
||||||
variables: true,
|
|
||||||
edges: true,
|
|
||||||
resultsTablePreferences: true,
|
|
||||||
publicId: true,
|
|
||||||
customDomain: true,
|
|
||||||
})
|
|
||||||
.partial(),
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.output(
|
.output(
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import prisma from '@/lib/prisma'
|
import prisma from '@/lib/prisma'
|
||||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||||
import { TRPCError } from '@trpc/server'
|
import { TRPCError } from '@trpc/server'
|
||||||
import { typebotSchema } from '@typebot.io/schemas'
|
import { typebotCreateSchema, typebotSchema } from '@typebot.io/schemas'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
import {
|
import {
|
||||||
isCustomDomainNotAvailable,
|
isCustomDomainNotAvailable,
|
||||||
@@ -25,23 +25,13 @@ export const updateTypebot = authenticatedProcedure
|
|||||||
.input(
|
.input(
|
||||||
z.object({
|
z.object({
|
||||||
typebotId: z.string(),
|
typebotId: z.string(),
|
||||||
typebot: typebotSchema
|
typebot: typebotCreateSchema.merge(
|
||||||
|
typebotSchema
|
||||||
.pick({
|
.pick({
|
||||||
name: true,
|
|
||||||
icon: true,
|
|
||||||
selectedThemeTemplateId: true,
|
|
||||||
groups: true,
|
|
||||||
theme: true,
|
|
||||||
settings: true,
|
|
||||||
folderId: true,
|
|
||||||
variables: true,
|
|
||||||
edges: true,
|
|
||||||
isClosed: true,
|
isClosed: true,
|
||||||
resultsTablePreferences: true,
|
|
||||||
publicId: true,
|
|
||||||
customDomain: true,
|
|
||||||
})
|
})
|
||||||
.partial(),
|
.partial()
|
||||||
|
),
|
||||||
updatedAt: z
|
updatedAt: z
|
||||||
.date()
|
.date()
|
||||||
.optional()
|
.optional()
|
||||||
|
|||||||
@@ -71,6 +71,23 @@ export const typebotSchema = z.object({
|
|||||||
isClosed: z.boolean(),
|
isClosed: z.boolean(),
|
||||||
}) satisfies z.ZodType<TypebotPrisma>
|
}) satisfies z.ZodType<TypebotPrisma>
|
||||||
|
|
||||||
|
export const typebotCreateSchema = typebotSchema
|
||||||
|
.pick({
|
||||||
|
name: true,
|
||||||
|
icon: true,
|
||||||
|
selectedThemeTemplateId: true,
|
||||||
|
groups: true,
|
||||||
|
theme: true,
|
||||||
|
settings: true,
|
||||||
|
folderId: true,
|
||||||
|
variables: true,
|
||||||
|
edges: true,
|
||||||
|
resultsTablePreferences: true,
|
||||||
|
publicId: true,
|
||||||
|
customDomain: true,
|
||||||
|
})
|
||||||
|
.partial()
|
||||||
|
|
||||||
export type Typebot = z.infer<typeof typebotSchema>
|
export type Typebot = z.infer<typeof typebotSchema>
|
||||||
export type Target = z.infer<typeof targetSchema>
|
export type Target = z.infer<typeof targetSchema>
|
||||||
export type Source = z.infer<typeof sourceSchema>
|
export type Source = z.infer<typeof sourceSchema>
|
||||||
|
|||||||
Reference in New Issue
Block a user