@tinycloud/sdk-services 3.2.0-beta.3 → 3.2.0-beta.5

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/kv/index.cjs CHANGED
@@ -1939,6 +1939,7 @@ var KVService = class extends BaseService {
1939
1939
  "kv"
1940
1940
  ));
1941
1941
  }
1942
+ const requestPrefix = options.prefix === "/" ? "" : options.prefix;
1942
1943
  const headers = {};
1943
1944
  if (options.limit !== void 0) headers["x-tinycloud-limit"] = String(options.limit);
1944
1945
  if (options.cursor !== void 0) headers["x-tinycloud-cursor"] = options.cursor;
@@ -1948,7 +1949,7 @@ var KVService = class extends BaseService {
1948
1949
  const request = this.createRequestSignal(options.signal, options.timeout);
1949
1950
  try {
1950
1951
  const response = await this.invokeOperation(
1951
- options.prefix,
1952
+ requestPrefix,
1952
1953
  KVAction.SYNC,
1953
1954
  void 0,
1954
1955
  request.signal,
@@ -1964,7 +1965,7 @@ var KVService = class extends BaseService {
1964
1965
  } catch {
1965
1966
  body = void 0;
1966
1967
  }
1967
- const page = this.normalizeChangesResponse(body);
1968
+ const page = this.normalizeChangesResponse(body, options.prefix);
1968
1969
  if (!page) {
1969
1970
  return err(serviceError(
1970
1971
  ErrorCodes.NETWORK_ERROR,
@@ -2044,7 +2045,7 @@ var KVService = class extends BaseService {
2044
2045
  { meta }
2045
2046
  ));
2046
2047
  }
2047
- normalizeChangesResponse(data) {
2048
+ normalizeChangesResponse(data, requestedPrefix) {
2048
2049
  if (!isJsonObject(data)) return void 0;
2049
2050
  const { changes, more, cursor, source, authority } = data;
2050
2051
  if (!Array.isArray(changes) || typeof more !== "boolean" || typeof cursor !== "string" || !isJsonObject(source) || typeof source.nodeDid !== "string" || typeof source.space !== "string" || typeof source.prefix !== "string" || !isJsonObject(authority)) {
@@ -2076,7 +2077,11 @@ var KVService = class extends BaseService {
2076
2077
  changes: parsed,
2077
2078
  more,
2078
2079
  cursor,
2079
- source: { nodeDid: source.nodeDid, space: source.space, prefix: source.prefix },
2080
+ source: {
2081
+ nodeDid: source.nodeDid,
2082
+ space: source.space,
2083
+ prefix: requestedPrefix === "/" && source.prefix === "" ? "/" : source.prefix
2084
+ },
2080
2085
  authority: { notBefore, expiresAt, retainUntil }
2081
2086
  };
2082
2087
  }
@@ -2371,13 +2376,14 @@ ${canonical.space}
2371
2376
  ${canonical.principal}`;
2372
2377
  }
2373
2378
 
2374
- // src/kv/replication/scope.ts
2379
+ // src/kv/replication/prefix.ts
2375
2380
  function kvPrefixCovers(prefix, key) {
2376
- if (prefix === "") return true;
2377
- if (prefix.endsWith("/")) return key.startsWith(prefix);
2378
- return key === prefix || key.startsWith(`${prefix}/`);
2381
+ return prefix === "/" || key.startsWith(prefix);
2379
2382
  }
2383
+
2384
+ // src/kv/replication/scope.ts
2380
2385
  function requiresSecretsOptIn(space, prefix) {
2386
+ if (prefix === "/") return true;
2381
2387
  if (space === "secrets" || space.endsWith(":secrets")) return true;
2382
2388
  return prefix.split("/", 1)[0] === "vault";
2383
2389
  }