MCPcopy
hub / github.com/CapSoftware/Cap / doubleConfirm

Function doubleConfirm

scripts/analytics/delete-all-data.js:27–75  ·  view source on GitHub ↗
({
	workspaceName,
	workspaceId,
	host,
	datasources,
})

Source from the content-addressed store, hash-verified

25}
26
27async function doubleConfirm({
28 workspaceName,
29 workspaceId,
30 host,
31 datasources,
32}) {
33 const workspaceLabel =
34 workspaceName || workspaceId || new URL(host).host || "unknown-workspace";
35
36 intro("Delete ALL analytics data from Tinybird");
37 log.warn(
38 `This will TRUNCATE all datasources in the Tinybird workspace:\n` +
39 `- Workspace: ${workspaceLabel}\n` +
40 `- Host: ${host}\n` +
41 `- Datasources (${datasources.length}): ${datasources.join(", ")}`,
42 );
43
44 const first = await text({
45 message: `Type the workspace name or ID to confirm (${workspaceLabel})`,
46 placeholder: workspaceLabel,
47 defaultValue: "",
48 validate: (value) => {
49 if (!value) return "Required";
50 if (
51 value !== workspaceName &&
52 value !== workspaceId &&
53 value !== workspaceLabel
54 ) {
55 return "Value does not match the workspace name or ID";
56 }
57 },
58 });
59 if (isCancel(first)) {
60 outro("Cancelled.");
61 process.exit(0);
62 }
63
64 const second = await text({
65 message: 'Final confirmation: type "DELETE ALL" to proceed',
66 placeholder: "DELETE ALL",
67 defaultValue: "",
68 validate: (value) =>
69 value === "DELETE ALL" ? undefined : 'You must type "DELETE ALL"',
70 });
71 if (isCancel(second)) {
72 outro("Cancelled.");
73 process.exit(0);
74 }
75}
76
77async function deleteAllData() {
78 const auth = resolveTinybirdAuth();

Callers 1

deleteAllDataFunction · 0.85

Calls 1

textFunction · 0.50

Tested by

no test coverage detected