Skip to content

Commit

Permalink
🐛 (sheets) Convert to base options before changing action
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jan 3, 2023
1 parent ca2c15d commit f4615d8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,29 @@ export const GoogleSheetsSettingsBody = ({
onOptionsChange({ ...options, sheetId })

const handleActionChange = (action: GoogleSheetsAction) => {
const baseOptions = {
credentialsId: options.credentialsId,
spreadsheetId: options.spreadsheetId,
sheetId: options.sheetId,
}
switch (action) {
case GoogleSheetsAction.GET: {
const newOptions: GoogleSheetsGetOptions = {
...options,
...baseOptions,
...defaultGoogleSheetsGetOptions,
}
return onOptionsChange({ ...newOptions })
}
case GoogleSheetsAction.INSERT_ROW: {
const newOptions: GoogleSheetsInsertRowOptions = {
...options,
...baseOptions,
...defaultGoogleSheetsInsertOptions,
}
return onOptionsChange({ ...newOptions })
}
case GoogleSheetsAction.UPDATE_ROW: {
const newOptions: GoogleSheetsUpdateRowOptions = {
...options,
...baseOptions,
...defaultGoogleSheetsUpdateOptions,
}
return onOptionsChange({ ...newOptions })
Expand Down
68 changes: 29 additions & 39 deletions packages/scripts/fixTypebots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
Group,
InputBlockType,
PublicTypebot,
publicTypebotSchema,
Theme,
Typebot,
typebotSchema,
} from 'models'
import { isNotDefined } from 'utils'
import { isDefined, isNotDefined } from 'utils'
import { promptAndSetEnvironment } from './utils'
import { detailedDiff } from 'deep-object-diff'

Expand Down Expand Up @@ -78,18 +78,22 @@ const fixBlocks = (
}) as Block[]
}

const fixBrokenBlockOption = (option: BlockOptions, blockType: BlockType) =>
const fixBrokenBlockOption = (options: BlockOptions, blockType: BlockType) =>
removeUndefinedFromObject({
...option,
...options,
sheetId:
'sheetId' in option && option.sheetId
? option.sheetId.toString()
'sheetId' in options && isDefined(options.sheetId)
? options.sheetId.toString()
: undefined,
step:
'step' in options && isDefined(options.step) ? options.step : undefined,
value:
'value' in options && isDefined(options.value)
? options.value
: undefined,
step: 'step' in option && option.step ? option.step : undefined,
value: 'value' in option && option.value ? option.value : undefined,
retryMessageContent: fixRetryMessageContent(
//@ts-ignore
option.retryMessageContent,
options.retryMessageContent,
blockType
),
}) as BlockOptions
Expand Down Expand Up @@ -121,7 +125,18 @@ const fixTypebots = async () => {
log: [{ emit: 'event', level: 'query' }, 'info', 'warn', 'error'],
})

const typebots = await prisma.publicTypebot.findMany()
const twoDaysAgo = new Date()
twoDaysAgo.setDate(twoDaysAgo.getDate() - 2)

const typebots = await prisma.typebot.findMany({
where: {
updatedAt: {
gte: twoDaysAgo,
},
},
})

writeFileSync('logs/typebots.json', JSON.stringify(typebots))

const total = typebots.length
let totalFixed = 0
Expand All @@ -135,26 +150,23 @@ const fixTypebots = async () => {
(progress / total) * 100
)}%) (${totalFixed} fixed typebots)`
)
const parser = publicTypebotSchema.safeParse({
const parser = typebotSchema.safeParse({
...typebot,
updatedAt: new Date(typebot.updatedAt),
createdAt: new Date(typebot.createdAt),
})
if ('error' in parser) {
const fixedTypebot = {
...fixTypebot(typebot as Typebot | PublicTypebot),
updatedAt: new Date(typebot.updatedAt),
updatedAt: new Date(),
createdAt: new Date(typebot.createdAt),
}
publicTypebotSchema.parse(fixedTypebot)
typebotSchema.parse(fixedTypebot)
fixedTypebots.push(fixedTypebot)
totalFixed += 1
diffs.push({
id: typebot.id,
failedObject: resolve(
parser.error.issues[0].path.join('.'),
fixedTypebot
),
failedObject: resolve(parser.error.issues[0].path.join('.'), typebot),
...detailedDiff(typebot, fixedTypebot),
})
}
Expand Down Expand Up @@ -184,26 +196,4 @@ const fixTypebots = async () => {
await prisma.$transaction(queries)
}

// export const parseZodError = (parser: any) => {
// if ('error' in parser) {
// console.log(
// parser.error.issues.map((issue) =>
// JSON.stringify({
// message: issue.message,
// path: issue.path,
// })
// )
// )
// writeFileSync(
// 'failedObject.json',
// JSON.stringify(
// resolve(parser.error.issues[0].path.join('.'), fixedTypebot)
// )
// )
// writeFileSync('failedTypebot.json', JSON.stringify(fixedTypebot))
// writeFileSync('issue.json', JSON.stringify(parser.error.issues))
// exit()
// }
// }

fixTypebots()

5 comments on commit f4615d8

@vercel
Copy link

@vercel vercel bot commented on f4615d8 Jan 3, 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 f4615d8 Jan 3, 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

bot.joof.it
yoda.riku.ai
bergamo.store
bot.tvbeat.it
app.yvon.earth
bots.bridge.ai
chat.hayuri.id
gollum.riku.ai
talk.gocare.io
bot.jesopizz.it
fitness.riku.ai
bot.contakit.com
zap.fundviser.in
bot.rihabilita.it
viewer.typebot.io
bot.danyservice.it
bot.boston-voip.com
bot.dsignagency.com
chatbot.matthesv.de
demo.wemakebots.xyz
88584434.therpm.club
92109660.therpm.club
bot.barrettamario.it
hello.advergreen.com
bot.coachayongzul.com
bot.digitalpointer.id
bot.eikju.photography
bot.outstandbrand.com
bot.robertohairlab.it
criar.somaperuzzo.com
bot.ilmuseoaiborghi.it
bot.pratikmandalia.com
form.bridesquadapp.com
michaeljackson.riku.ai
87656003.actualizar.xyz
88152257.actualizar.xyz
91375310.actualizar.xyz
arrivalx2.wpwakanda.com
bot.hotelplayarimini.it
link.venturasuceder.com
invite.bridesquadapp.com
bot.amicidisanfaustino.it
chat.thehomebuyersusa.com
forms.hiabhaykulkarni.com
typebot-viewer.vercel.app
bot.adventureconsulting.hu
casestudyemb.wpwakanda.com
chat.atlasoutfittersk9.com
herbalife.barrettamario.it
homepageonly.wpwakanda.com
liveconvert.kandalearn.com
mainmenu1one.wpwakanda.com
tarian.theiofoundation.org
bot.pinpointinteractive.com
bot.polychromes-project.com
bot.seidinembroseanchetu.it
liveconvert2.kandalearn.com
bot.seidibergamoseanchetu.it
desabafe.sergiolimajr.com.br
forms.escoladeautomacao.com.br
viewer-v2-typebot-io.vercel.app
bot.studiotecnicoimmobiliaremerelli.it
viewer-v2-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on f4615d8 Jan 3, 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-alpha – ./apps/viewer

ns8.vn
yobot.me
247987.com
8jours.top
bee.cr8.ai
bot.aws.bj
bot.bbc.bj
cat.cr8.ai
finplex.be
pig.cr8.ai
sat.cr8.ai
bot.aipr.kr
docs.cr8.ai
minipost.uk
mole.cr8.ai
team.cr8.ai
bot.artiweb.app
bot.devitus.com
bot.tc-mail.com
chat.sureb4.com
eventhub.com.au
games.klujo.com
sakuranembro.it
typebot.aloe.do
bot.piccinato.co
bot.sv-energy.it
botc.ceox.com.br
clo.closeer.work
cockroach.cr8.ai
faqs.nigerias.io
feedback.ofx.one
form.syncwin.com
kw.wpwakanda.com
myrentalhost.com
stan.vselise.com
start.taxtree.io
typebot.aloe.bot
voicehelp.cr8.ai
app.chatforms.net
bot.agfunnel.tech
bot.hostnation.de
bot.maitempah.com
bot.phuonghub.com
bot.reviewzer.com
cares.urlabout.me
fmm.wpwakanda.com
gentleman-shop.fr
k1.kandabrand.com
lb.ticketfute.com
ov1.wpwakanda.com
ov2.wpwakanda.com
ov3.wpwakanda.com
1988.bouclidom.com
andreimayer.com.br
bot.megafox.com.br
bot.neferlopez.com
bots.robomotion.io
cadu.uninta.edu.br
dicanatural.online
goalsettingbot.com
bot.cabinrentalagency.com
bot.fusionstarreviews.com
boyfriend-breakup.riku.ai
brigadeirosemdrama.com.br
chat.ertcrebateportal.com
chat.thisiscrushhouse.com
sellmyharleylouisiana.com
verfica.botmachine.com.br
configurator.bouclidom.com
help.atlasoutfittersk9.com
ted.meujalecobrasil.com.br
type.dericsoncalari.com.br
chatbot.berbelanjabiz.trade
designguide.techyscouts.com
presente.empresarias.com.mx
sell.sellthemotorhome.co.uk
anamnese.odontopavani.com.br
austin.channelautomation.com
bot.marketingplusmindset.com
piazzatorre.barrettamario.it
requests.swamprecordsgnv.com
type.cookieacademyonline.com
bot.brigadeirosemdrama.com.br
onboarding.libertydreamcare.ie
type.talitasouzamarques.com.br
agendamento.sergiolimajr.com.br
anamnese.clinicamegasjdr.com.br
bookings.littlepartymonkeys.com
bot.comercializadoraomicron.com
elevateyourmind.groovepages.com
yourfeedback.comebackreward.com
personal-trainer.barrettamario.it
preagendamento.sergiolimajr.com.br
studiotecnicoimmobiliaremerelli.it
download.thailandmicespecialist.com
register.thailandmicespecialist.com
viewer-v2-alpha-typebot-io.vercel.app
pesquisa.escolamodacomproposito.com.br
anamnese.clinicaramosodontologia.com.br
viewer-v2-alpha-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on f4615d8 Jan 3, 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-git-main-typebot-io.vercel.app
docs.typebot.io

@vercel
Copy link

@vercel vercel bot commented on f4615d8 Jan 3, 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
builder-v2-git-main-typebot-io.vercel.app
app.typebot.io

Please sign in to comment.