@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.
@@ -1,7 +1,8 @@
1
1
  import { B as BaseService } from '../BaseService-BDQXjWMx.cjs';
2
2
  import { R as Result, I as IService } from '../types-7A5rHWRY.cjs';
3
- import { Z as KVGetOptions, a2 as KVResponse, S as KVBatchReadResponse, a1 as KVPutOptions, N as KVBatchPutItem, O as KVBatchPutOptions, Q as KVBatchPutResponse, $ as KVListOptions, a0 as KVListResponse, V as KVChangesOptions, W as KVChangesResponse, Y as KVDeleteOptions, _ as KVHeadOptions, X as KVCreateSignedReadUrlOptions, a5 as KVSignedReadUrlResponse, a4 as KVServiceConfig, c as KVReadThrough } from '../scope-D855kRDx.cjs';
4
- export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING, I as DEFAULT_SIGNED_READ_URL_EXPIRY_MS, J as KVAction, M as KVActionType, T as KVChange, U as KVChangesAuthority, b as KVListPage, d as KVReplicaHandle, e as KVReplicaSpec, f as KVReplicaStorage, a as KVReplicationController, K as KVReplicationDeps, a3 as KVResponseHeaders, L as LocalGetResult, g as LocalListResult, h as LocalReadMeta, i as LocalReplicaStatus, j as LocalSyncResult, k as PendingWriteRecord, l as PendingWriteState, P as PendingWriteStore, m as PinnedKey, n as PurgeTarget, o as ReplicaAuthorityState, p as ReplicaCoverage, q as ReplicaDevice, r as ReplicaGrantInfo, s as ReplicaState, t as ReplicaStatusEntry, u as ReplicationAuthority, v as ReplicationControl, w as ReplicationEvent, R as ReplicationIdentity, x as ReplicationOptions, y as ReplicationPurgeReport, z as ReplicationReason, B as ReplicationScheduler, D as ResolvedReplicationOptions, E as canonicalReplicationIdentity, F as kvPrefixCovers, G as replicationIdentityKey, H as requiresSecretsOptIn } from '../scope-D855kRDx.cjs';
3
+ import { Y as KVGetOptions, a1 as KVResponse, Q as KVBatchReadResponse, a0 as KVPutOptions, M as KVBatchPutItem, N as KVBatchPutOptions, O as KVBatchPutResponse, _ as KVListOptions, $ as KVListResponse, U as KVChangesOptions, V as KVChangesResponse, X as KVDeleteOptions, Z as KVHeadOptions, W as KVCreateSignedReadUrlOptions, a4 as KVSignedReadUrlResponse, a3 as KVServiceConfig, c as KVReadThrough } from '../scope-C05VVAXH.cjs';
4
+ export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING, H as DEFAULT_SIGNED_READ_URL_EXPIRY_MS, I as KVAction, J as KVActionType, S as KVChange, T as KVChangesAuthority, b as KVListPage, d as KVReplicaHandle, e as KVReplicaSpec, f as KVReplicaStorage, a as KVReplicationController, K as KVReplicationDeps, a2 as KVResponseHeaders, L as LocalGetResult, g as LocalListResult, h as LocalReadMeta, i as LocalReplicaStatus, j as LocalSyncResult, k as PendingWriteRecord, l as PendingWriteState, P as PendingWriteStore, m as PinnedKey, n as PurgeTarget, o as ReplicaAuthorityState, p as ReplicaCoverage, q as ReplicaDevice, r as ReplicaGrantInfo, s as ReplicaState, t as ReplicaStatusEntry, u as ReplicationAuthority, v as ReplicationControl, w as ReplicationEvent, R as ReplicationIdentity, x as ReplicationOptions, y as ReplicationPurgeReport, z as ReplicationReason, B as ReplicationScheduler, D as ResolvedReplicationOptions, E as canonicalReplicationIdentity, F as replicationIdentityKey, G as requiresSecretsOptIn } from '../scope-C05VVAXH.cjs';
5
+ export { kvPrefixCovers } from './replication/prefix.cjs';
5
6
 
6
7
  /**
7
8
  * PrefixedKVService - A prefix-scoped view of KVService.
@@ -1,7 +1,8 @@
1
1
  import { B as BaseService } from '../BaseService-Di_hVfUV.js';
2
2
  import { R as Result, I as IService } from '../types-7A5rHWRY.js';
3
- import { Z as KVGetOptions, a2 as KVResponse, S as KVBatchReadResponse, a1 as KVPutOptions, N as KVBatchPutItem, O as KVBatchPutOptions, Q as KVBatchPutResponse, $ as KVListOptions, a0 as KVListResponse, V as KVChangesOptions, W as KVChangesResponse, Y as KVDeleteOptions, _ as KVHeadOptions, X as KVCreateSignedReadUrlOptions, a5 as KVSignedReadUrlResponse, a4 as KVServiceConfig, c as KVReadThrough } from '../scope-BmLxwyl-.js';
4
- export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING, I as DEFAULT_SIGNED_READ_URL_EXPIRY_MS, J as KVAction, M as KVActionType, T as KVChange, U as KVChangesAuthority, b as KVListPage, d as KVReplicaHandle, e as KVReplicaSpec, f as KVReplicaStorage, a as KVReplicationController, K as KVReplicationDeps, a3 as KVResponseHeaders, L as LocalGetResult, g as LocalListResult, h as LocalReadMeta, i as LocalReplicaStatus, j as LocalSyncResult, k as PendingWriteRecord, l as PendingWriteState, P as PendingWriteStore, m as PinnedKey, n as PurgeTarget, o as ReplicaAuthorityState, p as ReplicaCoverage, q as ReplicaDevice, r as ReplicaGrantInfo, s as ReplicaState, t as ReplicaStatusEntry, u as ReplicationAuthority, v as ReplicationControl, w as ReplicationEvent, R as ReplicationIdentity, x as ReplicationOptions, y as ReplicationPurgeReport, z as ReplicationReason, B as ReplicationScheduler, D as ResolvedReplicationOptions, E as canonicalReplicationIdentity, F as kvPrefixCovers, G as replicationIdentityKey, H as requiresSecretsOptIn } from '../scope-BmLxwyl-.js';
3
+ import { Y as KVGetOptions, a1 as KVResponse, Q as KVBatchReadResponse, a0 as KVPutOptions, M as KVBatchPutItem, N as KVBatchPutOptions, O as KVBatchPutResponse, _ as KVListOptions, $ as KVListResponse, U as KVChangesOptions, V as KVChangesResponse, X as KVDeleteOptions, Z as KVHeadOptions, W as KVCreateSignedReadUrlOptions, a4 as KVSignedReadUrlResponse, a3 as KVServiceConfig, c as KVReadThrough } from '../scope-BKge7zDT.js';
4
+ export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING, H as DEFAULT_SIGNED_READ_URL_EXPIRY_MS, I as KVAction, J as KVActionType, S as KVChange, T as KVChangesAuthority, b as KVListPage, d as KVReplicaHandle, e as KVReplicaSpec, f as KVReplicaStorage, a as KVReplicationController, K as KVReplicationDeps, a2 as KVResponseHeaders, L as LocalGetResult, g as LocalListResult, h as LocalReadMeta, i as LocalReplicaStatus, j as LocalSyncResult, k as PendingWriteRecord, l as PendingWriteState, P as PendingWriteStore, m as PinnedKey, n as PurgeTarget, o as ReplicaAuthorityState, p as ReplicaCoverage, q as ReplicaDevice, r as ReplicaGrantInfo, s as ReplicaState, t as ReplicaStatusEntry, u as ReplicationAuthority, v as ReplicationControl, w as ReplicationEvent, R as ReplicationIdentity, x as ReplicationOptions, y as ReplicationPurgeReport, z as ReplicationReason, B as ReplicationScheduler, D as ResolvedReplicationOptions, E as canonicalReplicationIdentity, F as replicationIdentityKey, G as requiresSecretsOptIn } from '../scope-BKge7zDT.js';
5
+ export { kvPrefixCovers } from './replication/prefix.js';
5
6
 
6
7
  /**
7
8
  * PrefixedKVService - A prefix-scoped view of KVService.
package/dist/kv/index.js CHANGED
@@ -1905,6 +1905,7 @@ var KVService = class extends BaseService {
1905
1905
  "kv"
1906
1906
  ));
1907
1907
  }
1908
+ const requestPrefix = options.prefix === "/" ? "" : options.prefix;
1908
1909
  const headers = {};
1909
1910
  if (options.limit !== void 0) headers["x-tinycloud-limit"] = String(options.limit);
1910
1911
  if (options.cursor !== void 0) headers["x-tinycloud-cursor"] = options.cursor;
@@ -1914,7 +1915,7 @@ var KVService = class extends BaseService {
1914
1915
  const request = this.createRequestSignal(options.signal, options.timeout);
1915
1916
  try {
1916
1917
  const response = await this.invokeOperation(
1917
- options.prefix,
1918
+ requestPrefix,
1918
1919
  KVAction.SYNC,
1919
1920
  void 0,
1920
1921
  request.signal,
@@ -1930,7 +1931,7 @@ var KVService = class extends BaseService {
1930
1931
  } catch {
1931
1932
  body = void 0;
1932
1933
  }
1933
- const page = this.normalizeChangesResponse(body);
1934
+ const page = this.normalizeChangesResponse(body, options.prefix);
1934
1935
  if (!page) {
1935
1936
  return err(serviceError(
1936
1937
  ErrorCodes.NETWORK_ERROR,
@@ -2010,7 +2011,7 @@ var KVService = class extends BaseService {
2010
2011
  { meta }
2011
2012
  ));
2012
2013
  }
2013
- normalizeChangesResponse(data) {
2014
+ normalizeChangesResponse(data, requestedPrefix) {
2014
2015
  if (!isJsonObject(data)) return void 0;
2015
2016
  const { changes, more, cursor, source, authority } = data;
2016
2017
  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)) {
@@ -2042,7 +2043,11 @@ var KVService = class extends BaseService {
2042
2043
  changes: parsed,
2043
2044
  more,
2044
2045
  cursor,
2045
- source: { nodeDid: source.nodeDid, space: source.space, prefix: source.prefix },
2046
+ source: {
2047
+ nodeDid: source.nodeDid,
2048
+ space: source.space,
2049
+ prefix: requestedPrefix === "/" && source.prefix === "" ? "/" : source.prefix
2050
+ },
2046
2051
  authority: { notBefore, expiresAt, retainUntil }
2047
2052
  };
2048
2053
  }
@@ -2337,13 +2342,14 @@ ${canonical.space}
2337
2342
  ${canonical.principal}`;
2338
2343
  }
2339
2344
 
2340
- // src/kv/replication/scope.ts
2345
+ // src/kv/replication/prefix.ts
2341
2346
  function kvPrefixCovers(prefix, key) {
2342
- if (prefix === "") return true;
2343
- if (prefix.endsWith("/")) return key.startsWith(prefix);
2344
- return key === prefix || key.startsWith(`${prefix}/`);
2347
+ return prefix === "/" || key.startsWith(prefix);
2345
2348
  }
2349
+
2350
+ // src/kv/replication/scope.ts
2346
2351
  function requiresSecretsOptIn(space, prefix) {
2352
+ if (prefix === "/") return true;
2347
2353
  if (space === "secrets" || space.endsWith(":secrets")) return true;
2348
2354
  return prefix.split("/", 1)[0] === "vault";
2349
2355
  }