zen-fs-config 0.7.20 → 0.7.22
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/index.d.mts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +34 -5
- package/dist/index.mjs +34 -5
- package/dist/zen-fs-config.js +34 -5
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -551,6 +551,12 @@ interface SyncGroupHandle {
|
|
|
551
551
|
* 不一致时界面必须让用户挑一个,不允许代码静默择一。
|
|
552
552
|
*/
|
|
553
553
|
getIdentityCandidates(): IdentityCandidate[];
|
|
554
|
+
/**
|
|
555
|
+
* 同上,但会现场回读各根再返回(同步 getter 只给缓存)。
|
|
556
|
+
* 界面优先用它,才能在「本地已有身份、远端与本地不一致」时看到两个值。
|
|
557
|
+
* 可选:老版本实现可能没有这个方法。
|
|
558
|
+
*/
|
|
559
|
+
getIdentityCandidatesAsync?(): Promise<IdentityCandidate[]>;
|
|
554
560
|
/**
|
|
555
561
|
* 候选之间是否互相矛盾(需要用户在界面上拍板)。
|
|
556
562
|
* 可选:老版本实现可能没有这个方法,调用方按候选去重自行判断。
|
|
@@ -1466,8 +1472,16 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
1466
1472
|
ensureGroupInstanceId(): Promise<string>;
|
|
1467
1473
|
/** 组实例身份(同步读取;init 之前可能为 `undefined`)。 */
|
|
1468
1474
|
getGroupInstanceId(): string | undefined;
|
|
1469
|
-
/** 配置组的身份候选:本地描述符 +
|
|
1475
|
+
/** 配置组的身份候选:本地描述符 + 已注册后端根上的值(只读缓存)。 */
|
|
1470
1476
|
getIdentityCandidates(): IdentityCandidate[];
|
|
1477
|
+
/**
|
|
1478
|
+
* 现场回读各根,重算候选并填充缓存。
|
|
1479
|
+
*
|
|
1480
|
+
* 缓存只在「初始化时本地没有身份」才被填充;本地已有身份时缓存是空的,
|
|
1481
|
+
* 同步 getter 也就只剩一个本地值 —— 界面看不到「本地 6abe… vs 远端 5a52…」
|
|
1482
|
+
* 这种真正需要拍板的分歧。所以给界面一个能主动回读的入口。
|
|
1483
|
+
*/
|
|
1484
|
+
getIdentityCandidatesAsync(): Promise<IdentityCandidate[]>;
|
|
1471
1485
|
/** 候选是否互相矛盾(界面据此要求用户拍板)。 */
|
|
1472
1486
|
isIdentityUnsettled(): boolean;
|
|
1473
1487
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -551,6 +551,12 @@ interface SyncGroupHandle {
|
|
|
551
551
|
* 不一致时界面必须让用户挑一个,不允许代码静默择一。
|
|
552
552
|
*/
|
|
553
553
|
getIdentityCandidates(): IdentityCandidate[];
|
|
554
|
+
/**
|
|
555
|
+
* 同上,但会现场回读各根再返回(同步 getter 只给缓存)。
|
|
556
|
+
* 界面优先用它,才能在「本地已有身份、远端与本地不一致」时看到两个值。
|
|
557
|
+
* 可选:老版本实现可能没有这个方法。
|
|
558
|
+
*/
|
|
559
|
+
getIdentityCandidatesAsync?(): Promise<IdentityCandidate[]>;
|
|
554
560
|
/**
|
|
555
561
|
* 候选之间是否互相矛盾(需要用户在界面上拍板)。
|
|
556
562
|
* 可选:老版本实现可能没有这个方法,调用方按候选去重自行判断。
|
|
@@ -1466,8 +1472,16 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
1466
1472
|
ensureGroupInstanceId(): Promise<string>;
|
|
1467
1473
|
/** 组实例身份(同步读取;init 之前可能为 `undefined`)。 */
|
|
1468
1474
|
getGroupInstanceId(): string | undefined;
|
|
1469
|
-
/** 配置组的身份候选:本地描述符 +
|
|
1475
|
+
/** 配置组的身份候选:本地描述符 + 已注册后端根上的值(只读缓存)。 */
|
|
1470
1476
|
getIdentityCandidates(): IdentityCandidate[];
|
|
1477
|
+
/**
|
|
1478
|
+
* 现场回读各根,重算候选并填充缓存。
|
|
1479
|
+
*
|
|
1480
|
+
* 缓存只在「初始化时本地没有身份」才被填充;本地已有身份时缓存是空的,
|
|
1481
|
+
* 同步 getter 也就只剩一个本地值 —— 界面看不到「本地 6abe… vs 远端 5a52…」
|
|
1482
|
+
* 这种真正需要拍板的分歧。所以给界面一个能主动回读的入口。
|
|
1483
|
+
*/
|
|
1484
|
+
getIdentityCandidatesAsync(): Promise<IdentityCandidate[]>;
|
|
1471
1485
|
/** 候选是否互相矛盾(界面据此要求用户拍板)。 */
|
|
1472
1486
|
isIdentityUnsettled(): boolean;
|
|
1473
1487
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2906,6 +2906,9 @@ var LEGACY_CONFIG_SYNC_GROUP_FILE = `${META_DIR}/config-sync-group.json`;
|
|
|
2906
2906
|
var GROUP_NAME_MAX_LENGTH = 40;
|
|
2907
2907
|
var NODES_DIR = "/nodes";
|
|
2908
2908
|
var SHARED_DIR = "/shared";
|
|
2909
|
+
function isDeletableLegacyMetaPath(path) {
|
|
2910
|
+
return path === LEGACY_TOMBSTONES_DIR || path.startsWith(`${LEGACY_TOMBSTONES_DIR}/`) || path === LEGACY_CONFLICTS_DIR || path.startsWith(`${LEGACY_CONFLICTS_DIR}/`);
|
|
2911
|
+
}
|
|
2909
2912
|
var CONFIG_GROUP_ID = "config";
|
|
2910
2913
|
var CONFIG_GROUP_FEATURES = {
|
|
2911
2914
|
tombstones: true,
|
|
@@ -4853,12 +4856,40 @@ var ConfigRepo = class {
|
|
|
4853
4856
|
getGroupInstanceId() {
|
|
4854
4857
|
return this.instanceId;
|
|
4855
4858
|
}
|
|
4856
|
-
/** 配置组的身份候选:本地描述符 +
|
|
4859
|
+
/** 配置组的身份候选:本地描述符 + 已注册后端根上的值(只读缓存)。 */
|
|
4857
4860
|
getIdentityCandidates() {
|
|
4858
4861
|
if (this.identityCandidates.length > 0) return this.identityCandidates.map((c) => ({ ...c }));
|
|
4859
4862
|
if (!this.instanceId) return [];
|
|
4860
4863
|
return [{ source: "local", instanceId: this.instanceId, rootCount: 1, kind: "config", id: CONFIG_GROUP_ID }];
|
|
4861
4864
|
}
|
|
4865
|
+
/**
|
|
4866
|
+
* 现场回读各根,重算候选并填充缓存。
|
|
4867
|
+
*
|
|
4868
|
+
* 缓存只在「初始化时本地没有身份」才被填充;本地已有身份时缓存是空的,
|
|
4869
|
+
* 同步 getter 也就只剩一个本地值 —— 界面看不到「本地 6abe… vs 远端 5a52…」
|
|
4870
|
+
* 这种真正需要拍板的分歧。所以给界面一个能主动回读的入口。
|
|
4871
|
+
*/
|
|
4872
|
+
async getIdentityCandidatesAsync() {
|
|
4873
|
+
if (!this.instanceId) return [];
|
|
4874
|
+
const collected = await this.collectConfigIdentityCandidates("config", CONFIG_GROUP_ID);
|
|
4875
|
+
if (!collected.candidates.some((c) => c.source === "local") && this.instanceId) {
|
|
4876
|
+
collected.candidates.unshift({
|
|
4877
|
+
source: "local",
|
|
4878
|
+
instanceId: this.instanceId,
|
|
4879
|
+
rootCount: 1,
|
|
4880
|
+
kind: "config",
|
|
4881
|
+
id: CONFIG_GROUP_ID
|
|
4882
|
+
});
|
|
4883
|
+
}
|
|
4884
|
+
this.identityCandidates = collected.candidates;
|
|
4885
|
+
this.configIdentityUnsettled = collected.distinct.length > 1;
|
|
4886
|
+
if (this.configIdentityUnsettled) {
|
|
4887
|
+
log5.warn(
|
|
4888
|
+
`[ConfigRepo] identity candidates disagree (${collected.distinct.join(" / ")}) \u2014 left to the user to decide in the UI`
|
|
4889
|
+
);
|
|
4890
|
+
}
|
|
4891
|
+
return this.identityCandidates.map((c) => ({ ...c }));
|
|
4892
|
+
}
|
|
4862
4893
|
/** 候选是否互相矛盾(界面据此要求用户拍板)。 */
|
|
4863
4894
|
isIdentityUnsettled() {
|
|
4864
4895
|
return this.configIdentityUnsettled;
|
|
@@ -6055,10 +6086,8 @@ var AppDataGroupImpl = class {
|
|
|
6055
6086
|
hiddenPrefixes: [CONFIG_DIR],
|
|
6056
6087
|
readOnlyPrefixes: [
|
|
6057
6088
|
TOMBSTONES_DIR,
|
|
6058
|
-
LEGACY_TOMBSTONES_DIR,
|
|
6059
6089
|
VERSIONS_DIR,
|
|
6060
|
-
CONFLICTS_DIR
|
|
6061
|
-
LEGACY_CONFLICTS_DIR
|
|
6090
|
+
CONFLICTS_DIR
|
|
6062
6091
|
],
|
|
6063
6092
|
confirmPrefixes: [GROUP_DESCRIPTOR_FILE3],
|
|
6064
6093
|
onWrite: async (path, data) => {
|
|
@@ -6303,7 +6332,7 @@ var AppDataGroupImpl = class {
|
|
|
6303
6332
|
async deleteFile(path) {
|
|
6304
6333
|
if (this.disposed) throw new Error("DataSyncGroup has been disposed");
|
|
6305
6334
|
const normalized = path.startsWith("/") ? path : `/${path}`;
|
|
6306
|
-
if (normalized ===
|
|
6335
|
+
if (normalized === CONFIG_DIR || normalized.startsWith(`${CONFIG_DIR}/`) || (normalized === META_DIR || normalized.startsWith(`${META_DIR}/`)) && !isDeletableLegacyMetaPath(normalized)) {
|
|
6307
6336
|
throw new Error(`Cannot delete metadata path "${normalized}"`);
|
|
6308
6337
|
}
|
|
6309
6338
|
if (await isDirectoryPath(this.localFS, normalized)) {
|
package/dist/index.mjs
CHANGED
|
@@ -2147,6 +2147,9 @@ var LEGACY_CONFIG_SYNC_GROUP_FILE = `${META_DIR}/config-sync-group.json`;
|
|
|
2147
2147
|
var GROUP_NAME_MAX_LENGTH = 40;
|
|
2148
2148
|
var NODES_DIR = "/nodes";
|
|
2149
2149
|
var SHARED_DIR = "/shared";
|
|
2150
|
+
function isDeletableLegacyMetaPath(path) {
|
|
2151
|
+
return path === LEGACY_TOMBSTONES_DIR || path.startsWith(`${LEGACY_TOMBSTONES_DIR}/`) || path === LEGACY_CONFLICTS_DIR || path.startsWith(`${LEGACY_CONFLICTS_DIR}/`);
|
|
2152
|
+
}
|
|
2150
2153
|
var CONFIG_GROUP_ID = "config";
|
|
2151
2154
|
var CONFIG_GROUP_FEATURES = {
|
|
2152
2155
|
tombstones: true,
|
|
@@ -4094,12 +4097,40 @@ var ConfigRepo = class {
|
|
|
4094
4097
|
getGroupInstanceId() {
|
|
4095
4098
|
return this.instanceId;
|
|
4096
4099
|
}
|
|
4097
|
-
/** 配置组的身份候选:本地描述符 +
|
|
4100
|
+
/** 配置组的身份候选:本地描述符 + 已注册后端根上的值(只读缓存)。 */
|
|
4098
4101
|
getIdentityCandidates() {
|
|
4099
4102
|
if (this.identityCandidates.length > 0) return this.identityCandidates.map((c) => ({ ...c }));
|
|
4100
4103
|
if (!this.instanceId) return [];
|
|
4101
4104
|
return [{ source: "local", instanceId: this.instanceId, rootCount: 1, kind: "config", id: CONFIG_GROUP_ID }];
|
|
4102
4105
|
}
|
|
4106
|
+
/**
|
|
4107
|
+
* 现场回读各根,重算候选并填充缓存。
|
|
4108
|
+
*
|
|
4109
|
+
* 缓存只在「初始化时本地没有身份」才被填充;本地已有身份时缓存是空的,
|
|
4110
|
+
* 同步 getter 也就只剩一个本地值 —— 界面看不到「本地 6abe… vs 远端 5a52…」
|
|
4111
|
+
* 这种真正需要拍板的分歧。所以给界面一个能主动回读的入口。
|
|
4112
|
+
*/
|
|
4113
|
+
async getIdentityCandidatesAsync() {
|
|
4114
|
+
if (!this.instanceId) return [];
|
|
4115
|
+
const collected = await this.collectConfigIdentityCandidates("config", CONFIG_GROUP_ID);
|
|
4116
|
+
if (!collected.candidates.some((c) => c.source === "local") && this.instanceId) {
|
|
4117
|
+
collected.candidates.unshift({
|
|
4118
|
+
source: "local",
|
|
4119
|
+
instanceId: this.instanceId,
|
|
4120
|
+
rootCount: 1,
|
|
4121
|
+
kind: "config",
|
|
4122
|
+
id: CONFIG_GROUP_ID
|
|
4123
|
+
});
|
|
4124
|
+
}
|
|
4125
|
+
this.identityCandidates = collected.candidates;
|
|
4126
|
+
this.configIdentityUnsettled = collected.distinct.length > 1;
|
|
4127
|
+
if (this.configIdentityUnsettled) {
|
|
4128
|
+
log5.warn(
|
|
4129
|
+
`[ConfigRepo] identity candidates disagree (${collected.distinct.join(" / ")}) \u2014 left to the user to decide in the UI`
|
|
4130
|
+
);
|
|
4131
|
+
}
|
|
4132
|
+
return this.identityCandidates.map((c) => ({ ...c }));
|
|
4133
|
+
}
|
|
4103
4134
|
/** 候选是否互相矛盾(界面据此要求用户拍板)。 */
|
|
4104
4135
|
isIdentityUnsettled() {
|
|
4105
4136
|
return this.configIdentityUnsettled;
|
|
@@ -5296,10 +5327,8 @@ var AppDataGroupImpl = class {
|
|
|
5296
5327
|
hiddenPrefixes: [CONFIG_DIR],
|
|
5297
5328
|
readOnlyPrefixes: [
|
|
5298
5329
|
TOMBSTONES_DIR,
|
|
5299
|
-
LEGACY_TOMBSTONES_DIR,
|
|
5300
5330
|
VERSIONS_DIR,
|
|
5301
|
-
CONFLICTS_DIR
|
|
5302
|
-
LEGACY_CONFLICTS_DIR
|
|
5331
|
+
CONFLICTS_DIR
|
|
5303
5332
|
],
|
|
5304
5333
|
confirmPrefixes: [GROUP_DESCRIPTOR_FILE3],
|
|
5305
5334
|
onWrite: async (path, data) => {
|
|
@@ -5544,7 +5573,7 @@ var AppDataGroupImpl = class {
|
|
|
5544
5573
|
async deleteFile(path) {
|
|
5545
5574
|
if (this.disposed) throw new Error("DataSyncGroup has been disposed");
|
|
5546
5575
|
const normalized = path.startsWith("/") ? path : `/${path}`;
|
|
5547
|
-
if (normalized ===
|
|
5576
|
+
if (normalized === CONFIG_DIR || normalized.startsWith(`${CONFIG_DIR}/`) || (normalized === META_DIR || normalized.startsWith(`${META_DIR}/`)) && !isDeletableLegacyMetaPath(normalized)) {
|
|
5548
5577
|
throw new Error(`Cannot delete metadata path "${normalized}"`);
|
|
5549
5578
|
}
|
|
5550
5579
|
if (await isDirectoryPath(this.localFS, normalized)) {
|
package/dist/zen-fs-config.js
CHANGED
|
@@ -28863,6 +28863,9 @@ var ZenFSConfig = (() => {
|
|
|
28863
28863
|
var GROUP_NAME_MAX_LENGTH = 40;
|
|
28864
28864
|
var NODES_DIR = "/nodes";
|
|
28865
28865
|
var SHARED_DIR = "/shared";
|
|
28866
|
+
function isDeletableLegacyMetaPath(path) {
|
|
28867
|
+
return path === LEGACY_TOMBSTONES_DIR || path.startsWith(`${LEGACY_TOMBSTONES_DIR}/`) || path === LEGACY_CONFLICTS_DIR || path.startsWith(`${LEGACY_CONFLICTS_DIR}/`);
|
|
28868
|
+
}
|
|
28866
28869
|
var CONFIG_GROUP_ID = "config";
|
|
28867
28870
|
var CONFIG_GROUP_FEATURES = {
|
|
28868
28871
|
tombstones: true,
|
|
@@ -30810,12 +30813,40 @@ var ZenFSConfig = (() => {
|
|
|
30810
30813
|
getGroupInstanceId() {
|
|
30811
30814
|
return this.instanceId;
|
|
30812
30815
|
}
|
|
30813
|
-
/** 配置组的身份候选:本地描述符 +
|
|
30816
|
+
/** 配置组的身份候选:本地描述符 + 已注册后端根上的值(只读缓存)。 */
|
|
30814
30817
|
getIdentityCandidates() {
|
|
30815
30818
|
if (this.identityCandidates.length > 0) return this.identityCandidates.map((c) => ({ ...c }));
|
|
30816
30819
|
if (!this.instanceId) return [];
|
|
30817
30820
|
return [{ source: "local", instanceId: this.instanceId, rootCount: 1, kind: "config", id: CONFIG_GROUP_ID }];
|
|
30818
30821
|
}
|
|
30822
|
+
/**
|
|
30823
|
+
* 现场回读各根,重算候选并填充缓存。
|
|
30824
|
+
*
|
|
30825
|
+
* 缓存只在「初始化时本地没有身份」才被填充;本地已有身份时缓存是空的,
|
|
30826
|
+
* 同步 getter 也就只剩一个本地值 —— 界面看不到「本地 6abe… vs 远端 5a52…」
|
|
30827
|
+
* 这种真正需要拍板的分歧。所以给界面一个能主动回读的入口。
|
|
30828
|
+
*/
|
|
30829
|
+
async getIdentityCandidatesAsync() {
|
|
30830
|
+
if (!this.instanceId) return [];
|
|
30831
|
+
const collected = await this.collectConfigIdentityCandidates("config", CONFIG_GROUP_ID);
|
|
30832
|
+
if (!collected.candidates.some((c) => c.source === "local") && this.instanceId) {
|
|
30833
|
+
collected.candidates.unshift({
|
|
30834
|
+
source: "local",
|
|
30835
|
+
instanceId: this.instanceId,
|
|
30836
|
+
rootCount: 1,
|
|
30837
|
+
kind: "config",
|
|
30838
|
+
id: CONFIG_GROUP_ID
|
|
30839
|
+
});
|
|
30840
|
+
}
|
|
30841
|
+
this.identityCandidates = collected.candidates;
|
|
30842
|
+
this.configIdentityUnsettled = collected.distinct.length > 1;
|
|
30843
|
+
if (this.configIdentityUnsettled) {
|
|
30844
|
+
log9.warn(
|
|
30845
|
+
`[ConfigRepo] identity candidates disagree (${collected.distinct.join(" / ")}) \u2014 left to the user to decide in the UI`
|
|
30846
|
+
);
|
|
30847
|
+
}
|
|
30848
|
+
return this.identityCandidates.map((c) => ({ ...c }));
|
|
30849
|
+
}
|
|
30819
30850
|
/** 候选是否互相矛盾(界面据此要求用户拍板)。 */
|
|
30820
30851
|
isIdentityUnsettled() {
|
|
30821
30852
|
return this.configIdentityUnsettled;
|
|
@@ -32012,10 +32043,8 @@ var ZenFSConfig = (() => {
|
|
|
32012
32043
|
hiddenPrefixes: [CONFIG_DIR],
|
|
32013
32044
|
readOnlyPrefixes: [
|
|
32014
32045
|
TOMBSTONES_DIR,
|
|
32015
|
-
LEGACY_TOMBSTONES_DIR,
|
|
32016
32046
|
VERSIONS_DIR,
|
|
32017
|
-
CONFLICTS_DIR
|
|
32018
|
-
LEGACY_CONFLICTS_DIR
|
|
32047
|
+
CONFLICTS_DIR
|
|
32019
32048
|
],
|
|
32020
32049
|
confirmPrefixes: [GROUP_DESCRIPTOR_FILE3],
|
|
32021
32050
|
onWrite: async (path, data) => {
|
|
@@ -32260,7 +32289,7 @@ var ZenFSConfig = (() => {
|
|
|
32260
32289
|
async deleteFile(path) {
|
|
32261
32290
|
if (this.disposed) throw new Error("DataSyncGroup has been disposed");
|
|
32262
32291
|
const normalized = path.startsWith("/") ? path : `/${path}`;
|
|
32263
|
-
if (normalized ===
|
|
32292
|
+
if (normalized === CONFIG_DIR || normalized.startsWith(`${CONFIG_DIR}/`) || (normalized === META_DIR || normalized.startsWith(`${META_DIR}/`)) && !isDeletableLegacyMetaPath(normalized)) {
|
|
32264
32293
|
throw new Error(`Cannot delete metadata path "${normalized}"`);
|
|
32265
32294
|
}
|
|
32266
32295
|
if (await isDirectoryPath(this.localFS, normalized)) {
|