@lark-apaas/miaoda-cli 0.1.3-alpha.4bf312e → 0.1.3-alpha.67da0bb

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 (62) hide show
  1. package/dist/api/app/api.js +3 -3
  2. package/dist/api/app/schemas.js +43 -43
  3. package/dist/api/db/api.js +108 -112
  4. package/dist/api/db/client.js +41 -41
  5. package/dist/api/db/parsers.js +20 -20
  6. package/dist/api/db/sql-keywords.js +87 -87
  7. package/dist/api/deploy/api.js +5 -5
  8. package/dist/api/deploy/schemas.js +32 -32
  9. package/dist/api/file/api.js +74 -87
  10. package/dist/api/file/client.js +22 -22
  11. package/dist/api/file/detect.js +3 -3
  12. package/dist/api/file/parsers.js +18 -7
  13. package/dist/api/observability/api.js +6 -6
  14. package/dist/api/observability/schemas.js +14 -14
  15. package/dist/api/plugin/api.js +31 -31
  16. package/dist/cli/commands/app/index.js +12 -12
  17. package/dist/cli/commands/db/index.js +268 -163
  18. package/dist/cli/commands/deploy/index.js +28 -28
  19. package/dist/cli/commands/file/index.js +81 -61
  20. package/dist/cli/commands/observability/index.js +69 -69
  21. package/dist/cli/commands/plugin/index.js +27 -27
  22. package/dist/cli/commands/shared.js +10 -10
  23. package/dist/cli/handlers/app/update.js +2 -2
  24. package/dist/cli/handlers/db/audit.js +52 -43
  25. package/dist/cli/handlers/db/changelog.js +25 -12
  26. package/dist/cli/handlers/db/data.js +31 -30
  27. package/dist/cli/handlers/db/migration.js +27 -27
  28. package/dist/cli/handlers/db/quota.js +3 -3
  29. package/dist/cli/handlers/db/recovery.js +111 -82
  30. package/dist/cli/handlers/db/schema.js +33 -33
  31. package/dist/cli/handlers/db/sql.js +69 -69
  32. package/dist/cli/handlers/deploy/deploy.js +4 -4
  33. package/dist/cli/handlers/deploy/error-log.js +1 -1
  34. package/dist/cli/handlers/deploy/get.js +3 -3
  35. package/dist/cli/handlers/deploy/polling.js +11 -11
  36. package/dist/cli/handlers/file/cp.js +30 -30
  37. package/dist/cli/handlers/file/ls.js +5 -5
  38. package/dist/cli/handlers/file/quota.js +2 -2
  39. package/dist/cli/handlers/file/rm.js +24 -24
  40. package/dist/cli/handlers/file/sign.js +3 -3
  41. package/dist/cli/handlers/file/stat.js +10 -9
  42. package/dist/cli/handlers/observability/analytics.js +47 -47
  43. package/dist/cli/handlers/observability/helpers.js +2 -2
  44. package/dist/cli/handlers/observability/log.js +9 -9
  45. package/dist/cli/handlers/observability/metric.js +26 -26
  46. package/dist/cli/handlers/observability/trace.js +5 -5
  47. package/dist/cli/handlers/plugin/plugin-local.js +53 -53
  48. package/dist/cli/handlers/plugin/plugin.js +15 -15
  49. package/dist/cli/help.js +16 -16
  50. package/dist/main.js +12 -12
  51. package/dist/utils/args.js +1 -1
  52. package/dist/utils/colors.js +2 -2
  53. package/dist/utils/config.js +2 -2
  54. package/dist/utils/devops-error.js +9 -9
  55. package/dist/utils/error.js +2 -2
  56. package/dist/utils/git.js +4 -4
  57. package/dist/utils/http.js +19 -19
  58. package/dist/utils/output.js +47 -47
  59. package/dist/utils/poll.js +2 -2
  60. package/dist/utils/render.js +27 -27
  61. package/dist/utils/time.js +47 -42
  62. package/package.json +1 -1
@@ -25,9 +25,9 @@ function traceHttp(method, url, start, response, err) {
25
25
  try {
26
26
  const cost = Date.now() - start;
27
27
  const status = response?.status ?? 0;
28
- const logid = response?.headers?.get?.("x-tt-logid") ?? "-";
28
+ const logid = response?.headers?.get?.('x-tt-logid') ?? '-';
29
29
  if (err !== undefined) {
30
- const errMsg = err instanceof Error ? err.message : typeof err === "string" ? err : JSON.stringify(err);
30
+ const errMsg = err instanceof Error ? err.message : typeof err === 'string' ? err : JSON.stringify(err);
31
31
  (0, logger_1.debug)(`http ${method} ${url} ${String(status)} cost=${String(cost)}ms x-tt-logid=${logid} err=${errMsg}`);
32
32
  return;
33
33
  }
@@ -46,16 +46,16 @@ function traceHttp(method, url, start, response, err) {
46
46
  */
47
47
  function ensureInnerSuccess(body) {
48
48
  if (!body) {
49
- throw new error_1.AppError("INTERNAL_DB_ERROR", "empty response body");
49
+ throw new error_1.AppError('INTERNAL_DB_ERROR', 'empty response body');
50
50
  }
51
- const code = body.status_code ?? body.ErrorCode ?? "0";
52
- if (code === "0" || code === "")
51
+ const code = body.status_code ?? body.ErrorCode ?? '0';
52
+ if (code === '0' || code === '')
53
53
  return;
54
54
  const appErr = mapDataloomBizError(code, body.error_msg ?? body.ErrorMessage ?? `dataloom API error [${code}]`);
55
55
  // PRD 多语句失败:后端在 envelope 顶层透出 errorStatementIndex(从 0 起计),
56
56
  // 单语句 / 单元执行不会带这个字段。挂到 AppError 上让 emitError 落到错误信封
57
57
  // statement_index 字段。
58
- if (typeof body.errorStatementIndex === "number") {
58
+ if (typeof body.errorStatementIndex === 'number') {
59
59
  appErr.statement_index = body.errorStatementIndex;
60
60
  }
61
61
  throw appErr;
@@ -77,14 +77,14 @@ function ensureInnerSuccess(body) {
77
77
  */
78
78
  function mapDataloomBizError(code, rawMessage) {
79
79
  const message = stripPgPrefix(rawMessage);
80
- if (code === "k_dl_1300002") {
80
+ if (code === 'k_dl_1300002') {
81
81
  const sqlstate = extractSqlstate(message);
82
82
  if (sqlstate && exports.SQLSTATE_MAP[sqlstate]) {
83
83
  return new error_1.AppError(exports.SQLSTATE_MAP[sqlstate], message);
84
84
  }
85
85
  }
86
- if (code === "k_dl_1600000" && message.startsWith("Invalid DB Branch")) {
87
- return new error_1.AppError("MULTI_ENV_NOT_INITIALIZED", "--env is not available (multi-env not initialized)", { next_actions: ["Verify the --env value matches an existing dbBranch."] });
86
+ if (code === 'k_dl_1600000' && message.startsWith('Invalid DB Branch')) {
87
+ return new error_1.AppError('MULTI_ENV_NOT_INITIALIZED', '--env is not available (multi-env not initialized)', { next_actions: ['Verify the --env value matches an existing dbBranch.'] });
88
88
  }
89
89
  const mapped = BIZ_ERR_MAP.get(code);
90
90
  if (mapped) {
@@ -100,7 +100,7 @@ function mapDataloomBizError(code, rawMessage) {
100
100
  * 大小写敏感,只匹配 PG 标准格式。
101
101
  */
102
102
  function stripPgPrefix(msg) {
103
- return msg.replace(/^ERROR:\s*/, "");
103
+ return msg.replace(/^ERROR:\s*/, '');
104
104
  }
105
105
  /** 从 PG 执行错误消息里提取 "(SQLSTATE XXXXX)"。 */
106
106
  function extractSqlstate(msg) {
@@ -117,63 +117,63 @@ const BIZ_ERR_MAP = new Map(Object.entries({
117
117
  // 来源:真实环境探测(dataloom InnerExecuteSQL / InnerGetSchema)
118
118
  // k_dl_000001:DB 连接 / QPS 限流 等基础设施层错误
119
119
  k_dl_000001: {
120
- code: "INTERNAL_DB_ERROR",
121
- hint: "检查 dbBranch 与应用 PG 实例状态,或稍后重试",
120
+ code: 'INTERNAL_DB_ERROR',
121
+ hint: '检查 dbBranch 与应用 PG 实例状态,或稍后重试',
122
122
  },
123
123
  // k_dl_000002:SQL 解析 / 不支持的 SQL 类型(VACUUM、COPY、SET、SHOW 等)
124
- k_dl_000002: { code: "SQL_SYNTAX_ERROR" },
124
+ k_dl_000002: { code: 'SQL_SYNTAX_ERROR' },
125
125
  // k_dl_000003:查询命中系统表(pg_tables / pg_user 等)被拒
126
- k_dl_000003: { code: "SQL_OPERATION_FORBIDDEN" },
126
+ k_dl_000003: { code: 'SQL_OPERATION_FORBIDDEN' },
127
127
  // k_dl_1300002:PG 执行错误;实际 SQLSTATE 由 extractSqlstate 单独映射
128
128
  // 未匹配到 SQLSTATE 时走下面兜底 DB_API_<code>
129
129
  // k_dl_1300015:SELECT 结果超过 1000 行硬拦;多行 hint 由 output.ts 的
130
130
  // SERVER_ERROR_HINTS 按语义 code 兜底,这里只做 code 改名
131
- k_dl_1300015: { code: "RESULT_SET_TOO_LARGE" },
131
+ k_dl_1300015: { code: 'RESULT_SET_TOO_LARGE' },
132
132
  // audit
133
133
  k_dl_1310001: {
134
- code: "AUDIT_ALREADY_ENABLED",
135
- hint: "Use `miaoda db audit status <table>` to confirm current state.",
134
+ code: 'AUDIT_ALREADY_ENABLED',
135
+ hint: 'Use `miaoda db audit status <table>` to confirm current state.',
136
136
  },
137
137
  k_dl_1310002: {
138
- code: "AUDIT_NOT_ENABLED",
139
- hint: "Run `miaoda db audit enable <table>` first.",
138
+ code: 'AUDIT_NOT_ENABLED',
139
+ hint: 'Run `miaoda db audit enable <table>` first.',
140
140
  },
141
141
  k_dl_1310003: {
142
- code: "INVALID_RETENTION",
143
- hint: "Allowed values: 7d, 30d, 180d, 360d, forever.",
142
+ code: 'INVALID_RETENTION',
143
+ hint: 'Allowed values: 7d, 30d, 180d, 360d, forever.',
144
144
  },
145
145
  // migration
146
146
  k_dl_1320001: {
147
- code: "MIGRATION_NOT_AVAILABLE",
148
- hint: "Migration commands require an expert-mode application.",
147
+ code: 'MIGRATION_NOT_AVAILABLE',
148
+ hint: 'Migration commands require an expert-mode application.',
149
149
  },
150
- k_dl_1320002: { code: "MULTI_ENV_ALREADY_INITIALIZED" },
150
+ k_dl_1320002: { code: 'MULTI_ENV_ALREADY_INITIALIZED' },
151
151
  k_dl_1320003: {
152
- code: "NO_PENDING_CHANGES",
153
- hint: "dev and online schemas are already in sync.",
152
+ code: 'NO_PENDING_CHANGES',
153
+ hint: 'dev and online schemas are already in sync.',
154
154
  },
155
155
  // recovery
156
156
  k_dl_1330001: {
157
- code: "RECOVERY_WINDOW_EXCEEDED",
158
- hint: "Pick a timestamp inside the supported recovery window.",
157
+ code: 'RECOVERY_WINDOW_EXCEEDED',
158
+ hint: 'Pick a timestamp inside the supported recovery window.',
159
159
  },
160
160
  k_dl_1330002: {
161
- code: "RECOVERY_IN_PROGRESS",
162
- hint: "Wait for the running recovery to finish, or check its status.",
161
+ code: 'RECOVERY_IN_PROGRESS',
162
+ hint: 'Wait for the running recovery to finish, or check its status.',
163
163
  },
164
164
  k_dl_1330003: {
165
- code: "INVALID_TIMESTAMP",
166
- hint: "Use ISO 8601 / yyyy-mm-dd / yyyy-mm-dd HH:MM:SS.",
165
+ code: 'INVALID_TIMESTAMP',
166
+ hint: 'Use ISO 8601 / yyyy-mm-dd / yyyy-mm-dd HH:MM:SS.',
167
167
  },
168
168
  }));
169
169
  /** PG SQLSTATE → CLI code(当前 dataloom 不一定透传,预留未来使用) */
170
170
  exports.SQLSTATE_MAP = {
171
- "42601": "SQL_SYNTAX_ERROR",
172
- "42P01": "TABLE_NOT_FOUND",
173
- "42703": "COLUMN_NOT_FOUND",
174
- "57014": "STATEMENT_TIMEOUT",
175
- "23505": "UNIQUE_VIOLATION",
176
- "22P02": "TYPE_MISMATCH",
171
+ '42601': 'SQL_SYNTAX_ERROR',
172
+ '42P01': 'TABLE_NOT_FOUND',
173
+ '42703': 'COLUMN_NOT_FOUND',
174
+ '57014': 'STATEMENT_TIMEOUT',
175
+ '23505': 'UNIQUE_VIOLATION',
176
+ '22P02': 'TYPE_MISMATCH',
177
177
  };
178
178
  /**
179
179
  * 从 envelope 里取 data 业务字段,校验成功后返回;失败则 throw。
@@ -181,7 +181,7 @@ exports.SQLSTATE_MAP = {
181
181
  function extractData(body) {
182
182
  ensureInnerSuccess(body);
183
183
  if (!body?.data) {
184
- throw new error_1.AppError("INTERNAL_DB_ERROR", "response missing data field");
184
+ throw new error_1.AppError('INTERNAL_DB_ERROR', 'response missing data field');
185
185
  }
186
186
  return body.data;
187
187
  }
@@ -197,12 +197,12 @@ function extractData(body) {
197
197
  * 调用方传入的 path 已包含 `/db` / `/data` 中段,这里只负责拼前缀和 query。
198
198
  */
199
199
  function buildInnerUrl(appId, path, query) {
200
- const normalized = path.startsWith("/") ? path : `/${path}`;
200
+ const normalized = path.startsWith('/') ? path : `/${path}`;
201
201
  let url = `/v1/dataloom/app/${encodeURIComponent(appId)}${normalized}`;
202
202
  if (query) {
203
203
  const usp = new URLSearchParams();
204
204
  for (const [k, v] of Object.entries(query)) {
205
- if (v !== undefined && v !== "")
205
+ if (v !== undefined && v !== '')
206
206
  usp.append(k, v);
207
207
  }
208
208
  const qs = usp.toString();
@@ -9,7 +9,7 @@ const error_1 = require("../../utils/error");
9
9
  * 解析 InnerExecuteSQL 的单条 results[](PRD 要求多条语句只取最后一条)。
10
10
  */
11
11
  function parseSqlResult(r) {
12
- if (r.sqlType === "SELECT") {
12
+ if (r.sqlType === 'SELECT') {
13
13
  let rows = [];
14
14
  if (r.data) {
15
15
  try {
@@ -18,23 +18,23 @@ function parseSqlResult(r) {
18
18
  rows = parsed;
19
19
  }
20
20
  catch {
21
- throw new error_1.AppError("INTERNAL_DB_ERROR", "Failed to parse SELECT result JSON");
21
+ throw new error_1.AppError('INTERNAL_DB_ERROR', 'Failed to parse SELECT result JSON');
22
22
  }
23
23
  }
24
24
  return {
25
- kind: "select",
25
+ kind: 'select',
26
26
  rows,
27
27
  recordCount: r.recordCount ?? rows.length,
28
28
  };
29
29
  }
30
- if (r.sqlType === "INSERT" ||
31
- r.sqlType === "UPDATE" ||
32
- r.sqlType === "DELETE" ||
33
- r.sqlType === "MERGE" ||
34
- r.sqlType === "DML") {
30
+ if (r.sqlType === 'INSERT' ||
31
+ r.sqlType === 'UPDATE' ||
32
+ r.sqlType === 'DELETE' ||
33
+ r.sqlType === 'MERGE' ||
34
+ r.sqlType === 'DML') {
35
35
  const affected = r.affectedRows ?? extractRowCount(r.data);
36
36
  return {
37
- kind: "dml",
37
+ kind: 'dml',
38
38
  // 上面已 narrow,这里 cast 是为了 SqlType 联合里的 (string & {}) 让 TS 无法
39
39
  // 自动收窄到字面量集合,不影响运行时安全
40
40
  sqlType: r.sqlType,
@@ -43,7 +43,7 @@ function parseSqlResult(r) {
43
43
  }
44
44
  // DDL or unknown — sqlType 透传后端给的细粒度(CREATE_TABLE / DROP_TABLE / ...
45
45
  // / 笼统 "DDL"),CLI JSON 输出直接当 command 用
46
- return { kind: "ddl", sqlType: r.sqlType };
46
+ return { kind: 'ddl', sqlType: r.sqlType };
47
47
  }
48
48
  /** DML 的 data 通常是 `[{"rowCount": N}]`;兜底从这里读影响行数。 */
49
49
  function extractRowCount(data) {
@@ -54,7 +54,7 @@ function extractRowCount(data) {
54
54
  if (Array.isArray(parsed) && parsed.length > 0) {
55
55
  const first = parsed[0];
56
56
  const v = first.rowCount ?? first.affected_rows;
57
- if (typeof v === "number")
57
+ if (typeof v === 'number')
58
58
  return v;
59
59
  }
60
60
  }
@@ -87,8 +87,8 @@ function toSummary(t, stats) {
87
87
  name: t.tableName,
88
88
  description: t.comment && t.comment.length > 0 ? t.comment : null,
89
89
  columns: (t.fields ?? []).length,
90
- estimated_row_count: typeof stats?.estimatedRowCount === "number" ? stats.estimatedRowCount : null,
91
- size_bytes: typeof stats?.sizeBytes === "number" ? stats.sizeBytes : null,
90
+ estimated_row_count: typeof stats?.estimatedRowCount === 'number' ? stats.estimatedRowCount : null,
91
+ size_bytes: typeof stats?.sizeBytes === 'number' ? stats.sizeBytes : null,
92
92
  };
93
93
  }
94
94
  /**
@@ -125,18 +125,18 @@ function toDetail(t, stats) {
125
125
  if (cols.length === 0)
126
126
  continue;
127
127
  const kind = i.indexType.toLowerCase();
128
- if (kind === "primary") {
129
- constraints.push({ type: "PRIMARY KEY", columns: cols });
128
+ if (kind === 'primary') {
129
+ constraints.push({ type: 'PRIMARY KEY', columns: cols });
130
130
  }
131
- else if (kind === "unique") {
132
- constraints.push({ type: "UNIQUE", columns: cols });
131
+ else if (kind === 'unique') {
132
+ constraints.push({ type: 'UNIQUE', columns: cols });
133
133
  }
134
134
  else {
135
135
  // foreign / normal / 其它统一进 indexes 段;method 从 indexDef 的 USING 段解析
136
136
  indexes.push({
137
137
  name: i.indexName,
138
138
  columns: cols,
139
- method: parseIndexMethod(i.indexDef) ?? "btree",
139
+ method: parseIndexMethod(i.indexDef) ?? 'btree',
140
140
  });
141
141
  }
142
142
  }
@@ -146,8 +146,8 @@ function toDetail(t, stats) {
146
146
  columns: (t.fields ?? []).map(toColumn),
147
147
  constraints,
148
148
  indexes,
149
- estimated_row_count: typeof stats?.estimatedRowCount === "number" ? stats.estimatedRowCount : null,
150
- size_bytes: typeof stats?.sizeBytes === "number" ? stats.sizeBytes : null,
149
+ estimated_row_count: typeof stats?.estimatedRowCount === 'number' ? stats.estimatedRowCount : null,
150
+ size_bytes: typeof stats?.sizeBytes === 'number' ? stats.sizeBytes : null,
151
151
  };
152
152
  }
153
153
  function toColumn(f) {
@@ -21,103 +21,103 @@ exports.SQL_KEYWORDS = void 0;
21
21
  */
22
22
  exports.SQL_KEYWORDS = [
23
23
  // DML 动词
24
- "SELECT",
25
- "INSERT",
26
- "UPDATE",
27
- "DELETE",
28
- "MERGE",
24
+ 'SELECT',
25
+ 'INSERT',
26
+ 'UPDATE',
27
+ 'DELETE',
28
+ 'MERGE',
29
29
  // FROM / JOIN 系列
30
- "FROM",
31
- "WHERE",
32
- "JOIN",
33
- "LEFT",
34
- "RIGHT",
35
- "INNER",
36
- "OUTER",
37
- "FULL",
38
- "CROSS",
39
- "USING",
30
+ 'FROM',
31
+ 'WHERE',
32
+ 'JOIN',
33
+ 'LEFT',
34
+ 'RIGHT',
35
+ 'INNER',
36
+ 'OUTER',
37
+ 'FULL',
38
+ 'CROSS',
39
+ 'USING',
40
40
  // 聚合 / 排序 / 分页
41
- "GROUP",
42
- "ORDER",
43
- "BY",
44
- "HAVING",
45
- "LIMIT",
46
- "OFFSET",
47
- "FETCH",
41
+ 'GROUP',
42
+ 'ORDER',
43
+ 'BY',
44
+ 'HAVING',
45
+ 'LIMIT',
46
+ 'OFFSET',
47
+ 'FETCH',
48
48
  // 集合操作
49
- "UNION",
50
- "INTERSECT",
51
- "EXCEPT",
52
- "DISTINCT",
53
- "ALL",
49
+ 'UNION',
50
+ 'INTERSECT',
51
+ 'EXCEPT',
52
+ 'DISTINCT',
53
+ 'ALL',
54
54
  // 别名 / 关联
55
- "AS",
56
- "ON",
55
+ 'AS',
56
+ 'ON',
57
57
  // 操作符词
58
- "AND",
59
- "OR",
60
- "NOT",
61
- "IN",
62
- "IS",
63
- "NULL",
64
- "TRUE",
65
- "FALSE",
66
- "BETWEEN",
67
- "LIKE",
68
- "ILIKE",
69
- "SIMILAR",
58
+ 'AND',
59
+ 'OR',
60
+ 'NOT',
61
+ 'IN',
62
+ 'IS',
63
+ 'NULL',
64
+ 'TRUE',
65
+ 'FALSE',
66
+ 'BETWEEN',
67
+ 'LIKE',
68
+ 'ILIKE',
69
+ 'SIMILAR',
70
70
  // DDL
71
- "CREATE",
72
- "ALTER",
73
- "DROP",
74
- "TRUNCATE",
75
- "RENAME",
76
- "TABLE",
77
- "INDEX",
78
- "VIEW",
79
- "DATABASE",
80
- "SCHEMA",
81
- "COLUMN",
82
- "CONSTRAINT",
83
- "SEQUENCE",
71
+ 'CREATE',
72
+ 'ALTER',
73
+ 'DROP',
74
+ 'TRUNCATE',
75
+ 'RENAME',
76
+ 'TABLE',
77
+ 'INDEX',
78
+ 'VIEW',
79
+ 'DATABASE',
80
+ 'SCHEMA',
81
+ 'COLUMN',
82
+ 'CONSTRAINT',
83
+ 'SEQUENCE',
84
84
  // 约束
85
- "PRIMARY",
86
- "KEY",
87
- "FOREIGN",
88
- "REFERENCES",
89
- "UNIQUE",
90
- "CHECK",
91
- "DEFAULT",
85
+ 'PRIMARY',
86
+ 'KEY',
87
+ 'FOREIGN',
88
+ 'REFERENCES',
89
+ 'UNIQUE',
90
+ 'CHECK',
91
+ 'DEFAULT',
92
92
  // 写入
93
- "VALUES",
94
- "SET",
95
- "RETURNING",
96
- "INTO",
93
+ 'VALUES',
94
+ 'SET',
95
+ 'RETURNING',
96
+ 'INTO',
97
97
  // 事务
98
- "BEGIN",
99
- "COMMIT",
100
- "ROLLBACK",
101
- "SAVEPOINT",
102
- "TRANSACTION",
98
+ 'BEGIN',
99
+ 'COMMIT',
100
+ 'ROLLBACK',
101
+ 'SAVEPOINT',
102
+ 'TRANSACTION',
103
103
  // 控制流 / CTE
104
- "IF",
105
- "EXISTS",
106
- "REPLACE",
107
- "WITH",
108
- "RECURSIVE",
109
- "CASE",
110
- "WHEN",
111
- "THEN",
112
- "ELSE",
113
- "END",
104
+ 'IF',
105
+ 'EXISTS',
106
+ 'REPLACE',
107
+ 'WITH',
108
+ 'RECURSIVE',
109
+ 'CASE',
110
+ 'WHEN',
111
+ 'THEN',
112
+ 'ELSE',
113
+ 'END',
114
114
  // 类型转换 / 时间提取
115
- "CAST",
116
- "EXTRACT",
115
+ 'CAST',
116
+ 'EXTRACT',
117
117
  // 排序方向
118
- "ASC",
119
- "DESC",
120
- "NULLS",
121
- "FIRST",
122
- "LAST",
118
+ 'ASC',
119
+ 'DESC',
120
+ 'NULLS',
121
+ 'FIRST',
122
+ 'LAST',
123
123
  ];
@@ -6,7 +6,7 @@ exports.getErrorLog = getErrorLog;
6
6
  exports.queryPipelineInstance = queryPipelineInstance;
7
7
  const http_1 = require("../../utils/http");
8
8
  const devops_error_1 = require("../../utils/devops-error");
9
- const DEFAULT_ERR_CODE = "INTERNAL_DEVOPS_ERROR";
9
+ const DEFAULT_ERR_CODE = 'INTERNAL_DEVOPS_ERROR';
10
10
  function envelopeOpts(errPrefix) {
11
11
  return {
12
12
  errPrefix,
@@ -18,7 +18,7 @@ function envelopeOpts(errPrefix) {
18
18
  /** POST /v1/devops/app/:appID/release — 触发发布 */
19
19
  async function createRelease(req) {
20
20
  const url = `/v1/devops/app/${encodeURIComponent(req.appID)}/release`;
21
- return (0, http_1.postInnerApi)(url, req, envelopeOpts("Failed to create release"));
21
+ return (0, http_1.postInnerApi)(url, req, envelopeOpts('Failed to create release'));
22
22
  }
23
23
  /**
24
24
  * POST /v1/pipeline/app/:appID/instance/list — 分页查询发布历史
@@ -29,7 +29,7 @@ async function createRelease(req) {
29
29
  async function listPipelineInstances(req) {
30
30
  const url = `/v1/pipeline/app/${encodeURIComponent(req.appID)}/instance/list`;
31
31
  return (0, http_1.postInnerApi)(url, req, {
32
- errPrefix: "Failed to list deploys",
32
+ errPrefix: 'Failed to list deploys',
33
33
  defaultErrCode: DEFAULT_ERR_CODE,
34
34
  });
35
35
  }
@@ -42,7 +42,7 @@ async function listPipelineInstances(req) {
42
42
  async function getErrorLog(req) {
43
43
  const url = `/v1/pipeline/app/${encodeURIComponent(req.appID)}/instance/${encodeURIComponent(req.instanceID)}/error_log`;
44
44
  return (0, http_1.getInnerApi)(url, {
45
- errPrefix: "Failed to get error log",
45
+ errPrefix: 'Failed to get error log',
46
46
  defaultErrCode: DEFAULT_ERR_CODE,
47
47
  });
48
48
  }
@@ -54,7 +54,7 @@ async function getErrorLog(req) {
54
54
  async function queryPipelineInstance(req) {
55
55
  const url = `/v1/pipeline/app/${encodeURIComponent(req.appID)}/instance/${encodeURIComponent(req.instanceID)}/detail`;
56
56
  return (0, http_1.getInnerApi)(url, {
57
- errPrefix: "Failed to query pipeline",
57
+ errPrefix: 'Failed to query pipeline',
58
58
  defaultErrCode: DEFAULT_ERR_CODE,
59
59
  });
60
60
  }
@@ -6,18 +6,18 @@ exports.nodeStatusFromText = nodeStatusFromText;
6
6
  const output_1 = require("../../utils/output");
7
7
  const types_1 = require("./types");
8
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",
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
16
  };
17
17
  function nodeStatusText(v) {
18
- if (typeof v === "string")
18
+ if (typeof v === 'string')
19
19
  return v;
20
- if (typeof v !== "number")
20
+ if (typeof v !== 'number')
21
21
  return undefined;
22
22
  return NODE_STATUS_TEXT[v];
23
23
  }
@@ -46,17 +46,17 @@ function pipelineDurationMs(row) {
46
46
  */
47
47
  exports.deployHistorySchema = {
48
48
  columns: [
49
- { key: "ID", label: "deploy-id" },
49
+ { key: 'ID', label: 'deploy-id' },
50
50
  {
51
- key: "status_text",
52
- label: "status",
51
+ key: 'status_text',
52
+ label: 'status',
53
53
  derive: (row) => nodeStatusText(row.status),
54
54
  },
55
- { key: "creator", label: "creator" },
56
- { key: "createdAt", label: "created-at", format: output_1.fmt.ms() },
55
+ { key: 'creator', label: 'creator' },
56
+ { key: 'createdAt', label: 'created-at', format: output_1.fmt.ms() },
57
57
  {
58
- key: "duration",
59
- label: "duration",
58
+ key: 'duration',
59
+ label: 'duration',
60
60
  format: output_1.fmt.durationMs(),
61
61
  derive: pipelineDurationMs,
62
62
  },
@@ -71,35 +71,35 @@ exports.deployHistorySchema = {
71
71
  */
72
72
  exports.deployGetSchema = {
73
73
  columns: [
74
- { key: "ID", label: "deploy-id" },
74
+ { key: 'ID', label: 'deploy-id' },
75
75
  {
76
- key: "status_text",
77
- label: "status",
76
+ key: 'status_text',
77
+ label: 'status',
78
78
  derive: (row) => nodeStatusText(row.status),
79
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() },
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
84
  {
85
- key: "duration",
86
- label: "duration",
85
+ key: 'duration',
86
+ label: 'duration',
87
87
  format: output_1.fmt.durationMs(),
88
88
  derive: pipelineDurationMs,
89
89
  },
90
- { key: "templateID", label: "template" },
91
- { key: "description" },
92
- { key: "parameters" },
93
- { key: "envVariables", label: "env-vars" },
90
+ { key: 'templateID', label: 'template' },
91
+ { key: 'description' },
92
+ { key: 'parameters' },
93
+ { key: 'envVariables', label: 'env-vars' },
94
94
  ],
95
95
  strict: true,
96
96
  };
97
97
  /** deploy error-log 表格渲染契约 */
98
98
  exports.errorJobSchema = {
99
99
  columns: [
100
- { key: "jobID", label: "job-id" },
101
- { key: "componentName", label: "component" },
102
- { key: "errorMsg", label: "error" },
100
+ { key: 'jobID', label: 'job-id' },
101
+ { key: 'componentName', label: 'component' },
102
+ { key: 'errorMsg', label: 'error' },
103
103
  ],
104
104
  strict: true,
105
105
  };