@lark-apaas/miaoda-cli 0.1.2-alpha.ccfdc05 → 0.1.2-alpha.d5d1878

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 (59) hide show
  1. package/README.md +7 -8
  2. package/dist/api/db/api.js +317 -6
  3. package/dist/api/db/client.js +36 -0
  4. package/dist/api/db/index.js +11 -1
  5. package/dist/api/file/api.js +15 -0
  6. package/dist/api/file/index.js +2 -1
  7. package/dist/api/index.js +1 -7
  8. package/dist/cli/commands/db/index.js +137 -0
  9. package/dist/cli/commands/file/index.js +7 -0
  10. package/dist/cli/commands/index.js +6 -10
  11. package/dist/cli/commands/shared.js +3 -81
  12. package/dist/cli/handlers/db/audit.js +285 -0
  13. package/dist/cli/handlers/db/changelog.js +117 -0
  14. package/dist/cli/handlers/db/data.js +1 -1
  15. package/dist/cli/handlers/db/index.js +17 -1
  16. package/dist/cli/handlers/db/migration.js +235 -0
  17. package/dist/cli/handlers/{app/update.js → db/quota.js} +29 -20
  18. package/dist/cli/handlers/db/recovery.js +281 -0
  19. package/dist/cli/handlers/file/index.js +3 -1
  20. package/dist/cli/handlers/{deploy/error-log.js → file/quota.js} +27 -22
  21. package/dist/main.js +7 -27
  22. package/dist/utils/http.js +0 -118
  23. package/dist/utils/index.js +3 -13
  24. package/dist/utils/output.js +29 -338
  25. package/dist/utils/poll.js +27 -0
  26. package/package.json +5 -7
  27. package/dist/api/app/api.js +0 -25
  28. package/dist/api/app/index.js +0 -15
  29. package/dist/api/app/schemas.js +0 -79
  30. package/dist/api/app/types.js +0 -58
  31. package/dist/api/deploy/api.js +0 -60
  32. package/dist/api/deploy/index.js +0 -16
  33. package/dist/api/deploy/schemas.js +0 -103
  34. package/dist/api/deploy/types.js +0 -22
  35. package/dist/api/observability/api.js +0 -52
  36. package/dist/api/observability/index.js +0 -16
  37. package/dist/api/observability/schemas.js +0 -60
  38. package/dist/api/observability/types.js +0 -27
  39. package/dist/cli/commands/app/index.js +0 -62
  40. package/dist/cli/commands/deploy/index.js +0 -145
  41. package/dist/cli/commands/observability/index.js +0 -237
  42. package/dist/cli/handlers/app/get.js +0 -48
  43. package/dist/cli/handlers/app/index.js +0 -7
  44. package/dist/cli/handlers/deploy/deploy.js +0 -83
  45. package/dist/cli/handlers/deploy/get.js +0 -70
  46. package/dist/cli/handlers/deploy/helpers.js +0 -41
  47. package/dist/cli/handlers/deploy/history.js +0 -70
  48. package/dist/cli/handlers/deploy/index.js +0 -14
  49. package/dist/cli/handlers/deploy/polling.js +0 -139
  50. package/dist/cli/handlers/observability/analytics.js +0 -212
  51. package/dist/cli/handlers/observability/helpers.js +0 -66
  52. package/dist/cli/handlers/observability/index.js +0 -12
  53. package/dist/cli/handlers/observability/log.js +0 -94
  54. package/dist/cli/handlers/observability/metric.js +0 -208
  55. package/dist/cli/handlers/observability/trace.js +0 -102
  56. package/dist/cli/version.js +0 -15
  57. package/dist/utils/devops-error.js +0 -28
  58. package/dist/utils/git.js +0 -29
  59. package/dist/utils/time.js +0 -203
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 file ls
19
- miaoda file upload ./local/path
17
+ # 插件管理
18
+ miaoda plugin list-packages
19
+ miaoda plugin install @demo/example-plugin
20
20
  ```
21
21
 
22
22
  JSON 结构化输出(Agent 推荐):
23
23
 
24
24
  ```bash
25
25
  # 输出全部字段
26
- miaoda file ls --json
26
+ miaoda plugin list --json
27
27
 
28
28
  # 可选字段级选择
29
- miaoda file ls --json id,name
29
+ miaoda plugin list --json id,name
30
30
 
31
31
  # 或通过 --output 指定格式
32
- miaoda file ls --output json
32
+ miaoda plugin list --output json
33
33
  ```
34
34
 
35
35
  ## 命令树
@@ -38,8 +38,7 @@ miaoda file ls --output json
38
38
 
39
39
  | 域 | 用途 |
40
40
  |---|---|
41
- | `miaoda file ...` | 文件操作:上传、下载、元数据、签名下载、批量删除 |
42
- | `miaoda db ...` | 数据操作:SQL 执行、表结构查询、数据导入导出 |
41
+ | `miaoda plugin ...` | 插件管理:安装、更新、移除、插件实例查询 |
43
42
 
44
43
  完整命令通过 `miaoda --help` 或 `miaoda <domain> --help` 查看。
45
44
 
@@ -4,6 +4,16 @@ exports.execSql = execSql;
4
4
  exports.getSchema = getSchema;
5
5
  exports.importData = importData;
6
6
  exports.exportData = exportData;
7
+ exports.listDDLChangelog = listDDLChangelog;
8
+ exports.getAuditStatus = getAuditStatus;
9
+ exports.setAuditConfig = setAuditConfig;
10
+ exports.listAuditLog = listAuditLog;
11
+ exports.migrationInit = migrationInit;
12
+ exports.migrate = migrate;
13
+ exports.getMigrationStatus = getMigrationStatus;
14
+ exports.recover = recover;
15
+ exports.getRecoveryPreview = getRecoveryPreview;
16
+ exports.getDbQuota = getDbQuota;
7
17
  const http_1 = require("../../utils/http");
8
18
  const error_1 = require("../../utils/error");
9
19
  const http_client_1 = require("@lark-apaas/http-client");
@@ -25,6 +35,22 @@ async function mapDbHttpError(err, url, ctx,
25
35
  onErrorBody) {
26
36
  if (err instanceof error_1.AppError)
27
37
  throw err;
38
+ // 客户端超时 / abort:SdkHttpError 时 response 通常缺失(status=0),落到 throw 时
39
+ // message 形如 'Failed to recover: 0' 让用户看不懂。识别 abort / timeout 关键字
40
+ // 转成专用错误码 + 友好 hint。
41
+ if (err instanceof Error) {
42
+ const msg = err.message.toLowerCase();
43
+ if (msg.includes("aborted") ||
44
+ msg.includes("timeout") ||
45
+ err.name === "AbortError" ||
46
+ err.name === "TimeoutError") {
47
+ throw new error_1.AppError("REQUEST_TIMEOUT", `${ctx}: request timed out`, {
48
+ next_actions: [
49
+ "Server-side async tasks may take up to 60s. Retry the command if the underlying task likely succeeded.",
50
+ ],
51
+ });
52
+ }
53
+ }
28
54
  if (err instanceof http_client_1.HttpError) {
29
55
  const status = err.response?.status ?? 0;
30
56
  const statusText = err.response?.statusText ?? "";
@@ -247,10 +273,14 @@ async function exportData(opts) {
247
273
  await mapDbHttpError(err, url, "Failed to export data");
248
274
  throw err; // 不可达
249
275
  }
250
- // 成功路径:响应 body 通常是原始 CSV/JSON 字节,但部分错误场景下网关会返
276
+ // 成功路径:响应 body 通常是原始 CSV/SQL/JSON 字节,但部分错误场景下网关会返
251
277
  // HTTP 200 + JSON envelope(status_code != "0"),需要在这里嗅探兜底。
252
- const contentType = response.headers.get("Content-Type") ??
253
- (opts.format === "csv" ? "text/csv" : "application/json");
278
+ const defaultContentType = {
279
+ csv: "text/csv",
280
+ sql: "text/plain",
281
+ json: "application/json",
282
+ };
283
+ const contentType = response.headers.get("Content-Type") ?? defaultContentType[opts.format];
254
284
  const ab = await response.arrayBuffer();
255
285
  const buf = Buffer.from(new Uint8Array(ab));
256
286
  if (buf.length === 0) {
@@ -258,8 +288,9 @@ async function exportData(opts) {
258
288
  }
259
289
  // Envelope sniff:HTTP 200 + Content-Type 为 application/json + body 解析得到
260
290
  // InnerEnvelope 且 status_code 非 "0" 时,按业务错误抛出。
261
- // CSV 格式做 sniff —— JSON 格式正常成功响应也是 application/json,会误判。
262
- if (opts.format === "csv" && /application\/json/i.test(contentType)) {
291
+ // CSV / SQL 都是非 JSON 输出,application/json 响应必是错误信封;JSON 格式
292
+ // 成功响应自身就是 application/json,跳过 sniff 避免误判。
293
+ if (opts.format !== "json" && /application\/json/i.test(contentType)) {
263
294
  try {
264
295
  const parsed = JSON.parse(buf.toString("utf8"));
265
296
  if (parsed.status_code != null && parsed.status_code !== "0") {
@@ -269,7 +300,7 @@ async function exportData(opts) {
269
300
  }
270
301
  catch (err) {
271
302
  // 已经被 extractData 抛成 AppError → 透传;否则 JSON.parse 失败说明 body
272
- // 真的是 CSV 文本,继续按成功流程走
303
+ // 真的是 CSV / SQL 文本,继续按成功流程走
273
304
  if (err instanceof error_1.AppError)
274
305
  throw err;
275
306
  }
@@ -286,3 +317,283 @@ async function exportData(opts) {
286
317
  recordCount,
287
318
  };
288
319
  }
320
+ // ── db changelog → InnerAdminListDDLChangelog ──
321
+ /**
322
+ * 后端:GET /v1/dataloom/app/{appId}/db/changelog?table=&since=&until=&limit=&cursor=&dbBranch=
323
+ *
324
+ * 时间字段 since/until 由 CLI 端归一化为 ISO 8601 UTC 后透传;后端按 created_at 比较。
325
+ */
326
+ async function listDDLChangelog(opts) {
327
+ const client = (0, http_1.getHttpClient)();
328
+ const url = (0, client_1.buildInnerUrl)(opts.appId, "/db/changelog", {
329
+ table: opts.table,
330
+ since: opts.since,
331
+ until: opts.until,
332
+ limit: opts.limit !== undefined ? String(opts.limit) : undefined,
333
+ cursor: opts.cursor,
334
+ dbBranch: opts.dbBranch,
335
+ });
336
+ const start = Date.now();
337
+ let response;
338
+ try {
339
+ response = await client.get(url);
340
+ (0, client_1.traceHttp)("GET", url, start, response);
341
+ }
342
+ catch (err) {
343
+ (0, client_1.traceHttp)("GET", url, start, err instanceof http_client_1.HttpError ? err.response : undefined, err);
344
+ await mapDbHttpError(err, url, "Failed to list DDL changelog");
345
+ throw err; // 不可达
346
+ }
347
+ const body = (await response.json());
348
+ const data = (0, client_1.extractData)(body);
349
+ return {
350
+ items: data.items ?? [],
351
+ nextCursor: data.nextCursor && data.nextCursor !== "" ? data.nextCursor : null,
352
+ hasMore: Boolean(data.hasMore),
353
+ };
354
+ }
355
+ // ── db audit → InnerAdminGetAuditStatus / InnerAdminSetAuditConfig ──
356
+ /**
357
+ * 后端:GET /v1/dataloom/app/{appId}/db/audit/status?table=&dbBranch=
358
+ * 查表审计开关状态。table 非空 → 单表过滤;空 → 返当前 workspace 全部已配置表。
359
+ */
360
+ async function getAuditStatus(opts) {
361
+ const client = (0, http_1.getHttpClient)();
362
+ const url = (0, client_1.buildInnerUrl)(opts.appId, "/db/audit/status", {
363
+ table: opts.table,
364
+ dbBranch: opts.dbBranch,
365
+ });
366
+ const start = Date.now();
367
+ let response;
368
+ try {
369
+ response = await client.get(url);
370
+ (0, client_1.traceHttp)("GET", url, start, response);
371
+ }
372
+ catch (err) {
373
+ (0, client_1.traceHttp)("GET", url, start, err instanceof http_client_1.HttpError ? err.response : undefined, err);
374
+ await mapDbHttpError(err, url, "Failed to get audit status");
375
+ throw err; // 不可达
376
+ }
377
+ const respBody = (await response.json());
378
+ const data = (0, client_1.extractData)(respBody);
379
+ return data.items ?? [];
380
+ }
381
+ /**
382
+ * 后端:POST /v1/dataloom/app/{appId}/db/audit/config
383
+ * 写:enabled=true 开启 / false 关闭。retention 仅 enabled=true 生效。
384
+ */
385
+ async function setAuditConfig(opts) {
386
+ const client = (0, http_1.getHttpClient)();
387
+ const url = (0, client_1.buildInnerUrl)(opts.appId, "/db/audit/config");
388
+ const body = {
389
+ table: opts.table,
390
+ enabled: opts.enabled,
391
+ };
392
+ if (opts.retention !== undefined && opts.retention !== "")
393
+ body.retention = opts.retention;
394
+ if (opts.dbBranch !== undefined && opts.dbBranch !== "")
395
+ body.dbBranch = opts.dbBranch;
396
+ const start = Date.now();
397
+ let response;
398
+ try {
399
+ response = await client.post(url, body);
400
+ (0, client_1.traceHttp)("POST", url, start, response);
401
+ }
402
+ catch (err) {
403
+ (0, client_1.traceHttp)("POST", url, start, err instanceof http_client_1.HttpError ? err.response : undefined, err);
404
+ await mapDbHttpError(err, url, "Failed to set audit config");
405
+ throw err; // 不可达
406
+ }
407
+ const respBody = (await response.json());
408
+ const data = (0, client_1.extractData)(respBody);
409
+ if (!data.status) {
410
+ throw new error_1.AppError("INTERNAL_DB_ERROR", "audit config response missing status field");
411
+ }
412
+ return data.status;
413
+ }
414
+ // ── db audit log → InnerAdminListAuditLog ──
415
+ /**
416
+ * 后端:GET /v1/dataloom/app/{appId}/db/audit/log?tables=&since=&until=&limit=&cursor=&dbBranch=
417
+ *
418
+ * 走 admin-inner 接口而不是 InnerAdminExecuteSQL 直接 SELECT pg_audit:
419
+ * - operator 在 details JSONB 内是 user_id,服务端解析成 username
420
+ * - summary 后端按 type + before/after diff 合成(pg_audit 表无此列)
421
+ * - before/after JSONB 后端 JSON.stringify 后透传字符串,CLI 按需 parse
422
+ *
423
+ * 多表用逗号拼接走 query;后端按 target_table IN (...) 一次查。skipped 字段返
424
+ * 多表中无记录的表名,便于 CLI 展示 hint。
425
+ */
426
+ async function listAuditLog(opts) {
427
+ if (opts.tables.length === 0) {
428
+ throw new error_1.AppError("ARGS_INVALID", "at least one table is required");
429
+ }
430
+ const client = (0, http_1.getHttpClient)();
431
+ const url = (0, client_1.buildInnerUrl)(opts.appId, "/db/audit/log", {
432
+ tables: opts.tables.join(","),
433
+ since: opts.since,
434
+ until: opts.until,
435
+ limit: opts.limit !== undefined ? String(opts.limit) : undefined,
436
+ cursor: opts.cursor,
437
+ dbBranch: opts.dbBranch,
438
+ });
439
+ const start = Date.now();
440
+ let response;
441
+ try {
442
+ response = await client.get(url);
443
+ (0, client_1.traceHttp)("GET", url, start, response);
444
+ }
445
+ catch (err) {
446
+ (0, client_1.traceHttp)("GET", url, start, err instanceof http_client_1.HttpError ? err.response : undefined, err);
447
+ await mapDbHttpError(err, url, "Failed to list audit log");
448
+ throw err; // 不可达
449
+ }
450
+ const body = (await response.json());
451
+ const data = (0, client_1.extractData)(body);
452
+ return {
453
+ items: data.items ?? [],
454
+ nextCursor: data.nextCursor && data.nextCursor !== "" ? data.nextCursor : null,
455
+ hasMore: Boolean(data.hasMore),
456
+ skipped: data.skipped ?? [],
457
+ };
458
+ }
459
+ // ── db migration → InnerAdminMigrationInit / InnerAdminMigrate ──
460
+ /**
461
+ * 后端:POST /v1/dataloom/app/{appId}/db/enableMultiEnv
462
+ * 单库 → dev/online 双库初始化,不可逆。对应公开 API EnableMultiEnvDB 的 admin-inner 通道。
463
+ */
464
+ async function migrationInit(opts) {
465
+ const client = (0, http_1.getHttpClient)();
466
+ const url = (0, client_1.buildInnerUrl)(opts.appId, "/db/enableMultiEnv");
467
+ const body = {};
468
+ if (opts.syncData !== undefined)
469
+ body.syncData = opts.syncData;
470
+ const start = Date.now();
471
+ let response;
472
+ try {
473
+ response = await client.post(url, body);
474
+ (0, client_1.traceHttp)("POST", url, start, response);
475
+ }
476
+ catch (err) {
477
+ (0, client_1.traceHttp)("POST", url, start, err instanceof http_client_1.HttpError ? err.response : undefined, err);
478
+ await mapDbHttpError(err, url, "Failed to init migration");
479
+ throw err; // 不可达
480
+ }
481
+ const respBody = (await response.json());
482
+ return (0, client_1.extractData)(respBody);
483
+ }
484
+ /**
485
+ * 后端:POST /v1/dataloom/app/{appId}/db/migration
486
+ * 合并 diff + apply:dryRun=true 只返 changes 不下发;dryRun=false 才执行。
487
+ */
488
+ async function migrate(opts) {
489
+ const client = (0, http_1.getHttpClient)();
490
+ const url = (0, client_1.buildInnerUrl)(opts.appId, "/db/migration");
491
+ const start = Date.now();
492
+ let response;
493
+ try {
494
+ response = await client.post(url, { dryRun: opts.dryRun });
495
+ (0, client_1.traceHttp)("POST", url, start, response);
496
+ }
497
+ catch (err) {
498
+ (0, client_1.traceHttp)("POST", url, start, err instanceof http_client_1.HttpError ? err.response : undefined, err);
499
+ await mapDbHttpError(err, url, "Failed to migrate");
500
+ throw err; // 不可达
501
+ }
502
+ const respBody = (await response.json());
503
+ return (0, client_1.extractData)(respBody);
504
+ }
505
+ /**
506
+ * 后端:GET /v1/dataloom/app/{appId}/db/migration/status?taskId=...
507
+ * CLI 拿到 migration apply 的 taskId 后定时调本接口,直到 status=success/failed。
508
+ * 网络层超时仍走 mapDbHttpError → 单次 30s;轮询节奏由 CLI handler 自行控制。
509
+ */
510
+ async function getMigrationStatus(opts) {
511
+ const client = (0, http_1.getHttpClient)();
512
+ const url = (0, client_1.buildInnerUrl)(opts.appId, "/db/migration/status", {
513
+ taskId: opts.taskId,
514
+ dbBranch: opts.dbBranch,
515
+ });
516
+ const start = Date.now();
517
+ let response;
518
+ try {
519
+ response = await client.get(url);
520
+ (0, client_1.traceHttp)("GET", url, start, response);
521
+ }
522
+ catch (err) {
523
+ (0, client_1.traceHttp)("GET", url, start, err instanceof http_client_1.HttpError ? err.response : undefined, err);
524
+ await mapDbHttpError(err, url, "Failed to get migration status");
525
+ throw err; // 不可达
526
+ }
527
+ const body = (await response.json());
528
+ return (0, client_1.extractData)(body);
529
+ }
530
+ // ── db recovery → InnerAdminRecover ──
531
+ /**
532
+ * 后端:POST /v1/dataloom/app/{appId}/db/recovery
533
+ * 合并 PITR diff + apply:dryRun=true 预览影响;dryRun=false 触发恢复。
534
+ */
535
+ async function recover(opts) {
536
+ const client = (0, http_1.getHttpClient)();
537
+ const url = (0, client_1.buildInnerUrl)(opts.appId, "/db/recovery");
538
+ const start = Date.now();
539
+ let response;
540
+ try {
541
+ response = await client.post(url, {
542
+ target: opts.target,
543
+ dryRun: opts.dryRun,
544
+ });
545
+ (0, client_1.traceHttp)("POST", url, start, response);
546
+ }
547
+ catch (err) {
548
+ (0, client_1.traceHttp)("POST", url, start, err instanceof http_client_1.HttpError ? err.response : undefined, err);
549
+ await mapDbHttpError(err, url, "Failed to recover");
550
+ throw err; // 不可达
551
+ }
552
+ const respBody = (await response.json());
553
+ return (0, client_1.extractData)(respBody);
554
+ }
555
+ /**
556
+ * 后端:GET /v1/dataloom/app/{appId}/db/recovery/preview?previewRequestId=...
557
+ * CLI 拿到 recovery diff 的 previewRequestId 后定时调本接口直到 previewStatus=success/failed。
558
+ */
559
+ async function getRecoveryPreview(opts) {
560
+ const client = (0, http_1.getHttpClient)();
561
+ const url = (0, client_1.buildInnerUrl)(opts.appId, "/db/recovery/preview", {
562
+ previewRequestId: opts.previewRequestId,
563
+ dbBranch: opts.dbBranch,
564
+ });
565
+ const start = Date.now();
566
+ let response;
567
+ try {
568
+ response = await client.get(url);
569
+ (0, client_1.traceHttp)("GET", url, start, response);
570
+ }
571
+ catch (err) {
572
+ (0, client_1.traceHttp)("GET", url, start, err instanceof http_client_1.HttpError ? err.response : undefined, err);
573
+ await mapDbHttpError(err, url, "Failed to get recovery preview");
574
+ throw err; // 不可达
575
+ }
576
+ const body = (await response.json());
577
+ return (0, client_1.extractData)(body);
578
+ }
579
+ // ── db quota → InnerAdminGetDbQuota ──
580
+ /**
581
+ * 后端:GET /v1/dataloom/app/{appId}/db/quota?dbBranch=
582
+ */
583
+ async function getDbQuota(opts) {
584
+ const client = (0, http_1.getHttpClient)();
585
+ const url = (0, client_1.buildInnerUrl)(opts.appId, "/db/quota", { dbBranch: opts.dbBranch });
586
+ const start = Date.now();
587
+ let response;
588
+ try {
589
+ response = await client.get(url);
590
+ (0, client_1.traceHttp)("GET", url, start, response);
591
+ }
592
+ catch (err) {
593
+ (0, client_1.traceHttp)("GET", url, start, err instanceof http_client_1.HttpError ? err.response : undefined, err);
594
+ await mapDbHttpError(err, url, "Failed to get db quota");
595
+ throw err; // 不可达
596
+ }
597
+ const respBody = (await response.json());
598
+ return (0, client_1.extractData)(respBody);
599
+ }
@@ -129,6 +129,42 @@ const BIZ_ERR_MAP = new Map(Object.entries({
129
129
  // k_dl_1300015:SELECT 结果超过 1000 行硬拦;多行 hint 由 output.ts 的
130
130
  // SERVER_ERROR_HINTS 按语义 code 兜底,这里只做 code 改名
131
131
  k_dl_1300015: { code: "RESULT_SET_TOO_LARGE" },
132
+ // audit
133
+ k_dl_1310001: {
134
+ code: "AUDIT_ALREADY_ENABLED",
135
+ hint: "Use `miaoda db audit status <table>` to confirm current state.",
136
+ },
137
+ k_dl_1310002: {
138
+ code: "AUDIT_NOT_ENABLED",
139
+ hint: "Run `miaoda db audit enable <table>` first.",
140
+ },
141
+ k_dl_1310003: {
142
+ code: "INVALID_RETENTION",
143
+ hint: "Allowed values: 7d, 30d, 180d, 360d, forever.",
144
+ },
145
+ // migration
146
+ k_dl_1320001: {
147
+ code: "MIGRATION_NOT_AVAILABLE",
148
+ hint: "Migration commands require an expert-mode application.",
149
+ },
150
+ k_dl_1320002: { code: "MULTI_ENV_ALREADY_INITIALIZED" },
151
+ k_dl_1320003: {
152
+ code: "NO_PENDING_CHANGES",
153
+ hint: "dev and online schemas are already in sync.",
154
+ },
155
+ // recovery
156
+ k_dl_1330001: {
157
+ code: "RECOVERY_WINDOW_EXCEEDED",
158
+ hint: "Pick a timestamp inside the supported recovery window.",
159
+ },
160
+ k_dl_1330002: {
161
+ code: "RECOVERY_IN_PROGRESS",
162
+ hint: "Wait for the running recovery to finish, or check its status.",
163
+ },
164
+ k_dl_1330003: {
165
+ code: "INVALID_TIMESTAMP",
166
+ hint: "Use ISO 8601 / yyyy-mm-dd / yyyy-mm-dd HH:MM:SS.",
167
+ },
132
168
  }));
133
169
  /** PG SQLSTATE → CLI code(当前 dataloom 不一定透传,预留未来使用) */
134
170
  exports.SQLSTATE_MAP = {
@@ -1,11 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pickTableDetail = exports.flattenSchemaList = exports.parseSqlResult = exports.SQLSTATE_MAP = exports.ensureInnerSuccess = exports.buildInnerUrl = exports.exportData = exports.importData = exports.getSchema = exports.execSql = void 0;
3
+ exports.pickTableDetail = exports.flattenSchemaList = exports.parseSqlResult = exports.SQLSTATE_MAP = exports.ensureInnerSuccess = exports.buildInnerUrl = exports.getDbQuota = exports.getRecoveryPreview = exports.recover = exports.getMigrationStatus = exports.migrate = exports.migrationInit = exports.listAuditLog = exports.setAuditConfig = exports.getAuditStatus = exports.listDDLChangelog = exports.exportData = exports.importData = exports.getSchema = exports.execSql = void 0;
4
4
  var api_1 = require("./api");
5
5
  Object.defineProperty(exports, "execSql", { enumerable: true, get: function () { return api_1.execSql; } });
6
6
  Object.defineProperty(exports, "getSchema", { enumerable: true, get: function () { return api_1.getSchema; } });
7
7
  Object.defineProperty(exports, "importData", { enumerable: true, get: function () { return api_1.importData; } });
8
8
  Object.defineProperty(exports, "exportData", { enumerable: true, get: function () { return api_1.exportData; } });
9
+ Object.defineProperty(exports, "listDDLChangelog", { enumerable: true, get: function () { return api_1.listDDLChangelog; } });
10
+ Object.defineProperty(exports, "getAuditStatus", { enumerable: true, get: function () { return api_1.getAuditStatus; } });
11
+ Object.defineProperty(exports, "setAuditConfig", { enumerable: true, get: function () { return api_1.setAuditConfig; } });
12
+ Object.defineProperty(exports, "listAuditLog", { enumerable: true, get: function () { return api_1.listAuditLog; } });
13
+ Object.defineProperty(exports, "migrationInit", { enumerable: true, get: function () { return api_1.migrationInit; } });
14
+ Object.defineProperty(exports, "migrate", { enumerable: true, get: function () { return api_1.migrate; } });
15
+ Object.defineProperty(exports, "getMigrationStatus", { enumerable: true, get: function () { return api_1.getMigrationStatus; } });
16
+ Object.defineProperty(exports, "recover", { enumerable: true, get: function () { return api_1.recover; } });
17
+ Object.defineProperty(exports, "getRecoveryPreview", { enumerable: true, get: function () { return api_1.getRecoveryPreview; } });
18
+ Object.defineProperty(exports, "getDbQuota", { enumerable: true, get: function () { return api_1.getDbQuota; } });
9
19
  var client_1 = require("./client");
10
20
  Object.defineProperty(exports, "buildInnerUrl", { enumerable: true, get: function () { return client_1.buildInnerUrl; } });
11
21
  Object.defineProperty(exports, "ensureInnerSuccess", { enumerable: true, get: function () { return client_1.ensureInnerSuccess; } });
@@ -8,6 +8,7 @@ exports.uploadFile = uploadFile;
8
8
  exports.signDownload = signDownload;
9
9
  exports.downloadFile = downloadFile;
10
10
  exports.deleteFiles = deleteFiles;
11
+ exports.getStorageQuota = getStorageQuota;
11
12
  const error_1 = require("../../utils/error");
12
13
  const logger_1 = require("../../utils/logger");
13
14
  const client_1 = require("./client");
@@ -519,3 +520,17 @@ async function deleteFiles(opts) {
519
520
  }
520
521
  return { deleted, failed };
521
522
  }
523
+ // ── storage quota ──
524
+ /**
525
+ * 后端:GET /v1/storage/app/{appId}/bucket/{bucketId}/quota
526
+ * 单 bucket 用量;StorageQuotaBytes 暂未对接,CLI 拿到 0 时按 "—" 渲染。
527
+ * bucketId 缺省时走默认 bucket(与 ls / stat / cp 等一致)。
528
+ */
529
+ async function getStorageQuota(opts) {
530
+ const bucketId = opts.bucketId ?? (await (0, client_1.getDefaultBucketId)(opts.appId));
531
+ const url = `/v1/storage/app/${encodeURIComponent(opts.appId)}/bucket/${encodeURIComponent(bucketId)}/quota`;
532
+ const body = await (0, client_1.doGet)(url, {
533
+ errorContext: `fetch storage quota for app '${opts.appId}' bucket '${bucketId}'`,
534
+ });
535
+ return extractEnvelope(body);
536
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toAbsolutePath = exports.looksLikePath = exports.resetBucketCache = exports.getDefaultBucketId = exports.parseTimeFilterMs = exports.resolveInputs = exports.deleteFiles = exports.downloadFile = exports.signDownload = exports.uploadFile = exports.statFile = exports.listFiles = void 0;
3
+ exports.toAbsolutePath = exports.looksLikePath = exports.resetBucketCache = exports.getDefaultBucketId = exports.getStorageQuota = exports.parseTimeFilterMs = exports.resolveInputs = exports.deleteFiles = exports.downloadFile = exports.signDownload = exports.uploadFile = exports.statFile = exports.listFiles = void 0;
4
4
  var api_1 = require("./api");
5
5
  Object.defineProperty(exports, "listFiles", { enumerable: true, get: function () { return api_1.listFiles; } });
6
6
  Object.defineProperty(exports, "statFile", { enumerable: true, get: function () { return api_1.statFile; } });
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "downloadFile", { enumerable: true, get: function
10
10
  Object.defineProperty(exports, "deleteFiles", { enumerable: true, get: function () { return api_1.deleteFiles; } });
11
11
  Object.defineProperty(exports, "resolveInputs", { enumerable: true, get: function () { return api_1.resolveInputs; } });
12
12
  Object.defineProperty(exports, "parseTimeFilterMs", { enumerable: true, get: function () { return api_1.parseTimeFilterMs; } });
13
+ Object.defineProperty(exports, "getStorageQuota", { enumerable: true, get: function () { return api_1.getStorageQuota; } });
13
14
  var client_1 = require("./client");
14
15
  Object.defineProperty(exports, "getDefaultBucketId", { enumerable: true, get: function () { return client_1.getDefaultBucketId; } });
15
16
  Object.defineProperty(exports, "resetBucketCache", { enumerable: true, get: function () { return client_1.resetBucketCache; } });
package/dist/api/index.js CHANGED
@@ -33,16 +33,10 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.deploy = exports.app = exports.observability = exports.db = exports.file = exports.plugin = void 0;
36
+ 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"));
43
40
  exports.plugin = { ..._plugin };
44
41
  exports.file = { ..._file };
45
42
  exports.db = { ..._db };
46
- exports.observability = { ..._observability };
47
- exports.app = { ..._app };
48
- exports.deploy = { ..._deploy };