Skip to content

Commit

Permalink
🚸 Loosen file import parsing strictness
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Aug 18, 2023
1 parent e2075d6 commit 19fc576
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
Fade,
Flex,
HStack,
useColorMode,
useColorModeValue,
VStack,
} from '@chakra-ui/react'
Expand All @@ -20,7 +19,6 @@ import { useDrag } from '@use-gesture/react'
import { ResizeHandle } from './ResizeHandle'

export const PreviewDrawer = () => {
const isDark = useColorMode().colorMode === 'dark'
const { save, isSavingLoading } = useTypebot()
const { setRightPanel } = useEditor()
const { setPreviewingBlock } = useGraph()
Expand Down Expand Up @@ -69,7 +67,6 @@ export const PreviewDrawer = () => {
<Fade in={isResizeHandleVisible}>
<ResizeHandle
{...useResizeHandleDrag()}
isDark={isDark}
pos="absolute"
left="-7.5px"
top={`calc(50% - ${headerHeight}px)`}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FlexProps, Flex, useColorModeValue, Box } from '@chakra-ui/react'

export const ResizeHandle = (props: { isDark: boolean } & FlexProps) => {
export const ResizeHandle = (props: FlexProps) => {
return (
<Flex
w="15px"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ export const PublishButton = (props: ButtonProps) => {
description: error.message,
}),
onSuccess: () => {
refetchPublishedTypebot({
typebotId: typebot?.id as string,
})
if (!publishedTypebot) push(`/typebots/${query.typebotId}/share`)
refetchPublishedTypebot()
},
})

Expand All @@ -76,7 +78,6 @@ export const PublishButton = (props: ButtonProps) => {
description: error.message,
}),
onSuccess: () => {
if (!publishedTypebot) push(`/typebots/${query.typebotId}/share`)
refetchPublishedTypebot()
},
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { parseInvalidTypebot } from '@/features/typebot/helpers/parseInvalidTypebot'
import { useToast } from '@/hooks/useToast'
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'

type Props = {
Expand All @@ -19,12 +19,9 @@ export const ImportTypebotFromFileButton = ({
const file = e.target.files[0]
const fileContent = await readFile(file)
try {
const typebot = typebotSchema
.omit({
createdAt: true,
updatedAt: true,
})
.parse(parseInvalidTypebot(JSON.parse(fileContent)))
const typebot = typebotCreateSchema.parse(
parseInvalidTypebot(JSON.parse(fileContent))
)
onNewTypebot(typebot as Typebot)
} catch (err) {
console.error(err)
Expand Down
18 changes: 2 additions & 16 deletions apps/builder/src/features/typebot/api/createTypebot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Plan, WorkspaceRole } from '@typebot.io/prisma'
import {
defaultSettings,
defaultTheme,
typebotCreateSchema,
typebotSchema,
} from '@typebot.io/schemas'
import { z } from 'zod'
Expand All @@ -31,22 +32,7 @@ export const createTypebot = authenticatedProcedure
.input(
z.object({
workspaceId: z.string(),
typebot: 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(),
typebot: typebotCreateSchema,
})
)
.output(
Expand Down
26 changes: 8 additions & 18 deletions apps/builder/src/features/typebot/api/updateTypebot.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import prisma from '@/lib/prisma'
import { authenticatedProcedure } from '@/helpers/server/trpc'
import { TRPCError } from '@trpc/server'
import { typebotSchema } from '@typebot.io/schemas'
import { typebotCreateSchema, typebotSchema } from '@typebot.io/schemas'
import { z } from 'zod'
import {
isCustomDomainNotAvailable,
Expand All @@ -25,23 +25,13 @@ export const updateTypebot = authenticatedProcedure
.input(
z.object({
typebotId: z.string(),
typebot: typebotSchema
.pick({
name: true,
icon: true,
selectedThemeTemplateId: true,
groups: true,
theme: true,
settings: true,
folderId: true,
variables: true,
edges: true,
isClosed: true,
resultsTablePreferences: true,
publicId: true,
customDomain: true,
})
.partial(),
typebot: typebotCreateSchema.merge(
typebotSchema
.pick({
isClosed: true,
})
.partial()
),
updatedAt: z
.date()
.optional()
Expand Down
17 changes: 17 additions & 0 deletions packages/schemas/features/typebot/typebot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,23 @@ export const typebotSchema = z.object({
isClosed: z.boolean(),
}) 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 Target = z.infer<typeof targetSchema>
export type Source = z.infer<typeof sourceSchema>
Expand Down

4 comments on commit 19fc576

@vercel
Copy link

@vercel vercel bot commented on 19fc576 Aug 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

desafioem21d.com
faqs.nigerias.io
feiraodehoje.com
georgemarttt.com
go.chatbotcv.com
haymanevents.com
kw.wpwakanda.com
localamor.online
lojamundobox.com
myrentalhost.com
silvercop.com.br
silvercop.online
stan.vselise.com
typebot.aloe.bot
vidalimentar.com
voicehelp.cr8.ai
web.bjogador.com
www.pantaflow.ai
zap.fundviser.in
analistamines.com
app.bouclidom.com
app.chatforms.net
appmillion.online
bot.cerograsa.com
bot.chatbotcv.com
bot.hostnation.de
bot.ketoolife.com
bot.maitempah.com
bot.phuonghub.com
bot.reviewamp.com
bot.reviewzer.com
bot.uluhub.com.br
cares.urlabout.me
chat.ezbooking.ai
chat.gaswadern.de
chat.gniorder.com
chat.onrentme.com
chat.rojie.online
chatdocidadao.com
chatwebonline.com
fmm.wpwakanda.com
footballmeetup.ie
gentleman-shop.fr
island.wakanda.is
k1.kandabrand.com
kp.pedroknoll.com
lb.ticketfute.com
metodoelev.com.br
nutriandreia.shop
ov1.wpwakanda.com
ov2.wpwakanda.com
ov3.wpwakanda.com
pcb.drapamela.com
redeemchatgpt.com
softwarelucra.com
support.triplo.ai
viewer.typebot.io
welcome.triplo.ai
www.thegymgame.it
zeropendencia.com
viewer-v2-typebot-io.vercel.app
mdb.assessoria.desideri.progenbr.com
mdb.assessoria.fernanda.progenbr.com
mdb.assessoria.jbatista.progenbr.com
mdb.assessoria.mauricio.progenbr.com
mdb.evento.autocadastro.progenbr.com
form.shopmercedesbenzsouthorlando.com
mdb.evento.equipeinterna.progenbr.com
bot.studiotecnicoimmobiliaremerelli.it
mdb.assessoria.boaventura.progenbr.com
mdb.assessoria.jtrebesqui.progenbr.com
pesquisa.escolamodacomproposito.com.br
anamnese.clinicaramosodontologia.com.br
gabinete.baleia.formulario.progenbr.com
mdb.assessoria.carreirinha.progenbr.com
chrome-os-inquiry-system.itschromeos.com
mdb.assessoria.paulomarques.progenbr.com
viewer-v2-git-main-typebot-io.vercel.app
main-menu-for-itschromeos.itschromeos.com
mdb.assessoria.qrcode.ademir.progenbr.com
mdb.assessoria.qrcode.arthur.progenbr.com
mdb.assessoria.qrcode.danilo.progenbr.com
mdb.assessoria.qrcode.marcao.progenbr.com
mdb.assessoria.qrcode.marcio.progenbr.com
mdb.assessoria.qrcode.aloisio.progenbr.com
mdb.assessoria.qrcode.girotto.progenbr.com
mdb.assessoria.qrcode.marinho.progenbr.com
mdb.assessoria.qrcode.rodrigo.progenbr.com
mdb.assessoria.carlosalexandre.progenbr.com
mdb.assessoria.qrcode.desideri.progenbr.com
mdb.assessoria.qrcode.fernanda.progenbr.com
mdb.assessoria.qrcode.jbatista.progenbr.com
mdb.assessoria.qrcode.mauricio.progenbr.com
mdb.assessoria.fernanda.regional.progenbr.com
mdb.assessoria.qrcode.boaventura.progenbr.com
mdb.assessoria.qrcode.jtrebesqui.progenbr.com
mdb.assessoria.qrcode.carreirinha.progenbr.com
mdb.assessoria.qrcode.paulomarques.progenbr.com
mdb.assessoria.qrcode.carlosalexandre.progenbr.com
mdb.assessoria.qrcode.fernanda.regional.progenbr.com

@vercel
Copy link

@vercel vercel bot commented on 19fc576 Aug 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-typebot-io.vercel.app
app.typebot.io
builder-v2-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 19fc576 Aug 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 19fc576 Aug 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-typebot-io.vercel.app
docs.typebot.io
docs-git-main-typebot-io.vercel.app

Please sign in to comment.