@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/index.cjs CHANGED
@@ -3013,6 +3013,7 @@ var KVService = class extends BaseService {
3013
3013
  "kv"
3014
3014
  ));
3015
3015
  }
3016
+ const requestPrefix = options.prefix === "/" ? "" : options.prefix;
3016
3017
  const headers = {};
3017
3018
  if (options.limit !== void 0) headers["x-tinycloud-limit"] = String(options.limit);
3018
3019
  if (options.cursor !== void 0) headers["x-tinycloud-cursor"] = options.cursor;
@@ -3022,7 +3023,7 @@ var KVService = class extends BaseService {
3022
3023
  const request = this.createRequestSignal(options.signal, options.timeout);
3023
3024
  try {
3024
3025
  const response = await this.invokeOperation(
3025
- options.prefix,
3026
+ requestPrefix,
3026
3027
  KVAction.SYNC,
3027
3028
  void 0,
3028
3029
  request.signal,
@@ -3038,7 +3039,7 @@ var KVService = class extends BaseService {
3038
3039
  } catch {
3039
3040
  body = void 0;
3040
3041
  }
3041
- const page = this.normalizeChangesResponse(body);
3042
+ const page = this.normalizeChangesResponse(body, options.prefix);
3042
3043
  if (!page) {
3043
3044
  return err(serviceError(
3044
3045
  ErrorCodes.NETWORK_ERROR,
@@ -3118,7 +3119,7 @@ var KVService = class extends BaseService {
3118
3119
  { meta }
3119
3120
  ));
3120
3121
  }
3121
- normalizeChangesResponse(data) {
3122
+ normalizeChangesResponse(data, requestedPrefix) {
3122
3123
  if (!isJsonObject(data)) return void 0;
3123
3124
  const { changes, more, cursor, source, authority } = data;
3124
3125
  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)) {
@@ -3150,7 +3151,11 @@ var KVService = class extends BaseService {
3150
3151
  changes: parsed,
3151
3152
  more,
3152
3153
  cursor,
3153
- source: { nodeDid: source.nodeDid, space: source.space, prefix: source.prefix },
3154
+ source: {
3155
+ nodeDid: source.nodeDid,
3156
+ space: source.space,
3157
+ prefix: requestedPrefix === "/" && source.prefix === "" ? "/" : source.prefix
3158
+ },
3154
3159
  authority: { notBefore, expiresAt, retainUntil }
3155
3160
  };
3156
3161
  }
@@ -3445,13 +3450,14 @@ ${canonical.space}
3445
3450
  ${canonical.principal}`;
3446
3451
  }
3447
3452
 
3448
- // src/kv/replication/scope.ts
3453
+ // src/kv/replication/prefix.ts
3449
3454
  function kvPrefixCovers(prefix, key) {
3450
- if (prefix === "") return true;
3451
- if (prefix.endsWith("/")) return key.startsWith(prefix);
3452
- return key === prefix || key.startsWith(`${prefix}/`);
3455
+ return prefix === "/" || key.startsWith(prefix);
3453
3456
  }
3457
+
3458
+ // src/kv/replication/scope.ts
3454
3459
  function requiresSecretsOptIn(space, prefix) {
3460
+ if (prefix === "/") return true;
3455
3461
  if (space === "secrets" || space.endsWith(":secrets")) return true;
3456
3462
  return prefix.split("/", 1)[0] === "vault";
3457
3463
  }