zen-fs-config 0.9.8 → 0.10.0
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/DESIGN.md +2 -1
- package/dist/index.d.mts +87 -3
- package/dist/index.d.ts +87 -3
- package/dist/index.js +388 -23
- package/dist/index.mjs +387 -23
- package/dist/zen-fs-config.js +387 -23
- package/package.json +1 -1
package/DESIGN.md
CHANGED
|
@@ -136,7 +136,8 @@ group wiring instead of syncing the marker.
|
|
|
136
136
|
│ │ └─ ...
|
|
137
137
|
│ ├─ app-data-groups/ References to data-sync groups (per app)
|
|
138
138
|
│ │ └─ {appId}/
|
|
139
|
-
│ │ └─ {dataGroupId}.json { groupType: "data-sync",
|
|
139
|
+
│ │ └─ {dataGroupId}.json { groupType: "data-sync", ... }(无 backends)
|
|
140
|
+
│ │ └─ backends/{backendId}.json 应用后端,一文件一端点
|
|
140
141
|
│ ├─ .deleted/ Tombstones for deletion propagation
|
|
141
142
|
│ │ └─ {encoded-path}.json
|
|
142
143
|
│ └─ .conflicts/ Conflict archives (safekeeping)
|
package/dist/index.d.mts
CHANGED
|
@@ -291,6 +291,14 @@ interface ConfigRepoOptions {
|
|
|
291
291
|
folderPath?: string;
|
|
292
292
|
/** Node identifier. Auto-detected if not provided (see DESIGN.md §8.2). */
|
|
293
293
|
nodeId?: string;
|
|
294
|
+
/**
|
|
295
|
+
* 配置组的 profile 名。缺省 `config`。
|
|
296
|
+
*
|
|
297
|
+
* 身份按 profile 确定性派生(`config:<profile>`),所以多个应用共享同一个
|
|
298
|
+
* 配置组时,只要 profile 与远端根相同,各端算出的 instanceId 都相同。
|
|
299
|
+
* 一个远端根只能承载一个 profile。
|
|
300
|
+
*/
|
|
301
|
+
profile?: string;
|
|
294
302
|
/**
|
|
295
303
|
* Cache configuration for replica backends.
|
|
296
304
|
*
|
|
@@ -380,6 +388,12 @@ interface AppDataGroupDescriptor {
|
|
|
380
388
|
instanceId?: string;
|
|
381
389
|
/** Capability overrides (versions/conflicts are opt-in for data groups). */
|
|
382
390
|
features?: Partial<SyncGroupFeatures>;
|
|
391
|
+
/**
|
|
392
|
+
* @deprecated 不再写入描述符文件:后端改存独立文件
|
|
393
|
+
* `/.config/app-data-groups/<appId>/backends/<backendId>.json`。
|
|
394
|
+
* 读取时仍兼容旧描述符里的数组,并会在首次加载时迁移成文件。
|
|
395
|
+
* 运行时 API 返回的对象仍带这份列表,方便调用方直接使用。
|
|
396
|
+
*/
|
|
383
397
|
backends: AppDataBackendDescriptor[];
|
|
384
398
|
}
|
|
385
399
|
/** Descriptor for the config-sync group itself (display metadata only). */
|
|
@@ -471,6 +485,13 @@ interface GroupDescriptor {
|
|
|
471
485
|
instanceId?: string;
|
|
472
486
|
/** User-editable display name. */
|
|
473
487
|
name?: string;
|
|
488
|
+
/**
|
|
489
|
+
* 配置组的 profile 名(仅 `kind=config`)。缺省 `config`。
|
|
490
|
+
*
|
|
491
|
+
* 一个远端根只承载一个 profile;身份按 profile 派生,因此多个应用共享同一个
|
|
492
|
+
* 配置组(同一 profile、同一远端根)时算出的 instanceId 天然一致。
|
|
493
|
+
*/
|
|
494
|
+
profile?: string;
|
|
474
495
|
features?: Partial<SyncGroupFeatures>;
|
|
475
496
|
/**
|
|
476
497
|
* @deprecated 不再写入、读取侧忽略。时间戳写进随同步走的内容会形成
|
|
@@ -712,6 +733,11 @@ interface ConnectOptions {
|
|
|
712
733
|
folderPath?: string;
|
|
713
734
|
/** Node identifier. Auto-detected if not provided. */
|
|
714
735
|
nodeId?: string;
|
|
736
|
+
/**
|
|
737
|
+
* 配置组的 profile 名。缺省 `config`(见 `GroupDescriptor.profile`)。
|
|
738
|
+
* 只影响配置组的确定性身份,不改变任何目录结构。
|
|
739
|
+
*/
|
|
740
|
+
profile?: string;
|
|
715
741
|
/**
|
|
716
742
|
* Cache configuration for replica backends. Omit for the default
|
|
717
743
|
* (`IdbCacheStore`, persists across reloads); pass `false` to disable; pass a
|
|
@@ -1297,6 +1323,13 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
1297
1323
|
* `instanceId`,不一致就不建同步对 —— 两个不同的同步组永不互相同步。
|
|
1298
1324
|
*/
|
|
1299
1325
|
private instanceId?;
|
|
1326
|
+
/**
|
|
1327
|
+
* 配置组的 profile 名(缺省 `config`)。身份按它确定性派生;
|
|
1328
|
+
* 一个远端根只承载一个 profile,因此不改变任何目录结构。
|
|
1329
|
+
*/
|
|
1330
|
+
private profile;
|
|
1331
|
+
/** 调用方是否显式传了 profile(否则沿用描述符里的值)。 */
|
|
1332
|
+
private profileExplicit;
|
|
1300
1333
|
/** 配置组身份的候选(本地 + 每个后端根),供界面展示。 */
|
|
1301
1334
|
private identityCandidates;
|
|
1302
1335
|
/** 候选互相矛盾:需要用户裁决,绝不由库层自动择一。 */
|
|
@@ -1321,7 +1354,7 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
1321
1354
|
* preventing concurrent syncEngine.syncAll() calls.
|
|
1322
1355
|
*/
|
|
1323
1356
|
private initialSyncPromise;
|
|
1324
|
-
constructor(appId: string, nodeId: string, primaryBackendId: string, cachedFS: MinimalAsyncFS, serializer: PathAwareSerializer, onConflict?: (conflict: ConflictInfo) => Promise<unknown | null>, pollIntervalMs?: number, cacheOptions?: CacheOptions);
|
|
1357
|
+
constructor(appId: string, nodeId: string, primaryBackendId: string, cachedFS: MinimalAsyncFS, serializer: PathAwareSerializer, onConflict?: (conflict: ConflictInfo) => Promise<unknown | null>, pollIntervalMs?: number, cacheOptions?: CacheOptions, profile?: string);
|
|
1325
1358
|
/** Full path to this node's directory on the primary backend. */
|
|
1326
1359
|
get nodePath(): string;
|
|
1327
1360
|
/** Number of replica backends registered (excludes the local primary). */
|
|
@@ -1733,6 +1766,36 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
1733
1766
|
* 因此时间戳差异不会让两台设备互相覆盖。
|
|
1734
1767
|
*/
|
|
1735
1768
|
private writeAppDataGroupDescriptorFile;
|
|
1769
|
+
/**
|
|
1770
|
+
* 应用数据组后端文件目录(平铺,不额外套 `<groupId>.backends/`):
|
|
1771
|
+
* `/.config/app-data-groups/<appId>/backends/`。
|
|
1772
|
+
*
|
|
1773
|
+
* 归属靠文件内的 `groupId` 字段区分:同一 app 下不同组即使后端 id 相同,
|
|
1774
|
+
* 也各用各自的文件,不会在同步时互相覆盖(同一组不同端点同理)。
|
|
1775
|
+
*/
|
|
1776
|
+
private appDataBackendsDirPath;
|
|
1777
|
+
private appDataBackendFilePath;
|
|
1778
|
+
/** 读本 app 目录下所有后端文件(忽略损坏/非本格式的文件)。 */
|
|
1779
|
+
private readAppDataBackendFiles;
|
|
1780
|
+
/** 读某个数据组声明的全部后端文件(按 id 去重,先到先得)。 */
|
|
1781
|
+
private readAppDataBackendFilesForGroup;
|
|
1782
|
+
/** 幂等写一个后端文件(`createdAt` 取 min,避免两节点互覆盖时间戳)。 */
|
|
1783
|
+
private writeAppDataBackendFile;
|
|
1784
|
+
/**
|
|
1785
|
+
* 用权威后端列表重写本组的后端文件:缺的补齐、多的删除(删除走墓碑)。
|
|
1786
|
+
* 目录是平铺共享的,只处理 `groupId` 属于本组的文件,别组文件不碰。
|
|
1787
|
+
*/
|
|
1788
|
+
private reconcileAppDataBackendFiles;
|
|
1789
|
+
/**
|
|
1790
|
+
* 读组后端:新布局(独立文件)优先;旧描述符里还带 `backends` 数组时,
|
|
1791
|
+
* 迁移成文件并回写描述符(去掉数组),让两种布局收敛到同一种。
|
|
1792
|
+
*/
|
|
1793
|
+
private resolveAppDataGroupBackends;
|
|
1794
|
+
/**
|
|
1795
|
+
* 由端点指纹派生后端 id:同类型 + 同身份参数(不含 token)+ 同组 → 同 id。
|
|
1796
|
+
* 两个节点各自录入同一端点时,文件名一致,不会各写一份。
|
|
1797
|
+
*/
|
|
1798
|
+
private deriveAppDataBackendId;
|
|
1736
1799
|
/**
|
|
1737
1800
|
* Resolve a backend descriptor's options by merging account fields
|
|
1738
1801
|
* from the referenced config-sync backend (if accountBackendId is set).
|
|
@@ -2058,8 +2121,29 @@ interface GroupIdentity {
|
|
|
2058
2121
|
}
|
|
2059
2122
|
/** 生成一个新的组实例身份(UUID v4)。 */
|
|
2060
2123
|
declare function newGroupInstanceId(): string;
|
|
2061
|
-
/** 只接受 UUID v4
|
|
2124
|
+
/** 只接受 UUID 形态(v4 随机 / v5 确定性都合法),避免把任意字符串当成身份写进会被同步的内容。 */
|
|
2062
2125
|
declare function isValidGroupInstanceId(value: unknown): value is string;
|
|
2126
|
+
/** 派生身份的输入:配置组用 `profile`,数据组用 `appId + groupId`。 */
|
|
2127
|
+
interface DerivedIdentityInput {
|
|
2128
|
+
/** 配置组:profile 名(缺省 `config`);数据组忽略。 */
|
|
2129
|
+
profile?: string;
|
|
2130
|
+
/** 数据组:应用 id;配置组忽略。 */
|
|
2131
|
+
appId?: string;
|
|
2132
|
+
/** 数据组:组 id;配置组忽略。 */
|
|
2133
|
+
groupId?: string;
|
|
2134
|
+
}
|
|
2135
|
+
/**
|
|
2136
|
+
* 确定性组身份(UUID v5)。
|
|
2137
|
+
*
|
|
2138
|
+
* 规则(与 GROUP-IDENTITY-INIT 的「第一期」一致):
|
|
2139
|
+
* - 配置组:`config:${profile}`(profile 缺省 `config`),因此同一个远端根
|
|
2140
|
+
* 无论被哪台设备、哪个应用先连上,算出来的身份都相同,不需要再「认领」;
|
|
2141
|
+
* - 数据组:`data:${appId}:${groupId}`,不同应用的 `default` 不会撞在一起。
|
|
2142
|
+
*
|
|
2143
|
+
* 只在「本地 / 引导副本 / 所有远端根都没有身份」且确实有后端需要认领时使用;
|
|
2144
|
+
* 已有身份(含历史随机 UUID)一律沿用,绝不改写。
|
|
2145
|
+
*/
|
|
2146
|
+
declare function deriveGroupInstanceId(kind: SyncGroupKind, input?: DerivedIdentityInput): string;
|
|
2063
2147
|
/**
|
|
2064
2148
|
* 读远端根的归属,必要时认领。
|
|
2065
2149
|
*
|
|
@@ -2725,4 +2809,4 @@ interface EnsureDataGroupResult {
|
|
|
2725
2809
|
*/
|
|
2726
2810
|
declare function ensureDataGroup(source: DataGroupSource, appId: string, opts?: EnsureDataGroupOptions): Promise<EnsureDataGroupResult>;
|
|
2727
2811
|
|
|
2728
|
-
export { type AddBackendResult, type AppDataBackendDescriptor, type AppDataGroup, type AppDataGroupDescriptor, type AppRepo, BackendAlreadyExistsError, type BackendConflictInfo, type BackendConflictReason, type BackendConflictResolution, type BackendConflictResolutionResult, type BackendDescriptor, BackendEndpointConflictError, type BackendFactory, BackendIdentityError, type BackendInstance, type BackendMetadata, type BackendParamDef, type BackendSyncState, type BackendsMeta, CONFIG_DIR, CONFLICTS_DIR, type CacheOptions, type ConfigBackendInput, ConfigNotReadyError, ConfigRepo, type ConfigRepoOptions, type ConfigSerializer, type ConfigSyncGroupDescriptor, type ConfigSyncGroupHandle, type ConflictArchive, type ConflictInfo, ConflictStore, ConnectFailedError, type ConnectOptions, type ConnectResult, ConnectV2Error, type ConnectV2Options, DATA_GROUP_DEFAULT_FEATURES, DATA_GROUP_PREFERENCE_PREFIX, type DataBackendInput, type DataGroup, DataGroupBackendError, type DataGroupCandidate, DataGroupCreateError, type DataGroupFlushResult, type DataGroupInfo, DataGroupNotFoundError, DataGroupOperationError, type DataGroupSource, type DataGroupSyncEvent, type DataGroupSyncProgress, type DataGroupSyncResult, type EnsureDataGroupOptions, type EnsureDataGroupResult, FolderStore, GROUP_DESCRIPTOR_FILE, type GroupDescriptor, type GroupIdentity, type GroupInstanceIdRootResult, type GroupProbeResult, type GroupProbeState, type IConfigRepo, type IdentityBindingResult, type IdentityCandidate, type IdentityCandidateSource, type IdentityConflictReason, type IdentityResolutionMode, type IdentityResolutionResult, InvalidBackendError, type KeepPurgeResult, LEGACY_CONFLICTS_DIR, LEGACY_TOMBSTONES_DIR, LOCAL_IDB_BACKEND_ID, LOCAL_STORAGE_UNAVAILABLE, type LocalStorageUnavailableDetails, LocalStorageUnavailableError, type LocalStoreDeletionResult, META_DIR, type MigrateLocalFS, type MigrateReplicaFS, type MtimePurgeResult, NeedsInitError, type PreferenceOptions, type PreferenceStorage, type PurgeKeepOptions, type PurgeLocalSyncConfigOptions, type PurgeLocalSyncConfigResult, type PurgeMtimeOptions, type PurgeableFS$1 as PurgeableFS, type RemoteIdentitySnapshot, type RemoteIdentityState, RemoteUnreachableError, type ReplicaSetupSummary, type ResolveDataGroupOptions, type SetGroupInstanceIdOptions, type SetGroupInstanceIdResult, type SyncGroupFeatures, type SyncGroupHandle, type SyncGroupKind, type SyncGroupSyncEvent, type SyncGroupType, TOMBSTONES_DIR, type TombstoneMeta, TombstoneStore, type UiConnection, VERSIONS_DIR, type VersionMeta, type VersionMigrationOptions, type VersionMigrationResult, VersionStore, bindRemoteGroupIdentity, bindRemoteGroupIdentityDetailed, collectDataGroupCandidates, configKeyToFilePath, connect, connectV2, connectionToAppRepo, createBackend, createConfigRepo, createSerializerChain, dataGroupLocalStoreName, deleteDataGroupLocalStore, deleteIndexedDbStore, encodeMetaPath, ensureDataGroup, getAccountFields, getBackendMetadata, getExtension, getPreferredDataGroupId, getUiConnection, groupHasPath, hasBackend, incrementVersion, isBrowserEnv, isKeepFile, isLocalBackendType, isLocalStorageUnavailableError, isMtimeSidecar, isValidGroupInstanceId, legacyVersionPathFor, listBackendMetadata, listBackends, listDataGroupCandidates, localPrimaryType, localSyncStoreNames, mergeAccountFields, migrateVersionSidecars, newGroupInstanceId, probeGroupTypeDetailed, purgeKeepFiles, purgeLocalSyncConfig, purgeMtimeSidecars, readGroupDescriptor, readVersion, registerBackend, registerFolderBackend, resolveDataGroup, resolveLocalPrimary, resolveRemoteIdentity, setPreferredDataGroupId, sha256, shortInstanceId, summarizeIdentity, unregisterBackend, verifyOrRepairVersion, versionPathFor, wrapZenFSFileSystem, writeGroupDescriptor, writeVersion };
|
|
2812
|
+
export { type AddBackendResult, type AppDataBackendDescriptor, type AppDataGroup, type AppDataGroupDescriptor, type AppRepo, BackendAlreadyExistsError, type BackendConflictInfo, type BackendConflictReason, type BackendConflictResolution, type BackendConflictResolutionResult, type BackendDescriptor, BackendEndpointConflictError, type BackendFactory, BackendIdentityError, type BackendInstance, type BackendMetadata, type BackendParamDef, type BackendSyncState, type BackendsMeta, CONFIG_DIR, CONFLICTS_DIR, type CacheOptions, type ConfigBackendInput, ConfigNotReadyError, ConfigRepo, type ConfigRepoOptions, type ConfigSerializer, type ConfigSyncGroupDescriptor, type ConfigSyncGroupHandle, type ConflictArchive, type ConflictInfo, ConflictStore, ConnectFailedError, type ConnectOptions, type ConnectResult, ConnectV2Error, type ConnectV2Options, DATA_GROUP_DEFAULT_FEATURES, DATA_GROUP_PREFERENCE_PREFIX, type DataBackendInput, type DataGroup, DataGroupBackendError, type DataGroupCandidate, DataGroupCreateError, type DataGroupFlushResult, type DataGroupInfo, DataGroupNotFoundError, DataGroupOperationError, type DataGroupSource, type DataGroupSyncEvent, type DataGroupSyncProgress, type DataGroupSyncResult, type DerivedIdentityInput, type EnsureDataGroupOptions, type EnsureDataGroupResult, FolderStore, GROUP_DESCRIPTOR_FILE, type GroupDescriptor, type GroupIdentity, type GroupInstanceIdRootResult, type GroupProbeResult, type GroupProbeState, type IConfigRepo, type IdentityBindingResult, type IdentityCandidate, type IdentityCandidateSource, type IdentityConflictReason, type IdentityResolutionMode, type IdentityResolutionResult, InvalidBackendError, type KeepPurgeResult, LEGACY_CONFLICTS_DIR, LEGACY_TOMBSTONES_DIR, LOCAL_IDB_BACKEND_ID, LOCAL_STORAGE_UNAVAILABLE, type LocalStorageUnavailableDetails, LocalStorageUnavailableError, type LocalStoreDeletionResult, META_DIR, type MigrateLocalFS, type MigrateReplicaFS, type MtimePurgeResult, NeedsInitError, type PreferenceOptions, type PreferenceStorage, type PurgeKeepOptions, type PurgeLocalSyncConfigOptions, type PurgeLocalSyncConfigResult, type PurgeMtimeOptions, type PurgeableFS$1 as PurgeableFS, type RemoteIdentitySnapshot, type RemoteIdentityState, RemoteUnreachableError, type ReplicaSetupSummary, type ResolveDataGroupOptions, type SetGroupInstanceIdOptions, type SetGroupInstanceIdResult, type SyncGroupFeatures, type SyncGroupHandle, type SyncGroupKind, type SyncGroupSyncEvent, type SyncGroupType, TOMBSTONES_DIR, type TombstoneMeta, TombstoneStore, type UiConnection, VERSIONS_DIR, type VersionMeta, type VersionMigrationOptions, type VersionMigrationResult, VersionStore, bindRemoteGroupIdentity, bindRemoteGroupIdentityDetailed, collectDataGroupCandidates, configKeyToFilePath, connect, connectV2, connectionToAppRepo, createBackend, createConfigRepo, createSerializerChain, dataGroupLocalStoreName, deleteDataGroupLocalStore, deleteIndexedDbStore, deriveGroupInstanceId, encodeMetaPath, ensureDataGroup, getAccountFields, getBackendMetadata, getExtension, getPreferredDataGroupId, getUiConnection, groupHasPath, hasBackend, incrementVersion, isBrowserEnv, isKeepFile, isLocalBackendType, isLocalStorageUnavailableError, isMtimeSidecar, isValidGroupInstanceId, legacyVersionPathFor, listBackendMetadata, listBackends, listDataGroupCandidates, localPrimaryType, localSyncStoreNames, mergeAccountFields, migrateVersionSidecars, newGroupInstanceId, probeGroupTypeDetailed, purgeKeepFiles, purgeLocalSyncConfig, purgeMtimeSidecars, readGroupDescriptor, readVersion, registerBackend, registerFolderBackend, resolveDataGroup, resolveLocalPrimary, resolveRemoteIdentity, setPreferredDataGroupId, sha256, shortInstanceId, summarizeIdentity, unregisterBackend, verifyOrRepairVersion, versionPathFor, wrapZenFSFileSystem, writeGroupDescriptor, writeVersion };
|
package/dist/index.d.ts
CHANGED
|
@@ -291,6 +291,14 @@ interface ConfigRepoOptions {
|
|
|
291
291
|
folderPath?: string;
|
|
292
292
|
/** Node identifier. Auto-detected if not provided (see DESIGN.md §8.2). */
|
|
293
293
|
nodeId?: string;
|
|
294
|
+
/**
|
|
295
|
+
* 配置组的 profile 名。缺省 `config`。
|
|
296
|
+
*
|
|
297
|
+
* 身份按 profile 确定性派生(`config:<profile>`),所以多个应用共享同一个
|
|
298
|
+
* 配置组时,只要 profile 与远端根相同,各端算出的 instanceId 都相同。
|
|
299
|
+
* 一个远端根只能承载一个 profile。
|
|
300
|
+
*/
|
|
301
|
+
profile?: string;
|
|
294
302
|
/**
|
|
295
303
|
* Cache configuration for replica backends.
|
|
296
304
|
*
|
|
@@ -380,6 +388,12 @@ interface AppDataGroupDescriptor {
|
|
|
380
388
|
instanceId?: string;
|
|
381
389
|
/** Capability overrides (versions/conflicts are opt-in for data groups). */
|
|
382
390
|
features?: Partial<SyncGroupFeatures>;
|
|
391
|
+
/**
|
|
392
|
+
* @deprecated 不再写入描述符文件:后端改存独立文件
|
|
393
|
+
* `/.config/app-data-groups/<appId>/backends/<backendId>.json`。
|
|
394
|
+
* 读取时仍兼容旧描述符里的数组,并会在首次加载时迁移成文件。
|
|
395
|
+
* 运行时 API 返回的对象仍带这份列表,方便调用方直接使用。
|
|
396
|
+
*/
|
|
383
397
|
backends: AppDataBackendDescriptor[];
|
|
384
398
|
}
|
|
385
399
|
/** Descriptor for the config-sync group itself (display metadata only). */
|
|
@@ -471,6 +485,13 @@ interface GroupDescriptor {
|
|
|
471
485
|
instanceId?: string;
|
|
472
486
|
/** User-editable display name. */
|
|
473
487
|
name?: string;
|
|
488
|
+
/**
|
|
489
|
+
* 配置组的 profile 名(仅 `kind=config`)。缺省 `config`。
|
|
490
|
+
*
|
|
491
|
+
* 一个远端根只承载一个 profile;身份按 profile 派生,因此多个应用共享同一个
|
|
492
|
+
* 配置组(同一 profile、同一远端根)时算出的 instanceId 天然一致。
|
|
493
|
+
*/
|
|
494
|
+
profile?: string;
|
|
474
495
|
features?: Partial<SyncGroupFeatures>;
|
|
475
496
|
/**
|
|
476
497
|
* @deprecated 不再写入、读取侧忽略。时间戳写进随同步走的内容会形成
|
|
@@ -712,6 +733,11 @@ interface ConnectOptions {
|
|
|
712
733
|
folderPath?: string;
|
|
713
734
|
/** Node identifier. Auto-detected if not provided. */
|
|
714
735
|
nodeId?: string;
|
|
736
|
+
/**
|
|
737
|
+
* 配置组的 profile 名。缺省 `config`(见 `GroupDescriptor.profile`)。
|
|
738
|
+
* 只影响配置组的确定性身份,不改变任何目录结构。
|
|
739
|
+
*/
|
|
740
|
+
profile?: string;
|
|
715
741
|
/**
|
|
716
742
|
* Cache configuration for replica backends. Omit for the default
|
|
717
743
|
* (`IdbCacheStore`, persists across reloads); pass `false` to disable; pass a
|
|
@@ -1297,6 +1323,13 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
1297
1323
|
* `instanceId`,不一致就不建同步对 —— 两个不同的同步组永不互相同步。
|
|
1298
1324
|
*/
|
|
1299
1325
|
private instanceId?;
|
|
1326
|
+
/**
|
|
1327
|
+
* 配置组的 profile 名(缺省 `config`)。身份按它确定性派生;
|
|
1328
|
+
* 一个远端根只承载一个 profile,因此不改变任何目录结构。
|
|
1329
|
+
*/
|
|
1330
|
+
private profile;
|
|
1331
|
+
/** 调用方是否显式传了 profile(否则沿用描述符里的值)。 */
|
|
1332
|
+
private profileExplicit;
|
|
1300
1333
|
/** 配置组身份的候选(本地 + 每个后端根),供界面展示。 */
|
|
1301
1334
|
private identityCandidates;
|
|
1302
1335
|
/** 候选互相矛盾:需要用户裁决,绝不由库层自动择一。 */
|
|
@@ -1321,7 +1354,7 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
1321
1354
|
* preventing concurrent syncEngine.syncAll() calls.
|
|
1322
1355
|
*/
|
|
1323
1356
|
private initialSyncPromise;
|
|
1324
|
-
constructor(appId: string, nodeId: string, primaryBackendId: string, cachedFS: MinimalAsyncFS, serializer: PathAwareSerializer, onConflict?: (conflict: ConflictInfo) => Promise<unknown | null>, pollIntervalMs?: number, cacheOptions?: CacheOptions);
|
|
1357
|
+
constructor(appId: string, nodeId: string, primaryBackendId: string, cachedFS: MinimalAsyncFS, serializer: PathAwareSerializer, onConflict?: (conflict: ConflictInfo) => Promise<unknown | null>, pollIntervalMs?: number, cacheOptions?: CacheOptions, profile?: string);
|
|
1325
1358
|
/** Full path to this node's directory on the primary backend. */
|
|
1326
1359
|
get nodePath(): string;
|
|
1327
1360
|
/** Number of replica backends registered (excludes the local primary). */
|
|
@@ -1733,6 +1766,36 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
1733
1766
|
* 因此时间戳差异不会让两台设备互相覆盖。
|
|
1734
1767
|
*/
|
|
1735
1768
|
private writeAppDataGroupDescriptorFile;
|
|
1769
|
+
/**
|
|
1770
|
+
* 应用数据组后端文件目录(平铺,不额外套 `<groupId>.backends/`):
|
|
1771
|
+
* `/.config/app-data-groups/<appId>/backends/`。
|
|
1772
|
+
*
|
|
1773
|
+
* 归属靠文件内的 `groupId` 字段区分:同一 app 下不同组即使后端 id 相同,
|
|
1774
|
+
* 也各用各自的文件,不会在同步时互相覆盖(同一组不同端点同理)。
|
|
1775
|
+
*/
|
|
1776
|
+
private appDataBackendsDirPath;
|
|
1777
|
+
private appDataBackendFilePath;
|
|
1778
|
+
/** 读本 app 目录下所有后端文件(忽略损坏/非本格式的文件)。 */
|
|
1779
|
+
private readAppDataBackendFiles;
|
|
1780
|
+
/** 读某个数据组声明的全部后端文件(按 id 去重,先到先得)。 */
|
|
1781
|
+
private readAppDataBackendFilesForGroup;
|
|
1782
|
+
/** 幂等写一个后端文件(`createdAt` 取 min,避免两节点互覆盖时间戳)。 */
|
|
1783
|
+
private writeAppDataBackendFile;
|
|
1784
|
+
/**
|
|
1785
|
+
* 用权威后端列表重写本组的后端文件:缺的补齐、多的删除(删除走墓碑)。
|
|
1786
|
+
* 目录是平铺共享的,只处理 `groupId` 属于本组的文件,别组文件不碰。
|
|
1787
|
+
*/
|
|
1788
|
+
private reconcileAppDataBackendFiles;
|
|
1789
|
+
/**
|
|
1790
|
+
* 读组后端:新布局(独立文件)优先;旧描述符里还带 `backends` 数组时,
|
|
1791
|
+
* 迁移成文件并回写描述符(去掉数组),让两种布局收敛到同一种。
|
|
1792
|
+
*/
|
|
1793
|
+
private resolveAppDataGroupBackends;
|
|
1794
|
+
/**
|
|
1795
|
+
* 由端点指纹派生后端 id:同类型 + 同身份参数(不含 token)+ 同组 → 同 id。
|
|
1796
|
+
* 两个节点各自录入同一端点时,文件名一致,不会各写一份。
|
|
1797
|
+
*/
|
|
1798
|
+
private deriveAppDataBackendId;
|
|
1736
1799
|
/**
|
|
1737
1800
|
* Resolve a backend descriptor's options by merging account fields
|
|
1738
1801
|
* from the referenced config-sync backend (if accountBackendId is set).
|
|
@@ -2058,8 +2121,29 @@ interface GroupIdentity {
|
|
|
2058
2121
|
}
|
|
2059
2122
|
/** 生成一个新的组实例身份(UUID v4)。 */
|
|
2060
2123
|
declare function newGroupInstanceId(): string;
|
|
2061
|
-
/** 只接受 UUID v4
|
|
2124
|
+
/** 只接受 UUID 形态(v4 随机 / v5 确定性都合法),避免把任意字符串当成身份写进会被同步的内容。 */
|
|
2062
2125
|
declare function isValidGroupInstanceId(value: unknown): value is string;
|
|
2126
|
+
/** 派生身份的输入:配置组用 `profile`,数据组用 `appId + groupId`。 */
|
|
2127
|
+
interface DerivedIdentityInput {
|
|
2128
|
+
/** 配置组:profile 名(缺省 `config`);数据组忽略。 */
|
|
2129
|
+
profile?: string;
|
|
2130
|
+
/** 数据组:应用 id;配置组忽略。 */
|
|
2131
|
+
appId?: string;
|
|
2132
|
+
/** 数据组:组 id;配置组忽略。 */
|
|
2133
|
+
groupId?: string;
|
|
2134
|
+
}
|
|
2135
|
+
/**
|
|
2136
|
+
* 确定性组身份(UUID v5)。
|
|
2137
|
+
*
|
|
2138
|
+
* 规则(与 GROUP-IDENTITY-INIT 的「第一期」一致):
|
|
2139
|
+
* - 配置组:`config:${profile}`(profile 缺省 `config`),因此同一个远端根
|
|
2140
|
+
* 无论被哪台设备、哪个应用先连上,算出来的身份都相同,不需要再「认领」;
|
|
2141
|
+
* - 数据组:`data:${appId}:${groupId}`,不同应用的 `default` 不会撞在一起。
|
|
2142
|
+
*
|
|
2143
|
+
* 只在「本地 / 引导副本 / 所有远端根都没有身份」且确实有后端需要认领时使用;
|
|
2144
|
+
* 已有身份(含历史随机 UUID)一律沿用,绝不改写。
|
|
2145
|
+
*/
|
|
2146
|
+
declare function deriveGroupInstanceId(kind: SyncGroupKind, input?: DerivedIdentityInput): string;
|
|
2063
2147
|
/**
|
|
2064
2148
|
* 读远端根的归属,必要时认领。
|
|
2065
2149
|
*
|
|
@@ -2725,4 +2809,4 @@ interface EnsureDataGroupResult {
|
|
|
2725
2809
|
*/
|
|
2726
2810
|
declare function ensureDataGroup(source: DataGroupSource, appId: string, opts?: EnsureDataGroupOptions): Promise<EnsureDataGroupResult>;
|
|
2727
2811
|
|
|
2728
|
-
export { type AddBackendResult, type AppDataBackendDescriptor, type AppDataGroup, type AppDataGroupDescriptor, type AppRepo, BackendAlreadyExistsError, type BackendConflictInfo, type BackendConflictReason, type BackendConflictResolution, type BackendConflictResolutionResult, type BackendDescriptor, BackendEndpointConflictError, type BackendFactory, BackendIdentityError, type BackendInstance, type BackendMetadata, type BackendParamDef, type BackendSyncState, type BackendsMeta, CONFIG_DIR, CONFLICTS_DIR, type CacheOptions, type ConfigBackendInput, ConfigNotReadyError, ConfigRepo, type ConfigRepoOptions, type ConfigSerializer, type ConfigSyncGroupDescriptor, type ConfigSyncGroupHandle, type ConflictArchive, type ConflictInfo, ConflictStore, ConnectFailedError, type ConnectOptions, type ConnectResult, ConnectV2Error, type ConnectV2Options, DATA_GROUP_DEFAULT_FEATURES, DATA_GROUP_PREFERENCE_PREFIX, type DataBackendInput, type DataGroup, DataGroupBackendError, type DataGroupCandidate, DataGroupCreateError, type DataGroupFlushResult, type DataGroupInfo, DataGroupNotFoundError, DataGroupOperationError, type DataGroupSource, type DataGroupSyncEvent, type DataGroupSyncProgress, type DataGroupSyncResult, type EnsureDataGroupOptions, type EnsureDataGroupResult, FolderStore, GROUP_DESCRIPTOR_FILE, type GroupDescriptor, type GroupIdentity, type GroupInstanceIdRootResult, type GroupProbeResult, type GroupProbeState, type IConfigRepo, type IdentityBindingResult, type IdentityCandidate, type IdentityCandidateSource, type IdentityConflictReason, type IdentityResolutionMode, type IdentityResolutionResult, InvalidBackendError, type KeepPurgeResult, LEGACY_CONFLICTS_DIR, LEGACY_TOMBSTONES_DIR, LOCAL_IDB_BACKEND_ID, LOCAL_STORAGE_UNAVAILABLE, type LocalStorageUnavailableDetails, LocalStorageUnavailableError, type LocalStoreDeletionResult, META_DIR, type MigrateLocalFS, type MigrateReplicaFS, type MtimePurgeResult, NeedsInitError, type PreferenceOptions, type PreferenceStorage, type PurgeKeepOptions, type PurgeLocalSyncConfigOptions, type PurgeLocalSyncConfigResult, type PurgeMtimeOptions, type PurgeableFS$1 as PurgeableFS, type RemoteIdentitySnapshot, type RemoteIdentityState, RemoteUnreachableError, type ReplicaSetupSummary, type ResolveDataGroupOptions, type SetGroupInstanceIdOptions, type SetGroupInstanceIdResult, type SyncGroupFeatures, type SyncGroupHandle, type SyncGroupKind, type SyncGroupSyncEvent, type SyncGroupType, TOMBSTONES_DIR, type TombstoneMeta, TombstoneStore, type UiConnection, VERSIONS_DIR, type VersionMeta, type VersionMigrationOptions, type VersionMigrationResult, VersionStore, bindRemoteGroupIdentity, bindRemoteGroupIdentityDetailed, collectDataGroupCandidates, configKeyToFilePath, connect, connectV2, connectionToAppRepo, createBackend, createConfigRepo, createSerializerChain, dataGroupLocalStoreName, deleteDataGroupLocalStore, deleteIndexedDbStore, encodeMetaPath, ensureDataGroup, getAccountFields, getBackendMetadata, getExtension, getPreferredDataGroupId, getUiConnection, groupHasPath, hasBackend, incrementVersion, isBrowserEnv, isKeepFile, isLocalBackendType, isLocalStorageUnavailableError, isMtimeSidecar, isValidGroupInstanceId, legacyVersionPathFor, listBackendMetadata, listBackends, listDataGroupCandidates, localPrimaryType, localSyncStoreNames, mergeAccountFields, migrateVersionSidecars, newGroupInstanceId, probeGroupTypeDetailed, purgeKeepFiles, purgeLocalSyncConfig, purgeMtimeSidecars, readGroupDescriptor, readVersion, registerBackend, registerFolderBackend, resolveDataGroup, resolveLocalPrimary, resolveRemoteIdentity, setPreferredDataGroupId, sha256, shortInstanceId, summarizeIdentity, unregisterBackend, verifyOrRepairVersion, versionPathFor, wrapZenFSFileSystem, writeGroupDescriptor, writeVersion };
|
|
2812
|
+
export { type AddBackendResult, type AppDataBackendDescriptor, type AppDataGroup, type AppDataGroupDescriptor, type AppRepo, BackendAlreadyExistsError, type BackendConflictInfo, type BackendConflictReason, type BackendConflictResolution, type BackendConflictResolutionResult, type BackendDescriptor, BackendEndpointConflictError, type BackendFactory, BackendIdentityError, type BackendInstance, type BackendMetadata, type BackendParamDef, type BackendSyncState, type BackendsMeta, CONFIG_DIR, CONFLICTS_DIR, type CacheOptions, type ConfigBackendInput, ConfigNotReadyError, ConfigRepo, type ConfigRepoOptions, type ConfigSerializer, type ConfigSyncGroupDescriptor, type ConfigSyncGroupHandle, type ConflictArchive, type ConflictInfo, ConflictStore, ConnectFailedError, type ConnectOptions, type ConnectResult, ConnectV2Error, type ConnectV2Options, DATA_GROUP_DEFAULT_FEATURES, DATA_GROUP_PREFERENCE_PREFIX, type DataBackendInput, type DataGroup, DataGroupBackendError, type DataGroupCandidate, DataGroupCreateError, type DataGroupFlushResult, type DataGroupInfo, DataGroupNotFoundError, DataGroupOperationError, type DataGroupSource, type DataGroupSyncEvent, type DataGroupSyncProgress, type DataGroupSyncResult, type DerivedIdentityInput, type EnsureDataGroupOptions, type EnsureDataGroupResult, FolderStore, GROUP_DESCRIPTOR_FILE, type GroupDescriptor, type GroupIdentity, type GroupInstanceIdRootResult, type GroupProbeResult, type GroupProbeState, type IConfigRepo, type IdentityBindingResult, type IdentityCandidate, type IdentityCandidateSource, type IdentityConflictReason, type IdentityResolutionMode, type IdentityResolutionResult, InvalidBackendError, type KeepPurgeResult, LEGACY_CONFLICTS_DIR, LEGACY_TOMBSTONES_DIR, LOCAL_IDB_BACKEND_ID, LOCAL_STORAGE_UNAVAILABLE, type LocalStorageUnavailableDetails, LocalStorageUnavailableError, type LocalStoreDeletionResult, META_DIR, type MigrateLocalFS, type MigrateReplicaFS, type MtimePurgeResult, NeedsInitError, type PreferenceOptions, type PreferenceStorage, type PurgeKeepOptions, type PurgeLocalSyncConfigOptions, type PurgeLocalSyncConfigResult, type PurgeMtimeOptions, type PurgeableFS$1 as PurgeableFS, type RemoteIdentitySnapshot, type RemoteIdentityState, RemoteUnreachableError, type ReplicaSetupSummary, type ResolveDataGroupOptions, type SetGroupInstanceIdOptions, type SetGroupInstanceIdResult, type SyncGroupFeatures, type SyncGroupHandle, type SyncGroupKind, type SyncGroupSyncEvent, type SyncGroupType, TOMBSTONES_DIR, type TombstoneMeta, TombstoneStore, type UiConnection, VERSIONS_DIR, type VersionMeta, type VersionMigrationOptions, type VersionMigrationResult, VersionStore, bindRemoteGroupIdentity, bindRemoteGroupIdentityDetailed, collectDataGroupCandidates, configKeyToFilePath, connect, connectV2, connectionToAppRepo, createBackend, createConfigRepo, createSerializerChain, dataGroupLocalStoreName, deleteDataGroupLocalStore, deleteIndexedDbStore, deriveGroupInstanceId, encodeMetaPath, ensureDataGroup, getAccountFields, getBackendMetadata, getExtension, getPreferredDataGroupId, getUiConnection, groupHasPath, hasBackend, incrementVersion, isBrowserEnv, isKeepFile, isLocalBackendType, isLocalStorageUnavailableError, isMtimeSidecar, isValidGroupInstanceId, legacyVersionPathFor, listBackendMetadata, listBackends, listDataGroupCandidates, localPrimaryType, localSyncStoreNames, mergeAccountFields, migrateVersionSidecars, newGroupInstanceId, probeGroupTypeDetailed, purgeKeepFiles, purgeLocalSyncConfig, purgeMtimeSidecars, readGroupDescriptor, readVersion, registerBackend, registerFolderBackend, resolveDataGroup, resolveLocalPrimary, resolveRemoteIdentity, setPreferredDataGroupId, sha256, shortInstanceId, summarizeIdentity, unregisterBackend, verifyOrRepairVersion, versionPathFor, wrapZenFSFileSystem, writeGroupDescriptor, writeVersion };
|