@graphit/cli 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skill/SKILL.md +70 -20
- package/skill/cursor/graphit-chart-patterns.mdc +67 -129
- package/skill/graphit.mdc +62 -80
- package/skill/references/chart-patterns.md +66 -128
- package/dist/api/client.d.ts +0 -16
- package/dist/api/client.js +0 -67
- package/dist/api/client.js.map +0 -1
- package/dist/auth/credentials.d.ts +0 -15
- package/dist/auth/credentials.js +0 -34
- package/dist/auth/credentials.js.map +0 -1
- package/dist/auth/login.d.ts +0 -2
- package/dist/auth/login.js +0 -229
- package/dist/auth/login.js.map +0 -1
- package/dist/auth/token.d.ts +0 -5
- package/dist/auth/token.js +0 -42
- package/dist/auth/token.js.map +0 -1
- package/dist/commands/auth.d.ts +0 -2
- package/dist/commands/auth.js +0 -68
- package/dist/commands/auth.js.map +0 -1
- package/dist/commands/connector.d.ts +0 -2
- package/dist/commands/connector.js +0 -97
- package/dist/commands/connector.js.map +0 -1
- package/dist/commands/dashboard.d.ts +0 -2
- package/dist/commands/dashboard.js +0 -124
- package/dist/commands/dashboard.js.map +0 -1
- package/dist/commands/ds.d.ts +0 -2
- package/dist/commands/ds.js +0 -53
- package/dist/commands/ds.js.map +0 -1
- package/dist/commands/kb.d.ts +0 -2
- package/dist/commands/kb.js +0 -259
- package/dist/commands/kb.js.map +0 -1
- package/dist/commands/query.d.ts +0 -2
- package/dist/commands/query.js +0 -61
- package/dist/commands/query.js.map +0 -1
- package/dist/commands/setup.d.ts +0 -2
- package/dist/commands/setup.js +0 -173
- package/dist/commands/setup.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -24
- package/dist/index.js.map +0 -1
- package/dist/output/format.d.ts +0 -8
- package/dist/output/format.js +0 -30
- package/dist/output/format.js.map +0 -1
- package/dist/output/json.d.ts +0 -1
- package/dist/output/json.js +0 -4
- package/dist/output/json.js.map +0 -1
- package/dist/output/table.d.ts +0 -2
- package/dist/output/table.js +0 -17
- package/dist/output/table.js.map +0 -1
package/dist/auth/token.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../src/auth/token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAErE,MAAM,kBAAkB,GAAG,6CAA6C,CAAC;AACzE,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,yCAAyC,CAAC;AAC3G,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAOhC,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,MAAM,KAAK,GAAG,MAAM,eAAe,EAAE,CAAC;IACtC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IAED,IACE,KAAK,CAAC,QAAQ;QACd,KAAK,CAAC,eAAe;QACrB,KAAK,CAAC,eAAe,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,oBAAoB,EAChE,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IAC9D,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,KAAK,CACtB,GAAG,kBAAkB,QAAQ,gBAAgB,EAAE,EAC/C;QACE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,mCAAmC,EAAE;QAChE,IAAI,EAAE,IAAI,eAAe,CAAC;YACxB,UAAU,EAAE,eAAe;YAC3B,aAAa,EAAE,KAAK,CAAC,aAAa;SACnC,CAAC;QACF,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC;KAClC,CACF,CAAC;IAEF,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACb,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAC/B,IAAI,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,uBAAuB,CAAC,EAAE,CAAC;YAC7E,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;QACnF,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,CAAC,MAAM,MAAM,IAAI,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAK9B,CAAC;IAEF,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IAE7C,MAAM,gBAAgB,CAAC;QACrB,GAAG,KAAK;QACR,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,KAAK,CAAC,aAAa;QACxD,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,eAAe,EAAE,MAAM;KACxB,CAAC,CAAC;IAEH,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;AAC5D,CAAC"}
|
package/dist/commands/auth.d.ts
DELETED
package/dist/commands/auth.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { readCredentials, deleteCredentials, getCredentialsPath } from "../auth/credentials.js";
|
|
2
|
-
import { performLogin } from "../auth/login.js";
|
|
3
|
-
import { apiClient } from "../api/client.js";
|
|
4
|
-
import { output, errorOutput } from "../output/format.js";
|
|
5
|
-
export function registerAuthCommands(program) {
|
|
6
|
-
const auth = program.command("auth").description("Authentication commands");
|
|
7
|
-
auth
|
|
8
|
-
.command("login")
|
|
9
|
-
.description("Log in to Graphit via browser")
|
|
10
|
-
.action(async function () {
|
|
11
|
-
try {
|
|
12
|
-
const creds = await performLogin();
|
|
13
|
-
console.log(`Logged in as ${creds.email}`);
|
|
14
|
-
console.log(`Organization: ${creds.org_name}`);
|
|
15
|
-
console.log(`Seat type: ${creds.seat_type}`);
|
|
16
|
-
console.log(`\nCredentials saved to ${getCredentialsPath()}`);
|
|
17
|
-
}
|
|
18
|
-
catch (err) {
|
|
19
|
-
errorOutput(err);
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
auth
|
|
23
|
-
.command("status")
|
|
24
|
-
.description("Show current authentication status")
|
|
25
|
-
.action(async function () {
|
|
26
|
-
try {
|
|
27
|
-
const creds = await readCredentials();
|
|
28
|
-
if (!creds) {
|
|
29
|
-
errorOutput(new Error("Not logged in. Run `graphit auth login` first."));
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const me = await apiClient.get("/api/v1/cli/me");
|
|
33
|
-
const tokenExpiry = creds.id_token_expiry
|
|
34
|
-
? new Date(creds.id_token_expiry * 1000).toISOString()
|
|
35
|
-
: "none";
|
|
36
|
-
output(this, {
|
|
37
|
-
email: me.email,
|
|
38
|
-
org_name: me.org_name,
|
|
39
|
-
org_id: me.org_id,
|
|
40
|
-
seat_type: me.seat_type,
|
|
41
|
-
token_expiry: tokenExpiry,
|
|
42
|
-
credentials: getCredentialsPath(),
|
|
43
|
-
}, { keyValue: true });
|
|
44
|
-
}
|
|
45
|
-
catch (err) {
|
|
46
|
-
errorOutput(err);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
auth
|
|
50
|
-
.command("logout")
|
|
51
|
-
.description("Log out and clear stored credentials")
|
|
52
|
-
.action(async function () {
|
|
53
|
-
try {
|
|
54
|
-
try {
|
|
55
|
-
await apiClient.post("/api/v1/cli/auth/revoke", {});
|
|
56
|
-
}
|
|
57
|
-
catch {
|
|
58
|
-
// Best-effort server-side revocation
|
|
59
|
-
}
|
|
60
|
-
await deleteCredentials();
|
|
61
|
-
console.log("Logged out. Credentials removed.");
|
|
62
|
-
}
|
|
63
|
-
catch (err) {
|
|
64
|
-
errorOutput(err);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=auth.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAU1D,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACnD,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC;IAE5E,IAAI;SACD,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,+BAA+B,CAAC;SAC5C,MAAM,CAAC,KAAK;QACX,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,YAAY,EAAE,CAAC;YACnC,OAAO,CAAC,GAAG,CAAC,gBAAgB,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;YAC3C,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC/C,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;YAC7C,OAAO,CAAC,GAAG,CAAC,0BAA0B,kBAAkB,EAAE,EAAE,CAAC,CAAC;QAChE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,IAAI;SACD,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C,kCAAkC,CAAC,CAAC;QAClD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { readFile, stat } from "node:fs/promises";
|
|
2
|
-
import { apiClient } from "../api/client.js";
|
|
3
|
-
import { output, errorOutput } from "../output/format.js";
|
|
4
|
-
export function registerConnectorCommands(program) {
|
|
5
|
-
const connector = program.command("connector").description("Connection management");
|
|
6
|
-
connector
|
|
7
|
-
.command("list")
|
|
8
|
-
.description("List active connections")
|
|
9
|
-
.action(async function () {
|
|
10
|
-
try {
|
|
11
|
-
const resp = await apiClient.get("/api/v1/cli/connectors");
|
|
12
|
-
output(this, resp.connectors, {
|
|
13
|
-
columns: ["id", "name", "account", "auth_type"],
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
catch (err) {
|
|
17
|
-
errorOutput(err);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
const add = connector.command("add").description("Add a new connection");
|
|
21
|
-
add
|
|
22
|
-
.command("snowflake-keypair")
|
|
23
|
-
.description("Add Snowflake via keypair auth")
|
|
24
|
-
.requiredOption("--account <account>", "Snowflake account identifier")
|
|
25
|
-
.requiredOption("--user <user>", "Snowflake username")
|
|
26
|
-
.requiredOption("--key <path>", "Path to private key file (.p8)")
|
|
27
|
-
.option("--warehouse <wh>", "Default warehouse")
|
|
28
|
-
.option("--role <role>", "Default role")
|
|
29
|
-
.option("--database <db>", "Default database")
|
|
30
|
-
.action(async function () {
|
|
31
|
-
try {
|
|
32
|
-
const opts = this.opts();
|
|
33
|
-
const keyStats = await stat(opts.key);
|
|
34
|
-
const mode = keyStats.mode & 0o777;
|
|
35
|
-
if (mode > 0o600) {
|
|
36
|
-
console.error(`Warning: Key file has loose permissions (${mode.toString(8)}). Consider chmod 600.`);
|
|
37
|
-
}
|
|
38
|
-
const keyPem = await readFile(opts.key, "utf-8");
|
|
39
|
-
const resp = await apiClient.post("/api/v1/cli/connectors/snowflake-keypair", {
|
|
40
|
-
account: opts.account,
|
|
41
|
-
user: opts.user,
|
|
42
|
-
private_key_pem: keyPem,
|
|
43
|
-
warehouse: opts.warehouse || null,
|
|
44
|
-
role: opts.role || null,
|
|
45
|
-
database: opts.database || null,
|
|
46
|
-
});
|
|
47
|
-
output(this, resp, { keyValue: true });
|
|
48
|
-
}
|
|
49
|
-
catch (err) {
|
|
50
|
-
errorOutput(err);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
add
|
|
54
|
-
.command("snowflake-oauth")
|
|
55
|
-
.description("Add Snowflake via OAuth (opens browser)")
|
|
56
|
-
.action(function () {
|
|
57
|
-
console.error(JSON.stringify({
|
|
58
|
-
error: "Snowflake OAuth is configured via the Graphit web app. Use snowflake-keypair for CLI setup.",
|
|
59
|
-
}));
|
|
60
|
-
process.exit(1);
|
|
61
|
-
});
|
|
62
|
-
add
|
|
63
|
-
.command("github")
|
|
64
|
-
.description("Add GitHub connection (opens browser)")
|
|
65
|
-
.action(function () {
|
|
66
|
-
console.error(JSON.stringify({
|
|
67
|
-
error: "GitHub connections are configured via the Graphit web app.",
|
|
68
|
-
}));
|
|
69
|
-
process.exit(1);
|
|
70
|
-
});
|
|
71
|
-
connector
|
|
72
|
-
.command("test <id>")
|
|
73
|
-
.description("Test a connection")
|
|
74
|
-
.action(async function (id) {
|
|
75
|
-
try {
|
|
76
|
-
const resp = await apiClient.post(`/api/v1/cli/connectors/${id}/test`, {});
|
|
77
|
-
output(this, resp, { keyValue: true });
|
|
78
|
-
}
|
|
79
|
-
catch (err) {
|
|
80
|
-
errorOutput(err);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
connector
|
|
84
|
-
.command("remove <id>")
|
|
85
|
-
.description("Remove a connection (requires --yes)")
|
|
86
|
-
.requiredOption("--yes", "Confirm removal")
|
|
87
|
-
.action(async function (id) {
|
|
88
|
-
try {
|
|
89
|
-
await apiClient.delete(`/api/v1/cli/connectors/${id}`);
|
|
90
|
-
console.log(JSON.stringify({ status: "removed", id }));
|
|
91
|
-
}
|
|
92
|
-
catch (err) {
|
|
93
|
-
errorOutput(err);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
//# sourceMappingURL=connector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connector.js","sourceRoot":"","sources":["../../src/commands/connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE1D,MAAM,UAAU,yBAAyB,CAAC,OAAgB;IACxD,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;IAEpF,SAAS;SACN,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,yBAAyB,CAAC;SACtC,MAAM,CAAC,KAAK;QACX,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,GAAG,CAC9B,wBAAwB,CACzB,CAAC;YACF,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE;gBAC5B,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC;aAChD,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC;IAEzE,GAAG;SACA,OAAO,CAAC,mBAAmB,CAA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AS,CAAC,MAAM,CAAC,0BAA0B,EAAE,EAAE,CAAC,CAAC;YACvD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { apiClient } from "../api/client.js";
|
|
3
|
-
import { output, errorOutput } from "../output/format.js";
|
|
4
|
-
function dashboardUrl(id) {
|
|
5
|
-
const base = process.env.GRAPHIT_FRONTEND_URL || "https://app.graphit-app.com";
|
|
6
|
-
return `${base}/custom-dashboards/${id}`;
|
|
7
|
-
}
|
|
8
|
-
export function registerDashboardCommands(program) {
|
|
9
|
-
const dashboard = program.command("dashboard").description("Custom dashboard management");
|
|
10
|
-
dashboard
|
|
11
|
-
.command("list")
|
|
12
|
-
.description("List custom dashboards")
|
|
13
|
-
.action(async function () {
|
|
14
|
-
try {
|
|
15
|
-
const resp = await apiClient.get("/api/v1/cli/dashboards");
|
|
16
|
-
const withUrls = resp.dashboards.map((d) => ({
|
|
17
|
-
...d,
|
|
18
|
-
url: dashboardUrl(d.id),
|
|
19
|
-
}));
|
|
20
|
-
output(this, withUrls, {
|
|
21
|
-
columns: ["id", "name", "has_content", "url"],
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
catch (err) {
|
|
25
|
-
errorOutput(err);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
dashboard
|
|
29
|
-
.command("create")
|
|
30
|
-
.description("Create a new custom dashboard")
|
|
31
|
-
.requiredOption("--name <name>", "Dashboard name")
|
|
32
|
-
.action(async function () {
|
|
33
|
-
try {
|
|
34
|
-
const opts = this.opts();
|
|
35
|
-
const resp = await apiClient.post("/api/v1/cli/dashboards", {
|
|
36
|
-
name: opts.name,
|
|
37
|
-
});
|
|
38
|
-
output(this, { ...resp, url: dashboardUrl(resp.id) }, { keyValue: true });
|
|
39
|
-
}
|
|
40
|
-
catch (err) {
|
|
41
|
-
errorOutput(err);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
dashboard
|
|
45
|
-
.command("get <id>")
|
|
46
|
-
.description("Get dashboard details")
|
|
47
|
-
.option("--html", "Include HTML content in output")
|
|
48
|
-
.action(async function (id) {
|
|
49
|
-
try {
|
|
50
|
-
const opts = this.opts();
|
|
51
|
-
const params = opts.html ? "?include_html=true" : "";
|
|
52
|
-
const resp = await apiClient.get(`/api/v1/cli/dashboards/${id}${params}`);
|
|
53
|
-
output(this, resp, { keyValue: true });
|
|
54
|
-
}
|
|
55
|
-
catch (err) {
|
|
56
|
-
errorOutput(err);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
dashboard
|
|
60
|
-
.command("update-html <id>")
|
|
61
|
-
.description("Replace dashboard HTML content")
|
|
62
|
-
.option("--file <path>", "Read HTML from a local file")
|
|
63
|
-
.option("--stdin", "Read HTML from stdin")
|
|
64
|
-
.action(async function (id) {
|
|
65
|
-
try {
|
|
66
|
-
const opts = this.opts();
|
|
67
|
-
let html;
|
|
68
|
-
if (opts.file) {
|
|
69
|
-
html = await readFile(opts.file, "utf-8");
|
|
70
|
-
}
|
|
71
|
-
else if (opts.stdin) {
|
|
72
|
-
html = await readStdin();
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
errorOutput(new Error("Specify --file <path> or --stdin"));
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const resp = await apiClient.put(`/api/v1/cli/dashboards/${id}/html`, { html });
|
|
79
|
-
output(this, { ...resp, url: dashboardUrl(resp.id) }, { keyValue: true });
|
|
80
|
-
}
|
|
81
|
-
catch (err) {
|
|
82
|
-
errorOutput(err);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
dashboard
|
|
86
|
-
.command("get-html <id>")
|
|
87
|
-
.description("Get the current HTML content of a dashboard")
|
|
88
|
-
.action(async function (id) {
|
|
89
|
-
try {
|
|
90
|
-
const resp = await apiClient.get(`/api/v1/cli/dashboards/${id}?include_html=true`);
|
|
91
|
-
if (!resp.html_content) {
|
|
92
|
-
console.log("<!-- Canvas is empty - no HTML content yet -->");
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
console.log(resp.html_content);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
catch (err) {
|
|
99
|
-
errorOutput(err);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
dashboard
|
|
103
|
-
.command("delete <id>")
|
|
104
|
-
.description("Delete a custom dashboard (requires --yes)")
|
|
105
|
-
.requiredOption("--yes", "Confirm deletion")
|
|
106
|
-
.action(async function (id) {
|
|
107
|
-
try {
|
|
108
|
-
await apiClient.delete(`/api/v1/cli/dashboards/${id}`);
|
|
109
|
-
console.log(JSON.stringify({ status: "deleted", id }));
|
|
110
|
-
}
|
|
111
|
-
catch (err) {
|
|
112
|
-
errorOutput(err);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
function readStdin() {
|
|
117
|
-
return new Promise((resolve, reject) => {
|
|
118
|
-
const chunks = [];
|
|
119
|
-
process.stdin.on("data", (chunk) => chunks.push(chunk));
|
|
120
|
-
process.stdin.on("end", () => resolve(Buffer.concat(chunks).toString("utf-8")));
|
|
121
|
-
process.stdin.on("error", reject);
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
//# sourceMappingURL=dashboard.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard.js","sourceRoot":"","sources":["../../src/commands/dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AA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EAAE,CAAC;YACb,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,SAAS;SACN,OAAO,CAAC,aAAa,CAAC;SACtB,WAAW,CAAC,4CAA4C,CAAC;SACzD,cAAc,CAAC,OAAO,EAAE,kBAAkB,CAAC;SAC3C,MAAM,CAAC,KAAK,WAA0B,EAAU;QAC/C,IAAI,CAAC;YACH,MAAM,SAAS,CAAC,MAAM,CAAC,0BAA0B,EAAE,EAAE,CAAC,CAAC;YACvD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,SAAS;IAChB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACxD,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAChF,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/commands/ds.d.ts
DELETED
package/dist/commands/ds.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { apiClient } from "../api/client.js";
|
|
2
|
-
import { output, errorOutput } from "../output/format.js";
|
|
3
|
-
export function registerDSCommands(program) {
|
|
4
|
-
const ds = program.command("ds").description("Data source management");
|
|
5
|
-
ds.command("list")
|
|
6
|
-
.description("List data sources")
|
|
7
|
-
.option("--limit <n>", "Max results", "50")
|
|
8
|
-
.action(async function () {
|
|
9
|
-
try {
|
|
10
|
-
const opts = this.opts();
|
|
11
|
-
const resp = await apiClient.get(`/api/v1/cli/ds?limit=${opts.limit}`);
|
|
12
|
-
output(this, resp.data_sources, {
|
|
13
|
-
columns: ["id", "name", "status", "row_count", "verified"],
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
catch (err) {
|
|
17
|
-
errorOutput(err);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
ds.command("create")
|
|
21
|
-
.description("Create a data source from a SQL query")
|
|
22
|
-
.requiredOption("--sql <query>", "Source SQL query")
|
|
23
|
-
.requiredOption("--name <name>", "Data source name")
|
|
24
|
-
.option("--connection <id>", "Snowflake connection ID")
|
|
25
|
-
.option("--schema <name>", "Schema name")
|
|
26
|
-
.action(async function () {
|
|
27
|
-
try {
|
|
28
|
-
const opts = this.opts();
|
|
29
|
-
const resp = await apiClient.post("/api/v1/cli/ds", {
|
|
30
|
-
name: opts.name,
|
|
31
|
-
sql: opts.sql,
|
|
32
|
-
connection_id: opts.connection || null,
|
|
33
|
-
schema_name: opts.schema || null,
|
|
34
|
-
});
|
|
35
|
-
output(this, resp, { keyValue: true });
|
|
36
|
-
}
|
|
37
|
-
catch (err) {
|
|
38
|
-
errorOutput(err);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
ds.command("refresh <id>")
|
|
42
|
-
.description("Trigger a data source refresh")
|
|
43
|
-
.action(async function (id) {
|
|
44
|
-
try {
|
|
45
|
-
const resp = await apiClient.post(`/api/v1/cli/ds/${id}/refresh`, {});
|
|
46
|
-
output(this, resp, { keyValue: true });
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
errorOutput(err);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=ds.js.map
|
package/dist/commands/ds.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ds.js","sourceRoot":"","sources":["../../src/commands/ds.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE1D,MAAM,UAAU,kBAAkB,CAAC,OAAgB;IACjD,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,wBAAwB,CAAC,CAAC;IAEvE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,mBAAmB,CAAC;SAChC,MAAM,CAAC,aAAa,EAAE,aAAa,EAAE,IAAI,CAAC;SAC1C,MAAM,CAAC,KAAK;QACX,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YACzB,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,GAAG,CAC9B,wBAAwB,IAAI,CAAC,KAAK,EAAE,CACrC,CAAC;YACF,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE;gBAC9B,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,CAAC;aAC3D,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,uCAAuC,CAAC;SACpD,cAAc,CAAC,eAAe,EAAE,kBAAkB,CAAC;SACnD,cAAc,CAAC,eAAe,EAAE,kBAAkB,CAAC;SACnD,MAAM,CAAC,mBAAmB,EAAE,yBAAyB,CAAC;SACtD,MAAM,CAAC,iBAAiB,EAAE,aAAa,CAAC;SACxC,MAAM,CAAC,KAAK;QACX,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YACzB,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,IAAI,CAA0B,gBAAgB,EAAE;gBAC3E,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,aAAa,EAAE,IAAI,CAAC,UAAU,IAAI,IAAI;gBACtC,WAAW,EAAE,IAAI,CAAC,MAAM,IAAI,IAAI;aACjC,CAAC,CAAC;YACH,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC;SACvB,WAAW,CAAC,+BAA+B,CAAC;SAC5C,MAAM,CAAC,KAAK,WAA0B,EAAU;QAC/C,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,IAAI,CAC/B,kBAAkB,EAAE,UAAU,EAC9B,EAAE,CACH,CAAC;YACF,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/commands/kb.d.ts
DELETED
package/dist/commands/kb.js
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import { apiClient } from "../api/client.js";
|
|
2
|
-
import { output, errorOutput } from "../output/format.js";
|
|
3
|
-
const ENTITY_COLUMNS = {
|
|
4
|
-
metric: ["id", "name", "description", "calculation", "verified"],
|
|
5
|
-
dimension: ["id", "name", "description", "expression", "verified"],
|
|
6
|
-
table: ["id", "name", "description", "verified"],
|
|
7
|
-
rule: ["id", "name", "description", "verified"],
|
|
8
|
-
domain: ["id", "name", "description"],
|
|
9
|
-
synonym: ["id", "name", "target_name", "target_type"],
|
|
10
|
-
};
|
|
11
|
-
export function registerKBCommands(program) {
|
|
12
|
-
const kb = program.command("kb").description("Knowledge Base operations");
|
|
13
|
-
kb.command("list <type>")
|
|
14
|
-
.description("List KB entities (metric, dimension, table, rule, domain, synonym)")
|
|
15
|
-
.option("--limit <n>", "Max results", "50")
|
|
16
|
-
.option("--verified", "Only verified entities")
|
|
17
|
-
.option("--unverified", "Only unverified entities")
|
|
18
|
-
.action(async function (type) {
|
|
19
|
-
try {
|
|
20
|
-
const opts = this.opts();
|
|
21
|
-
const params = new URLSearchParams({ limit: opts.limit });
|
|
22
|
-
if (opts.verified)
|
|
23
|
-
params.set("verified", "true");
|
|
24
|
-
if (opts.unverified)
|
|
25
|
-
params.set("verified", "false");
|
|
26
|
-
const resp = await apiClient.get(`/api/v1/cli/kb/${type}?${params}`);
|
|
27
|
-
output(this, resp.entities, { columns: ENTITY_COLUMNS[type] });
|
|
28
|
-
}
|
|
29
|
-
catch (err) {
|
|
30
|
-
errorOutput(err);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
kb.command("get <type> <name>")
|
|
34
|
-
.description("Get a KB entity by name")
|
|
35
|
-
.action(async function (type, name) {
|
|
36
|
-
try {
|
|
37
|
-
const resp = await apiClient.get(`/api/v1/cli/kb/${type}/by-name/${encodeURIComponent(name)}`);
|
|
38
|
-
output(this, resp.entity, { keyValue: true });
|
|
39
|
-
}
|
|
40
|
-
catch (err) {
|
|
41
|
-
errorOutput(err);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
kb.command("search <query>")
|
|
45
|
-
.description("Search KB assets across all types")
|
|
46
|
-
.option("--type <type>", "Filter by entity type")
|
|
47
|
-
.option("--limit <n>", "Max results", "20")
|
|
48
|
-
.action(async function (query) {
|
|
49
|
-
try {
|
|
50
|
-
const opts = this.opts();
|
|
51
|
-
const params = new URLSearchParams({ q: query, limit: opts.limit });
|
|
52
|
-
if (opts.type)
|
|
53
|
-
params.set("type", opts.type);
|
|
54
|
-
const resp = await apiClient.get(`/api/v1/cli/kb/search?${params}`);
|
|
55
|
-
output(this, resp.results, { columns: ["type", "name", "description"] });
|
|
56
|
-
}
|
|
57
|
-
catch (err) {
|
|
58
|
-
errorOutput(err);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
kb.command("explore <type> <name>")
|
|
62
|
-
.description("Traverse KB graph (metric -> tables -> dimensions)")
|
|
63
|
-
.action(async function (type, name) {
|
|
64
|
-
try {
|
|
65
|
-
const resp = await apiClient.get(`/api/v1/cli/kb/explore/${type}/${encodeURIComponent(name)}`);
|
|
66
|
-
output(this, resp, { keyValue: true });
|
|
67
|
-
}
|
|
68
|
-
catch (err) {
|
|
69
|
-
errorOutput(err);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
// -- Create commands --
|
|
73
|
-
const create = kb.command("create").description("Create KB entities");
|
|
74
|
-
create
|
|
75
|
-
.command("metric")
|
|
76
|
-
.description("Create a new metric")
|
|
77
|
-
.requiredOption("--name <name>", "Metric name (UPPER_SNAKE_CASE)")
|
|
78
|
-
.requiredOption("--sql <expr>", "SQL calculation expression")
|
|
79
|
-
.requiredOption("--table <table>", "Primary table")
|
|
80
|
-
.option("--description <desc>", "Description", "")
|
|
81
|
-
.action(async function () {
|
|
82
|
-
try {
|
|
83
|
-
const opts = this.opts();
|
|
84
|
-
const resp = await apiClient.post("/api/v1/cli/kb/metric", {
|
|
85
|
-
name: opts.name,
|
|
86
|
-
calculation: opts.sql,
|
|
87
|
-
table: opts.table,
|
|
88
|
-
description: opts.description,
|
|
89
|
-
});
|
|
90
|
-
output(this, resp.entity, { keyValue: true });
|
|
91
|
-
}
|
|
92
|
-
catch (err) {
|
|
93
|
-
errorOutput(err);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
create
|
|
97
|
-
.command("dimension")
|
|
98
|
-
.description("Create a new dimension")
|
|
99
|
-
.requiredOption("--name <name>", "Dimension name (UPPER_SNAKE_CASE)")
|
|
100
|
-
.requiredOption("--expr <expr>", "SQL expression")
|
|
101
|
-
.requiredOption("--table <table>", "Primary table")
|
|
102
|
-
.option("--type <type>", "Dimension type", "categorical")
|
|
103
|
-
.option("--description <desc>", "Description", "")
|
|
104
|
-
.action(async function () {
|
|
105
|
-
try {
|
|
106
|
-
const opts = this.opts();
|
|
107
|
-
const resp = await apiClient.post("/api/v1/cli/kb/dimension", {
|
|
108
|
-
name: opts.name,
|
|
109
|
-
expression: opts.expr,
|
|
110
|
-
table: opts.table,
|
|
111
|
-
type: opts.type,
|
|
112
|
-
description: opts.description,
|
|
113
|
-
});
|
|
114
|
-
output(this, resp.entity, { keyValue: true });
|
|
115
|
-
}
|
|
116
|
-
catch (err) {
|
|
117
|
-
errorOutput(err);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
create
|
|
121
|
-
.command("rule")
|
|
122
|
-
.description("Create a new rule")
|
|
123
|
-
.requiredOption("--name <name>", "Rule name (UPPER_SNAKE_CASE)")
|
|
124
|
-
.requiredOption("--sql <expr>", "Rule content/SQL")
|
|
125
|
-
.requiredOption("--table <table>", "Referenced table")
|
|
126
|
-
.option("--description <desc>", "Description", "")
|
|
127
|
-
.action(async function () {
|
|
128
|
-
try {
|
|
129
|
-
const opts = this.opts();
|
|
130
|
-
const resp = await apiClient.post("/api/v1/cli/kb/rule", {
|
|
131
|
-
name: opts.name,
|
|
132
|
-
content: opts.sql,
|
|
133
|
-
table: opts.table,
|
|
134
|
-
description: opts.description,
|
|
135
|
-
});
|
|
136
|
-
output(this, resp.entity, { keyValue: true });
|
|
137
|
-
}
|
|
138
|
-
catch (err) {
|
|
139
|
-
errorOutput(err);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
create
|
|
143
|
-
.command("table")
|
|
144
|
-
.description("Tables are created via data sources. Use `graphit ds create`.")
|
|
145
|
-
.action(function () {
|
|
146
|
-
console.error(JSON.stringify({
|
|
147
|
-
error: "Tables are created via data sources. Use `graphit ds create` instead.",
|
|
148
|
-
}));
|
|
149
|
-
process.exit(1);
|
|
150
|
-
});
|
|
151
|
-
create
|
|
152
|
-
.command("domain")
|
|
153
|
-
.description("Domains are managed via the web app.")
|
|
154
|
-
.action(function () {
|
|
155
|
-
console.error(JSON.stringify({
|
|
156
|
-
error: "Domains are managed via the Graphit web app.",
|
|
157
|
-
}));
|
|
158
|
-
process.exit(1);
|
|
159
|
-
});
|
|
160
|
-
// -- Update commands --
|
|
161
|
-
const update = kb.command("update").description("Update KB entities");
|
|
162
|
-
update
|
|
163
|
-
.command("metric <name>")
|
|
164
|
-
.description("Update a metric")
|
|
165
|
-
.option("--sql <expr>", "New SQL calculation")
|
|
166
|
-
.option("--table <table>", "New primary table")
|
|
167
|
-
.option("--description <desc>", "New description")
|
|
168
|
-
.action(async function (name) {
|
|
169
|
-
try {
|
|
170
|
-
const opts = this.opts();
|
|
171
|
-
const resp = await apiClient.put(`/api/v1/cli/kb/metric/${encodeURIComponent(name)}`, {
|
|
172
|
-
calculation: opts.sql ?? null,
|
|
173
|
-
table: opts.table ?? null,
|
|
174
|
-
description: opts.description ?? null,
|
|
175
|
-
});
|
|
176
|
-
output(this, resp.entity, { keyValue: true });
|
|
177
|
-
}
|
|
178
|
-
catch (err) {
|
|
179
|
-
errorOutput(err);
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
update
|
|
183
|
-
.command("dimension <name>")
|
|
184
|
-
.description("Update a dimension")
|
|
185
|
-
.option("--expr <expr>", "New SQL expression")
|
|
186
|
-
.option("--table <table>", "New primary table")
|
|
187
|
-
.option("--description <desc>", "New description")
|
|
188
|
-
.action(async function (name) {
|
|
189
|
-
try {
|
|
190
|
-
const opts = this.opts();
|
|
191
|
-
const resp = await apiClient.put(`/api/v1/cli/kb/dimension/${encodeURIComponent(name)}`, {
|
|
192
|
-
expression: opts.expr ?? null,
|
|
193
|
-
table: opts.table ?? null,
|
|
194
|
-
description: opts.description ?? null,
|
|
195
|
-
});
|
|
196
|
-
output(this, resp.entity, { keyValue: true });
|
|
197
|
-
}
|
|
198
|
-
catch (err) {
|
|
199
|
-
errorOutput(err);
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
update
|
|
203
|
-
.command("rule <name>")
|
|
204
|
-
.description("Update a rule")
|
|
205
|
-
.option("--sql <expr>", "New rule content")
|
|
206
|
-
.option("--description <desc>", "New description")
|
|
207
|
-
.action(async function (name) {
|
|
208
|
-
try {
|
|
209
|
-
const opts = this.opts();
|
|
210
|
-
const resp = await apiClient.put(`/api/v1/cli/kb/rule/${encodeURIComponent(name)}`, {
|
|
211
|
-
content: opts.sql ?? null,
|
|
212
|
-
description: opts.description ?? null,
|
|
213
|
-
});
|
|
214
|
-
output(this, resp.entity, { keyValue: true });
|
|
215
|
-
}
|
|
216
|
-
catch (err) {
|
|
217
|
-
errorOutput(err);
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
update
|
|
221
|
-
.command("table <name>")
|
|
222
|
-
.description("Update a table's description or domain")
|
|
223
|
-
.option("--description <desc>", "New description")
|
|
224
|
-
.option("--domain <domain_id>", "New domain ID")
|
|
225
|
-
.action(async function (name) {
|
|
226
|
-
try {
|
|
227
|
-
const opts = this.opts();
|
|
228
|
-
const resp = await apiClient.put(`/api/v1/cli/kb/table/${encodeURIComponent(name)}`, {
|
|
229
|
-
description: opts.description ?? null,
|
|
230
|
-
domain_id: opts.domain ?? null,
|
|
231
|
-
});
|
|
232
|
-
output(this, resp.entity, { keyValue: true });
|
|
233
|
-
}
|
|
234
|
-
catch (err) {
|
|
235
|
-
errorOutput(err);
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
// -- Delete command --
|
|
239
|
-
kb.command("delete <type> <name>")
|
|
240
|
-
.description("Delete a KB entity (requires --yes flag)")
|
|
241
|
-
.requiredOption("--yes", "Confirm deletion")
|
|
242
|
-
.action(async function (type, name) {
|
|
243
|
-
try {
|
|
244
|
-
const validTypes = ["metric", "dimension", "rule"];
|
|
245
|
-
if (!validTypes.includes(type)) {
|
|
246
|
-
console.error(JSON.stringify({
|
|
247
|
-
error: `Delete not supported for '${type}'. Supported: ${validTypes.join(", ")}`,
|
|
248
|
-
}));
|
|
249
|
-
process.exit(1);
|
|
250
|
-
}
|
|
251
|
-
await apiClient.delete(`/api/v1/cli/kb/${type}/${encodeURIComponent(name)}`);
|
|
252
|
-
console.log(JSON.stringify({ status: "deleted", type, name: name.toUpperCase() }));
|
|
253
|
-
}
|
|
254
|
-
catch (err) {
|
|
255
|
-
errorOutput(err);
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
//# sourceMappingURL=kb.js.map
|