-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
217 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,5 @@ dump.tar | |
|
||
__env.js | ||
|
||
invalidTypebots.json | ||
typebotsToFix.json | ||
**/scripts/logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
import { PrismaClient } from 'db' | ||
import { readFileSync, writeFileSync } from 'fs' | ||
import { | ||
Block, | ||
BlockOptions, | ||
BlockType, | ||
defaultEmailInputOptions, | ||
Group, | ||
InputBlockType, | ||
Theme, | ||
Typebot, | ||
typebotSchema, | ||
} from 'models' | ||
import { isNotDefined } from 'utils' | ||
import { promptAndSetEnvironment } from './utils' | ||
import { detailedDiff } from 'deep-object-diff' | ||
|
||
const fixTypebot = (brokenTypebot: Typebot) => | ||
({ | ||
...brokenTypebot, | ||
theme: fixTheme(brokenTypebot.theme), | ||
groups: fixGroups(brokenTypebot.groups), | ||
} satisfies Typebot) | ||
|
||
const fixTheme = (brokenTheme: Theme) => | ||
({ | ||
...brokenTheme, | ||
chat: { | ||
...brokenTheme.chat, | ||
hostAvatar: brokenTheme.chat.hostAvatar | ||
? { | ||
isEnabled: brokenTheme.chat.hostAvatar.isEnabled, | ||
url: brokenTheme.chat.hostAvatar.url ?? undefined, | ||
} | ||
: undefined, | ||
}, | ||
} satisfies Theme) | ||
|
||
const fixGroups = (brokenGroups: Group[]) => | ||
brokenGroups.map( | ||
(brokenGroup, index) => | ||
({ | ||
...brokenGroup, | ||
graphCoordinates: { | ||
...brokenGroup.graphCoordinates, | ||
x: brokenGroup.graphCoordinates.x ?? 0, | ||
y: brokenGroup.graphCoordinates.y ?? 0, | ||
}, | ||
blocks: fixBlocks(brokenGroup.blocks, brokenGroup.id, index), | ||
} satisfies Group) | ||
) | ||
|
||
const fixBlocks = ( | ||
brokenBlocks: Block[], | ||
groupId: string, | ||
groupIndex: number | ||
) => { | ||
if (groupIndex === 0 && brokenBlocks.length > 1) return [brokenBlocks[0]] | ||
return brokenBlocks | ||
.filter((block) => block && Object.keys(block).length > 0) | ||
.map((brokenBlock) => { | ||
return removeUndefinedFromObject({ | ||
...brokenBlock, | ||
webhookId: | ||
('webhookId' in brokenBlock ? brokenBlock.webhookId : undefined) ?? | ||
('webhook' in brokenBlock && brokenBlock.webhook | ||
? //@ts-ignore | ||
brokenBlock.webhook.id | ||
: undefined), | ||
webhook: undefined, | ||
groupId: brokenBlock.groupId ?? groupId, | ||
options: | ||
brokenBlock && 'options' in brokenBlock && brokenBlock.options | ||
? fixBrokenBlockOption(brokenBlock.options, brokenBlock.type) | ||
: undefined, | ||
}) | ||
}) as Block[] | ||
} | ||
|
||
const fixBrokenBlockOption = (option: BlockOptions, blockType: BlockType) => | ||
removeUndefinedFromObject({ | ||
...option, | ||
sheetId: | ||
'sheetId' in option && option.sheetId | ||
? option.sheetId.toString() | ||
: 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, | ||
blockType | ||
), | ||
}) as BlockOptions | ||
|
||
const fixRetryMessageContent = ( | ||
retryMessageContent: string | undefined, | ||
blockType: BlockType | ||
) => { | ||
if (isNotDefined(retryMessageContent) && blockType === InputBlockType.EMAIL) | ||
return defaultEmailInputOptions.retryMessageContent | ||
if (isNotDefined(retryMessageContent)) return undefined | ||
return retryMessageContent | ||
} | ||
|
||
const removeUndefinedFromObject = (obj: any) => { | ||
Object.keys(obj).forEach((key) => obj[key] === undefined && delete obj[key]) | ||
return obj | ||
} | ||
|
||
const resolve = (path: string, obj: object, separator = '.') => { | ||
const properties = Array.isArray(path) ? path : path.split(separator) | ||
//@ts-ignore | ||
return properties.reduce((prev, curr) => prev?.[curr], obj) | ||
} | ||
|
||
const fixTypebots = async () => { | ||
await promptAndSetEnvironment() | ||
const prisma = new PrismaClient({ | ||
log: [{ emit: 'event', level: 'query' }, 'info', 'warn', 'error'], | ||
}) | ||
|
||
prisma.$on('query', (e) => { | ||
console.log(e.query) | ||
console.log(e.params) | ||
console.log(e.duration, 'ms') | ||
}) | ||
|
||
const typebots = JSON.parse(readFileSync('typebots.json', 'utf-8')) as any[] | ||
|
||
const total = typebots.length | ||
let totalFixed = 0 | ||
let progress = 0 | ||
const fixedTypebots: Typebot[] = [] | ||
const diffs: any[] = [] | ||
for (const typebot of typebots) { | ||
progress += 1 | ||
console.log( | ||
`Progress: ${progress}/${total} (${Math.round( | ||
(progress / total) * 100 | ||
)}%) (${totalFixed} fixed typebots)` | ||
) | ||
const parser = typebotSchema.safeParse({ | ||
...typebot, | ||
updatedAt: new Date(typebot.updatedAt), | ||
createdAt: new Date(typebot.createdAt), | ||
}) | ||
if ('error' in parser) { | ||
const fixedTypebot = { | ||
...fixTypebot(typebot), | ||
updatedAt: new Date(typebot.updatedAt), | ||
createdAt: new Date(typebot.createdAt), | ||
} | ||
fixedTypebots.push(fixedTypebot) | ||
totalFixed += 1 | ||
diffs.push({ | ||
id: typebot.id, | ||
failedObject: resolve( | ||
parser.error.issues[0].path.join('.'), | ||
fixedTypebot | ||
), | ||
...detailedDiff(typebot, fixedTypebot), | ||
}) | ||
} | ||
} | ||
writeFileSync('logs/fixedTypebots.json', JSON.stringify(fixedTypebots)) | ||
writeFileSync( | ||
'logs/diffs.json', | ||
JSON.stringify(diffs.reverse().slice(0, 100)) | ||
) | ||
} | ||
|
||
// 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
ad72557
There was a problem hiding this comment.
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:
landing-page-v2 – ./apps/landing-page
landing-page-v2-git-main-typebot-io.vercel.app
typebot.io
landing-page-v2-typebot-io.vercel.app
www.typebot.io
get-typebot.com
www.get-typebot.com
ad72557
There was a problem hiding this comment.
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
app.typebot.io
builder-v2-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app
ad72557
There was a problem hiding this comment.
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-git-main-typebot-io.vercel.app
docs-typebot-io.vercel.app
docs.typebot.io
ad72557
There was a problem hiding this comment.
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
forms.escoladeautomacao.com.br
viewer-v2-typebot-io.vercel.app
bot.studiotecnicoimmobiliaremerelli.it
viewer-v2-git-main-typebot-io.vercel.app
ad72557
There was a problem hiding this comment.
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
pant.maxbot.com.br
positivobra.com.br
survey.digienge.io
this-is-a-test.com
zap.techadviser.in
bot.digitalbled.com
bot.eventhub.com.au
bot.jepierre.com.br
bot.winglabs.com.br
carsalesenquiry.com
chatbot.repplai.com
demo.botscientis.us
forms.webisharp.com
kbsub.wpwakanda.com
live.botscientis.us
nutrisamirbayde.com
bot.truongnguyen.live
cdd.searchcube.com.sg
chat.missarkansas.org
chatbot.ownacademy.co
sbutton.wpwakanda.com
815639944.21000000.one
aplicacao.bmind.com.br
apply.ansuraniphone.my
bbutton.wpwwakanda.com
bot.louismarcondes.com
bot.t20worldcup.com.au
c23111azqw.nigerias.io
felipewelington.com.br
form.searchcube.com.sg
gcase.barrettamario.it
help.giversforgood.com
info.clickasuransi.com
kodawariab736.skeep.it
my.swamprecordsgnv.com
premium.kandabrand.com
report.gratirabbit.com
resume.gratirabbit.com
83242573.actualizar.xyz
bot.blackboxtips.com.br
bot.upgradesolutions.eu
help.comebackreward.com
mainmenu.diddancing.com
register.kandabrand.com
signup.hypemarketing.in
subfooter.wpwakanda.com
survey.hypemarketing.in
testbot.afterorigin.com
91181264.your-access.one
ai.chromebookstoreph.com
form.sergiolimajr.com.br
hunterbot.saleshunter.ai
link.cascadigital.com.br
onboarding.growthside.io
reward.onlinebotdemo.xyz
type.opaulovieira.com.br
aibot.angrybranding.co.uk
bot.aidigitalmarketing.kr
bot.arraesecenteno.com.br
bot.blackboxsports.com.br
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