dsh-config-manager 0.4.1 → 0.4.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 (131) hide show
  1. package/README.md +14 -0
  2. package/lib/cli/actions.js +2 -3
  3. package/lib/cli/import-source.js +2 -6
  4. package/lib/cli/index.js +2 -3
  5. package/lib/client.d.ts +5 -5
  6. package/lib/client.js +26250 -25872
  7. package/lib/core/access-mode.d.ts +25 -0
  8. package/lib/core/access-mode.js +28 -0
  9. package/lib/core/exporter.js +2 -4
  10. package/lib/core/host-schedulers/cache-cleanup.d.ts +41 -0
  11. package/lib/core/host-schedulers/cache-cleanup.js +45 -0
  12. package/lib/core/host-schedulers/lifecycle-hooks.d.ts +51 -0
  13. package/lib/core/host-schedulers/lifecycle-hooks.js +78 -0
  14. package/lib/core/host-schedulers/market-cache.d.ts +40 -0
  15. package/lib/core/host-schedulers/market-cache.js +92 -0
  16. package/lib/core/model-tools.js +2 -6
  17. package/lib/core/restore.d.ts +0 -2
  18. package/lib/core/restore.js +16 -18
  19. package/lib/core/verify-recovery.js +4 -7
  20. package/lib/index.d.ts +3 -22
  21. package/lib/index.js +74 -330
  22. package/lib/profiles/dsh-profile-manager.d.ts +23 -1
  23. package/lib/profiles/dsh-profile-manager.js +70 -2
  24. package/lib/routes/kit.d.ts +61 -1
  25. package/lib/routes/kit.js +72 -3
  26. package/lib/routes/prefs.js +6 -6
  27. package/lib/routes/recovery.js +25 -41
  28. package/lib/routes/request-trust.d.ts +28 -0
  29. package/lib/routes/request-trust.js +65 -0
  30. package/lib/routes/route-support.d.ts +23 -1
  31. package/lib/routes/route-support.js +185 -0
  32. package/lib/routes/snapshots.js +4 -11
  33. package/lib/routes/sync.js +5 -7
  34. package/lib/security/redaction.d.ts +5 -1
  35. package/lib/security/redaction.js +26 -23
  36. package/lib/sync/backup-scheduler.js +2 -6
  37. package/lib/ui/backup-inspect.d.ts +1 -1
  38. package/lib/ui/dsh-profiles-view.d.ts +0 -10
  39. package/lib/ui/dsh-profiles-view.js +3 -7
  40. package/lib/ui/snapshots-view.d.ts +0 -14
  41. package/lib/ui/snapshots-view.js +16 -2
  42. package/lib/utils/paths.d.ts +20 -4
  43. package/lib/utils/paths.js +22 -6
  44. package/lib/utils/time.d.ts +31 -0
  45. package/lib/utils/time.js +54 -0
  46. package/package.json +1 -1
  47. package/src/cli/actions.ts +2 -3
  48. package/src/cli/import-source.ts +2 -7
  49. package/src/cli/index.ts +2 -3
  50. package/src/client/about/AboutPanel.tsx +8 -1
  51. package/src/client/about/ReleaseBody.tsx +22 -52
  52. package/src/client/about/ReleaseNotesDialog.tsx +15 -69
  53. package/src/client/about/release-notes-view.ts +4 -11
  54. package/src/client/common/access-mode.ts +21 -0
  55. package/src/client/common/info-hint-guard.test.ts +11 -5
  56. package/src/client/common/ui.tsx +23 -0
  57. package/src/client/config-manager.module.css +201 -32
  58. package/src/client/css-token-guard.test.ts +135 -1
  59. package/src/client/home/HomePanel.tsx +31 -6
  60. package/src/client/import/ConflictList.tsx +3 -3
  61. package/src/client/import/ImportWizardView.tsx +1 -1
  62. package/src/client/library/ArtifactRow.tsx +2 -2
  63. package/src/client/library/RestorePlanView.tsx +21 -9
  64. package/src/client/library/report-dismiss.test.ts +5 -3
  65. package/src/client/locales/about.ts +103 -0
  66. package/src/client/locales/backup.ts +141 -0
  67. package/src/client/locales/common.ts +113 -0
  68. package/src/client/locales/export.ts +184 -0
  69. package/src/client/locales/foreign.ts +184 -0
  70. package/src/client/locales/import-compat.ts +32 -0
  71. package/src/client/locales/import.ts +192 -0
  72. package/src/client/locales/next-steps.ts +25 -0
  73. package/src/client/locales/overview-control.ts +32 -0
  74. package/src/client/locales/overview.ts +153 -0
  75. package/src/client/locales/profiles.ts +263 -0
  76. package/src/client/locales/report.ts +17 -0
  77. package/src/client/locales/restore.ts +132 -0
  78. package/src/client/locales/sessions.ts +257 -0
  79. package/src/client/locales/shell.ts +149 -0
  80. package/src/client/locales.ts +49 -1783
  81. package/src/client/market/MarketImportReview.tsx +2 -2
  82. package/src/client/market/MarketPanel.tsx +1 -1
  83. package/src/client/market/market-view.ts +3 -5
  84. package/src/client/recovery/RecoveryPanel.tsx +62 -1054
  85. package/src/client/recovery/SessionHealthCard.tsx +134 -0
  86. package/src/client/recovery/SessionHealthDialog.tsx +665 -0
  87. package/src/client/recovery/SessionLayoutSection.tsx +284 -0
  88. package/src/client/recovery/recovery-api.ts +10 -1
  89. package/src/client/recovery/recovery-panel-layout.test.ts +20 -5
  90. package/src/client/recovery/session-dialog-mount.test.ts +16 -9
  91. package/src/client/recovery/use-recovery-write.test.ts +90 -0
  92. package/src/client/recovery/use-recovery-write.ts +53 -0
  93. package/src/client/run-store.ts +57 -2
  94. package/src/client/sync/PushPreviewCard.tsx +2 -2
  95. package/src/client/sync/SyncConfirmView.tsx +5 -5
  96. package/src/client/sync/SyncLogList.tsx +2 -2
  97. package/src/client/sync/history-model.ts +4 -5
  98. package/src/client/sync/sync-view.ts +3 -4
  99. package/src/core/access-mode.ts +37 -0
  100. package/src/core/exporter.ts +2 -4
  101. package/src/core/host-schedulers/cache-cleanup.test.ts +84 -0
  102. package/src/core/host-schedulers/cache-cleanup.ts +74 -0
  103. package/src/core/host-schedulers/lifecycle-hooks.test.ts +111 -0
  104. package/src/core/host-schedulers/lifecycle-hooks.ts +118 -0
  105. package/src/core/host-schedulers/market-cache.test.ts +93 -0
  106. package/src/core/host-schedulers/market-cache.ts +116 -0
  107. package/src/core/model-tools.ts +2 -7
  108. package/src/core/restore-failure-state.test.ts +210 -0
  109. package/src/core/restore.ts +16 -18
  110. package/src/core/verify-recovery.ts +4 -7
  111. package/src/index.ts +81 -335
  112. package/src/profiles/dsh-profile-copy-rollback.test.ts +156 -0
  113. package/src/profiles/dsh-profile-manager.ts +71 -3
  114. package/src/routes/kit.ts +106 -3
  115. package/src/routes/prefs.ts +6 -6
  116. package/src/routes/recovery.ts +25 -42
  117. package/src/routes/request-trust.ts +97 -0
  118. package/src/routes/route-support.ts +208 -1
  119. package/src/routes/snapshots.ts +4 -9
  120. package/src/routes/sync.ts +4 -7
  121. package/src/security/redaction.ts +29 -23
  122. package/src/sync/backup-scheduler.ts +3 -6
  123. package/src/sync/sync-config.test.ts +24 -13
  124. package/src/ui/backup-inspect.ts +1 -1
  125. package/src/ui/dsh-profiles-view.ts +3 -5
  126. package/src/ui/i18n.test.ts +8 -3
  127. package/src/ui/snapshots-view.ts +2 -2
  128. package/src/utils/paths.test.ts +36 -1
  129. package/src/utils/paths.ts +30 -6
  130. package/src/utils/time.test.ts +46 -0
  131. package/src/utils/time.ts +55 -0
@@ -25,6 +25,7 @@ import { decryptCredentials, SecurityError } from '../security/index.js';
25
25
  import { engineMsg } from '../core/engine-locale.js';
26
26
  import { createPreRestoreAttemptDir } from '../core/restore.js';
27
27
  import { collectRestoreWalEntries, createRestoreWal, restoreActionStepId, restoreWalHandlesFromSteps } from '../core/restore-wal.js';
28
+ import { GIST_PROVIDER, cloudSecretRef, isS3CompatProvider, isWebDavConfig, parseSyncChannel, validateCloudChannelInput, validateRepoUrl, validateWebDavUrl } from '../sync/sync-config.js';
28
29
  import { DEFAULT_AUTOSYNC_AUTO_APPLY_TIER, DEFAULT_AUTOSYNC_CONFLICT_POLICY, DEFAULT_AUTOSYNC_REALTIME, DEFAULT_AUTOSYNC_REMOTE_CHECK_MS, lastRunFailureMessage, readAllAutosyncConfigs, readAutosyncConfig } from '../sync/autosync-config.js';
29
30
  import { SYNC_CHANNELS } from '../sync/sync-config.js';
30
31
  import { normalizeSessionsInclude } from '../sync/sync-selection.js';
@@ -634,4 +635,188 @@ export function makeRestoreExecutor(snapshotDir, host, profile) {
634
635
  },
635
636
  };
636
637
  }
638
+ /**
639
+ * 解析同步请求体,按 transport 分支返回归一化的 SyncConfig(可辨识联合,schemaVersion=2)。
640
+ * 请求体形状(flat,M4 契约):
641
+ * - git: { transport:'git', repoUrl, token? } —— token 非空写 SYNC_CREDENTIAL_REF;
642
+ * git 可执行文件固定使用系统 PATH 中的 git(不再接受自定义 gitBin)。
643
+ * - webdav: { transport:'webdav', url, username?, password? } —— password 非空写 SYNC_WEBDAV_CREDENTIAL_REF。
644
+ * 返回值不含任何 secret(password/token 只进 credentials,永不回传/落同步文件)。
645
+ */
646
+ export async function parseSyncBody(body, deps) {
647
+ const rawTransport = body['transport'];
648
+ // 通道值解析:接受通道名(s3/gist);也接受**具体兼容商**(oss/cos/minio/kodo)直接落到 s3 通道
649
+ const transport = parseSyncChannel(rawTransport) ?? (isS3CompatProvider(rawTransport) ? 's3' : 'git');
650
+ if (transport === 's3')
651
+ return parseCloudS3Body(body, rawTransport, deps);
652
+ if (transport === 'gist')
653
+ return parseCloudGistBody(body, deps);
654
+ if (transport === 'webdav') {
655
+ const url = typeof body['url'] === 'string' ? body['url'].trim() : '';
656
+ if (url === '')
657
+ throw new SyncRouteError('url is required for webdav');
658
+ const urlError = validateWebDavUrl(url);
659
+ if (urlError !== null)
660
+ throw new SyncRouteError(urlError);
661
+ const username = typeof body['username'] === 'string' && body['username'] !== '' ? body['username'] : undefined;
662
+ const password = typeof body['password'] === 'string' && body['password'] !== '' ? body['password'] : undefined;
663
+ if (password !== undefined) {
664
+ try {
665
+ await deps.credentials.set(credentialRef(SYNC_WEBDAV_CREDENTIAL_REF), password);
666
+ }
667
+ catch (error) {
668
+ const reason = error instanceof Error ? error.message : String(error);
669
+ throw new SyncRouteError(engineMsg('host.syncWebdavPasswordWriteFailed', { reason, ref: SYNC_WEBDAV_CREDENTIAL_REF }));
670
+ }
671
+ }
672
+ return {
673
+ schemaVersion: 2,
674
+ transport: 'webdav',
675
+ webdav: { url, ...(username !== undefined ? { username } : {}) },
676
+ };
677
+ }
678
+ // git 通道(沿用现有逻辑)
679
+ const repoUrl = typeof body['repoUrl'] === 'string' ? body['repoUrl'].trim() : '';
680
+ if (repoUrl === '')
681
+ throw new SyncRouteError('repoUrl is required');
682
+ const urlError = validateRepoUrl(repoUrl);
683
+ if (urlError !== null)
684
+ throw new SyncRouteError(urlError);
685
+ const token = typeof body['token'] === 'string' && body['token'] !== '' ? body['token'] : undefined;
686
+ if (token !== undefined) {
687
+ try {
688
+ await deps.credentials.set(credentialRef(SYNC_CREDENTIAL_REF), token);
689
+ }
690
+ catch (error) {
691
+ const reason = error instanceof Error ? error.message : String(error);
692
+ throw new SyncRouteError(engineMsg('host.syncTokenWriteFailed', { reason, ref: SYNC_CREDENTIAL_REF }));
693
+ }
694
+ }
695
+ return {
696
+ schemaVersion: 2,
697
+ transport: 'git',
698
+ git: { repoUrl },
699
+ };
700
+ }
701
+ /** 请求体字段 → 去空白字符串(非字符串 = 空)。 */
702
+ function syncStr(value) {
703
+ return typeof value === 'string' ? value.trim() : '';
704
+ }
705
+ /** 云端点密钥写入失败 → 可操作错误(**含 ref 名、绝不含密钥值**)。 */
706
+ function cloudCredentialWriteError(ref, kind, error) {
707
+ const reason = error instanceof Error ? error.message : String(error);
708
+ return new SyncRouteError(engineMsg('host.syncCredentialWriteFailed', { kind, reason, ref }), 400, 'cloud.credentialsWriteFailed');
709
+ }
710
+ /**
711
+ * s3 通道请求体 → SyncConfig(provider 必填或由 transport 直接给出)。
712
+ * 非密字段按 validateCloudChannelInput 校验(错误码 = HTTP body.code,由 UI 映射字典);
713
+ * 密钥**只写**进 DSH credentials 的 cloudSecretRef(provider) 槽位,绝不进返回值 / 文件 / 日志。
714
+ */
715
+ async function parseCloudS3Body(body, rawTransport, deps) {
716
+ const provider = isS3CompatProvider(body['provider'])
717
+ ? body['provider']
718
+ : (isS3CompatProvider(rawTransport) ? rawTransport : null);
719
+ if (provider === null) {
720
+ throw new SyncRouteError('provider is required for s3 (s3/oss/cos/minio/kodo)', 400, 'cloud.providerUnknown');
721
+ }
722
+ const endpoint = syncStr(body['endpoint']).replace(/\/+$/, '');
723
+ const region = syncStr(body['region']);
724
+ const bucket = syncStr(body['bucket']);
725
+ const accessKeyId = syncStr(body['accessKeyId']);
726
+ const prefix = syncStr(body['prefix']);
727
+ const pathStyle = typeof body['pathStyle'] === 'boolean' ? body['pathStyle'] : undefined;
728
+ const dialectId = body['dialectId'] === 'aws4' || body['dialectId'] === 'oss4' ? body['dialectId'] : undefined;
729
+ const issue = validateCloudChannelInput(provider, {
730
+ endpoint,
731
+ region,
732
+ bucket,
733
+ accessKeyId,
734
+ ...(prefix === '' ? {} : { prefix }),
735
+ ...(pathStyle === undefined ? {} : { pathStyle }),
736
+ ...(dialectId === undefined ? {} : { dialectId }),
737
+ });
738
+ if (issue !== null)
739
+ throw new SyncRouteError(issue, 400, issue);
740
+ const secret = typeof body['secret'] === 'string' && body['secret'] !== '' ? body['secret'] : undefined;
741
+ if (secret !== undefined) {
742
+ const ref = cloudSecretRef(provider);
743
+ try {
744
+ await deps.credentials.set(credentialRef(ref), secret);
745
+ }
746
+ catch (error) {
747
+ throw cloudCredentialWriteError(ref, engineMsg('host.syncKindS3Secret'), error);
748
+ }
749
+ }
750
+ return {
751
+ schemaVersion: 2,
752
+ transport: 's3',
753
+ s3: {
754
+ provider,
755
+ endpoint,
756
+ region,
757
+ bucket,
758
+ accessKeyId,
759
+ ...(prefix === '' ? {} : { prefix }),
760
+ ...(pathStyle === undefined ? {} : { pathStyle }),
761
+ ...(dialectId === undefined ? {} : { dialectId }),
762
+ },
763
+ };
764
+ }
765
+ /**
766
+ * gist 通道请求体 → SyncConfig。token 只写进 cloudSecretRef('gist') 槽位
767
+ * (请求体字段名 token 或 secret 都接受;值绝不进返回值 / 文件 / 日志)。
768
+ */
769
+ async function parseCloudGistBody(body, deps) {
770
+ const gistId = syncStr(body['gistId']);
771
+ const apiBaseUrl = syncStr(body['apiBaseUrl']);
772
+ const filePrefix = syncStr(body['filePrefix']);
773
+ const issue = validateCloudChannelInput(GIST_PROVIDER, {
774
+ gistId,
775
+ ...(apiBaseUrl === '' ? {} : { apiBaseUrl }),
776
+ ...(filePrefix === '' ? {} : { filePrefix }),
777
+ });
778
+ if (issue !== null)
779
+ throw new SyncRouteError(issue, 400, issue);
780
+ const token = typeof body['token'] === 'string' && body['token'] !== ''
781
+ ? body['token']
782
+ : (typeof body['secret'] === 'string' && body['secret'] !== '' ? body['secret'] : undefined);
783
+ if (token !== undefined) {
784
+ const ref = cloudSecretRef(GIST_PROVIDER);
785
+ try {
786
+ await deps.credentials.set(credentialRef(ref), token);
787
+ }
788
+ catch (error) {
789
+ throw cloudCredentialWriteError(ref, 'Gist token', error);
790
+ }
791
+ }
792
+ return {
793
+ schemaVersion: 2,
794
+ transport: 'gist',
795
+ gist: {
796
+ gistId,
797
+ ...(apiBaseUrl === '' ? {} : { apiBaseUrl }),
798
+ ...(filePrefix === '' ? {} : { filePrefix }),
799
+ },
800
+ };
801
+ }
802
+ /** 由 SyncConfig 合成 WebDAV 通道 baseUrl(webdav.url,尾部规范化带 '/';git 通道返回 '')。 */
803
+ export function webdavBaseUrl(cfg) {
804
+ if (!isWebDavConfig(cfg))
805
+ return '';
806
+ return cfg.webdav.url.replace(/\/+$/, '') + '/';
807
+ }
808
+ /**
809
+ * 补全 webdav 配置缺失的 username(从持久化配置回填;纯函数,不修改入参)。
810
+ * 语义与 password 一致:请求未带 username(表单留空/挂载自动加载)→ 沿用已保存的值;
811
+ * 请求显式带 username → 原样保留(用户新输入优先)。非 webdav / 无持久化 → 原样返回。
812
+ */
813
+ export function mergePersistedWebDavUsername(cfg, persisted) {
814
+ if (!isWebDavConfig(cfg) || (cfg.webdav.username !== undefined && cfg.webdav.username !== ''))
815
+ return cfg;
816
+ if (persisted !== null && isWebDavConfig(persisted)
817
+ && typeof persisted.webdav.username === 'string' && persisted.webdav.username !== '') {
818
+ return { ...cfg, webdav: { ...cfg.webdav, username: persisted.webdav.username } };
819
+ }
820
+ return cfg;
821
+ }
637
822
  //# sourceMappingURL=route-support.js.map
@@ -4,13 +4,12 @@
4
4
  * W1(host-entry#F-02/#F-03):路由只在这里声明一次 —— endpoint({ path, methods }, handler) 的
5
5
  * path/methods 就是唯一声明处;围栏、方法判定与顶层异常处理由 src/routes/kit.ts 在注册点统一提供。
6
6
  */
7
- import { endpoint, readJsonBody, writeJson } from './kit.js';
8
- import { TransactionRecoveryRequiredError } from '../core/phase3-host.js';
7
+ import { endpoint, readJsonBody, writeJson, writeMutationError } from './kit.js';
9
8
  import { deleteSnapshot, isValidSnapshotId, listSnapshots, planRestore, setSnapshotPinned } from '../core/restore.js';
10
9
  import { snapshotFileDiff, summarizeRestoreChanges } from '../core/snapshot-diff.js';
11
10
  import { buildFileDiffBody, buildRestoreBody, executeRestorePlan, makeRestoreExecutor } from './route-support.js';
12
11
  import { probeRestoreResume, runRestoreWithResume } from '../core/restore-resume.js';
13
- import { EnvironmentLockUnavailableError, runWithMutationLock } from '../utils/env-lock.js';
12
+ import { runWithMutationLock } from '../utils/env-lock.js';
14
13
  import { isENOENT } from '../utils/guards.js';
15
14
  import { join } from 'node:path';
16
15
  import { createHash } from 'node:crypto';
@@ -185,14 +184,8 @@ export function snapshotRoutes(env) {
185
184
  });
186
185
  }
187
186
  catch (error) {
188
- if (error instanceof EnvironmentLockUnavailableError) {
189
- host.log.warn(`mutation lock blocked: op=${error.op} reason=${error.reason}${error.detail !== undefined ? ` detail=${error.detail}` : ''}`);
190
- writeJson(res, 423, { error: error.message, code: 'mutation-locked' });
191
- }
192
- else if (error instanceof TransactionRecoveryRequiredError) {
193
- writeJson(res, 423, { error: error.message, code: 'transaction-recovery-required' });
194
- }
195
- else {
187
+ // 423 家族(SAFE MODE / 环境锁 / 未收敛事务)的唯一映射在 kit;本路由其余错误沿用 400 口径。
188
+ if (!writeMutationError(res, host, error)) {
196
189
  writeJson(res, 400, { error: error instanceof Error ? error.message : String(error) });
197
190
  }
198
191
  }
@@ -4,8 +4,8 @@
4
4
  * W1(host-entry#F-02/#F-03):路由只在这里声明一次 —— endpoint({ path, methods }, handler) 的
5
5
  * path/methods 就是唯一声明处;围栏、方法判定与顶层异常处理由 src/routes/kit.ts 在注册点统一提供。
6
6
  */
7
- import { endpoint, queryParam, requireJsonObject, readJsonBody, writeJson } from './kit.js';
8
- import { EnvironmentLockUnavailableError, runWithMutationLock } from '../utils/env-lock.js';
7
+ import { endpoint, queryParam, requireJsonObject, readJsonBody, writeJson, writeMutationError } from './kit.js';
8
+ import { runWithMutationLock } from '../utils/env-lock.js';
9
9
  import { FileSnapshotStore } from '../core/index.js';
10
10
  import { rollback as performRollback } from '../core/rollback.js';
11
11
  /**
@@ -377,11 +377,9 @@ export function syncRoutes(env) {
377
377
  writeJson(res, 200, { ok: true, lastSyncChannel: channel });
378
378
  }
379
379
  catch (error) {
380
- if (error instanceof EnvironmentLockUnavailableError) {
381
- writeJson(res, 423, { error: error.message, code: 'mutation-locked' });
382
- return;
383
- }
384
- writeSyncRouteError(res, error);
380
+ // 423 家族(SAFE MODE / 环境锁)的唯一映射在 kit;其余沿用本组既有 SyncRouteError 口径。
381
+ if (!writeMutationError(res, host, error))
382
+ writeSyncRouteError(res, error);
385
383
  }
386
384
  }),
387
385
  // ------------------------------------------------------ sync/push
@@ -36,7 +36,11 @@ export declare function maskHighEntropy(text: string): string;
36
36
  export declare function redact(text: string, blacklist?: readonly string[]): string;
37
37
  /** 对象级掩码:字段名命中敏感名单 → 整值替换(返回新对象,不改原对象;结构与类型保留) */
38
38
  export declare function redactValue(value: unknown, blacklist?: readonly string[]): unknown;
39
- /** 预编译脱敏器(多次调用复用;blacklist 为附加规范化字段名) */
39
+ /**
40
+ * 预编译脱敏器(多次调用复用;blacklist 为附加规范化字段名)。
41
+ * 正则实例**在创建时**各复制一份:模块级常量若与本函数共享,多线程无害但会让「谁动了 lastIndex」
42
+ * 不可追溯;复制成本只有一次,换来每个脱敏器实例自持状态。
43
+ */
40
44
  export declare function createRedactor(blacklist?: readonly string[]): (text: string) => string;
41
45
  /** 默认名单(文档用;redact 的默认附加名单为空,内置判定已含 DEFAULT_SECRET_FIELD_NAMES) */
42
46
  export { DEFAULT_SECRET_FIELD_NAMES };
@@ -105,23 +105,31 @@ function replaceSensitiveField(text, re, blacklist) {
105
105
  });
106
106
  }
107
107
  /**
108
- * 文本脱敏(幂等)。blacklist 为**附加**规范化字段名(小写无分隔符,如 'clientsecret')。
109
- * 输出仍保留结构化形态(JSON 行合法)。
108
+ * 脱敏流水线(**唯一实现**,redact 与 createRedactor 共用一套顺序与语义)。
109
+ *
110
+ * 曾经这里与 createRedactor 各写一遍完全相同的 6 步(结构化 3 步 + 值形状 + URL query + userinfo),
111
+ * 两份代码只在「正则实例从哪来」上不同 —— 任何一步调整都要记得改两处,漏一次就是两条脱敏口径。
112
+ * 现在只由调用方决定正则实例的生命周期(模块级常量 / 每次预编译),流水线本身不再有副本。
110
113
  */
111
- export function redact(text, blacklist = []) {
112
- let out = text;
114
+ function redactPipeline(text, blacklist, json, kv, colon) {
113
115
  // 1. 结构化字段形态(顺序:JSON → kv → colon;JSON 键不会被后续形态二次命中)
114
- out = replaceSensitiveField(out, JSON_FIELD_RE, blacklist);
115
- out = replaceSensitiveField(out, KV_FIELD_RE, blacklist);
116
- out = replaceSensitiveField(out, COLON_FIELD_RE, blacklist);
116
+ let out = replaceSensitiveField(text, json, blacklist);
117
+ out = replaceSensitiveField(out, kv, blacklist);
118
+ out = replaceSensitiveField(out, colon, blacklist);
117
119
  // 2. 值形状模式(字段名无关,包含式)
118
120
  for (const { re } of VALUE_PATTERNS) {
119
121
  re.lastIndex = 0;
120
122
  out = out.replace(re, REDACTED);
121
123
  }
122
124
  out = out.replace(URL_QUERY_RE, `$1${REDACTED}`);
123
- out = out.replace(URL_USERINFO_RE, `$1${REDACTED}$3`);
124
- return out;
125
+ return out.replace(URL_USERINFO_RE, `$1${REDACTED}$3`);
126
+ }
127
+ /**
128
+ * 文本脱敏(幂等)。blacklist 为**附加**规范化字段名(小写无分隔符,如 'clientsecret')。
129
+ * 输出仍保留结构化形态(JSON 行合法)。
130
+ */
131
+ export function redact(text, blacklist = []) {
132
+ return redactPipeline(text, blacklist, JSON_FIELD_RE, KV_FIELD_RE, COLON_FIELD_RE);
125
133
  }
126
134
  /** 对象级掩码:字段名命中敏感名单 → 整值替换(返回新对象,不改原对象;结构与类型保留) */
127
135
  export function redactValue(value, blacklist = []) {
@@ -137,21 +145,16 @@ export function redactValue(value, blacklist = []) {
137
145
  }
138
146
  return out;
139
147
  }
140
- /** 预编译脱敏器(多次调用复用;blacklist 为附加规范化字段名) */
148
+ /**
149
+ * 预编译脱敏器(多次调用复用;blacklist 为附加规范化字段名)。
150
+ * 正则实例**在创建时**各复制一份:模块级常量若与本函数共享,多线程无害但会让「谁动了 lastIndex」
151
+ * 不可追溯;复制成本只有一次,换来每个脱敏器实例自持状态。
152
+ */
141
153
  export function createRedactor(blacklist = []) {
142
- const compiled = { json: JSON_FIELD_RE, kv: KV_FIELD_RE, colon: COLON_FIELD_RE };
143
- return (text) => {
144
- let out = replaceSensitiveField(text, new RegExp(compiled.json.source, 'g'), blacklist);
145
- out = replaceSensitiveField(out, new RegExp(compiled.kv.source, 'g'), blacklist);
146
- out = replaceSensitiveField(out, new RegExp(compiled.colon.source, 'g'), blacklist);
147
- for (const { re } of VALUE_PATTERNS) {
148
- re.lastIndex = 0;
149
- out = out.replace(re, REDACTED);
150
- }
151
- out = out.replace(URL_QUERY_RE, `$1${REDACTED}`);
152
- out = out.replace(URL_USERINFO_RE, `$1${REDACTED}$3`);
153
- return out;
154
- };
154
+ const json = new RegExp(JSON_FIELD_RE.source, 'g');
155
+ const kv = new RegExp(KV_FIELD_RE.source, 'g');
156
+ const colon = new RegExp(COLON_FIELD_RE.source, 'g');
157
+ return (text) => redactPipeline(text, blacklist, json, kv, colon);
155
158
  }
156
159
  /** 默认名单(文档用;redact 的默认附加名单为空,内置判定已含 DEFAULT_SECRET_FIELD_NAMES) */
157
160
  export { DEFAULT_SECRET_FIELD_NAMES };
@@ -7,6 +7,7 @@ import { readBackupSchedule, writeBackupSchedule, nextBackupDelayMs } from './ba
7
7
  import { shouldTriggerStartupRun } from './autosync-scheduler.js';
8
8
  import { AUTO_BACKUP_PREFIX, pruneAutoBackupsByPolicy } from './backup-files.js';
9
9
  import { DEFAULT_RETENTION_POLICY } from './retention-policy.js';
10
+ import { formatDateStamp } from '../utils/time.js';
10
11
  export class BackupScheduler {
11
12
  syncDir;
12
13
  exportsDir;
@@ -175,7 +176,7 @@ export class BackupScheduler {
175
176
  });
176
177
  // 显式落 exportsDir(与 host 路由同构;Exporter 缺省 outPath 是相对文件名,不落目录)
177
178
  // auto 前缀 = 定时备份产物标识:列表来源 Badge + cache-cleaner 豁免 + 保留策略清理依据
178
- const outPath = join(this.exportsDir, `${AUTO_BACKUP_PREFIX}${dateStamp(this.now())}-${randomBytes(3).toString('hex')}.zip`);
179
+ const outPath = join(this.exportsDir, `${AUTO_BACKUP_PREFIX}${formatDateStamp(this.now())}-${randomBytes(3).toString('hex')}.zip`);
179
180
  const { report } = await exporter.export({
180
181
  includeSecrets: false, // 恒不含 secret(与自动同步同语义)
181
182
  outPath,
@@ -304,9 +305,4 @@ export class BackupScheduler {
304
305
  }
305
306
  }
306
307
  }
307
- /** 导出文件时间戳(YYYYMMDD-HHmmss),与 host 路由 dateStamp 同构。 */
308
- function dateStamp(d) {
309
- const p = (n) => String(n).padStart(2, '0');
310
- return `${d.getFullYear()}${p(d.getMonth() + 1)}${p(d.getDate())}-${p(d.getHours())}${p(d.getMinutes())}${p(d.getSeconds())}`;
311
- }
312
308
  //# sourceMappingURL=backup-scheduler.js.map
@@ -34,7 +34,7 @@ export declare function inspectSections(analysis: ImportAnalysis, plan: ImportPl
34
34
  export declare function inspectSummary(analysis: ImportAnalysis, plan: ImportPlan): BackupInspectSummary;
35
35
  /** 变更明细分组键(渲染顺序 = 冲突 → 变更 → 路径映射 → 一致跳过 → 其他)。 */
36
36
  export type InspectGroupKey = 'conflicts' | 'changes' | 'paths' | 'skipped' | 'others';
37
- /** 单分组:key(语义)+ kind(Badge/kindTag 颜色语义)+ 组内条目。 */
37
+ /** 单分组:key(语义)+ kind(Badge 四态颜色语义)+ 组内条目。 */
38
38
  export interface InspectChangeGroup {
39
39
  key: InspectGroupKey;
40
40
  /** 颜色语义:error=冲突 / info=变更 / warn=路径映射与其它 / ok=一致跳过 */
@@ -1,13 +1,3 @@
1
- /**
2
- * 「档案」页(DSH profile 管理)—— 框架无关纯函数层(node 可测)。
3
- *
4
- * 职责:名字输入校验、列表排序(当前运行置顶)、列表摘要统计、危险态判定、运行中实例判定、
5
- * 展示格式化(时间/字节)、终端启动命令文本。不产出用户可见散文(文案走 locale 字典 `t()`),
6
- * 不 import node 模块、不 import React。
7
- *
8
- * 依赖方向:只从 `src/profiles/dsh-profile-shared.ts`(零依赖)取类型与纯函数——
9
- * 绝不 import 用 node fs 的引擎(否则 client bundle 会带上 node 内置模块依赖而整插件不加载)。
10
- */
11
1
  import { type DshProfileCopyWarning, type DshProfileIssue, type DshProfileLaunchResult, type DshProfileLaunchWarning, type DshProfileMeta, type DshProfileRunningView, type DshProfileShape, type DshProfileStopOutcome } from '../profiles/dsh-profile-shared.ts';
12
2
  /** 名称输入校验结果(UI 按码映射 i18n;null = 合法)。 */
13
3
  export type ProfileNameIssue = 'required' | 'tooLong' | 'illegal' | 'reserved';
@@ -8,6 +8,7 @@
8
8
  * 依赖方向:只从 `src/profiles/dsh-profile-shared.ts`(零依赖)取类型与纯函数——
9
9
  * 绝不 import 用 node fs 的引擎(否则 client bundle 会带上 node 内置模块依赖而整插件不加载)。
10
10
  */
11
+ import { formatMinuteStamp, parseDateInput } from '../utils/time.js';
11
12
  import { checkProfileName, isLaunchableShape, isManagedProfileName, } from '../profiles/dsh-profile-shared.js';
12
13
  /** 校验输入框里的 profile 名:与 host 侧同规则,但把「空」与「过长」细分以便给出更准的提示。 */
13
14
  export function validateProfileNameInput(name) {
@@ -237,13 +238,8 @@ export function issueLabelKey(issue) {
237
238
  }
238
239
  /** 时间戳(毫秒)→ 本地 `YYYY-MM-DD HH:mm`;null / 非法 = 空串。 */
239
240
  export function formatProfileTime(ms) {
240
- if (ms === null)
241
- return '';
242
- const d = new Date(ms);
243
- if (Number.isNaN(d.getTime()))
244
- return '';
245
- const p = (n) => String(n).padStart(2, '0');
246
- return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`;
241
+ const d = parseDateInput(ms);
242
+ return d === null ? '' : formatMinuteStamp(d);
247
243
  }
248
244
  /** 字节数 → 人类可读(B / KB / MB,保留一位小数)。 */
249
245
  export function formatBytes(bytes) {
@@ -1,17 +1,3 @@
1
- /**
2
- * 备份页(Backups:快照恢复 / 备份文件 / 定时备份设置)—— 框架无关纯函数层(node 可测)。
3
- *
4
- * t43 从 `src/client/snapshots/SnapshotsPanel.tsx` 下沉(该组件原先把这些逻辑私有在函数体内,
5
- * 违反仓库铁律「逻辑放 src/ui」——node 无法测试)。本层职责:
6
- * - 面板状态切片 ← runStore 快照切片 的投影(切页/刷新恢复的判定);
7
- * - 状态/档位 → **字典键**(本层不产出任何用户可见文案,由 React 壳 t() 渲染,见 backup-schedule.ts 同款约定);
8
- * - 时间与文件名的展示格式化;
9
- * - 备份文件列表的搜索过滤、备注可读性判定;
10
- * - 恢复计划是否含可执行动作(执行按钮的 disabled 判据)。
11
- *
12
- * 约束:不 import node 模块、不 import `../client/*`(架构边界 tests/architecture-boundaries.test.ts)、
13
- * 无 React 依赖;类型仅从 `../core/*` / `../sync/*` 以 type-only 方式取(运行时不加载)。
14
- */
15
1
  import type { RestorePlan, RestoreReport, SnapshotMeta } from '../core/restore.ts';
16
2
  import type { RestoreChangeSummary } from '../core/snapshot-diff.ts';
17
3
  import type { BackupFileMeta } from '../sync/backup-files.ts';
@@ -1,3 +1,18 @@
1
+ /**
2
+ * 备份页(Backups:快照恢复 / 备份文件 / 定时备份设置)—— 框架无关纯函数层(node 可测)。
3
+ *
4
+ * t43 从 `src/client/snapshots/SnapshotsPanel.tsx` 下沉(该组件原先把这些逻辑私有在函数体内,
5
+ * 违反仓库铁律「逻辑放 src/ui」——node 无法测试)。本层职责:
6
+ * - 面板状态切片 ← runStore 快照切片 的投影(切页/刷新恢复的判定);
7
+ * - 状态/档位 → **字典键**(本层不产出任何用户可见文案,由 React 壳 t() 渲染,见 backup-schedule.ts 同款约定);
8
+ * - 时间与文件名的展示格式化;
9
+ * - 备份文件列表的搜索过滤、备注可读性判定;
10
+ * - 恢复计划是否含可执行动作(执行按钮的 disabled 判据)。
11
+ *
12
+ * 约束:不 import node 模块、不 import `../client/*`(架构边界 tests/architecture-boundaries.test.ts)、
13
+ * 无 React 依赖;类型仅从 `../core/*` / `../sync/*` 以 type-only 方式取(运行时不加载)。
14
+ */
15
+ import { formatMinuteStamp } from '../utils/time.js';
1
16
  export const INITIAL_SNAPSHOTS_PANEL_STATE = {
2
17
  status: 'loading',
3
18
  error: null,
@@ -120,8 +135,7 @@ export function formatBackupFileTime(ms) {
120
135
  const d = new Date(ms);
121
136
  if (Number.isNaN(d.getTime()))
122
137
  return '';
123
- const p = (n) => String(n).padStart(2, '0');
124
- return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`;
138
+ return formatMinuteStamp(d);
125
139
  }
126
140
  /**
127
141
  * 备注是否「编码损坏」(全问号/控制符)→ 调用方改渲染 backupFiles.noteUnreadable 文案;
@@ -8,11 +8,27 @@ export declare function isAbsolutePath(p: string): boolean;
8
8
  /** ZIP 条目名安全检查(Zip Slip / 绝对路径 / 盘符 / NUL,规范 §19.1-2)。
9
9
  * 规则与 node:path 解耦:纯分段校验,跨平台无歧义。 */
10
10
  export declare function isPathSafe(entryName: string): boolean;
11
- /** 候选目录是否位于父目录之内(含等于父目录)。
11
+ /** 越界判定选项。 */
12
+ export interface PathInsideOptions {
13
+ /**
14
+ * 比较前折叠大小写(Windows 文件系统大小写不敏感)。缺省按当前平台。
15
+ * 显式传 false 的场景:拿另一台机器的路径做形状判定(跨平台导入)。
16
+ */
17
+ foldCase?: boolean;
18
+ }
19
+ /** 候选路径是否位于父目录之内(含等于父目录)。
12
20
  *
13
- * 纯字符串语义(不碰文件系统):两侧必须是**同一种拼写**,调用方若混用
14
- * realpath 结果与原路径(Windows 8.3 短名、macOS `/var`→`/private/var`)会误判为越界 ——
15
- * `path.relative` 不会折叠短名,务必先各自 realpath 再调用。 */
21
+ * 全仓**唯一**的越界判定(restore / verify-recovery / zip / recursive-walk / 路由都走这里):
22
+ * 早期四处各写一份,其中三份用 `rel.startsWith('..')` 判越界 —— 名字真的叫 `..foo` 的
23
+ * 兄弟目录会被误判为逃逸(`path.relative('/a/b','/a/b/..foo') === '..foo'`)。
24
+ * 越界只有两种形态:相对结果是 `..` 段本身,或以 `..` + 分隔符开头;绝对结果(跨盘符)同样越界。
25
+ *
26
+ * 纯字符串语义(**不碰文件系统**):两侧各自 `path.resolve` 后比较。调用方若混用
27
+ * realpath 结果与原路径(Windows 8.3 短名、macOS `/var`→`/private/var`)仍会误判为越界 ——
28
+ * `path.resolve` 不折叠短名,真实路径那一层必须两侧都先 realpath 再调用。
29
+ */
30
+ export declare function isPathInside(child: string, parent: string, options?: PathInsideOptions): boolean;
31
+ /** 候选目录是否位于父目录之内(含等于父目录)—— `isPathInside` 的读法友好别名。 */
16
32
  export declare function isSameOrChild(p: string, parent: string): boolean;
17
33
  /**
18
34
  * 归一化并折叠 `.` / `..` 路径段(Reviewer B P0 修复)。
@@ -47,14 +47,30 @@ export function isPathSafe(entryName) {
47
47
  return false; // 目录穿越
48
48
  return true;
49
49
  }
50
- /** 候选目录是否位于父目录之内(含等于父目录)。
50
+ /** 候选路径是否位于父目录之内(含等于父目录)。
51
51
  *
52
- * 纯字符串语义(不碰文件系统):两侧必须是**同一种拼写**,调用方若混用
53
- * realpath 结果与原路径(Windows 8.3 短名、macOS `/var`→`/private/var`)会误判为越界 ——
54
- * `path.relative` 不会折叠短名,务必先各自 realpath 再调用。 */
52
+ * 全仓**唯一**的越界判定(restore / verify-recovery / zip / recursive-walk / 路由都走这里):
53
+ * 早期四处各写一份,其中三份用 `rel.startsWith('..')` 判越界 —— 名字真的叫 `..foo` 的
54
+ * 兄弟目录会被误判为逃逸(`path.relative('/a/b','/a/b/..foo') === '..foo'`)。
55
+ * 越界只有两种形态:相对结果是 `..` 段本身,或以 `..` + 分隔符开头;绝对结果(跨盘符)同样越界。
56
+ *
57
+ * 纯字符串语义(**不碰文件系统**):两侧各自 `path.resolve` 后比较。调用方若混用
58
+ * realpath 结果与原路径(Windows 8.3 短名、macOS `/var`→`/private/var`)仍会误判为越界 ——
59
+ * `path.resolve` 不折叠短名,真实路径那一层必须两侧都先 realpath 再调用。
60
+ */
61
+ export function isPathInside(child, parent, options = {}) {
62
+ const foldCase = options.foldCase ?? process.platform === 'win32';
63
+ const fold = (v) => (foldCase ? v.toLowerCase() : v);
64
+ const rel = path.relative(fold(path.resolve(parent)), fold(path.resolve(child)));
65
+ if (rel === '')
66
+ return true;
67
+ if (path.isAbsolute(rel))
68
+ return false; // 跨盘符(win32 relative 直接回绝对路径)
69
+ return rel !== '..' && !rel.startsWith(`..${path.sep}`);
70
+ }
71
+ /** 候选目录是否位于父目录之内(含等于父目录)—— `isPathInside` 的读法友好别名。 */
55
72
  export function isSameOrChild(p, parent) {
56
- const rel = path.relative(parent, p);
57
- return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));
73
+ return isPathInside(p, parent);
58
74
  }
59
75
  /**
60
76
  * 内部 control-plane namespace(F23 修复):不可信 import(pluginFiles/self/file adapters)
@@ -0,0 +1,31 @@
1
+ /**
2
+ * 时间戳格式化的唯一实现(host 与 client 共用,**零 import**)。
3
+ *
4
+ * 为什么单列一个模块:同一串 `YYYYMMDD-HHmmss` 曾在 5 处各写一遍(model-tools / backup-scheduler /
5
+ * cli·actions / cli·import-source / cli·index),`YYYY-MM-DD` 2 处,展示用的
6
+ * `YYYY-MM-DD HH:mm` 5 处(sync 历史、sync 状态、market、profiles、release notes)——
7
+ * 改一处口径(比如补毫秒、改本地时区)就得记住改十处,漏一处就是两套时间显示。
8
+ *
9
+ * 约束:**不得 import node 模块**(`src/client/**` 直接消费本模块)。
10
+ *
11
+ * 分工:本模块只负责**格式**,不负责「非法输入怎么显示」——那是各处的产品口径
12
+ * (历史表显示 `—`、profiles 显示空串、release notes 原样回显),由调用方决定;
13
+ * 这里只提供 `parseDateInput` 这一个统一的「能不能解析」判定。
14
+ */
15
+ /** 日期戳 `YYYYMMDD-HHmmss`(**本地时区**,用于导出文件名:定宽、仅 ASCII、可排序)。 */
16
+ export declare function formatDateStamp(d?: Date): string;
17
+ /** 日期 `YYYY-MM-DD`(**本地时区**,用于导出文件名 / 只显示日期的场景)。 */
18
+ export declare function formatDateOnly(d: Date): string;
19
+ /** 展示用本地时间 `YYYY-MM-DD HH:mm`(**本地时区**,精确到分钟)。 */
20
+ export declare function formatMinuteStamp(d: Date): string;
21
+ /**
22
+ * 解析时间输入(ISO 字符串或毫秒数)→ Date;不可解析给 null。
23
+ *
24
+ * 与 `new Date(x)` 的差别只有三条**判定**,解析规则本身完全继承:
25
+ * 1. `null` / `undefined` / 空串 / 纯空白 → null(否则 `new Date('')` 给 Invalid Date,
26
+ * 更糟的是 `new Date(null)` 会静默变成 1970-01-01);
27
+ * 2. `number`:`NaN` / `Infinity` / `-Infinity` → null;
28
+ * 3. 解析结果 `getTime()` 非有限 → null。
29
+ * 调用方拿 null 决定回退文案(`—` / 空串 / 原样回显),本模块不替它选。
30
+ */
31
+ export declare function parseDateInput(input: string | number | null | undefined): Date | null;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * 时间戳格式化的唯一实现(host 与 client 共用,**零 import**)。
3
+ *
4
+ * 为什么单列一个模块:同一串 `YYYYMMDD-HHmmss` 曾在 5 处各写一遍(model-tools / backup-scheduler /
5
+ * cli·actions / cli·import-source / cli·index),`YYYY-MM-DD` 2 处,展示用的
6
+ * `YYYY-MM-DD HH:mm` 5 处(sync 历史、sync 状态、market、profiles、release notes)——
7
+ * 改一处口径(比如补毫秒、改本地时区)就得记住改十处,漏一处就是两套时间显示。
8
+ *
9
+ * 约束:**不得 import node 模块**(`src/client/**` 直接消费本模块)。
10
+ *
11
+ * 分工:本模块只负责**格式**,不负责「非法输入怎么显示」——那是各处的产品口径
12
+ * (历史表显示 `—`、profiles 显示空串、release notes 原样回显),由调用方决定;
13
+ * 这里只提供 `parseDateInput` 这一个统一的「能不能解析」判定。
14
+ */
15
+ function pad2(n) {
16
+ return String(n).padStart(2, '0');
17
+ }
18
+ /** 日期戳 `YYYYMMDD-HHmmss`(**本地时区**,用于导出文件名:定宽、仅 ASCII、可排序)。 */
19
+ export function formatDateStamp(d = new Date()) {
20
+ return `${d.getFullYear()}${pad2(d.getMonth() + 1)}${pad2(d.getDate())}`
21
+ + `-${pad2(d.getHours())}${pad2(d.getMinutes())}${pad2(d.getSeconds())}`;
22
+ }
23
+ /** 日期 `YYYY-MM-DD`(**本地时区**,用于导出文件名 / 只显示日期的场景)。 */
24
+ export function formatDateOnly(d) {
25
+ return `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;
26
+ }
27
+ /** 展示用本地时间 `YYYY-MM-DD HH:mm`(**本地时区**,精确到分钟)。 */
28
+ export function formatMinuteStamp(d) {
29
+ return `${formatDateOnly(d)} ${pad2(d.getHours())}:${pad2(d.getMinutes())}`;
30
+ }
31
+ /**
32
+ * 解析时间输入(ISO 字符串或毫秒数)→ Date;不可解析给 null。
33
+ *
34
+ * 与 `new Date(x)` 的差别只有三条**判定**,解析规则本身完全继承:
35
+ * 1. `null` / `undefined` / 空串 / 纯空白 → null(否则 `new Date('')` 给 Invalid Date,
36
+ * 更糟的是 `new Date(null)` 会静默变成 1970-01-01);
37
+ * 2. `number`:`NaN` / `Infinity` / `-Infinity` → null;
38
+ * 3. 解析结果 `getTime()` 非有限 → null。
39
+ * 调用方拿 null 决定回退文案(`—` / 空串 / 原样回显),本模块不替它选。
40
+ */
41
+ export function parseDateInput(input) {
42
+ if (input === null || input === undefined)
43
+ return null;
44
+ if (typeof input === 'number') {
45
+ if (!Number.isFinite(input))
46
+ return null;
47
+ return new Date(input);
48
+ }
49
+ if (input.trim() === '')
50
+ return null;
51
+ const d = new Date(input);
52
+ return Number.isFinite(d.getTime()) ? d : null;
53
+ }
54
+ //# sourceMappingURL=time.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-config-manager",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "license": "MIT",
5
5
  "description": "Backup, restore, export, import, migrate and sync your DeepSeek Harness (DSH) configuration: settings, plugins, MCP servers, skills, agent presets and workspaces. One-click migration to another machine. DSH 配置一键备份、恢复、导出、导入、迁移与同步插件。",
6
6
  "icon": "./icon.svg",