@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.
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/kv/replication/prefix.ts
21
+ var prefix_exports = {};
22
+ __export(prefix_exports, {
23
+ assertFolderPrefix: () => assertFolderPrefix,
24
+ kvPrefixCovers: () => kvPrefixCovers
25
+ });
26
+ module.exports = __toCommonJS(prefix_exports);
27
+ function kvPrefixCovers(prefix, key) {
28
+ return prefix === "/" || key.startsWith(prefix);
29
+ }
30
+ function assertFolderPrefix(prefix) {
31
+ const validFolder = typeof prefix === "string" && prefix.length > 0 && !prefix.startsWith("/") && !prefix.includes("//") && prefix.endsWith("/");
32
+ if (prefix !== "/" && !validFolder) {
33
+ const folderHint = typeof prefix === "string" ? prefix.replace(/^\/+/, "").replace(/\/+$/, "") : "";
34
+ const suggestion = folderHint.length > 0 && !folderHint.includes("//") ? ` Use ${JSON.stringify(`${folderHint}/`)}.` : ' Use "/" or a slash-terminated folder path such as "notes/".';
35
+ throw new TypeError(`Replication prefix must be "/" or a non-empty slash-terminated folder path without empty segments.${suggestion}`);
36
+ }
37
+ }
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ assertFolderPrefix,
41
+ kvPrefixCovers
42
+ });
43
+ //# sourceMappingURL=prefix.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/kv/replication/prefix.ts"],"sourcesContent":["/** Shared prefix boundary and configuration rules; no runtime dependencies. */\nexport function kvPrefixCovers(prefix: string, key: string): boolean {\n return prefix === \"/\" || key.startsWith(prefix);\n}\n\n/** Replication scopes are `/` or non-empty, slash-terminated folder paths. */\nexport function assertFolderPrefix(prefix: unknown): asserts prefix is string {\n const validFolder = typeof prefix === \"string\" &&\n prefix.length > 0 &&\n !prefix.startsWith(\"/\") &&\n !prefix.includes(\"//\") &&\n prefix.endsWith(\"/\");\n if (prefix !== \"/\" && !validFolder) {\n const folderHint = typeof prefix === \"string\"\n ? prefix.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\")\n : \"\";\n const suggestion = folderHint.length > 0 && !folderHint.includes(\"//\")\n ? ` Use ${JSON.stringify(`${folderHint}/`)}.`\n : ' Use \"/\" or a slash-terminated folder path such as \"notes/\".';\n throw new TypeError(`Replication prefix must be \"/\" or a non-empty slash-terminated folder path without empty segments.${suggestion}`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACO,SAAS,eAAe,QAAgB,KAAsB;AACnE,SAAO,WAAW,OAAO,IAAI,WAAW,MAAM;AAChD;AAGO,SAAS,mBAAmB,QAA2C;AAC5E,QAAM,cAAc,OAAO,WAAW,YACpC,OAAO,SAAS,KAChB,CAAC,OAAO,WAAW,GAAG,KACtB,CAAC,OAAO,SAAS,IAAI,KACrB,OAAO,SAAS,GAAG;AACrB,MAAI,WAAW,OAAO,CAAC,aAAa;AAClC,UAAM,aAAa,OAAO,WAAW,WACjC,OAAO,QAAQ,QAAQ,EAAE,EAAE,QAAQ,QAAQ,EAAE,IAC7C;AACJ,UAAM,aAAa,WAAW,SAAS,KAAK,CAAC,WAAW,SAAS,IAAI,IACjE,QAAQ,KAAK,UAAU,GAAG,UAAU,GAAG,CAAC,MACxC;AACJ,UAAM,IAAI,UAAU,qGAAqG,UAAU,EAAE;AAAA,EACvI;AACF;","names":[]}
@@ -0,0 +1,6 @@
1
+ /** Shared prefix boundary and configuration rules; no runtime dependencies. */
2
+ declare function kvPrefixCovers(prefix: string, key: string): boolean;
3
+ /** Replication scopes are `/` or non-empty, slash-terminated folder paths. */
4
+ declare function assertFolderPrefix(prefix: unknown): asserts prefix is string;
5
+
6
+ export { assertFolderPrefix, kvPrefixCovers };
@@ -0,0 +1,6 @@
1
+ /** Shared prefix boundary and configuration rules; no runtime dependencies. */
2
+ declare function kvPrefixCovers(prefix: string, key: string): boolean;
3
+ /** Replication scopes are `/` or non-empty, slash-terminated folder paths. */
4
+ declare function assertFolderPrefix(prefix: unknown): asserts prefix is string;
5
+
6
+ export { assertFolderPrefix, kvPrefixCovers };
@@ -0,0 +1,17 @@
1
+ // src/kv/replication/prefix.ts
2
+ function kvPrefixCovers(prefix, key) {
3
+ return prefix === "/" || key.startsWith(prefix);
4
+ }
5
+ function assertFolderPrefix(prefix) {
6
+ const validFolder = typeof prefix === "string" && prefix.length > 0 && !prefix.startsWith("/") && !prefix.includes("//") && prefix.endsWith("/");
7
+ if (prefix !== "/" && !validFolder) {
8
+ const folderHint = typeof prefix === "string" ? prefix.replace(/^\/+/, "").replace(/\/+$/, "") : "";
9
+ const suggestion = folderHint.length > 0 && !folderHint.includes("//") ? ` Use ${JSON.stringify(`${folderHint}/`)}.` : ' Use "/" or a slash-terminated folder path such as "notes/".';
10
+ throw new TypeError(`Replication prefix must be "/" or a non-empty slash-terminated folder path without empty segments.${suggestion}`);
11
+ }
12
+ }
13
+ export {
14
+ assertFolderPrefix,
15
+ kvPrefixCovers
16
+ };
17
+ //# sourceMappingURL=prefix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/kv/replication/prefix.ts"],"sourcesContent":["/** Shared prefix boundary and configuration rules; no runtime dependencies. */\nexport function kvPrefixCovers(prefix: string, key: string): boolean {\n return prefix === \"/\" || key.startsWith(prefix);\n}\n\n/** Replication scopes are `/` or non-empty, slash-terminated folder paths. */\nexport function assertFolderPrefix(prefix: unknown): asserts prefix is string {\n const validFolder = typeof prefix === \"string\" &&\n prefix.length > 0 &&\n !prefix.startsWith(\"/\") &&\n !prefix.includes(\"//\") &&\n prefix.endsWith(\"/\");\n if (prefix !== \"/\" && !validFolder) {\n const folderHint = typeof prefix === \"string\"\n ? prefix.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\")\n : \"\";\n const suggestion = folderHint.length > 0 && !folderHint.includes(\"//\")\n ? ` Use ${JSON.stringify(`${folderHint}/`)}.`\n : ' Use \"/\" or a slash-terminated folder path such as \"notes/\".';\n throw new TypeError(`Replication prefix must be \"/\" or a non-empty slash-terminated folder path without empty segments.${suggestion}`);\n }\n}\n"],"mappings":";AACO,SAAS,eAAe,QAAgB,KAAsB;AACnE,SAAO,WAAW,OAAO,IAAI,WAAW,MAAM;AAChD;AAGO,SAAS,mBAAmB,QAA2C;AAC5E,QAAM,cAAc,OAAO,WAAW,YACpC,OAAO,SAAS,KAChB,CAAC,OAAO,WAAW,GAAG,KACtB,CAAC,OAAO,SAAS,IAAI,KACrB,OAAO,SAAS,GAAG;AACrB,MAAI,WAAW,OAAO,CAAC,aAAa;AAClC,UAAM,aAAa,OAAO,WAAW,WACjC,OAAO,QAAQ,QAAQ,EAAE,EAAE,QAAQ,QAAQ,EAAE,IAC7C;AACJ,UAAM,aAAa,WAAW,SAAS,KAAK,CAAC,WAAW,SAAS,IAAI,IACjE,QAAQ,KAAK,UAAU,GAAG,UAAU,GAAG,CAAC,MACxC;AACJ,UAAM,IAAI,UAAU,qGAAqG,UAAU,EAAE;AAAA,EACvI;AACF;","names":[]}
@@ -729,6 +729,8 @@ interface KVReplicationDeps {
729
729
  * after restart. Pending-state failures also fail closed to network reads.
730
730
  */
731
731
  pending: PendingWriteStore;
732
+ /** Node `/info` features discovered on sign-in for protocol gating. */
733
+ nodeFeatures?: readonly string[];
732
734
  scheduler: ReplicationScheduler;
733
735
  emit(event: ReplicationEvent): void;
734
736
  fetch?: FetchFunction;
@@ -818,7 +820,7 @@ interface ReplicationControl {
818
820
  }
819
821
  interface ReplicationOptions {
820
822
  enabled: boolean;
821
- /** Non-empty primary-space prefixes; none empty or overlapping. Prefer no trailing slash. */
823
+ /** Non-empty list of folder prefixes ending in `/`, or `/` for the whole space. */
822
824
  prefixes: string[];
823
825
  /** Required for prefixes/spaces where requiresSecretsOptIn returns true. */
824
826
  allowSecrets?: boolean;
@@ -949,9 +951,7 @@ declare function canonicalReplicationIdentity(raw: ReplicationIdentity): Replica
949
951
  /** Stable in-memory key; durable adapters hash its UTF-8 bytes with their platform crypto. */
950
952
  declare function replicationIdentityKey(id: ReplicationIdentity): string;
951
953
 
952
- /** Published replica selector semantics: exact key plus descendants by segment. */
953
- declare function kvPrefixCovers(prefix: string, key: string): boolean;
954
954
  /** Whether replicating this space/prefix can copy encrypted secret material to disk. */
955
955
  declare function requiresSecretsOptIn(space: string, prefix: string): boolean;
956
956
 
957
- export { type KVListOptions as $, type AuthorityRefusal as A, type ReplicationScheduler as B, CLEAR_PENDING_WARNING as C, type ResolvedReplicationOptions as D, canonicalReplicationIdentity as E, kvPrefixCovers as F, replicationIdentityKey as G, requiresSecretsOptIn as H, DEFAULT_SIGNED_READ_URL_EXPIRY_MS as I, KVAction as J, type KVReplicationDeps as K, type LocalGetResult as L, type KVActionType as M, type KVBatchPutItem as N, type KVBatchPutOptions as O, type PendingWriteStore as P, type KVBatchPutResponse as Q, type ReplicationIdentity as R, type KVBatchReadResponse as S, type KVChange as T, type KVChangesAuthority as U, type KVChangesOptions as V, type KVChangesResponse as W, type KVCreateSignedReadUrlOptions as X, type KVDeleteOptions as Y, type KVGetOptions as Z, type KVHeadOptions as _, type KVReplicationController as a, type KVListResponse as a0, type KVPutOptions as a1, type KVResponse as a2, type KVResponseHeaders as a3, type KVServiceConfig as a4, type KVSignedReadUrlResponse as a5, type KVListPage as b, type KVReadThrough as c, type KVReplicaHandle as d, type KVReplicaSpec as e, type KVReplicaStorage as f, type LocalListResult as g, type LocalReadMeta as h, type LocalReplicaStatus as i, type LocalSyncResult as j, type PendingWriteRecord as k, type PendingWriteState as l, type PinnedKey as m, type PurgeTarget as n, type ReplicaAuthorityState as o, type ReplicaCoverage as p, type ReplicaDevice as q, type ReplicaGrantInfo as r, type ReplicaState as s, type ReplicaStatusEntry as t, type ReplicationAuthority as u, type ReplicationControl as v, type ReplicationEvent as w, type ReplicationOptions as x, type ReplicationPurgeReport as y, type ReplicationReason as z };
957
+ export { type KVListResponse as $, type AuthorityRefusal as A, type ReplicationScheduler as B, CLEAR_PENDING_WARNING as C, type ResolvedReplicationOptions as D, canonicalReplicationIdentity as E, replicationIdentityKey as F, requiresSecretsOptIn as G, DEFAULT_SIGNED_READ_URL_EXPIRY_MS as H, KVAction as I, type KVActionType as J, type KVReplicationDeps as K, type LocalGetResult as L, type KVBatchPutItem as M, type KVBatchPutOptions as N, type KVBatchPutResponse as O, type PendingWriteStore as P, type KVBatchReadResponse as Q, type ReplicationIdentity as R, type KVChange as S, type KVChangesAuthority as T, type KVChangesOptions as U, type KVChangesResponse as V, type KVCreateSignedReadUrlOptions as W, type KVDeleteOptions as X, type KVGetOptions as Y, type KVHeadOptions as Z, type KVListOptions as _, type KVReplicationController as a, type KVPutOptions as a0, type KVResponse as a1, type KVResponseHeaders as a2, type KVServiceConfig as a3, type KVSignedReadUrlResponse as a4, type KVListPage as b, type KVReadThrough as c, type KVReplicaHandle as d, type KVReplicaSpec as e, type KVReplicaStorage as f, type LocalListResult as g, type LocalReadMeta as h, type LocalReplicaStatus as i, type LocalSyncResult as j, type PendingWriteRecord as k, type PendingWriteState as l, type PinnedKey as m, type PurgeTarget as n, type ReplicaAuthorityState as o, type ReplicaCoverage as p, type ReplicaDevice as q, type ReplicaGrantInfo as r, type ReplicaState as s, type ReplicaStatusEntry as t, type ReplicationAuthority as u, type ReplicationControl as v, type ReplicationEvent as w, type ReplicationOptions as x, type ReplicationPurgeReport as y, type ReplicationReason as z };
@@ -729,6 +729,8 @@ interface KVReplicationDeps {
729
729
  * after restart. Pending-state failures also fail closed to network reads.
730
730
  */
731
731
  pending: PendingWriteStore;
732
+ /** Node `/info` features discovered on sign-in for protocol gating. */
733
+ nodeFeatures?: readonly string[];
732
734
  scheduler: ReplicationScheduler;
733
735
  emit(event: ReplicationEvent): void;
734
736
  fetch?: FetchFunction;
@@ -818,7 +820,7 @@ interface ReplicationControl {
818
820
  }
819
821
  interface ReplicationOptions {
820
822
  enabled: boolean;
821
- /** Non-empty primary-space prefixes; none empty or overlapping. Prefer no trailing slash. */
823
+ /** Non-empty list of folder prefixes ending in `/`, or `/` for the whole space. */
822
824
  prefixes: string[];
823
825
  /** Required for prefixes/spaces where requiresSecretsOptIn returns true. */
824
826
  allowSecrets?: boolean;
@@ -949,9 +951,7 @@ declare function canonicalReplicationIdentity(raw: ReplicationIdentity): Replica
949
951
  /** Stable in-memory key; durable adapters hash its UTF-8 bytes with their platform crypto. */
950
952
  declare function replicationIdentityKey(id: ReplicationIdentity): string;
951
953
 
952
- /** Published replica selector semantics: exact key plus descendants by segment. */
953
- declare function kvPrefixCovers(prefix: string, key: string): boolean;
954
954
  /** Whether replicating this space/prefix can copy encrypted secret material to disk. */
955
955
  declare function requiresSecretsOptIn(space: string, prefix: string): boolean;
956
956
 
957
- export { type KVListOptions as $, type AuthorityRefusal as A, type ReplicationScheduler as B, CLEAR_PENDING_WARNING as C, type ResolvedReplicationOptions as D, canonicalReplicationIdentity as E, kvPrefixCovers as F, replicationIdentityKey as G, requiresSecretsOptIn as H, DEFAULT_SIGNED_READ_URL_EXPIRY_MS as I, KVAction as J, type KVReplicationDeps as K, type LocalGetResult as L, type KVActionType as M, type KVBatchPutItem as N, type KVBatchPutOptions as O, type PendingWriteStore as P, type KVBatchPutResponse as Q, type ReplicationIdentity as R, type KVBatchReadResponse as S, type KVChange as T, type KVChangesAuthority as U, type KVChangesOptions as V, type KVChangesResponse as W, type KVCreateSignedReadUrlOptions as X, type KVDeleteOptions as Y, type KVGetOptions as Z, type KVHeadOptions as _, type KVReplicationController as a, type KVListResponse as a0, type KVPutOptions as a1, type KVResponse as a2, type KVResponseHeaders as a3, type KVServiceConfig as a4, type KVSignedReadUrlResponse as a5, type KVListPage as b, type KVReadThrough as c, type KVReplicaHandle as d, type KVReplicaSpec as e, type KVReplicaStorage as f, type LocalListResult as g, type LocalReadMeta as h, type LocalReplicaStatus as i, type LocalSyncResult as j, type PendingWriteRecord as k, type PendingWriteState as l, type PinnedKey as m, type PurgeTarget as n, type ReplicaAuthorityState as o, type ReplicaCoverage as p, type ReplicaDevice as q, type ReplicaGrantInfo as r, type ReplicaState as s, type ReplicaStatusEntry as t, type ReplicationAuthority as u, type ReplicationControl as v, type ReplicationEvent as w, type ReplicationOptions as x, type ReplicationPurgeReport as y, type ReplicationReason as z };
957
+ export { type KVListResponse as $, type AuthorityRefusal as A, type ReplicationScheduler as B, CLEAR_PENDING_WARNING as C, type ResolvedReplicationOptions as D, canonicalReplicationIdentity as E, replicationIdentityKey as F, requiresSecretsOptIn as G, DEFAULT_SIGNED_READ_URL_EXPIRY_MS as H, KVAction as I, type KVActionType as J, type KVReplicationDeps as K, type LocalGetResult as L, type KVBatchPutItem as M, type KVBatchPutOptions as N, type KVBatchPutResponse as O, type PendingWriteStore as P, type KVBatchReadResponse as Q, type ReplicationIdentity as R, type KVChange as S, type KVChangesAuthority as T, type KVChangesOptions as U, type KVChangesResponse as V, type KVCreateSignedReadUrlOptions as W, type KVDeleteOptions as X, type KVGetOptions as Y, type KVHeadOptions as Z, type KVListOptions as _, type KVReplicationController as a, type KVPutOptions as a0, type KVResponse as a1, type KVResponseHeaders as a2, type KVServiceConfig as a3, type KVSignedReadUrlResponse as a4, type KVListPage as b, type KVReadThrough as c, type KVReplicaHandle as d, type KVReplicaSpec as e, type KVReplicaStorage as f, type LocalListResult as g, type LocalReadMeta as h, type LocalReplicaStatus as i, type LocalSyncResult as j, type PendingWriteRecord as k, type PendingWriteState as l, type PinnedKey as m, type PurgeTarget as n, type ReplicaAuthorityState as o, type ReplicaCoverage as p, type ReplicaDevice as q, type ReplicaGrantInfo as r, type ReplicaState as s, type ReplicaStatusEntry as t, type ReplicationAuthority as u, type ReplicationControl as v, type ReplicationEvent as w, type ReplicationOptions as x, type ReplicationPurgeReport as y, type ReplicationReason as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinycloud/sdk-services",
3
- "version": "3.2.0-beta.3",
3
+ "version": "3.2.0-beta.5",
4
4
  "description": "TinyCloud SDK Services - Platform-agnostic service implementations",
5
5
  "author": "TinyCloud, Inc.",
6
6
  "license": "EGPL",
@@ -26,6 +26,16 @@
26
26
  "import": "./dist/kv/index.js",
27
27
  "require": "./dist/kv/index.cjs"
28
28
  },
29
+ "./kv/replication/prefix": {
30
+ "import": {
31
+ "types": "./dist/kv/replication/prefix.d.ts",
32
+ "default": "./dist/kv/replication/prefix.js"
33
+ },
34
+ "require": {
35
+ "types": "./dist/kv/replication/prefix.d.cts",
36
+ "default": "./dist/kv/replication/prefix.cjs"
37
+ }
38
+ },
29
39
  "./kv/replication": {
30
40
  "import": {
31
41
  "types": "./dist/kv/replication/index.d.ts",
@@ -56,6 +66,9 @@
56
66
  "*": {
57
67
  "kv/replication": [
58
68
  "dist/kv/replication/index.d.ts"
69
+ ],
70
+ "kv/replication/prefix": [
71
+ "dist/kv/replication/prefix.d.ts"
59
72
  ]
60
73
  }
61
74
  },