-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2385eaf
commit 7d6c964
Showing
7 changed files
with
199 additions
and
16 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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { PrismaClient } from '@typebot.io/prisma' | ||
import * as p from '@clack/prompts' | ||
import { promptAndSetEnvironment } from './utils' | ||
|
||
const destroyUser = async () => { | ||
await promptAndSetEnvironment('production') | ||
|
||
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 email = (await p.text({ | ||
message: 'User email?', | ||
})) as string | ||
|
||
if (!email || typeof email !== 'string') { | ||
console.log('No email provided') | ||
return | ||
} | ||
|
||
const workspaces = await prisma.workspace.findMany({ | ||
where: { | ||
members: { every: { user: { email } } }, | ||
}, | ||
include: { | ||
members: { select: { user: { select: { email: true } }, role: true } }, | ||
typebots: { | ||
select: { | ||
results: { | ||
select: { id: true }, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
console.log(`Found ${workspaces.length} workspaces`) | ||
|
||
const proceed = await p.confirm({ message: 'Proceed?' }) | ||
if (!proceed || typeof proceed !== 'boolean') { | ||
console.log('Aborting') | ||
return | ||
} | ||
|
||
for (const workspace of workspaces) { | ||
const hasResults = workspace.typebots.some((t) => t.results.length > 0) | ||
if (hasResults) { | ||
console.log( | ||
`Workspace ${workspace.name} has results. Deleting results first...`, | ||
workspace.typebots.filter((t) => t.results.length > 0) | ||
) | ||
console.log(JSON.stringify({ members: workspace.members }, null, 2)) | ||
const proceed = await p.confirm({ message: 'Proceed?' }) | ||
if (!proceed || typeof proceed !== 'boolean') { | ||
console.log('Aborting') | ||
return | ||
} | ||
} | ||
for (const typebot of workspace.typebots.filter( | ||
(t) => t.results.length > 0 | ||
)) { | ||
for (const result of typebot.results) { | ||
await prisma.result.deleteMany({ where: { id: result.id } }) | ||
} | ||
} | ||
await prisma.workspace.delete({ where: { id: workspace.id } }) | ||
} | ||
|
||
const user = await prisma.user.delete({ where: { email } }) | ||
|
||
console.log(`Deleted user ${JSON.stringify(user, null, 2)}`) | ||
} | ||
|
||
destroyUser() |
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,34 @@ | ||
import { PrismaClient } from '@typebot.io/prisma' | ||
import { promptAndSetEnvironment } from './utils' | ||
import * as p from '@clack/prompts' | ||
|
||
const updateTypebot = async () => { | ||
await promptAndSetEnvironment('production') | ||
|
||
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 typebotId = (await p.text({ | ||
message: 'Typebot ID?', | ||
})) as string | ||
|
||
const typebot = await prisma.typebot.update({ | ||
where: { | ||
id: typebotId, | ||
}, | ||
data: { | ||
riskLevel: -1, | ||
}, | ||
}) | ||
|
||
console.log(typebot) | ||
} | ||
|
||
updateTypebot() |
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,34 @@ | ||
import { PrismaClient } from '@typebot.io/prisma' | ||
import { promptAndSetEnvironment } from './utils' | ||
import * as p from '@clack/prompts' | ||
|
||
const updateTypebot = async () => { | ||
await promptAndSetEnvironment('production') | ||
|
||
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 workspaceId = (await p.text({ | ||
message: 'Workspace ID?', | ||
})) as string | ||
|
||
const workspace = await prisma.workspace.update({ | ||
where: { | ||
id: workspaceId, | ||
}, | ||
data: { | ||
isVerified: true, | ||
}, | ||
}) | ||
|
||
console.log(workspace) | ||
} | ||
|
||
updateTypebot() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.