@zhoujinandrew/te-cli 1.0.0
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/README.md +109 -0
- package/bin/te-cli.js +2 -0
- package/dist/analysis-SFPXKD3E.js +218 -0
- package/dist/audience-AZ72TU5F.js +119 -0
- package/dist/auth-2OVPSXHK.js +19 -0
- package/dist/auth-6QCDAUYV.js +67 -0
- package/dist/auth-CFVQVVQN.js +51 -0
- package/dist/auth-QNSRS5ZR.js +19 -0
- package/dist/auth-V4MDYFHU.js +67 -0
- package/dist/auth-Z652VWDK.js +19 -0
- package/dist/chunk-4YPCK7T5.js +217 -0
- package/dist/chunk-C3VJLU5Y.js +206 -0
- package/dist/chunk-CFCHSAMQ.js +108 -0
- package/dist/chunk-KA66K7EL.js +144 -0
- package/dist/chunk-KAWQCMDL.js +44 -0
- package/dist/chunk-KM57HI5B.js +107 -0
- package/dist/chunk-KNKRSOCY.js +144 -0
- package/dist/chunk-P7NQZGSZ.js +217 -0
- package/dist/chunk-STTYG7WN.js +91 -0
- package/dist/chunk-V3D6XL5Z.js +134 -0
- package/dist/client-CSJ3XBC4.js +16 -0
- package/dist/client-EZSKQFIH.js +16 -0
- package/dist/client-OT7PTMI2.js +16 -0
- package/dist/config-53KUB7OG.js +146 -0
- package/dist/config-QQE7LMPZ.js +40 -0
- package/dist/config-S53L4MQK.js +242 -0
- package/dist/index.js +239 -0
- package/dist/meta-ZXBX5RER.js +135 -0
- package/dist/operation-6POPVVIZ.js +214 -0
- package/dist/raw-76GSW4Q4.js +59 -0
- package/dist/raw-K2FR7QAI.js +55 -0
- package/dist/raw-YVFTDHSI.js +59 -0
- package/package.json +40 -0
- package/skills/te-analysis/SKILL.md +93 -0
- package/skills/te-analysis/references/create-dashboard.md +30 -0
- package/skills/te-analysis/references/get-dashboard.md +24 -0
- package/skills/te-analysis/references/get-report.md +24 -0
- package/skills/te-analysis/references/list-dashboard-reports.md +24 -0
- package/skills/te-analysis/references/list-dashboards.md +23 -0
- package/skills/te-analysis/references/list-reports.md +26 -0
- package/skills/te-analysis/references/query-report-data.md +34 -0
- package/skills/te-analysis/references/query-sql.md +31 -0
- package/skills/te-analysis/references/save-report.md +42 -0
- package/skills/te-analysis/references/update-dashboard.md +33 -0
- package/skills/te-audience/SKILL.md +60 -0
- package/skills/te-audience/references/te-audience-get-tag.md +21 -0
- package/skills/te-audience/references/te-audience-list-audience-events.md +20 -0
- package/skills/te-audience/references/te-audience-list-clusters.md +20 -0
- package/skills/te-audience/references/te-audience-list-tags.md +23 -0
- package/skills/te-audience/references/te-audience-load-audience-props.md +25 -0
- package/skills/te-audience/references/te-audience-predict-cluster-count.md +22 -0
- package/skills/te-meta/SKILL.md +80 -0
- package/skills/te-meta/references/get-table-columns.md +29 -0
- package/skills/te-meta/references/list-entities.md +26 -0
- package/skills/te-meta/references/list-events.md +29 -0
- package/skills/te-meta/references/list-metrics.md +26 -0
- package/skills/te-meta/references/list-tables.md +26 -0
- package/skills/te-meta/references/load-event-props.md +27 -0
- package/skills/te-meta/references/load-measure-props.md +24 -0
- package/skills/te-operation/SKILL.md +75 -0
- package/skills/te-operation/references/te-operation-create-task.md +29 -0
- package/skills/te-operation/references/te-operation-get-channel.md +20 -0
- package/skills/te-operation/references/te-operation-get-flow.md +20 -0
- package/skills/te-operation/references/te-operation-get-space-tree.md +19 -0
- package/skills/te-operation/references/te-operation-get-task-stats.md +20 -0
- package/skills/te-operation/references/te-operation-get-timezone.md +19 -0
- package/skills/te-operation/references/te-operation-list-channels.md +19 -0
- package/skills/te-operation/references/te-operation-list-flows.md +19 -0
- package/skills/te-operation/references/te-operation-list-mark-times.md +19 -0
- package/skills/te-operation/references/te-operation-list-tasks.md +25 -0
- package/skills/te-operation/references/te-operation-save-flow.md +29 -0
- package/skills/te-shared/SKILL.md +115 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import {
|
|
2
|
+
printError,
|
|
3
|
+
printOutput
|
|
4
|
+
} from "./chunk-KM57HI5B.js";
|
|
5
|
+
import {
|
|
6
|
+
getActiveHost
|
|
7
|
+
} from "./chunk-CFCHSAMQ.js";
|
|
8
|
+
|
|
9
|
+
// src/index.ts
|
|
10
|
+
import { Command as CommanderCommand } from "commander";
|
|
11
|
+
|
|
12
|
+
// src/framework/runner.ts
|
|
13
|
+
import * as readline from "readline";
|
|
14
|
+
async function runCommand(cmd, opts, globalOpts) {
|
|
15
|
+
try {
|
|
16
|
+
const ctx = createRuntimeContext(cmd, opts, globalOpts);
|
|
17
|
+
for (const flag of cmd.flags) {
|
|
18
|
+
if (flag.required) {
|
|
19
|
+
const val = opts[camelCase(flag.name)];
|
|
20
|
+
if (val === void 0 || val === null || val === "") {
|
|
21
|
+
printError("validation", `Missing required flag: --${flag.name}`, `Usage: te-cli ${cmd.service} ${cmd.command} --${flag.name} <value>`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (cmd.validate) {
|
|
27
|
+
cmd.validate(ctx);
|
|
28
|
+
}
|
|
29
|
+
if (globalOpts.dryRun) {
|
|
30
|
+
if (cmd.dryRun) {
|
|
31
|
+
const dryResult = cmd.dryRun(ctx);
|
|
32
|
+
printOutput(dryResult, globalOpts.format, globalOpts.jq);
|
|
33
|
+
} else {
|
|
34
|
+
printOutput({ message: "No dry-run implementation for this command" }, globalOpts.format);
|
|
35
|
+
}
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (cmd.risk === "write" && !globalOpts.yes) {
|
|
39
|
+
const confirmed = await confirm(`This is a write operation (${cmd.service} ${cmd.command}). Continue?`);
|
|
40
|
+
if (!confirmed) {
|
|
41
|
+
process.stderr.write("Aborted.\n");
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const result = await cmd.execute(ctx);
|
|
46
|
+
ctx.out(result);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
const message = err.message || String(err);
|
|
49
|
+
if (message.includes("token") || message.includes("auth") || message.includes("401") || message.includes("403")) {
|
|
50
|
+
printError("auth", message, "Run: te-cli auth login");
|
|
51
|
+
} else if (message.includes("TE API error")) {
|
|
52
|
+
printError("api", message);
|
|
53
|
+
} else {
|
|
54
|
+
printError("api", message);
|
|
55
|
+
}
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function createRuntimeContext(cmd, opts, globalOpts) {
|
|
60
|
+
let _clientModule = null;
|
|
61
|
+
async function getClient() {
|
|
62
|
+
if (!_clientModule) {
|
|
63
|
+
_clientModule = await import("./client-EZSKQFIH.js");
|
|
64
|
+
}
|
|
65
|
+
return _clientModule;
|
|
66
|
+
}
|
|
67
|
+
const ctx = {
|
|
68
|
+
str(name) {
|
|
69
|
+
return String(opts[camelCase(name)] ?? "");
|
|
70
|
+
},
|
|
71
|
+
num(name) {
|
|
72
|
+
const val = opts[camelCase(name)];
|
|
73
|
+
return val !== void 0 ? Number(val) : 0;
|
|
74
|
+
},
|
|
75
|
+
bool(name) {
|
|
76
|
+
return Boolean(opts[camelCase(name)]);
|
|
77
|
+
},
|
|
78
|
+
json(name) {
|
|
79
|
+
const val = opts[camelCase(name)];
|
|
80
|
+
if (val === void 0 || val === null) return void 0;
|
|
81
|
+
if (typeof val === "object") return val;
|
|
82
|
+
try {
|
|
83
|
+
return JSON.parse(String(val));
|
|
84
|
+
} catch {
|
|
85
|
+
printError("validation", `Invalid JSON for --${name}: ${val}`);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
async api(method, path, params, data) {
|
|
90
|
+
const client = await getClient();
|
|
91
|
+
if (method.toUpperCase() === "GET") {
|
|
92
|
+
return client.httpGet(path, params, ctx.host());
|
|
93
|
+
} else {
|
|
94
|
+
return client.httpPost(path, params, data, ctx.host());
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
async querySql(projectId, sql) {
|
|
98
|
+
const client = await getClient();
|
|
99
|
+
return client.querySql(projectId, sql, ctx.host());
|
|
100
|
+
},
|
|
101
|
+
async queryReportData(projectId, reportId, qp, eventModel, options) {
|
|
102
|
+
const client = await getClient();
|
|
103
|
+
return client.queryReportData(projectId, reportId, qp, eventModel, options, ctx.host());
|
|
104
|
+
},
|
|
105
|
+
async token() {
|
|
106
|
+
const { getToken } = await import("./auth-Z652VWDK.js");
|
|
107
|
+
return getToken(ctx.host());
|
|
108
|
+
},
|
|
109
|
+
host() {
|
|
110
|
+
if (globalOpts.host) return globalOpts.host;
|
|
111
|
+
return getActiveHost();
|
|
112
|
+
},
|
|
113
|
+
out(data) {
|
|
114
|
+
printOutput(data, globalOpts.format, globalOpts.jq);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
return ctx;
|
|
118
|
+
}
|
|
119
|
+
function camelCase(str) {
|
|
120
|
+
return str.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
121
|
+
}
|
|
122
|
+
async function confirm(message) {
|
|
123
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
|
|
124
|
+
return new Promise((resolve) => {
|
|
125
|
+
rl.question(`${message} [y/N] `, (answer) => {
|
|
126
|
+
rl.close();
|
|
127
|
+
resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/framework/register.ts
|
|
133
|
+
function registerCommands(program2, commands) {
|
|
134
|
+
const byService = /* @__PURE__ */ new Map();
|
|
135
|
+
for (const cmd of commands) {
|
|
136
|
+
const list = byService.get(cmd.service) || [];
|
|
137
|
+
list.push(cmd);
|
|
138
|
+
byService.set(cmd.service, list);
|
|
139
|
+
}
|
|
140
|
+
for (const [service, cmds] of byService) {
|
|
141
|
+
let serviceCmd = program2.commands.find((c) => c.name() === service);
|
|
142
|
+
if (!serviceCmd) {
|
|
143
|
+
serviceCmd = program2.command(service).description(`${service} domain commands`);
|
|
144
|
+
}
|
|
145
|
+
for (const cmd of cmds) {
|
|
146
|
+
const sub = serviceCmd.command(cmd.command).description(cmd.description);
|
|
147
|
+
for (const flag of cmd.flags) {
|
|
148
|
+
const flagStr = buildFlagString(flag);
|
|
149
|
+
if (flag.type === "boolean") {
|
|
150
|
+
sub.option(flagStr, flag.desc);
|
|
151
|
+
} else if (flag.default !== void 0) {
|
|
152
|
+
sub.option(flagStr, flag.desc, String(flag.default));
|
|
153
|
+
} else {
|
|
154
|
+
sub.option(flagStr, flag.desc);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
sub.action(async (opts) => {
|
|
158
|
+
const globalOpts = extractGlobalOptions(program2);
|
|
159
|
+
await runCommand(cmd, opts, globalOpts);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function buildFlagString(flag) {
|
|
165
|
+
const long = `--${flag.name}`;
|
|
166
|
+
const short = flag.alias ? `-${flag.alias}, ` : "";
|
|
167
|
+
if (flag.type === "boolean") {
|
|
168
|
+
return `${short}${long}`;
|
|
169
|
+
}
|
|
170
|
+
return `${short}${long} <value>`;
|
|
171
|
+
}
|
|
172
|
+
function extractGlobalOptions(program2) {
|
|
173
|
+
const opts = program2.opts();
|
|
174
|
+
return {
|
|
175
|
+
host: opts.host,
|
|
176
|
+
format: opts.format || "json",
|
|
177
|
+
jq: opts.jq,
|
|
178
|
+
dryRun: opts.dryRun || false,
|
|
179
|
+
yes: opts.yes || false
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// src/index.ts
|
|
184
|
+
var program = new CommanderCommand();
|
|
185
|
+
program.name("te-cli").version("1.0.0").description("CLI tool for ThinkingEngine (TE) analytics platform").option("--host <url>", "Override active TE host URL (e.g., https://ta.thinkingdata.cn)").option("--format <format>", "Output format: json | table", "json").option("--jq <expr>", "jq filter expression").option("--dry-run", "Show request details without executing", false).option("--yes", "Skip confirmation for write operations", false);
|
|
186
|
+
async function loadCommands() {
|
|
187
|
+
const commands = [];
|
|
188
|
+
try {
|
|
189
|
+
const meta = await import("./meta-ZXBX5RER.js");
|
|
190
|
+
commands.push(...meta.default);
|
|
191
|
+
} catch {
|
|
192
|
+
}
|
|
193
|
+
try {
|
|
194
|
+
const analysis = await import("./analysis-SFPXKD3E.js");
|
|
195
|
+
commands.push(...analysis.default);
|
|
196
|
+
} catch {
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
const audience = await import("./audience-AZ72TU5F.js");
|
|
200
|
+
commands.push(...audience.default);
|
|
201
|
+
} catch {
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
const operation = await import("./operation-6POPVVIZ.js");
|
|
205
|
+
commands.push(...operation.default);
|
|
206
|
+
} catch {
|
|
207
|
+
}
|
|
208
|
+
return commands;
|
|
209
|
+
}
|
|
210
|
+
async function registerAuthCommands() {
|
|
211
|
+
try {
|
|
212
|
+
const { registerAuth } = await import("./auth-V4MDYFHU.js");
|
|
213
|
+
registerAuth(program);
|
|
214
|
+
} catch {
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
async function registerConfigCommands() {
|
|
218
|
+
try {
|
|
219
|
+
const { registerConfig } = await import("./config-S53L4MQK.js");
|
|
220
|
+
registerConfig(program);
|
|
221
|
+
} catch {
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
async function registerApiCommand() {
|
|
225
|
+
try {
|
|
226
|
+
const { registerApi } = await import("./raw-YVFTDHSI.js");
|
|
227
|
+
registerApi(program);
|
|
228
|
+
} catch {
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
async function main() {
|
|
232
|
+
const commands = await loadCommands();
|
|
233
|
+
registerCommands(program, commands);
|
|
234
|
+
await registerAuthCommands();
|
|
235
|
+
await registerConfigCommands();
|
|
236
|
+
await registerApiCommand();
|
|
237
|
+
program.parse();
|
|
238
|
+
}
|
|
239
|
+
main();
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// src/commands/meta/list-events.ts
|
|
2
|
+
var listEvents = {
|
|
3
|
+
service: "meta",
|
|
4
|
+
command: "+list-events",
|
|
5
|
+
description: "Get event catalog for a project",
|
|
6
|
+
flags: [
|
|
7
|
+
{ name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" }
|
|
8
|
+
],
|
|
9
|
+
risk: "read",
|
|
10
|
+
execute: async (ctx) => {
|
|
11
|
+
return ctx.api("GET", "/v1/ta/event/catalog/listEvent", {
|
|
12
|
+
projectId: ctx.num("project-id")
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// src/commands/meta/load-event-props.ts
|
|
18
|
+
var loadEventProps = {
|
|
19
|
+
service: "meta",
|
|
20
|
+
command: "+load-event-props",
|
|
21
|
+
description: "Load filterable properties for events (event + user props)",
|
|
22
|
+
flags: [
|
|
23
|
+
{ name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
|
|
24
|
+
{ name: "events", type: "json", desc: "Events array: [{eventName, eventType?}]" }
|
|
25
|
+
],
|
|
26
|
+
risk: "read",
|
|
27
|
+
execute: async (ctx) => {
|
|
28
|
+
const events = ctx.json("events") || [];
|
|
29
|
+
return ctx.api("POST", "/v1/ta/event/model/meta/loadFiltProps", {
|
|
30
|
+
projectId: ctx.num("project-id")
|
|
31
|
+
}, { events });
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// src/commands/meta/load-measure-props.ts
|
|
36
|
+
var loadMeasureProps = {
|
|
37
|
+
service: "meta",
|
|
38
|
+
command: "+load-measure-props",
|
|
39
|
+
description: "Load measurable/aggregatable properties for events",
|
|
40
|
+
flags: [
|
|
41
|
+
{ name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
|
|
42
|
+
{ name: "events", type: "json", required: true, desc: "Events array: [{eventName, eventType?}]" }
|
|
43
|
+
],
|
|
44
|
+
risk: "read",
|
|
45
|
+
execute: async (ctx) => {
|
|
46
|
+
return ctx.api("POST", "/v1/ta/event/model/meta/loadPropQuotas", {
|
|
47
|
+
projectId: ctx.num("project-id")
|
|
48
|
+
}, { events: ctx.json("events") });
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// src/commands/meta/list-entities.ts
|
|
53
|
+
var listEntities = {
|
|
54
|
+
service: "meta",
|
|
55
|
+
command: "+list-entities",
|
|
56
|
+
description: "List analysis entities (user, account, device, etc.)",
|
|
57
|
+
flags: [
|
|
58
|
+
{ name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" }
|
|
59
|
+
],
|
|
60
|
+
risk: "read",
|
|
61
|
+
execute: async (ctx) => {
|
|
62
|
+
return ctx.api("GET", "/v1/ta/entity/listEntities", {
|
|
63
|
+
projectId: ctx.num("project-id")
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// src/commands/meta/list-metrics.ts
|
|
69
|
+
var listMetrics = {
|
|
70
|
+
service: "meta",
|
|
71
|
+
command: "+list-metrics",
|
|
72
|
+
description: "List predefined metrics for a project",
|
|
73
|
+
flags: [
|
|
74
|
+
{ name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" }
|
|
75
|
+
],
|
|
76
|
+
risk: "read",
|
|
77
|
+
execute: async (ctx) => {
|
|
78
|
+
return ctx.api("GET", "/v1/ta/metric/listProjectMetrics", {
|
|
79
|
+
projectId: ctx.num("project-id")
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// src/commands/meta/list-tables.ts
|
|
85
|
+
var listTables = {
|
|
86
|
+
service: "meta",
|
|
87
|
+
command: "+list-tables",
|
|
88
|
+
description: "List SQL-queryable tables (event views, user views, tag tables)",
|
|
89
|
+
flags: [
|
|
90
|
+
{ name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" }
|
|
91
|
+
],
|
|
92
|
+
risk: "read",
|
|
93
|
+
execute: async (ctx) => {
|
|
94
|
+
return ctx.api("GET", "/v1/ta/taIde/auth/listProjectTable", {
|
|
95
|
+
projectId: ctx.num("project-id")
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// src/commands/meta/get-table-columns.ts
|
|
101
|
+
var getTableColumns = {
|
|
102
|
+
service: "meta",
|
|
103
|
+
command: "+get-table-columns",
|
|
104
|
+
description: "Get column definitions for a specific SQL table",
|
|
105
|
+
flags: [
|
|
106
|
+
{ name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
|
|
107
|
+
{ name: "table", type: "string", required: true, desc: "Table name" },
|
|
108
|
+
{ name: "schema", type: "string", default: "ta", desc: "Schema name" },
|
|
109
|
+
{ name: "catalog", type: "string", default: "hive", desc: "Catalog name" }
|
|
110
|
+
],
|
|
111
|
+
risk: "read",
|
|
112
|
+
execute: async (ctx) => {
|
|
113
|
+
return ctx.api("GET", "/v1/ta/taIde/auth/tableColumns", {
|
|
114
|
+
projectId: ctx.num("project-id"),
|
|
115
|
+
table: ctx.str("table"),
|
|
116
|
+
schema: ctx.str("schema") || "ta",
|
|
117
|
+
catalog: ctx.str("catalog") || "hive"
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// src/commands/meta/index.ts
|
|
123
|
+
var commands = [
|
|
124
|
+
listEvents,
|
|
125
|
+
loadEventProps,
|
|
126
|
+
loadMeasureProps,
|
|
127
|
+
listEntities,
|
|
128
|
+
listMetrics,
|
|
129
|
+
listTables,
|
|
130
|
+
getTableColumns
|
|
131
|
+
];
|
|
132
|
+
var meta_default = commands;
|
|
133
|
+
export {
|
|
134
|
+
meta_default as default
|
|
135
|
+
};
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
// src/commands/operation/create-task.ts
|
|
2
|
+
var createTask = {
|
|
3
|
+
service: "operation",
|
|
4
|
+
command: "+create-task",
|
|
5
|
+
description: "Create and submit an operation task for approval",
|
|
6
|
+
flags: [
|
|
7
|
+
{ name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
|
|
8
|
+
{ name: "task-config", type: "json", required: true, desc: "Task configuration (JSON)" }
|
|
9
|
+
],
|
|
10
|
+
risk: "write",
|
|
11
|
+
execute: async (ctx) => {
|
|
12
|
+
return ctx.api("POST", "/v1/hermes/operationTask/approval/saveAndSubmit", {}, {
|
|
13
|
+
projectId: ctx.num("project-id"),
|
|
14
|
+
...ctx.json("task-config")
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// src/commands/operation/list-tasks.ts
|
|
20
|
+
var listTasks = {
|
|
21
|
+
service: "operation",
|
|
22
|
+
command: "+list-tasks",
|
|
23
|
+
description: "List operation tasks for a project",
|
|
24
|
+
flags: [
|
|
25
|
+
{ name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
|
|
26
|
+
{ name: "page", type: "number", default: 1, desc: "Page number" },
|
|
27
|
+
{ name: "page-size", type: "number", default: 20, desc: "Page size" }
|
|
28
|
+
],
|
|
29
|
+
risk: "read",
|
|
30
|
+
execute: async (ctx) => {
|
|
31
|
+
return ctx.api("POST", "/v1/hermes/operationTask/query/list", {}, {
|
|
32
|
+
projectId: ctx.num("project-id"),
|
|
33
|
+
page: ctx.num("page"),
|
|
34
|
+
pageSize: ctx.num("page-size")
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/commands/operation/get-task-stats.ts
|
|
40
|
+
var getTaskStats = {
|
|
41
|
+
service: "operation",
|
|
42
|
+
command: "+get-task-stats",
|
|
43
|
+
description: "Get task status statistics and optional performance data",
|
|
44
|
+
flags: [
|
|
45
|
+
{ name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
|
|
46
|
+
{ name: "task-id", type: "number", desc: "Task ID (optional, for performance data)" }
|
|
47
|
+
],
|
|
48
|
+
risk: "read",
|
|
49
|
+
execute: async (ctx) => {
|
|
50
|
+
const projectId = ctx.num("project-id");
|
|
51
|
+
const taskId = ctx.num("task-id");
|
|
52
|
+
const [statusStat, perfData] = await Promise.all([
|
|
53
|
+
ctx.api("POST", "/v1/hermes/operationTask/query/statusStat", {}, { projectId }),
|
|
54
|
+
taskId ? ctx.api("POST", "/v1/hermes/operationTask/stat/query", {}, { projectId, taskId }) : Promise.resolve(null)
|
|
55
|
+
]);
|
|
56
|
+
return { statusStat, perfData };
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// src/commands/operation/save-flow.ts
|
|
61
|
+
var saveFlow = {
|
|
62
|
+
service: "operation",
|
|
63
|
+
command: "+save-flow",
|
|
64
|
+
description: "Save a flow configuration",
|
|
65
|
+
flags: [
|
|
66
|
+
{ name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
|
|
67
|
+
{ name: "flow-config", type: "json", required: true, desc: "Flow configuration (JSON)" }
|
|
68
|
+
],
|
|
69
|
+
risk: "write",
|
|
70
|
+
execute: async (ctx) => {
|
|
71
|
+
return ctx.api("POST", "/v1/hermes/flow/save", {}, {
|
|
72
|
+
projectId: ctx.num("project-id"),
|
|
73
|
+
...ctx.json("flow-config")
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// src/commands/operation/list-flows.ts
|
|
79
|
+
var listFlows = {
|
|
80
|
+
service: "operation",
|
|
81
|
+
command: "+list-flows",
|
|
82
|
+
description: "List flows for a project",
|
|
83
|
+
flags: [
|
|
84
|
+
{ name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" }
|
|
85
|
+
],
|
|
86
|
+
risk: "read",
|
|
87
|
+
execute: async (ctx) => {
|
|
88
|
+
return ctx.api("POST", "/v1/hermes/flow/query/list", {}, {
|
|
89
|
+
projectId: ctx.num("project-id")
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// src/commands/operation/get-flow.ts
|
|
95
|
+
var getFlow = {
|
|
96
|
+
service: "operation",
|
|
97
|
+
command: "+get-flow",
|
|
98
|
+
description: "Get a flow by its UUID",
|
|
99
|
+
flags: [
|
|
100
|
+
{ name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
|
|
101
|
+
{ name: "flow-uuid", type: "string", required: true, desc: "Flow UUID" }
|
|
102
|
+
],
|
|
103
|
+
risk: "read",
|
|
104
|
+
execute: async (ctx) => {
|
|
105
|
+
return ctx.api("GET", "/v1/hermes/flow/queryByFlowUuid", {
|
|
106
|
+
projectId: ctx.num("project-id"),
|
|
107
|
+
flowUuid: ctx.str("flow-uuid")
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// src/commands/operation/list-channels.ts
|
|
113
|
+
var listChannels = {
|
|
114
|
+
service: "operation",
|
|
115
|
+
command: "+list-channels",
|
|
116
|
+
description: "List channels for a project",
|
|
117
|
+
flags: [
|
|
118
|
+
{ name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" }
|
|
119
|
+
],
|
|
120
|
+
risk: "read",
|
|
121
|
+
execute: async (ctx) => {
|
|
122
|
+
return ctx.api("GET", "/v1/hermes/channel/query/list", {
|
|
123
|
+
projectId: ctx.num("project-id")
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// src/commands/operation/get-channel.ts
|
|
129
|
+
var getChannel = {
|
|
130
|
+
service: "operation",
|
|
131
|
+
command: "+get-channel",
|
|
132
|
+
description: "Get channel details and meta info",
|
|
133
|
+
flags: [
|
|
134
|
+
{ name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
|
|
135
|
+
{ name: "channel-id", type: "number", required: true, desc: "Channel ID" }
|
|
136
|
+
],
|
|
137
|
+
risk: "read",
|
|
138
|
+
execute: async (ctx) => {
|
|
139
|
+
const projectId = ctx.num("project-id");
|
|
140
|
+
const channelId = ctx.num("channel-id");
|
|
141
|
+
const [channel, metaInfo] = await Promise.all([
|
|
142
|
+
ctx.api("GET", "/v1/hermes/channel/queryById", { projectId, channelId }),
|
|
143
|
+
ctx.api("GET", "/v1/hermes/channel/queryChannelMetaInfoById", { projectId, channelId })
|
|
144
|
+
]);
|
|
145
|
+
return { ...channel, metaInfo };
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// src/commands/operation/get-space-tree.ts
|
|
150
|
+
var getSpaceTree = {
|
|
151
|
+
service: "operation",
|
|
152
|
+
command: "+get-space-tree",
|
|
153
|
+
description: "Get the space tree for a project",
|
|
154
|
+
flags: [
|
|
155
|
+
{ name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" }
|
|
156
|
+
],
|
|
157
|
+
risk: "read",
|
|
158
|
+
execute: async (ctx) => {
|
|
159
|
+
return ctx.api("GET", "/v1/ta/space/getSpaceTree", {
|
|
160
|
+
projectId: ctx.num("project-id")
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// src/commands/operation/get-timezone.ts
|
|
166
|
+
var getTimezone = {
|
|
167
|
+
service: "operation",
|
|
168
|
+
command: "+get-timezone",
|
|
169
|
+
description: "Get the timezone offset for a project",
|
|
170
|
+
flags: [
|
|
171
|
+
{ name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" }
|
|
172
|
+
],
|
|
173
|
+
risk: "read",
|
|
174
|
+
execute: async (ctx) => {
|
|
175
|
+
return ctx.api("GET", "/v1/hermes/common/project/tzOffset", {
|
|
176
|
+
projectId: ctx.num("project-id")
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// src/commands/operation/list-mark-times.ts
|
|
182
|
+
var listMarkTimes = {
|
|
183
|
+
service: "operation",
|
|
184
|
+
command: "+list-mark-times",
|
|
185
|
+
description: "List milestone mark times for a project",
|
|
186
|
+
flags: [
|
|
187
|
+
{ name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" }
|
|
188
|
+
],
|
|
189
|
+
risk: "read",
|
|
190
|
+
execute: async (ctx) => {
|
|
191
|
+
return ctx.api("POST", "/v1/ta/projectMilestone/markTime/listMarkTime", {}, {
|
|
192
|
+
projectId: ctx.num("project-id")
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// src/commands/operation/index.ts
|
|
198
|
+
var commands = [
|
|
199
|
+
createTask,
|
|
200
|
+
listTasks,
|
|
201
|
+
getTaskStats,
|
|
202
|
+
saveFlow,
|
|
203
|
+
listFlows,
|
|
204
|
+
getFlow,
|
|
205
|
+
listChannels,
|
|
206
|
+
getChannel,
|
|
207
|
+
getSpaceTree,
|
|
208
|
+
getTimezone,
|
|
209
|
+
listMarkTimes
|
|
210
|
+
];
|
|
211
|
+
var operation_default = commands;
|
|
212
|
+
export {
|
|
213
|
+
operation_default as default
|
|
214
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
httpGet,
|
|
3
|
+
httpPost
|
|
4
|
+
} from "./chunk-KA66K7EL.js";
|
|
5
|
+
import {
|
|
6
|
+
printError,
|
|
7
|
+
printOutput
|
|
8
|
+
} from "./chunk-KM57HI5B.js";
|
|
9
|
+
import {
|
|
10
|
+
resolveHost
|
|
11
|
+
} from "./chunk-4YPCK7T5.js";
|
|
12
|
+
import "./chunk-STTYG7WN.js";
|
|
13
|
+
|
|
14
|
+
// src/api/raw.ts
|
|
15
|
+
function registerApi(program) {
|
|
16
|
+
program.command("api").description("Raw API call: te-cli api <METHOD> <PATH> [options]").argument("<method>", "HTTP method (GET, POST)").argument("<path>", "API path (e.g., /v1/ta/event/catalog/listEvent)").option("--params <json>", "URL parameters as JSON").option("--data <json>", "Request body as JSON").action(async (method, apiPath, opts) => {
|
|
17
|
+
const globalOpts = program.opts();
|
|
18
|
+
const host = resolveHost(globalOpts.host);
|
|
19
|
+
const format = globalOpts.format || "json";
|
|
20
|
+
const jq = globalOpts.jq;
|
|
21
|
+
if (!host) {
|
|
22
|
+
printError("config", "No TE host configured.", "Run: te-cli config set-host");
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
let params = {};
|
|
27
|
+
let body = void 0;
|
|
28
|
+
if (opts.params) {
|
|
29
|
+
try {
|
|
30
|
+
params = JSON.parse(opts.params);
|
|
31
|
+
} catch {
|
|
32
|
+
printError("validation", `Invalid JSON for --params: ${opts.params}`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (opts.data) {
|
|
37
|
+
try {
|
|
38
|
+
body = JSON.parse(opts.data);
|
|
39
|
+
} catch {
|
|
40
|
+
printError("validation", `Invalid JSON for --data: ${opts.data}`);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
let result;
|
|
45
|
+
if (method.toUpperCase() === "GET") {
|
|
46
|
+
result = await httpGet(apiPath, params, host);
|
|
47
|
+
} else {
|
|
48
|
+
result = await httpPost(apiPath, params, body, host);
|
|
49
|
+
}
|
|
50
|
+
printOutput(result, format, jq);
|
|
51
|
+
} catch (err) {
|
|
52
|
+
printError("api", err.message);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
registerApi
|
|
59
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
httpGet,
|
|
3
|
+
httpPost
|
|
4
|
+
} from "./chunk-V3D6XL5Z.js";
|
|
5
|
+
import {
|
|
6
|
+
printError,
|
|
7
|
+
printOutput
|
|
8
|
+
} from "./chunk-KM57HI5B.js";
|
|
9
|
+
import {
|
|
10
|
+
resolveHost
|
|
11
|
+
} from "./chunk-C3VJLU5Y.js";
|
|
12
|
+
import "./chunk-KAWQCMDL.js";
|
|
13
|
+
|
|
14
|
+
// src/api/raw.ts
|
|
15
|
+
function registerApi(program) {
|
|
16
|
+
program.command("api").description("Raw API call: te-cli api <METHOD> <PATH> [options]").argument("<method>", "HTTP method (GET, POST)").argument("<path>", "API path (e.g., /v1/ta/event/catalog/listEvent)").option("--params <json>", "URL parameters as JSON").option("--data <json>", "Request body as JSON").action(async (method, apiPath, opts) => {
|
|
17
|
+
const globalOpts = program.opts();
|
|
18
|
+
const host = resolveHost(globalOpts.host);
|
|
19
|
+
const format = globalOpts.format || "json";
|
|
20
|
+
const jq = globalOpts.jq;
|
|
21
|
+
try {
|
|
22
|
+
let params = {};
|
|
23
|
+
let body = void 0;
|
|
24
|
+
if (opts.params) {
|
|
25
|
+
try {
|
|
26
|
+
params = JSON.parse(opts.params);
|
|
27
|
+
} catch {
|
|
28
|
+
printError("validation", `Invalid JSON for --params: ${opts.params}`);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (opts.data) {
|
|
33
|
+
try {
|
|
34
|
+
body = JSON.parse(opts.data);
|
|
35
|
+
} catch {
|
|
36
|
+
printError("validation", `Invalid JSON for --data: ${opts.data}`);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
let result;
|
|
41
|
+
if (method.toUpperCase() === "GET") {
|
|
42
|
+
result = await httpGet(apiPath, params, host);
|
|
43
|
+
} else {
|
|
44
|
+
result = await httpPost(apiPath, params, body, host);
|
|
45
|
+
}
|
|
46
|
+
printOutput(result, format, jq);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
printError("api", err.message);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
registerApi
|
|
55
|
+
};
|