MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / deleteOrganization

Function deleteOrganization

admin/src/commands/delete-organization.ts:20–215  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18}
19
20export async function deleteOrganization() {
21 console.log(chalk.red('\n🗑️ Delete Organization\n'));
22 console.log(
23 chalk.yellow(
24 '⚠️ WARNING: This will permanently delete the organization and all its data!\n',
25 ),
26 );
27 console.log('Loading organizations...\n');
28
29 const organizations = await db.organization.findMany({
30 include: {
31 projects: true,
32 members: {
33 include: {
34 user: true,
35 },
36 },
37 },
38 orderBy: {
39 name: 'asc',
40 },
41 });
42
43 if (organizations.length === 0) {
44 console.log(chalk.red('No organizations found.'));
45 return;
46 }
47
48 const searchItems: OrgSearchItem[] = organizations.map((org) => ({
49 id: org.id,
50 name: org.name,
51 displayText: `${org.name} ${chalk.gray(`(${org.id})`)} ${chalk.cyan(`- ${org.projects.length} projects, ${org.members.length} members`)}`,
52 }));
53
54 const searchFunction = async (_answers: unknown, input = '') => {
55 const fuzzyResult = fuzzy.filter(input, searchItems, {
56 extract: (item: OrgSearchItem) => `${item.name} ${item.id}`,
57 });
58
59 return fuzzyResult.map((result: fuzzy.FilterResult<OrgSearchItem>) => ({
60 name: result.original.displayText,
61 value: result.original,
62 }));
63 };
64
65 const { selectedOrg } = (await inquirer.prompt([
66 {
67 type: 'autocomplete',
68 name: 'selectedOrg',
69 message: 'Search for an organization to delete:',
70 source: searchFunction,
71 pageSize: 15,
72 },
73 ])) as { selectedOrg: OrgSearchItem };
74
75 // Fetch full organization details
76 const organization = await db.organization.findUnique({
77 where: {

Callers 1

mainFunction · 0.90

Calls 4

deleteFromClickhouseFunction · 0.90
logMethod · 0.45
mapMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected