@mdfriday/foundry 26.3.9 → 26.3.11

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.
package/dist/cli.js CHANGED
@@ -1747,12 +1747,16 @@ var init_license = __esm({
1747
1747
  expiresAt;
1748
1748
  features;
1749
1749
  activatedAt;
1750
- constructor(key2, plan, expiresAt, features, activatedAt) {
1750
+ activated;
1751
+ firstTime;
1752
+ constructor(key2, plan, expiresAt, features, activatedAt, activated = false, firstTime = false) {
1751
1753
  this.key = key2;
1752
1754
  this.plan = plan;
1753
1755
  this.expiresAt = expiresAt;
1754
1756
  this.features = features;
1755
1757
  this.activatedAt = activatedAt;
1758
+ this.activated = activated;
1759
+ this.firstTime = firstTime;
1756
1760
  }
1757
1761
  // ============================================================================
1758
1762
  // Factory Methods
@@ -1760,7 +1764,7 @@ var init_license = __esm({
1760
1764
  /**
1761
1765
  * 创建 License 实例
1762
1766
  */
1763
- static create(key2, plan, expiresAt, features, activatedAt) {
1767
+ static create(key2, plan, expiresAt, features, activatedAt, activated, firstTime) {
1764
1768
  if (!_License.isValidFormat(key2)) {
1765
1769
  throw new Error(`Invalid license key format: ${key2}`);
1766
1770
  }
@@ -1769,7 +1773,9 @@ var init_license = __esm({
1769
1773
  plan,
1770
1774
  expiresAt,
1771
1775
  features,
1772
- activatedAt || Date.now()
1776
+ activatedAt || Date.now(),
1777
+ activated || false,
1778
+ firstTime || false
1773
1779
  );
1774
1780
  }
1775
1781
  /**
@@ -1781,7 +1787,9 @@ var init_license = __esm({
1781
1787
  data.plan,
1782
1788
  data.expiresAt,
1783
1789
  data.features,
1784
- data.activatedAt
1790
+ data.activatedAt,
1791
+ data.activated,
1792
+ data.firstTime
1785
1793
  );
1786
1794
  }
1787
1795
  // ============================================================================
@@ -1921,6 +1929,18 @@ var init_license = __esm({
1921
1929
  getActivatedAt() {
1922
1930
  return this.activatedAt;
1923
1931
  }
1932
+ /**
1933
+ * 获取激活状态
1934
+ */
1935
+ isActivated() {
1936
+ return this.activated;
1937
+ }
1938
+ /**
1939
+ * 是否首次激活
1940
+ */
1941
+ isFirstTime() {
1942
+ return this.firstTime;
1943
+ }
1924
1944
  /**
1925
1945
  * 检查是否是试用 License
1926
1946
  */
@@ -1948,7 +1968,9 @@ var init_license = __esm({
1948
1968
  plan: this.plan,
1949
1969
  expiresAt: this.expiresAt,
1950
1970
  features: { ...this.features },
1951
- activatedAt: this.activatedAt
1971
+ activatedAt: this.activatedAt,
1972
+ activated: this.activated,
1973
+ firstTime: this.firstTime
1952
1974
  };
1953
1975
  }
1954
1976
  /**
@@ -1962,6 +1984,8 @@ var init_license = __esm({
1962
1984
  expiresAt: this.expiresAt,
1963
1985
  features: { ...this.features },
1964
1986
  activatedAt: this.activatedAt,
1987
+ activated: this.activated,
1988
+ firstTime: this.firstTime,
1965
1989
  isValid: this.isValid(),
1966
1990
  daysRemaining: this.getDaysRemaining()
1967
1991
  };
@@ -1970,6 +1994,141 @@ var init_license = __esm({
1970
1994
  }
1971
1995
  });
1972
1996
 
1997
+ // internal/domain/identity/value-object/sync-config.ts
1998
+ var SyncConfig;
1999
+ var init_sync_config = __esm({
2000
+ "internal/domain/identity/value-object/sync-config.ts"() {
2001
+ "use strict";
2002
+ SyncConfig = class _SyncConfig {
2003
+ dbEndpoint;
2004
+ dbName;
2005
+ email;
2006
+ dbPassword;
2007
+ userDir;
2008
+ status;
2009
+ constructor(data) {
2010
+ this.dbEndpoint = data.dbEndpoint;
2011
+ this.dbName = data.dbName;
2012
+ this.email = data.email;
2013
+ this.dbPassword = data.dbPassword;
2014
+ this.userDir = data.userDir;
2015
+ this.status = data.status || "active";
2016
+ }
2017
+ // ============================================================================
2018
+ // Factory Methods
2019
+ // ============================================================================
2020
+ /**
2021
+ * 创建 SyncConfig 实例
2022
+ */
2023
+ static create(data) {
2024
+ if (!data.dbEndpoint || !data.dbName || !data.email || !data.dbPassword) {
2025
+ throw new Error("Missing required sync configuration fields");
2026
+ }
2027
+ return new _SyncConfig(data);
2028
+ }
2029
+ /**
2030
+ * 从 JSON 数据创建 SyncConfig
2031
+ */
2032
+ static fromJSON(data) {
2033
+ return _SyncConfig.create(data);
2034
+ }
2035
+ // ============================================================================
2036
+ // Getters
2037
+ // ============================================================================
2038
+ /**
2039
+ * 获取数据库端点 URL(包含数据库名)
2040
+ */
2041
+ getDbEndpoint() {
2042
+ return this.dbEndpoint;
2043
+ }
2044
+ /**
2045
+ * 获取数据库名称
2046
+ */
2047
+ getDbName() {
2048
+ return this.dbName;
2049
+ }
2050
+ /**
2051
+ * 获取用户邮箱
2052
+ */
2053
+ getEmail() {
2054
+ return this.email;
2055
+ }
2056
+ /**
2057
+ * 获取数据库密码
2058
+ */
2059
+ getDbPassword() {
2060
+ return this.dbPassword;
2061
+ }
2062
+ /**
2063
+ * 获取用户目录
2064
+ */
2065
+ getUserDir() {
2066
+ return this.userDir;
2067
+ }
2068
+ /**
2069
+ * 获取同步账号状态
2070
+ */
2071
+ getStatus() {
2072
+ return this.status;
2073
+ }
2074
+ /**
2075
+ * 检查同步账号是否激活
2076
+ */
2077
+ isActive() {
2078
+ return this.status === "active";
2079
+ }
2080
+ /**
2081
+ * 获取 CouchDB URI(不包含数据库名)
2082
+ * 例如:https://couch.example.com/dbname -> https://couch.example.com
2083
+ */
2084
+ getCouchDbUri() {
2085
+ return this.dbEndpoint.replace(`/${this.dbName}`, "");
2086
+ }
2087
+ // ============================================================================
2088
+ // Serialization
2089
+ // ============================================================================
2090
+ /**
2091
+ * 序列化为 JSON
2092
+ */
2093
+ toJSON() {
2094
+ return {
2095
+ dbEndpoint: this.dbEndpoint,
2096
+ dbName: this.dbName,
2097
+ email: this.email,
2098
+ dbPassword: this.dbPassword,
2099
+ userDir: this.userDir,
2100
+ status: this.status
2101
+ };
2102
+ }
2103
+ /**
2104
+ * 转换为 Obsidian LiveSync 插件格式
2105
+ * 用于直接配置 Obsidian 的 LiveSync 插件
2106
+ */
2107
+ toObsidianLiveSyncFormat() {
2108
+ return {
2109
+ couchDB_URI: this.getCouchDbUri(),
2110
+ couchDB_DBNAME: this.dbName,
2111
+ couchDB_USER: this.email,
2112
+ couchDB_PASSWORD: this.dbPassword,
2113
+ encrypt: true,
2114
+ syncOnStart: true,
2115
+ syncOnSave: true,
2116
+ liveSync: true
2117
+ };
2118
+ }
2119
+ // ============================================================================
2120
+ // Comparison
2121
+ // ============================================================================
2122
+ /**
2123
+ * 比较两个 SyncConfig 是否相同
2124
+ */
2125
+ equals(other) {
2126
+ return this.dbEndpoint === other.dbEndpoint && this.dbName === other.dbName && this.email === other.email;
2127
+ }
2128
+ };
2129
+ }
2130
+ });
2131
+
1973
2132
  // internal/domain/identity/value-object/device.ts
1974
2133
  var Device;
1975
2134
  var init_device = __esm({
@@ -2184,14 +2343,16 @@ var init_user = __esm({
2184
2343
  token;
2185
2344
  serverConfig;
2186
2345
  license;
2346
+ syncConfig;
2187
2347
  /**
2188
2348
  * 构造函数(私有,通过 Factory 创建)
2189
2349
  */
2190
- constructor(email, token, serverConfig, license = null) {
2350
+ constructor(email, token, serverConfig, license = null, syncConfig = null) {
2191
2351
  this.email = email;
2192
2352
  this.token = token;
2193
2353
  this.serverConfig = serverConfig;
2194
2354
  this.license = license;
2355
+ this.syncConfig = syncConfig;
2195
2356
  }
2196
2357
  // ============================================================================
2197
2358
  // Getters
@@ -2220,6 +2381,12 @@ var init_user = __esm({
2220
2381
  getLicense() {
2221
2382
  return this.license;
2222
2383
  }
2384
+ /**
2385
+ * 获取同步配置
2386
+ */
2387
+ getSyncConfig() {
2388
+ return this.syncConfig;
2389
+ }
2223
2390
  // ============================================================================
2224
2391
  // Business Logic
2225
2392
  // ============================================================================
@@ -2253,6 +2420,18 @@ var init_user = __esm({
2253
2420
  clearLicense() {
2254
2421
  this.license = null;
2255
2422
  }
2423
+ /**
2424
+ * 设置同步配置
2425
+ */
2426
+ setSyncConfig(syncConfig) {
2427
+ this.syncConfig = syncConfig;
2428
+ }
2429
+ /**
2430
+ * 清除同步配置
2431
+ */
2432
+ clearSyncConfig() {
2433
+ this.syncConfig = null;
2434
+ }
2256
2435
  /**
2257
2436
  * 检查是否已认证
2258
2437
  */
@@ -2318,7 +2497,8 @@ var init_user = __esm({
2318
2497
  email: this.email.toJSON(),
2319
2498
  token: this.token?.toJSON() || null,
2320
2499
  serverConfig: this.serverConfig.toJSON(),
2321
- license: this.license?.toJSON() || null
2500
+ license: this.license?.toJSON() || null,
2501
+ syncConfig: this.syncConfig?.toJSON() || null
2322
2502
  };
2323
2503
  }
2324
2504
  };
@@ -2335,6 +2515,7 @@ var init_user_factory = __esm({
2335
2515
  init_token();
2336
2516
  init_server_config();
2337
2517
  init_license();
2518
+ init_sync_config();
2338
2519
  init_device();
2339
2520
  init_log();
2340
2521
  log4 = getDomainLogger("user-factory", { component: "domain" });
@@ -2372,10 +2553,15 @@ var init_user_factory = __esm({
2372
2553
  if (userData.license) {
2373
2554
  user.setLicense(userData.license);
2374
2555
  }
2556
+ if (userData.syncConfig) {
2557
+ const syncConfig = SyncConfig.fromJSON(userData.syncConfig);
2558
+ user.setSyncConfig(syncConfig);
2559
+ }
2375
2560
  log4.debug("User loaded from storage", {
2376
2561
  email: email.getValue(),
2377
2562
  hasToken: !!userData.token,
2378
- hasLicense: !!userData.license
2563
+ hasLicense: !!userData.license,
2564
+ hasSyncConfig: !!userData.syncConfig
2379
2565
  });
2380
2566
  return user;
2381
2567
  } catch (error) {
@@ -2384,24 +2570,27 @@ var init_user_factory = __esm({
2384
2570
  }
2385
2571
  }
2386
2572
  /**
2387
- * 保存用户到存储(合并保存 token, license, server config)
2573
+ * 保存用户到存储(合并保存 token, license, server config, sync config
2388
2574
  */
2389
2575
  async save(user) {
2390
2576
  try {
2391
2577
  const token = user.getToken();
2392
2578
  const license = user.getLicense();
2579
+ const syncConfig = user.getSyncConfig();
2393
2580
  const serverConfig = user.getServerConfig();
2394
2581
  const email = user.getEmail().getValue();
2395
2582
  await this.storageProvider.saveUserData({
2396
2583
  token,
2397
2584
  license,
2585
+ syncConfig,
2398
2586
  serverConfig,
2399
2587
  email
2400
2588
  });
2401
2589
  log4.debug("User saved to storage", {
2402
2590
  email,
2403
2591
  hasToken: !!token,
2404
- hasLicense: !!license
2592
+ hasLicense: !!license,
2593
+ hasSyncConfig: !!syncConfig
2405
2594
  });
2406
2595
  } catch (error) {
2407
2596
  log4.error("Failed to save user to storage", error);
@@ -2662,13 +2851,38 @@ var init_user_factory = __esm({
2662
2851
  data.plan,
2663
2852
  data.expires_at,
2664
2853
  features,
2665
- Date.now()
2854
+ Date.now(),
2855
+ data.activated,
2856
+ data.first_time
2666
2857
  );
2667
2858
  user.setLicense(license);
2859
+ if (data.sync && data.features.sync_enabled) {
2860
+ const syncConfig = SyncConfig.create({
2861
+ dbEndpoint: data.sync.db_endpoint,
2862
+ dbName: data.sync.db_name,
2863
+ email: data.sync.email,
2864
+ dbPassword: data.sync.db_password,
2865
+ userDir: data.user.user_dir,
2866
+ status: data.sync.status
2867
+ });
2868
+ user.setSyncConfig(syncConfig);
2869
+ log4.info("Sync configuration saved", {
2870
+ dbName: syncConfig.getDbName(),
2871
+ email: syncConfig.getEmail(),
2872
+ userDir: syncConfig.getUserDir(),
2873
+ status: syncConfig.getStatus(),
2874
+ isActive: syncConfig.isActive()
2875
+ });
2876
+ }
2668
2877
  await this.save(user);
2669
2878
  log4.info("License activated successfully", {
2879
+ licenseKey: data.license_key,
2670
2880
  plan: license.getPlan(),
2671
- expires: license.getFormattedExpiresAt()
2881
+ expires: license.getFormattedExpiresAt(),
2882
+ activated: data.activated,
2883
+ firstTime: data.first_time,
2884
+ syncEnabled: data.features.sync_enabled,
2885
+ hasSyncConfig: user.getSyncConfig() !== null
2672
2886
  });
2673
2887
  return user;
2674
2888
  } catch (error) {
@@ -3113,6 +3327,7 @@ __export(identity_exports, {
3113
3327
  Email: () => Email,
3114
3328
  License: () => License,
3115
3329
  ServerConfig: () => ServerConfig,
3330
+ SyncConfig: () => SyncConfig,
3116
3331
  Token: () => Token,
3117
3332
  User: () => User,
3118
3333
  UserFactory: () => UserFactory
@@ -3124,6 +3339,7 @@ var init_identity = __esm({
3124
3339
  init_token();
3125
3340
  init_server_config();
3126
3341
  init_license();
3342
+ init_sync_config();
3127
3343
  init_device();
3128
3344
  init_user();
3129
3345
  init_user_factory();
@@ -54871,7 +55087,7 @@ For more information, visit: https://help.mdfriday.com
54871
55087
  * Show version
54872
55088
  */
54873
55089
  showVersion() {
54874
- const version = "26.3.9";
55090
+ const version = "26.3.11";
54875
55091
  return {
54876
55092
  success: true,
54877
55093
  message: `MDFriday CLI v${version}`
package/dist/index.d.ts CHANGED
@@ -3,4 +3,4 @@ export { processSSGParallel, ParallelSSGStats } from './internal/application/ssg
3
3
  export { startIncrementalBuild, IncrementalBuildConfig, IncrementalBuildCoordinator } from './internal/application/incremental-ssg';
4
4
  export { MarkdownRenderer, AutoIDGenerator, ParsingResult, Header, TocFragments, Link, Paragraph } from './internal/domain/markdown';
5
5
  export { PageTask } from './pkg/page-filter';
6
- export { ObsidianWorkspaceService, createObsidianWorkspaceService, ObsidianWorkspaceInitOptions, ObsidianWorkspaceInfo, ObsidianWorkspaceResult, ObsidianProjectService, createObsidianProjectService, ObsidianProjectCreateOptions, ObsidianProjectInfo, ObsidianProjectResult, ObsidianBuildService, createObsidianBuildService, ObsidianBuildOptions, ObsidianBuildResult, ObsidianGlobalConfigService, ObsidianProjectConfigService, createObsidianGlobalConfigService, createObsidianProjectConfigService, ObsidianConfigResult, ConfigGetResult, ConfigListResult, ObsidianPublishService, createObsidianPublishService, ObsidianPublishMethod, ObsidianPublishOptions, ObsidianPublishProgress, ObsidianPublishResult, ObsidianTestConnectionResult, ObsidianServeService, createObsidianServeService, ObsidianServeOptions, ObsidianServeResult, ObsidianServeProgress, ObsidianLicenseService, createObsidianLicenseService, ObsidianLicenseInfo, ObsidianLicenseUsage, ObsidianLicenseResult, ObsidianAuthService, createObsidianAuthService, ObsidianAuthStatus, ObsidianServerConfig, ObsidianAuthResult, ObsidianDomainService, createObsidianDomainService, ObsidianDomainInfo, ObsidianSubdomainCheckResult, ObsidianSubdomainUpdateResult, ObsidianCustomDomainCheckResult, ObsidianCustomDomainAddResult, ObsidianHttpsCertificate, ObsidianHttpsStatusResult, ObsidianDomainResult, createWorkspaceAppService, createWorkspaceFactory, type PublishHttpClient, type PublishHttpResponse, type IdentityHttpClient, type IdentityHttpResponse, type AnyPublishConfig, type FTPConfig, type NetlifyConfig, type MDFridayConfig, } from './internal/interfaces/obsidian';
6
+ export { ObsidianWorkspaceService, createObsidianWorkspaceService, ObsidianWorkspaceInitOptions, ObsidianWorkspaceInfo, ObsidianWorkspaceResult, ObsidianProjectService, createObsidianProjectService, ObsidianProjectCreateOptions, ObsidianProjectInfo, ObsidianProjectResult, ObsidianBuildService, createObsidianBuildService, ObsidianBuildOptions, ObsidianBuildResult, ObsidianGlobalConfigService, ObsidianProjectConfigService, createObsidianGlobalConfigService, createObsidianProjectConfigService, ObsidianConfigResult, ConfigGetResult, ConfigListResult, ObsidianPublishService, createObsidianPublishService, ObsidianPublishMethod, ObsidianPublishOptions, ObsidianPublishProgress, ObsidianPublishResult, ObsidianTestConnectionResult, ObsidianServeService, createObsidianServeService, ObsidianServeOptions, ObsidianServeResult, ObsidianServeProgress, ObsidianLicenseService, createObsidianLicenseService, ObsidianLicenseInfo, ObsidianLicenseUsage, ObsidianLicenseResult, ObsidianAuthService, createObsidianAuthService, ObsidianAuthStatus, ObsidianServerConfig, ObsidianAuthResult, ObsidianDomainService, createObsidianDomainService, ObsidianDomainInfo, ObsidianSubdomainCheckResult, ObsidianSubdomainUpdateResult, ObsidianCustomDomainCheckResult, ObsidianCustomDomainAddResult, ObsidianHttpsCertificate, ObsidianHttpsStatusResult, ObsidianDomainResult, createWorkspaceAppService, createWorkspaceFactory, type PublishHttpClient, type PublishHttpResponse, type IdentityHttpClient, type IdentityHttpResponse, type AnyPublishConfig, type FTPConfig, type NetlifyConfig, type MDFridayConfig, type SyncConfig, type SyncConfigData, } from './internal/interfaces/obsidian';