@lark-apaas/miaoda-cli 0.1.2 → 0.1.3

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.
Files changed (55) hide show
  1. package/README.md +8 -7
  2. package/dist/api/app/api.js +25 -0
  3. package/dist/api/app/index.js +15 -0
  4. package/dist/api/app/schemas.js +79 -0
  5. package/dist/api/app/types.js +58 -0
  6. package/dist/api/deploy/api.js +60 -0
  7. package/dist/api/deploy/index.js +16 -0
  8. package/dist/api/deploy/schemas.js +105 -0
  9. package/dist/api/deploy/types.js +22 -0
  10. package/dist/api/index.js +7 -1
  11. package/dist/api/observability/api.js +52 -0
  12. package/dist/api/observability/index.js +16 -0
  13. package/dist/api/observability/schemas.js +60 -0
  14. package/dist/api/observability/types.js +27 -0
  15. package/dist/cli/commands/app/index.js +62 -0
  16. package/dist/cli/commands/db/index.js +6 -5
  17. package/dist/cli/commands/deploy/index.js +155 -0
  18. package/dist/cli/commands/file/index.js +6 -5
  19. package/dist/cli/commands/index.js +10 -6
  20. package/dist/cli/commands/observability/index.js +240 -0
  21. package/dist/cli/commands/shared.js +83 -7
  22. package/dist/cli/handlers/app/get.js +47 -0
  23. package/dist/cli/handlers/app/index.js +7 -0
  24. package/dist/cli/handlers/app/update.js +59 -0
  25. package/dist/cli/handlers/db/data.js +2 -3
  26. package/dist/cli/handlers/db/schema.js +2 -3
  27. package/dist/cli/handlers/db/sql.js +1 -2
  28. package/dist/cli/handlers/deploy/deploy.js +84 -0
  29. package/dist/cli/handlers/deploy/error-log.js +60 -0
  30. package/dist/cli/handlers/deploy/format.js +39 -0
  31. package/dist/cli/handlers/deploy/get.js +71 -0
  32. package/dist/cli/handlers/deploy/helpers.js +41 -0
  33. package/dist/cli/handlers/deploy/history.js +70 -0
  34. package/dist/cli/handlers/deploy/index.js +14 -0
  35. package/dist/cli/handlers/deploy/polling.js +162 -0
  36. package/dist/cli/handlers/file/cp.js +1 -2
  37. package/dist/cli/handlers/file/ls.js +1 -2
  38. package/dist/cli/handlers/file/rm.js +1 -2
  39. package/dist/cli/handlers/file/sign.js +1 -2
  40. package/dist/cli/handlers/file/stat.js +1 -2
  41. package/dist/cli/handlers/observability/analytics.js +212 -0
  42. package/dist/cli/handlers/observability/helpers.js +66 -0
  43. package/dist/cli/handlers/observability/index.js +12 -0
  44. package/dist/cli/handlers/observability/log.js +94 -0
  45. package/dist/cli/handlers/observability/metric.js +208 -0
  46. package/dist/cli/handlers/observability/trace.js +102 -0
  47. package/dist/main.js +6 -2
  48. package/dist/utils/args.js +8 -0
  49. package/dist/utils/devops-error.js +28 -0
  50. package/dist/utils/git.js +29 -0
  51. package/dist/utils/http.js +118 -0
  52. package/dist/utils/index.js +13 -1
  53. package/dist/utils/output.js +338 -7
  54. package/dist/utils/time.js +203 -0
  55. package/package.json +7 -5
package/README.md CHANGED
@@ -14,22 +14,22 @@ pnpm add -g @lark-apaas/miaoda-cli
14
14
  # 设置默认应用(需要应用上下文的命令可用 --app-id 覆盖)
15
15
  export MIAODA_APP_ID=app_demo_xxx
16
16
 
17
- # 插件管理
18
- miaoda plugin list-packages
19
- miaoda plugin install @demo/example-plugin
17
+ # 文件操作
18
+ miaoda file ls
19
+ miaoda file upload ./local/path
20
20
  ```
21
21
 
22
22
  JSON 结构化输出(Agent 推荐):
23
23
 
24
24
  ```bash
25
25
  # 输出全部字段
26
- miaoda plugin list --json
26
+ miaoda file ls --json
27
27
 
28
28
  # 可选字段级选择
29
- miaoda plugin list --json id,name
29
+ miaoda file ls --json id,name
30
30
 
31
31
  # 或通过 --output 指定格式
32
- miaoda plugin list --output json
32
+ miaoda file ls --output json
33
33
  ```
34
34
 
35
35
  ## 命令树
@@ -38,7 +38,8 @@ miaoda plugin list --output json
38
38
 
39
39
  | 域 | 用途 |
40
40
  |---|---|
41
- | `miaoda plugin ...` | 插件管理:安装、更新、移除、插件实例查询 |
41
+ | `miaoda file ...` | 文件操作:上传、下载、元数据、签名下载、批量删除 |
42
+ | `miaoda db ...` | 数据操作:SQL 执行、表结构查询、数据导入导出 |
42
43
 
43
44
  完整命令通过 `miaoda --help` 或 `miaoda <domain> --help` 查看。
44
45
 
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAppInfo = getAppInfo;
4
+ exports.updateAppMeta = updateAppMeta;
5
+ const http_1 = require("../../utils/http");
6
+ const devops_error_1 = require("../../utils/devops-error");
7
+ const DEFAULT_ERR_CODE = "INTERNAL_DEVOPS_ERROR";
8
+ function envelopeOpts(errPrefix) {
9
+ return {
10
+ errPrefix,
11
+ defaultErrCode: DEFAULT_ERR_CODE,
12
+ mapErr: devops_error_1.mapDevopsError,
13
+ };
14
+ }
15
+ /** GET /v1/devops/app/:appID — 获取应用详情 */
16
+ async function getAppInfo(appID) {
17
+ const url = `/v1/devops/app/${encodeURIComponent(appID)}`;
18
+ return (0, http_1.getInnerApi)(url, envelopeOpts("Failed to get app info"));
19
+ }
20
+ /** POST /v1/devops/app/:appID/meta — 更新应用元数据 */
21
+ async function updateAppMeta(req) {
22
+ const url = `/v1/devops/app/${encodeURIComponent(req.appID)}/meta`;
23
+ // 路径已带 appID,body 里也保留以匹配 BAM IDL 的 sensitive:"no" 透传约定
24
+ return (0, http_1.postInnerApi)(url, req, envelopeOpts("Failed to update app"));
25
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ArchType = exports.Source = exports.BizType = exports.AppType = exports.AppMode = exports.AppStatus = exports.appMetaSchema = exports.updateAppMeta = exports.getAppInfo = void 0;
4
+ var api_1 = require("./api");
5
+ Object.defineProperty(exports, "getAppInfo", { enumerable: true, get: function () { return api_1.getAppInfo; } });
6
+ Object.defineProperty(exports, "updateAppMeta", { enumerable: true, get: function () { return api_1.updateAppMeta; } });
7
+ var schemas_1 = require("./schemas");
8
+ Object.defineProperty(exports, "appMetaSchema", { enumerable: true, get: function () { return schemas_1.appMetaSchema; } });
9
+ var types_1 = require("./types");
10
+ Object.defineProperty(exports, "AppStatus", { enumerable: true, get: function () { return types_1.AppStatus; } });
11
+ Object.defineProperty(exports, "AppMode", { enumerable: true, get: function () { return types_1.AppMode; } });
12
+ Object.defineProperty(exports, "AppType", { enumerable: true, get: function () { return types_1.AppType; } });
13
+ Object.defineProperty(exports, "BizType", { enumerable: true, get: function () { return types_1.BizType; } });
14
+ Object.defineProperty(exports, "Source", { enumerable: true, get: function () { return types_1.Source; } });
15
+ Object.defineProperty(exports, "ArchType", { enumerable: true, get: function () { return types_1.ArchType; } });
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.appMetaSchema = void 0;
4
+ const output_1 = require("../../utils/output");
5
+ const types_1 = require("./types");
6
+ // Partial<Record<...>>:未来 BAM 加新枚举值时这里没声明也不报错,运行期 lookup 自然得 undefined
7
+ const STATUS_TEXT = {
8
+ [types_1.AppStatus.UNSPECIFIED]: "unknown",
9
+ [types_1.AppStatus.PREPARING]: "preparing",
10
+ [types_1.AppStatus.UNRELEASED]: "unreleased",
11
+ [types_1.AppStatus.RELEASED]: "released",
12
+ [types_1.AppStatus.DELETED]: "deleted",
13
+ [types_1.AppStatus.UPGRADING]: "upgrading",
14
+ };
15
+ const MODE_TEXT = {
16
+ [types_1.AppMode.UNSPECIFIED]: "unknown",
17
+ [types_1.AppMode.STANDARD]: "standard",
18
+ [types_1.AppMode.EXPERT]: "expert",
19
+ };
20
+ const TYPE_TEXT = {
21
+ [types_1.AppType.UNSPECIFIED]: "unknown",
22
+ [types_1.AppType.STANDARD]: "standard",
23
+ [types_1.AppType.PROTOTYPE]: "prototype",
24
+ [types_1.AppType.APPLICATION]: "application",
25
+ [types_1.AppType.DESIGN]: "design",
26
+ [types_1.AppType.OPENCLAW]: "openclaw",
27
+ [types_1.AppType.CLAW_SUB]: "claw_sub",
28
+ };
29
+ const BIZ_TYPE_TEXT = {
30
+ [types_1.BizType.UNSPECIFIED]: "unknown",
31
+ [types_1.BizType.MIAODA]: "miaoda",
32
+ [types_1.BizType.FORCE]: "force",
33
+ };
34
+ const ARCH_TYPE_TEXT = {
35
+ [types_1.ArchType.UNSPECIFIED]: "unknown",
36
+ [types_1.ArchType.FULL_STACK]: "full_stack",
37
+ [types_1.ArchType.NOT_FULL_STACK]: "not_full_stack",
38
+ };
39
+ const SOURCE_TEXT = {
40
+ [types_1.Source.UNSPECIFIED]: "unknown",
41
+ [types_1.Source.CHAT]: "chat",
42
+ [types_1.Source.TEMPLATE]: "template",
43
+ [types_1.Source.IMPORT_ZIP]: "import_zip",
44
+ [types_1.Source.IMPORT_BASE]: "import_base",
45
+ };
46
+ function lookup(table) {
47
+ return (v) => {
48
+ if (typeof v !== "number")
49
+ return undefined;
50
+ return table[v];
51
+ };
52
+ }
53
+ /**
54
+ * AppMeta 的 pretty 渲染契约。
55
+ *
56
+ * 注:BAM 没给 createdAt / updatedAt 的单位注解;先按 ms(fmt.ms)渲染,
57
+ * 待 e2e 真值确认后调整。enum 字段通过 derive 翻译成可读字符串,JSON 模式
58
+ * 仍是 BAM 原值(数字枚举),与 BAM 接口契约保持一致。
59
+ */
60
+ exports.appMetaSchema = {
61
+ columns: [
62
+ { key: "appID", label: "app-id" },
63
+ { key: "name" },
64
+ { key: "description" },
65
+ { key: "status_text", label: "status", derive: (row) => lookup(STATUS_TEXT)(row.status) },
66
+ { key: "appType_text", label: "type", derive: (row) => lookup(TYPE_TEXT)(row.appType) },
67
+ { key: "appMode_text", label: "mode", derive: (row) => lookup(MODE_TEXT)(row.appMode) },
68
+ { key: "bizType_text", label: "biz-type", derive: (row) => lookup(BIZ_TYPE_TEXT)(row.bizType) },
69
+ { key: "archType_text", label: "arch", derive: (row) => lookup(ARCH_TYPE_TEXT)(row.archType) },
70
+ { key: "source_text", label: "source", derive: (row) => lookup(SOURCE_TEXT)(row.source) },
71
+ { key: "ownedBy", label: "owner" },
72
+ { key: "createdBy", label: "creator" },
73
+ { key: "dataBranchID", label: "branch" },
74
+ { key: "parentAppID", label: "parent-app" },
75
+ { key: "createdAt", label: "created-at", format: output_1.fmt.ms() },
76
+ { key: "updatedAt", label: "updated-at", format: output_1.fmt.ms() },
77
+ ],
78
+ strict: true,
79
+ };
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ // 与 BAM lark.apaas.devops v1.0.326 对齐:
3
+ // - CLIGetAppInfo (4070322) → AppInfo / AppMeta
4
+ // - CLIUpdateAppMeta (4070323) → 入参 name? / description?
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ArchType = exports.Source = exports.BizType = exports.AppType = exports.AppMode = exports.AppStatus = void 0;
7
+ /** 应用状态 */
8
+ var AppStatus;
9
+ (function (AppStatus) {
10
+ AppStatus[AppStatus["UNSPECIFIED"] = 0] = "UNSPECIFIED";
11
+ AppStatus[AppStatus["PREPARING"] = 1] = "PREPARING";
12
+ AppStatus[AppStatus["UNRELEASED"] = 2] = "UNRELEASED";
13
+ AppStatus[AppStatus["RELEASED"] = 3] = "RELEASED";
14
+ /** BAM 注释为 Deprecated;保留枚举以兼容历史响应数据 */
15
+ AppStatus[AppStatus["DELETED"] = 4] = "DELETED";
16
+ AppStatus[AppStatus["UPGRADING"] = 5] = "UPGRADING";
17
+ })(AppStatus || (exports.AppStatus = AppStatus = {}));
18
+ /** 应用模式 */
19
+ var AppMode;
20
+ (function (AppMode) {
21
+ AppMode[AppMode["UNSPECIFIED"] = 0] = "UNSPECIFIED";
22
+ AppMode[AppMode["STANDARD"] = 1] = "STANDARD";
23
+ AppMode[AppMode["EXPERT"] = 2] = "EXPERT";
24
+ })(AppMode || (exports.AppMode = AppMode = {}));
25
+ /** 应用类型 */
26
+ var AppType;
27
+ (function (AppType) {
28
+ AppType[AppType["UNSPECIFIED"] = 0] = "UNSPECIFIED";
29
+ AppType[AppType["STANDARD"] = 1] = "STANDARD";
30
+ AppType[AppType["PROTOTYPE"] = 2] = "PROTOTYPE";
31
+ AppType[AppType["APPLICATION"] = 3] = "APPLICATION";
32
+ AppType[AppType["DESIGN"] = 4] = "DESIGN";
33
+ AppType[AppType["OPENCLAW"] = 5] = "OPENCLAW";
34
+ AppType[AppType["CLAW_SUB"] = 6] = "CLAW_SUB";
35
+ })(AppType || (exports.AppType = AppType = {}));
36
+ /** 业务线 */
37
+ var BizType;
38
+ (function (BizType) {
39
+ BizType[BizType["UNSPECIFIED"] = 0] = "UNSPECIFIED";
40
+ BizType[BizType["MIAODA"] = 1] = "MIAODA";
41
+ BizType[BizType["FORCE"] = 2] = "FORCE";
42
+ })(BizType || (exports.BizType = BizType = {}));
43
+ /** 应用来源 */
44
+ var Source;
45
+ (function (Source) {
46
+ Source[Source["UNSPECIFIED"] = 0] = "UNSPECIFIED";
47
+ Source[Source["CHAT"] = 1] = "CHAT";
48
+ Source[Source["TEMPLATE"] = 2] = "TEMPLATE";
49
+ Source[Source["IMPORT_ZIP"] = 3] = "IMPORT_ZIP";
50
+ Source[Source["IMPORT_BASE"] = 4] = "IMPORT_BASE";
51
+ })(Source || (exports.Source = Source = {}));
52
+ /** 架构类型 */
53
+ var ArchType;
54
+ (function (ArchType) {
55
+ ArchType[ArchType["UNSPECIFIED"] = 0] = "UNSPECIFIED";
56
+ ArchType[ArchType["FULL_STACK"] = 1] = "FULL_STACK";
57
+ ArchType[ArchType["NOT_FULL_STACK"] = 2] = "NOT_FULL_STACK";
58
+ })(ArchType || (exports.ArchType = ArchType = {}));
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createRelease = createRelease;
4
+ exports.listPipelineInstances = listPipelineInstances;
5
+ exports.getErrorLog = getErrorLog;
6
+ exports.queryPipelineInstance = queryPipelineInstance;
7
+ const http_1 = require("../../utils/http");
8
+ const devops_error_1 = require("../../utils/devops-error");
9
+ const DEFAULT_ERR_CODE = "INTERNAL_DEVOPS_ERROR";
10
+ function envelopeOpts(errPrefix) {
11
+ return {
12
+ errPrefix,
13
+ defaultErrCode: DEFAULT_ERR_CODE,
14
+ // deploy 与 app 走同一个 PSM;业务码映射复用
15
+ mapErr: devops_error_1.mapDevopsError,
16
+ };
17
+ }
18
+ /** POST /v1/devops/app/:appID/release — 触发发布 */
19
+ async function createRelease(req) {
20
+ const url = `/v1/devops/app/${encodeURIComponent(req.appID)}/release`;
21
+ return (0, http_1.postInnerApi)(url, req, envelopeOpts("Failed to create release"));
22
+ }
23
+ /**
24
+ * POST /v1/pipeline/app/:appID/instance/list — 分页查询发布历史
25
+ *
26
+ * 走 lark.apaas.devops_platform PSM(同 queryPipelineInstance)。
27
+ * 不复用 mapDevopsError——那是 lark.apaas.devops 的业务码映射。
28
+ */
29
+ async function listPipelineInstances(req) {
30
+ const url = `/v1/pipeline/app/${encodeURIComponent(req.appID)}/instance/list`;
31
+ return (0, http_1.postInnerApi)(url, req, {
32
+ errPrefix: "Failed to list deploys",
33
+ defaultErrCode: DEFAULT_ERR_CODE,
34
+ });
35
+ }
36
+ /**
37
+ * GET /v1/pipeline/app/:appID/instance/:instanceID/error_log — 获取发布错误日志
38
+ *
39
+ * 走 lark.apaas.devops_platform PSM;instanceID 即 pipelineTaskID == deploy-id。
40
+ * BAM CliGetToolInstanceErrorJobs(4073972),路径段无 body。
41
+ */
42
+ async function getErrorLog(req) {
43
+ const url = `/v1/pipeline/app/${encodeURIComponent(req.appID)}/instance/${encodeURIComponent(req.instanceID)}/error_log`;
44
+ return (0, http_1.getInnerApi)(url, {
45
+ errPrefix: "Failed to get error log",
46
+ defaultErrCode: DEFAULT_ERR_CODE,
47
+ });
48
+ }
49
+ /**
50
+ * GET /v1/pipeline/app/:appID/instance/:instanceID/detail — 轮询发布状态
51
+ *
52
+ * 走 lark.apaas.devops_platform PSM;URL 前缀不同但共用同一管理端 gateway。
53
+ */
54
+ async function queryPipelineInstance(req) {
55
+ const url = `/v1/pipeline/app/${encodeURIComponent(req.appID)}/instance/${encodeURIComponent(req.instanceID)}/detail`;
56
+ return (0, http_1.getInnerApi)(url, {
57
+ errPrefix: "Failed to query pipeline",
58
+ defaultErrCode: DEFAULT_ERR_CODE,
59
+ });
60
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NodeStatus = exports.nodeStatusFromText = exports.nodeStatusText = exports.errorJobSchema = exports.deployGetSchema = exports.deployHistorySchema = exports.queryPipelineInstance = exports.getErrorLog = exports.listPipelineInstances = exports.createRelease = void 0;
4
+ var api_1 = require("./api");
5
+ Object.defineProperty(exports, "createRelease", { enumerable: true, get: function () { return api_1.createRelease; } });
6
+ Object.defineProperty(exports, "listPipelineInstances", { enumerable: true, get: function () { return api_1.listPipelineInstances; } });
7
+ Object.defineProperty(exports, "getErrorLog", { enumerable: true, get: function () { return api_1.getErrorLog; } });
8
+ Object.defineProperty(exports, "queryPipelineInstance", { enumerable: true, get: function () { return api_1.queryPipelineInstance; } });
9
+ var schemas_1 = require("./schemas");
10
+ Object.defineProperty(exports, "deployHistorySchema", { enumerable: true, get: function () { return schemas_1.deployHistorySchema; } });
11
+ Object.defineProperty(exports, "deployGetSchema", { enumerable: true, get: function () { return schemas_1.deployGetSchema; } });
12
+ Object.defineProperty(exports, "errorJobSchema", { enumerable: true, get: function () { return schemas_1.errorJobSchema; } });
13
+ Object.defineProperty(exports, "nodeStatusText", { enumerable: true, get: function () { return schemas_1.nodeStatusText; } });
14
+ Object.defineProperty(exports, "nodeStatusFromText", { enumerable: true, get: function () { return schemas_1.nodeStatusFromText; } });
15
+ var types_1 = require("./types");
16
+ Object.defineProperty(exports, "NodeStatus", { enumerable: true, get: function () { return types_1.NodeStatus; } });
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.errorJobSchema = exports.deployGetSchema = exports.deployHistorySchema = void 0;
4
+ exports.nodeStatusText = nodeStatusText;
5
+ exports.nodeStatusFromText = nodeStatusFromText;
6
+ const output_1 = require("../../utils/output");
7
+ const types_1 = require("./types");
8
+ const NODE_STATUS_TEXT = {
9
+ [types_1.NodeStatus.UNSPECIFIED]: "unknown",
10
+ [types_1.NodeStatus.TODO]: "todo",
11
+ [types_1.NodeStatus.RUNNING]: "running",
12
+ [types_1.NodeStatus.SUCCESS]: "success",
13
+ [types_1.NodeStatus.FAILED]: "failed",
14
+ [types_1.NodeStatus.CANCELED]: "canceled",
15
+ [types_1.NodeStatus.HOLD_ON]: "hold_on",
16
+ };
17
+ function nodeStatusText(v) {
18
+ if (typeof v === "string")
19
+ return v;
20
+ if (typeof v !== "number")
21
+ return undefined;
22
+ return NODE_STATUS_TEXT[v];
23
+ }
24
+ /** NodeStatus 文本(CLI flag 字符串)→ 枚举数值 */
25
+ function nodeStatusFromText(text) {
26
+ const lower = text.toLowerCase();
27
+ for (const [num, label] of Object.entries(NODE_STATUS_TEXT)) {
28
+ if (label === lower)
29
+ return Number(num);
30
+ }
31
+ return undefined;
32
+ }
33
+ function pipelineDurationMs(row) {
34
+ // SimpleInstance.createdAt / updatedAt:BAM IDL 未注单位,e2e 看是 ms。
35
+ const start = Number(row.createdAt);
36
+ const end = Number(row.updatedAt);
37
+ if (!Number.isFinite(start) || !Number.isFinite(end))
38
+ return undefined;
39
+ return end - start;
40
+ }
41
+ /**
42
+ * deploy history 列表的 pretty 渲染契约。
43
+ *
44
+ * BAM 返回 SimpleInstance(pipeline 实例),状态走 NodeStatus。
45
+ * 默认列:deploy-id(=ID)/ status / creator / created-at / duration(updatedAt-createdAt)。
46
+ */
47
+ exports.deployHistorySchema = {
48
+ columns: [
49
+ { key: "ID", label: "deploy-id" },
50
+ {
51
+ key: "status_text",
52
+ label: "status",
53
+ derive: (row) => nodeStatusText(row.status),
54
+ },
55
+ { key: "creator", label: "creator" },
56
+ { key: "createdAt", label: "created-at", format: output_1.fmt.ms() },
57
+ {
58
+ key: "duration",
59
+ label: "duration",
60
+ format: output_1.fmt.durationMs(),
61
+ derive: pipelineDurationMs,
62
+ },
63
+ ],
64
+ strict: true,
65
+ };
66
+ /**
67
+ * deploy get 单条详情的 key-value 渲染契约(基于 SimpleInstance)。
68
+ *
69
+ * 由于 BAM 没有 by-ID 的查询接口,handler 用 listPipelineInstances 在最近窗口
70
+ * 里筛一条 SimpleInstance 透传过来。
71
+ */
72
+ exports.deployGetSchema = {
73
+ columns: [
74
+ { key: "ID", label: "deploy-id" },
75
+ {
76
+ key: "status_text",
77
+ label: "status",
78
+ derive: (row) => nodeStatusText(row.status),
79
+ },
80
+ { key: "creator", label: "creator" },
81
+ { key: "updater", label: "updater" },
82
+ { key: "createdAt", label: "created-at", format: output_1.fmt.ms() },
83
+ { key: "updatedAt", label: "updated-at", format: output_1.fmt.ms() },
84
+ {
85
+ key: "duration",
86
+ label: "duration",
87
+ format: output_1.fmt.durationMs(),
88
+ derive: pipelineDurationMs,
89
+ },
90
+ { key: "templateID", label: "template" },
91
+ { key: "description" },
92
+ { key: "parameters" },
93
+ { key: "envVariables", label: "env-vars" },
94
+ ],
95
+ strict: true,
96
+ };
97
+ /** deploy error-log 表格渲染契约 */
98
+ exports.errorJobSchema = {
99
+ columns: [
100
+ { key: "jobID", label: "job-id" },
101
+ { key: "componentName", label: "component" },
102
+ { key: "errorMsg", label: "error" },
103
+ ],
104
+ strict: true,
105
+ };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ // 与 BAM lark.apaas.devops v1.0.326 / 1.0.327 + lark.apaas.devops_platform v1.0.247 对齐:
3
+ // - CLICreateForceRelease (4070318) 创建发布 lark.apaas.devops
4
+ // - CliQueryPipelineInstance (4069872) 轮询发布状态 lark.apaas.devops_platform
5
+ // - CliListPipelineInstances (4073969) 分页获取发布历史 lark.apaas.devops_platform
6
+ // - CliGetToolInstanceErrorJobs (4073972) 获取发布错误日志 lark.apaas.devops_platform
7
+ //
8
+ // 发布单的唯一标识是 pipelineTaskID,对外即 deploy-id;error-log 等接口直接用它做
9
+ // URL 路径段(instanceID)。曾经的 Release/releaseID 概念已全面废弃。
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.NodeStatus = void 0;
12
+ /** Pipeline 节点状态(devops_platform) */
13
+ var NodeStatus;
14
+ (function (NodeStatus) {
15
+ NodeStatus[NodeStatus["UNSPECIFIED"] = 0] = "UNSPECIFIED";
16
+ NodeStatus[NodeStatus["TODO"] = 1] = "TODO";
17
+ NodeStatus[NodeStatus["RUNNING"] = 2] = "RUNNING";
18
+ NodeStatus[NodeStatus["SUCCESS"] = 3] = "SUCCESS";
19
+ NodeStatus[NodeStatus["FAILED"] = 4] = "FAILED";
20
+ NodeStatus[NodeStatus["CANCELED"] = 5] = "CANCELED";
21
+ NodeStatus[NodeStatus["HOLD_ON"] = 6] = "HOLD_ON";
22
+ })(NodeStatus || (exports.NodeStatus = NodeStatus = {}));
package/dist/api/index.js CHANGED
@@ -33,10 +33,16 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.db = exports.file = exports.plugin = void 0;
36
+ exports.deploy = exports.app = exports.observability = exports.db = exports.file = exports.plugin = void 0;
37
37
  const _plugin = __importStar(require("../api/plugin/index"));
38
38
  const _file = __importStar(require("../api/file/index"));
39
39
  const _db = __importStar(require("../api/db/index"));
40
+ const _observability = __importStar(require("../api/observability/index"));
41
+ const _app = __importStar(require("../api/app/index"));
42
+ const _deploy = __importStar(require("../api/deploy/index"));
40
43
  exports.plugin = { ..._plugin };
41
44
  exports.file = { ..._file };
42
45
  exports.db = { ..._db };
46
+ exports.observability = { ..._observability };
47
+ exports.app = { ..._app };
48
+ exports.deploy = { ..._deploy };
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchLogs = searchLogs;
4
+ exports.searchTraces = searchTraces;
5
+ exports.getTraces = getTraces;
6
+ exports.queryMetricsData = queryMetricsData;
7
+ exports.queryAnalyticsData = queryAnalyticsData;
8
+ const http_1 = require("../../utils/http");
9
+ const DEFAULT_ERR_CODE = "INTERNAL_OB_ERROR";
10
+ // ── 日志 ──
11
+ async function searchLogs(req) {
12
+ const url = `/v1/observability/app/${encodeURIComponent(req.appID)}/logs/search`;
13
+ return (0, http_1.postInnerApi)(url, req, {
14
+ errPrefix: "Failed to search logs",
15
+ defaultErrCode: DEFAULT_ERR_CODE,
16
+ });
17
+ }
18
+ // ── 链路 ──
19
+ async function searchTraces(req) {
20
+ const url = `/v1/observability/app/${encodeURIComponent(req.appID)}/traces/search`;
21
+ return (0, http_1.postInnerApi)(url, req, {
22
+ errPrefix: "Failed to search traces",
23
+ defaultErrCode: DEFAULT_ERR_CODE,
24
+ });
25
+ }
26
+ async function getTraces(req) {
27
+ const url = `/v1/observability/app/${encodeURIComponent(req.appID)}/traces/${encodeURIComponent(req.traceID)}`;
28
+ return (0, http_1.postInnerApi)(url, req, {
29
+ errPrefix: "Failed to get trace",
30
+ defaultErrCode: DEFAULT_ERR_CODE,
31
+ });
32
+ }
33
+ // ── 监控指标 ──
34
+ async function queryMetricsData(req) {
35
+ const url = `/v1/observability/app/${encodeURIComponent(req.appID)}/metrics/data/query`;
36
+ return (0, http_1.postInnerApi)(url, req, {
37
+ errPrefix: "Failed to query metrics",
38
+ defaultErrCode: DEFAULT_ERR_CODE,
39
+ });
40
+ }
41
+ // ── 运营指标 ──
42
+ //
43
+ // 走 BAM v1.0.122 起的批量端点 CLIBatchQueryAnalyticsData:
44
+ // - 路径 /analytics/data/batch_query(旧版 /analytics/data/query 已废弃)
45
+ // - 支持 metricTypes 数组,单次拉多个指标
46
+ async function queryAnalyticsData(req) {
47
+ const url = `/v1/observability/app/${encodeURIComponent(req.appID)}/analytics/data/batch_query`;
48
+ return (0, http_1.postInnerApi)(url, req, {
49
+ errPrefix: "Failed to query analytics",
50
+ defaultErrCode: DEFAULT_ERR_CODE,
51
+ });
52
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StatusCode = exports.SpanKind = exports.WordOperator = exports.spanSchema = exports.logItemSchema = exports.queryAnalyticsData = exports.queryMetricsData = exports.getTraces = exports.searchTraces = exports.searchLogs = void 0;
4
+ var api_1 = require("./api");
5
+ Object.defineProperty(exports, "searchLogs", { enumerable: true, get: function () { return api_1.searchLogs; } });
6
+ Object.defineProperty(exports, "searchTraces", { enumerable: true, get: function () { return api_1.searchTraces; } });
7
+ Object.defineProperty(exports, "getTraces", { enumerable: true, get: function () { return api_1.getTraces; } });
8
+ Object.defineProperty(exports, "queryMetricsData", { enumerable: true, get: function () { return api_1.queryMetricsData; } });
9
+ Object.defineProperty(exports, "queryAnalyticsData", { enumerable: true, get: function () { return api_1.queryAnalyticsData; } });
10
+ var schemas_1 = require("./schemas");
11
+ Object.defineProperty(exports, "logItemSchema", { enumerable: true, get: function () { return schemas_1.logItemSchema; } });
12
+ Object.defineProperty(exports, "spanSchema", { enumerable: true, get: function () { return schemas_1.spanSchema; } });
13
+ var types_1 = require("./types");
14
+ Object.defineProperty(exports, "WordOperator", { enumerable: true, get: function () { return types_1.WordOperator; } });
15
+ Object.defineProperty(exports, "SpanKind", { enumerable: true, get: function () { return types_1.SpanKind; } });
16
+ Object.defineProperty(exports, "StatusCode", { enumerable: true, get: function () { return types_1.StatusCode; } });
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.spanSchema = exports.logItemSchema = void 0;
4
+ const output_1 = require("../../utils/output");
5
+ /** LogItem 渲染契约(log search) */
6
+ exports.logItemSchema = {
7
+ columns: [
8
+ { key: "timestampNs", label: "time", format: output_1.fmt.ns("yyyy-MM-dd HH:mm:ss.SSS") },
9
+ {
10
+ key: "module",
11
+ derive: (row) => {
12
+ return row.attributes?.module;
13
+ },
14
+ },
15
+ {
16
+ key: "user-id",
17
+ derive: (row) => {
18
+ return row.attributes?.user_id;
19
+ },
20
+ },
21
+ { key: "severityText", label: "severity-text" },
22
+ {
23
+ key: "duration",
24
+ format: output_1.fmt.durationMs(),
25
+ derive: (row) => {
26
+ return row.attributes?.duration_ms;
27
+ },
28
+ },
29
+ { key: "traceID", label: "trace-id" },
30
+ { key: "id", label: "log-id" },
31
+ { key: "body" },
32
+ ],
33
+ strict: true,
34
+ };
35
+ /** Span 渲染契约(trace list / trace get 复用)。
36
+ * duration 是 client-derived(BAM 只给 start/end,没有原生 durationNs 字段)。 */
37
+ exports.spanSchema = {
38
+ columns: [
39
+ { key: "startTimeUnixNano", label: "start-time", format: output_1.fmt.ns("yyyy-MM-dd HH:mm:ss.SSS") },
40
+ { key: "name", label: "root-span" },
41
+ {
42
+ key: "user-id",
43
+ derive: (row) => {
44
+ return row.attributes?.user_id;
45
+ },
46
+ },
47
+ {
48
+ key: "duration",
49
+ label: "duration",
50
+ format: output_1.fmt.durationMs(),
51
+ derive: (row) => {
52
+ return row.attributes?.duration_ms;
53
+ },
54
+ },
55
+ { key: "traceID", label: "trace-id" },
56
+ ],
57
+ strict: true,
58
+ };
59
+ // metric / analytics 都改用 BAM v1.0.123 起的合并响应(points: {timestamp, values}),
60
+ // pretty 渲染走 handler 内 pivot 后的临时 schema;不再导出固定 schema。
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ // ── 通用结构 ──
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.StatusCode = exports.SpanKind = exports.WordOperator = void 0;
5
+ /** 模糊搜索词运算符(对应后端 WordOperator) */
6
+ var WordOperator;
7
+ (function (WordOperator) {
8
+ WordOperator[WordOperator["AND"] = 0] = "AND";
9
+ WordOperator[WordOperator["OR"] = 1] = "OR";
10
+ })(WordOperator || (exports.WordOperator = WordOperator = {}));
11
+ /** OpenTelemetry SpanKind(BAM 透传) */
12
+ var SpanKind;
13
+ (function (SpanKind) {
14
+ SpanKind[SpanKind["UNSPECIFIED"] = 0] = "UNSPECIFIED";
15
+ SpanKind[SpanKind["INTERNAL"] = 1] = "INTERNAL";
16
+ SpanKind[SpanKind["SERVER"] = 2] = "SERVER";
17
+ SpanKind[SpanKind["CLIENT"] = 3] = "CLIENT";
18
+ SpanKind[SpanKind["PRODUCER"] = 4] = "PRODUCER";
19
+ SpanKind[SpanKind["CONSUMER"] = 5] = "CONSUMER";
20
+ })(SpanKind || (exports.SpanKind = SpanKind = {}));
21
+ /** Span 状态码(BAM 透传) */
22
+ var StatusCode;
23
+ (function (StatusCode) {
24
+ StatusCode[StatusCode["UNSET"] = 0] = "UNSET";
25
+ StatusCode[StatusCode["OK"] = 1] = "OK";
26
+ StatusCode[StatusCode["ERROR"] = 2] = "ERROR";
27
+ })(StatusCode || (exports.StatusCode = StatusCode = {}));