dsh-config-manager 0.1.48 → 0.1.50

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 (42) hide show
  1. package/lib/client.d.ts +40 -3
  2. package/lib/client.js +483 -149
  3. package/lib/client.js.map +1 -1
  4. package/lib/core/cache-cleaner.d.ts +6 -0
  5. package/lib/core/cache-cleaner.js +5 -1
  6. package/lib/core/cache-cleaner.js.map +1 -1
  7. package/lib/core/restore.d.ts +7 -0
  8. package/lib/core/restore.js +4 -0
  9. package/lib/core/restore.js.map +1 -1
  10. package/lib/core/run-registry.d.ts +11 -4
  11. package/lib/core/run-registry.js +14 -7
  12. package/lib/core/run-registry.js.map +1 -1
  13. package/lib/index.d.ts +7 -1
  14. package/lib/index.js +102 -8
  15. package/lib/index.js.map +1 -1
  16. package/lib/sync/backup-files.d.ts +42 -0
  17. package/lib/sync/backup-files.js +113 -0
  18. package/lib/sync/backup-files.js.map +1 -0
  19. package/lib/sync/backup-scheduler.d.ts +3 -0
  20. package/lib/sync/backup-scheduler.js +16 -1
  21. package/lib/sync/backup-scheduler.js.map +1 -1
  22. package/package.json +1 -1
  23. package/src/client/CLIENT_DEPENDENCIES.md +2 -0
  24. package/src/client/api.ts +26 -1
  25. package/src/client/config-manager.module.css +58 -0
  26. package/src/client/export/ExportView.tsx +2 -2
  27. package/src/client/import/ImportWizardView.tsx +62 -16
  28. package/src/client/locales.ts +24 -0
  29. package/src/client/run-store.test.ts +124 -1
  30. package/src/client/run-store.ts +82 -4
  31. package/src/client/snapshots/SnapshotsPanel.tsx +199 -15
  32. package/src/client/sync/SyncHistoryView.tsx +1 -0
  33. package/src/core/cache-cleaner.test.ts +29 -0
  34. package/src/core/cache-cleaner.ts +10 -1
  35. package/src/core/restore.ts +7 -0
  36. package/src/core/run-registry.test.ts +40 -0
  37. package/src/core/run-registry.ts +16 -9
  38. package/src/index.ts +97 -8
  39. package/src/sync/backup-files.test.ts +154 -0
  40. package/src/sync/backup-files.ts +127 -0
  41. package/src/sync/backup-scheduler.test.ts +86 -1
  42. package/src/sync/backup-scheduler.ts +17 -1
package/lib/client.d.ts CHANGED
@@ -281,8 +281,8 @@ interface SnapshotMeta {
281
281
  }
282
282
  //#endregion
283
283
  //#region src/core/run-registry.d.ts
284
- /** run 类型:导出 / 导入 / 自动同步 / 一键同步逐项应用 / 定时备份。 */
285
- type RunKind = 'export' | 'import' | 'autosync' | 'sync-apply' | 'backup-schedule';
284
+ /** run 类型:导出 / 导入 / 自动同步 / 一键同步逐项应用 / 定时备份 / 快照恢复。 */
285
+ type RunKind = 'export' | 'import' | 'autosync' | 'sync-apply' | 'backup-schedule' | 'restore';
286
286
  /** run 状态:进行中 / 完成 / 失败。 */
287
287
  type RunStatus = 'running' | 'done' | 'failed';
288
288
  /** 单个 run 的实时状态(/progress 返回体;纯 JSON 可序列化)。 */
@@ -346,6 +346,23 @@ interface BackupScheduleStatus {
346
346
  lastRunMessage?: string;
347
347
  }
348
348
  //#endregion
349
+ //#region src/sync/backup-files.d.ts
350
+ /** 备份文件来源(UI Badge 展示) */
351
+ type BackupFileSource = 'auto' | 'manual';
352
+ /** 备份文件元信息(列表行数据;无敏感字段) */
353
+ interface BackupFileMeta {
354
+ /** 文件名(如 dsh-config-auto-20260824-120000-abc.zip) */
355
+ name: string;
356
+ /** 绝对路径(供 /download 与导入向导引用) */
357
+ path: string;
358
+ /** 字节数 */
359
+ sizeBytes: number;
360
+ /** 修改时间(ms 时间戳;按此倒序展示/清理) */
361
+ mtimeMs: number;
362
+ /** 来源:auto = 定时备份;manual = 手动导出 */
363
+ source: BackupFileSource;
364
+ }
365
+ //#endregion
349
366
  //#region src/ui/i18n.d.ts
350
367
  /**
351
368
  * 客户端展示层(src/ui/*、src/client/common/*)的渲染文案目录(zh 源语言 / en 镜像)。
@@ -638,11 +655,13 @@ interface DecryptArchiveResponse {
638
655
  /** 解密覆盖的凭据 ref 名(非值);UI 据此从补录阶段剔除已恢复项 */
639
656
  refs: string[];
640
657
  }
641
- /** restore 端点响应:dryRun=true 返回 plan;执行返回 report(与 CLI 一致的诚实报告) */
658
+ /** restore 端点响应:dryRun=true 返回 plan;执行返回 report(与 CLI 一致的诚实报告)。
659
+ * runId 仅真实执行时存在(宿主 RunRegistry 登记;/runs + /progress 刷新恢复用)。 */
642
660
  interface RestoreResponse {
643
661
  dryRun: boolean;
644
662
  plan?: RestorePlan;
645
663
  report?: RestoreReport;
664
+ runId?: string;
646
665
  }
647
666
  /** Star 引导弹窗状态(GET /star-prompt;纯偏好,无 secret) */
648
667
  interface StarPromptStatus {
@@ -755,6 +774,12 @@ declare class ConfigManagerApi {
755
774
  run: BackupRunResult;
756
775
  schedule: BackupScheduleStatus;
757
776
  }>;
777
+ /** 列出导出目录(exports/*.zip)下的全部备份文件(时间倒序;含来源 auto/manual)。 */
778
+ listBackupFiles(): Promise<BackupFileMeta[]>;
779
+ /** 删除一个备份文件(危险操作:不可恢复;仅限 exports 目录内 .zip)。 */
780
+ deleteBackupFile(name: string): Promise<{
781
+ removed: boolean;
782
+ }>;
758
783
  }
759
784
  //#endregion
760
785
  //#region src/sync/sync-engine.d.ts
@@ -1643,6 +1668,18 @@ declare const zh$2: {
1643
1668
  readonly 'backupSchedule.status.failed': "失败";
1644
1669
  readonly 'backupSchedule.loading': "加载定时备份设置…";
1645
1670
  readonly 'backupSchedule.error': "定时备份设置加载失败";
1671
+ readonly 'backupFiles.title': "备份文件";
1672
+ readonly 'backupFiles.hint': "导出产物(手动导出与定时备份)统一在此管理:可下载到本机、直接导入恢复,或删除。定时备份自动保留最近 10 个。";
1673
+ readonly 'backupFiles.empty': "暂无备份文件。手动导出或启用定时备份后此处会列出。";
1674
+ readonly 'backupFiles.loading': "加载备份文件…";
1675
+ readonly 'backupFiles.error': "备份文件加载失败";
1676
+ readonly 'backupFiles.source.auto': "定时备份";
1677
+ readonly 'backupFiles.source.manual': "手动导出";
1678
+ readonly 'backupFiles.download': "下载";
1679
+ readonly 'backupFiles.import': "导入";
1680
+ readonly 'backupFiles.delete': "删除";
1681
+ readonly 'backupFiles.deleteConfirmTitle': "删除备份文件";
1682
+ readonly 'backupFiles.deleteConfirm': "确认删除备份文件「{name}」?此操作不可恢复。";
1646
1683
  readonly 'report.export.title': "导出完成";
1647
1684
  readonly 'report.import.title': "导入结果";
1648
1685
  readonly 'report.rollback.title': "回滚报告";