@voltro/kv 0.89.1 → 0.90.0

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/README.md CHANGED
@@ -24,113 +24,3 @@ deliberately short so there is nothing here to drift out of date.
24
24
 
25
25
  Proprietary. © 2026 Voltro UG. Your use is governed by the
26
26
  [Terms of Service](https://voltro.cloud/legal/terms). See the bundled `LICENSE`.
27
- ## Native Redis topologies
28
-
29
- RESP connection URLs distinguish standalone Redis, Cluster seeds and Sentinel
30
- master groups. Secure schemes retain certificate verification; Sentinel can use
31
- separate control credentials. Default and batch reads stay on primaries, scans visit
32
- discovered primaries and cross-slot deletion has no cross-key atomicity promise.
33
- Scheme names are case insensitive. Static, environment and tenant-resolved
34
- credentials share metadata admission before transport acquisition.
35
- Nonzero standalone/Sentinel databases require confirmed SELECT on every socket;
36
- failed selection closes the transport instead of allowing database-zero commands.
37
- Owned Pub/Sub sockets report gaps and acknowledge restored subscriptions before
38
- reconnection. See [connections](https://docs.voltro.dev/docs/caching/connections)
39
- for URL admission, migration, ownership and explicit eventual reads. Individual
40
- HotStore reads may request `consistency: 'eventual'`; the connection selects
41
- `readFrom: 'primary' | 'replica' | 'nearest'` through an owned read-only
42
- port. Native/HTTP Lua uses EVAL_RO. `nearest` probes fresh roundtrip times.
43
- Readers share tenant prefixes, rotation, leases and shutdown with the primary.
44
- A lost mutation response is an unknown outcome and never authorizes replay.
45
-
46
- ## Named Analytics
47
-
48
- Declare analytical destinations under `connections.analytics` and select the
49
- app-wide sink with `analytics: { connection: 'analytics:warehouse' }`. The
50
- app owns the pool; handlers and plugins borrow it. Install the selected
51
- provider package in the app. DuckDB does not require an application SQL store.
52
-
53
- ```ts
54
- import { env } from '@voltro/kv/connection'
55
-
56
- export default {
57
- name: 'analyticsApp',
58
- type: 'api',
59
- store: 'memory',
60
- connections: {
61
- analytics: {
62
- warehouse: { provider: 'duckdb', path: env('DUCKDB_PATH') },
63
- },
64
- defaults: { analytics: 'warehouse' },
65
- },
66
- analytics: { connection: 'analytics:warehouse' },
67
- }
68
- ```
69
-
70
- Declarations use `provider: 'duckdb' | 'clickhouse' | 'tinybird' | 'posthog'`.
71
- Endpoints and credentials use `env()`; DuckDB paths may use strings or `env()`.
72
- Operator overrides use `CONNECTIONS_ANALYTICS_<NAME>_<FIELD>`, including
73
- `URL`, `USERNAME`, `PASSWORD`, `PATH`, `TOKEN`, `API_URL`, `API_KEY` and `HOST`.
74
- The provider, identifiers, mirror tables and batching policy remain declared.
75
- Production network destinations require HTTPS. Missing credentials refuse boot.
76
-
77
- DuckDB and ClickHouse initialize their event schema before the read-only
78
- readiness query; Tinybird checks the configured aggregate pipe without emitting
79
- an event. PostHog acquisition currently refuses: its capture-key read-only probe
80
- is unfinished. It is not a silent noop or an event-writing health check.
81
-
82
- `dynamicAnalytics(resolve, { ttlMs })` declares a tenant-owned destination.
83
- Borrow it with `registry.analytics('analytics:tenant', { tenantId })`; declaration
84
- validation and inventory do not invoke the resolver. App-wide Analytics selection
85
- requires a static declaration. A tenant-scoped destination must be borrowed in
86
- its tenant context. The registry owns TTL/LRU bounds and disposal.
87
-
88
- Borrowed sinks follow `registry.reload` and the app owner's SIGHUP handling.
89
- Replacement readiness, provider, capabilities and mirror schema are checked
90
- before switching; failure retains the old generation. Accepted calls retain
91
- their generation until completion. Sink disposal never closes another consumer's
92
- shared pool. Closing the app owner refuses new operations and awaits cleanup.
93
-
94
- Connection inventory, the shared Connections panel and `voltro doctor
95
- --connections` include Analytics references without paths, endpoints,
96
- credentials or tenant IDs. Doctor probes initialize the provider schema before
97
- measuring a read-only query; they do not prove event delivery or capacity.
98
- Dynamic operator probes require an explicit tenant context.
99
-
100
- Tests can inject an `AnalyticsConnectionConnector` into the registry or pass
101
- `connectAnalytics` in `withConnections` options. The connector returns a sink,
102
- read-only probe and owned close Effect. Tests must still supply valid declarations.
103
- The browser-safe port and errors are exported from `@voltro/kv/analytics`; the
104
- runtime re-exports the same contract without a second error implementation.
105
-
106
- ## Unavailable read policy
107
-
108
- Plugin connection roles declare `onUnavailable: 'degrade' | 'fail'`; omitted
109
- policy means `fail`. The app passes each admitted role policy into plugin
110
- lifecycle and store-binding contexts and shows it in connection inventory.
111
- `readHotStoreWithFallback` from `@voltro/kv/hot/contract` exposes only HotStore
112
- read methods. Under `degrade`, a typed unavailable read selects the caller's
113
- explicit fallback once. SQL remains the durable source; the helper does not
114
- write, rebuild or retry. Other failures and interruption remain failures.
115
- Never invoke it from a Room tick.
116
-
117
- ## Conditional lease ownership
118
-
119
- `HotStore.compareDelete` and `compareExpire` atomically compare a `setNx` lease
120
- value before removal or TTL renewal. Missing, expired and mismatched values
121
- return false without changing a successor. Other structures fail with wrongType.
122
- Use a fresh server-owned value per acquisition, outside ticks. Temporary leases
123
- do not replace durable SQL revision/epoch fencing. Replacement ports must implement
124
- both operations and their atomic batch variants; migration
125
- `0.87.0/67_hot-store-conditional-leases` reports the contract. See the bilingual
126
- [HotStore guide](https://docs.voltro.dev/docs/caching/hot-store).
127
-
128
- ## Native command timeouts
129
-
130
- RESP declarations, resolved dynamic configuration and direct `connect` accept
131
- `connectTimeoutMs` and `commandTimeoutMs`. Values are integer milliseconds from
132
- 1 through 2147483647; HTTP/memory refuse them. Native primary, reader and
133
- subscriber construction shares these settings. A timed-out write remains an
134
- unknown outcome, not cancelled or safe to replay. Existing ownership and
135
- no-resend behavior remain authoritative. These are per-transport limits, not
136
- an aggregate business-operation deadline. See the bilingual connections guide.
@@ -3,255 +3,279 @@ var e = class extends Error {
3
3
  constructor() {
4
4
  super("Invalid atomic cache command or state."), this.name = "CacheAtomicProtocolError";
5
5
  }
6
- }, t = 9e5, n = () => {
6
+ }, t = 9e5, n = 64, r = 200, i = () => {
7
7
  throw new e();
8
- }, r = (e, t) => {
9
- if (typeof e != "object" || !e || Array.isArray(e) || Object.getPrototypeOf(e) !== Object.prototype && Object.getPrototypeOf(e) !== null) return n();
10
- let r = e;
11
- return Object.keys(r).length !== t.length || t.some((e) => !Object.hasOwn(r, e)) ? n() : r;
12
- }, i = (e) => typeof e == "string" ? e : n(), a = (e) => {
13
- let t = i(e);
14
- return /^(?:[a-f0-9]{2})+$/.test(t) ? t : n();
15
- }, o = (e) => {
16
- let t = i(e);
17
- return /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(t) ? t : n();
18
- }, s = (e, t, r) => {
19
- if (!Array.isArray(e)) return n();
20
- let i = e.map(t);
21
- return i.some((e, t) => t > 0 && r(i[t - 1]) >= r(e)) ? n() : i;
22
- }, c = (e) => s(e, a, (e) => e), l = (e) => Array.isArray(e) ? e : typeof e == "object" && e && Object.keys(e).length === 0 && (Object.getPrototypeOf(e) === Object.prototype || Object.getPrototypeOf(e) === null) ? [] : n(), u = (e) => {
8
+ }, a = (e, t) => {
9
+ if (typeof e != "object" || !e || Array.isArray(e) || Object.getPrototypeOf(e) !== Object.prototype && Object.getPrototypeOf(e) !== null) return i();
10
+ let n = e;
11
+ return Object.keys(n).length !== t.length || t.some((e) => !Object.hasOwn(n, e)) ? i() : n;
12
+ }, o = (e) => typeof e == "string" ? e : i(), s = (e) => {
13
+ let t = o(e);
14
+ return /^(?:[a-f0-9]{2})+$/.test(t) ? t : i();
15
+ }, c = (e) => {
16
+ let t = o(e);
17
+ return /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(t) ? t : i();
18
+ }, l = (e, t, n) => {
19
+ if (!Array.isArray(e)) return i();
20
+ let r = e.map(t);
21
+ return r.some((e, t) => t > 0 && n(r[t - 1]) >= n(e)) ? i() : r;
22
+ }, u = (e) => l(e, s, (e) => e), d = (e, t) => typeof e == "number" && Number.isSafeInteger(e) && e >= 1 && e <= t ? e : i(), f = (e) => Array.isArray(e) ? e : typeof e == "object" && e && Object.keys(e).length === 0 && (Object.getPrototypeOf(e) === Object.prototype || Object.getPrototypeOf(e) === null) ? [] : i(), p = (e) => {
23
23
  if (e === null) return null;
24
- let t = r(e, ["version", "tags"]);
24
+ let t = a(e, ["version", "tags"]);
25
25
  return {
26
- version: o(t.version),
27
- tags: c(l(t.tags))
26
+ version: c(t.version),
27
+ tags: u(f(t.tags))
28
28
  };
29
- }, d = (e) => {
30
- let t = i(e);
29
+ }, m = (e) => {
30
+ let t = o(e);
31
31
  return t[36] === ":" ? {
32
- version: o(t.slice(0, 36)),
33
- key: a(t.slice(37))
34
- } : n();
35
- }, f = (e) => typeof e == "string" ? Array.from(new TextEncoder().encode(JSON.stringify(e)), (e) => e.toString(16).padStart(2, "0")).join("") : n(), p = (e) => `{voltro:cache:atomic:${f(e)}}:r`, m = (e) => {
36
- if (typeof e != "object" || !e || Array.isArray(e)) return n();
32
+ version: c(t.slice(0, 36)),
33
+ key: s(t.slice(37))
34
+ } : i();
35
+ }, h = (e) => typeof e == "string" ? Array.from(new TextEncoder().encode(JSON.stringify(e)), (e) => e.toString(16).padStart(2, "0")).join("") : i(), g = (e) => `{voltro:cache:atomic:${h(e)}}:r`, _ = (e) => l(e, (e) => {
36
+ let t = a(e, ["key", "snapshot"]);
37
+ return {
38
+ key: s(t.key),
39
+ snapshot: p(t.snapshot)
40
+ };
41
+ }, (e) => e.key), v = (e) => {
42
+ if (typeof e != "object" || !e || Array.isArray(e)) return i();
37
43
  let t = e.op;
38
44
  switch (t) {
39
- case "revision": return r(e, ["op"]), { op: t };
40
- case "fence": return r(e, ["op"]), { op: t };
45
+ case "fence": return a(e, ["op"]), { op: t };
41
46
  case "inspect": return {
42
47
  op: t,
43
- key: a(r(e, ["op", "key"]).key)
44
- };
45
- case "inspect-values": return {
46
- op: t,
47
- keys: c(r(e, ["op", "keys"]).keys)
48
+ key: s(a(e, ["op", "key"]).key)
48
49
  };
50
+ case "inspect-values": {
51
+ let n = u(a(e, ["op", "keys"]).keys);
52
+ return n.length > 64 ? i() : {
53
+ op: t,
54
+ keys: n
55
+ };
56
+ }
49
57
  case "read": {
50
- let n = r(e, [
58
+ let n = a(e, [
51
59
  "op",
52
60
  "key",
53
61
  "snapshot"
54
- ]), i = u(n.snapshot);
62
+ ]), r = p(n.snapshot);
55
63
  return {
56
64
  op: t,
57
- key: a(n.key),
58
- snapshot: i
65
+ key: s(n.key),
66
+ snapshot: r
59
67
  };
60
68
  }
61
- case "tag": return {
62
- op: t,
63
- tag: a(r(e, ["op", "tag"]).tag)
64
- };
65
69
  case "scan": {
66
- let a = i(r(e, ["op", "cursor"]).cursor);
67
- return !/^(0|[1-9][0-9]{0,19})$/.test(a) || BigInt(a) > 18446744073709551615n ? n() : {
70
+ let n = a(e, [
71
+ "op",
72
+ "cursor",
73
+ "count"
74
+ ]), r = o(n.cursor);
75
+ return !/^(0|[1-9][0-9]{0,19})$/.test(r) || BigInt(r) > 18446744073709551615n ? i() : {
68
76
  op: t,
69
- cursor: a
77
+ cursor: r,
78
+ count: d(n.count, 200)
70
79
  };
71
80
  }
72
81
  case "write": {
73
- let s = r(e, [
82
+ let n = a(e, [
74
83
  "op",
75
84
  "key",
76
85
  "snapshot",
77
86
  "version",
78
- "revision",
79
87
  "tags",
80
88
  "value",
81
89
  "ttlMs",
82
90
  "fence"
83
- ]), l = u(s.snapshot), d = o(s.version);
84
- if (d === l?.version) return n();
85
- let f = s.ttlMs;
86
- if (f !== null && (typeof f != "number" || !Number.isSafeInteger(f) || f < 0)) return n();
87
- let p = s.fence;
88
- return p !== null && (typeof p != "number" || !Number.isSafeInteger(p) || p < 0) ? n() : {
91
+ ]), r = p(n.snapshot), l = c(n.version);
92
+ if (l === r?.version) return i();
93
+ let d = n.ttlMs;
94
+ if (d !== null && (typeof d != "number" || !Number.isSafeInteger(d) || d < 0)) return i();
95
+ let f = n.fence;
96
+ return f !== null && (typeof f != "number" || !Number.isSafeInteger(f) || f < 0) ? i() : {
89
97
  op: t,
90
- key: a(s.key),
91
- snapshot: l,
92
- version: d,
93
- revision: o(s.revision),
94
- tags: c(s.tags),
95
- value: i(s.value),
96
- ttlMs: f,
97
- fence: p
98
+ key: s(n.key),
99
+ snapshot: r,
100
+ version: l,
101
+ tags: u(n.tags),
102
+ value: o(n.value),
103
+ ttlMs: d,
104
+ fence: f
98
105
  };
99
106
  }
100
107
  case "remove": {
101
- let n = r(e, [
108
+ let n = a(e, [
102
109
  "op",
103
110
  "key",
104
- "snapshot",
105
- "revision"
111
+ "snapshot"
106
112
  ]);
107
113
  return {
108
114
  op: t,
109
- key: a(n.key),
110
- snapshot: u(n.snapshot),
111
- revision: o(n.revision)
115
+ key: s(n.key),
116
+ snapshot: p(n.snapshot)
112
117
  };
113
118
  }
114
- case "invalidate": {
115
- let c = r(e, [
119
+ case "retire": {
120
+ let n = a(e, [
116
121
  "op",
117
122
  "tag",
118
- "members",
119
- "snapshots",
120
- "revision"
121
- ]), l = s(c.members, (e) => (d(e), i(e)), (e) => e), f = s(c.snapshots, (e) => {
122
- let t = r(e, ["key", "snapshot"]);
123
- return {
124
- key: a(t.key),
125
- snapshot: u(t.snapshot)
126
- };
127
- }, (e) => e.key), p = [...new Set(l.map((e) => d(e).key))].sort();
128
- return p.length !== f.length || p.some((e, t) => f[t].key !== e) ? n() : {
123
+ "retired"
124
+ ]);
125
+ return {
129
126
  op: t,
130
- tag: a(c.tag),
131
- members: l,
132
- snapshots: f,
133
- revision: o(c.revision)
127
+ tag: s(n.tag),
128
+ retired: c(n.retired)
134
129
  };
135
130
  }
136
- case "clear": {
137
- let n = r(e, [
131
+ case "retired": {
132
+ let n = a(e, [
138
133
  "op",
139
- "keys",
140
- "revision"
134
+ "tag",
135
+ "retired",
136
+ "count"
141
137
  ]);
142
138
  return {
143
139
  op: t,
144
- keys: s(n.keys, i, (e) => e),
145
- revision: n.revision === null ? null : o(n.revision)
140
+ tag: s(n.tag),
141
+ retired: c(n.retired),
142
+ count: d(n.count, 64)
146
143
  };
147
144
  }
148
- default: return n();
145
+ case "purge": {
146
+ let n = a(e, [
147
+ "op",
148
+ "tag",
149
+ "retired",
150
+ "members",
151
+ "snapshots"
152
+ ]), r = l(n.members, (e) => (m(e), o(e)), (e) => e), u = _(n.snapshots), d = [...new Set(r.map((e) => m(e).key))].sort();
153
+ return r.length > 64 || d.length !== u.length || d.some((e, t) => u[t].key !== e) ? i() : {
154
+ op: t,
155
+ tag: s(n.tag),
156
+ retired: c(n.retired),
157
+ members: r,
158
+ snapshots: u
159
+ };
160
+ }
161
+ case "clear": return a(e, ["op"]), { op: t };
162
+ case "sweep": {
163
+ let n = a(e, [
164
+ "op",
165
+ "snapshots",
166
+ "retired"
167
+ ]), r = _(n.snapshots), s = l(n.retired, (e) => (m(e), o(e)), (e) => e);
168
+ return r.length > 64 || s.length > 64 ? i() : {
169
+ op: t,
170
+ snapshots: r,
171
+ retired: s
172
+ };
173
+ }
174
+ default: return i();
149
175
  }
150
- }, h = (e, t) => {
151
- let r = typeof e == "string" ? e.match(/\{voltro:cache:atomic:(?:[a-f0-9]{2})+\}:r$/)?.[0] : void 0;
152
- if (r === void 0) return n();
153
- let i = e.slice(0, -2), o = /* @__PURE__ */ new Set(), s = (e) => {
154
- o.add(`${i}:v:${a(e)}`);
155
- }, c = (e) => {
156
- o.add(`${i}:t:${a(e)}`);
157
- }, l = () => {
158
- o.add(`${i}:s`);
159
- }, u = (e) => {
160
- o.add(`${i}:e:${a(e)}`);
161
- };
176
+ }, y = (e, t) => {
177
+ if (typeof e != "string" || !/\{voltro:cache:atomic:(?:[a-f0-9]{2})+\}:r$/.test(e)) return i();
178
+ let n = e.slice(0, -2), r = /* @__PURE__ */ new Set(), a = (e) => {
179
+ r.add(`${n}:v:${s(e)}`);
180
+ }, o = (e) => {
181
+ r.add(`${n}:t:${s(e)}`);
182
+ }, c = () => {
183
+ r.add(`${n}:s`);
184
+ }, l = (e) => {
185
+ r.add(`${n}:e:${s(e)}`);
186
+ }, u = () => {
187
+ r.add(`${n}:g`);
188
+ }, d = (e) => {
189
+ m(e), r.add(`${n}:d:${e}`);
190
+ }, f = (e) => e.forEach((e) => {
191
+ a(e.key), e.snapshot?.tags.forEach(o);
192
+ });
162
193
  switch (t.op) {
163
194
  case "inspect":
164
- s(t.key);
195
+ a(t.key);
165
196
  break;
166
197
  case "inspect-values":
167
- t.keys.forEach(s);
198
+ t.keys.forEach(a);
168
199
  break;
169
200
  case "read":
170
- s(t.key), t.snapshot?.tags.forEach(c);
201
+ a(t.key), t.snapshot?.tags.forEach(o), u();
171
202
  break;
172
203
  case "fence":
173
- l();
204
+ c();
174
205
  break;
175
206
  case "write":
176
- s(t.key), t.tags.forEach(c), t.snapshot?.tags.forEach(c), t.fence !== null && t.tags.forEach(u);
207
+ a(t.key), t.tags.forEach(o), t.snapshot?.tags.forEach(o), u(), t.fence !== null && t.tags.forEach(l);
177
208
  break;
178
209
  case "remove":
179
- s(t.key), t.snapshot?.tags.forEach(c);
210
+ a(t.key), t.snapshot?.tags.forEach(o), u();
180
211
  break;
181
- case "tag":
182
- c(t.tag);
212
+ case "retire":
213
+ o(t.tag), c(), l(t.tag), d(b(t.retired, t.tag));
183
214
  break;
184
- case "invalidate":
185
- c(t.tag), l(), u(t.tag), t.snapshots.forEach((e) => {
186
- s(e.key), e.snapshot?.tags.forEach(c);
187
- });
215
+ case "retired":
216
+ d(b(t.retired, t.tag));
188
217
  break;
189
- case "clear": {
190
- let s = r.slice(0, -2), c = /* @__PURE__ */ new Set();
191
- for (let l of t.keys) {
192
- let t = l;
193
- if (l !== e && !l.startsWith(`${i}:v:`) && !l.startsWith(`${i}:t:`)) {
194
- if (l === r) t = e;
195
- else if (l.startsWith(`${s}:v:`) || l.startsWith(`${s}:t:`)) t = i + l.slice(s.length);
196
- else return n();
197
- }
198
- if (c.has(t)) return n();
199
- c.add(t), t !== e && (a(t.slice(i.length + 3)), o.add(t));
200
- }
218
+ case "purge":
219
+ o(t.tag), d(b(t.retired, t.tag)), u(), f(t.snapshots);
201
220
  break;
202
- }
221
+ case "clear":
222
+ u();
223
+ break;
224
+ case "sweep": u(), f(t.snapshots), t.retired.forEach(d);
203
225
  }
204
- return [e, ...[...o].sort()];
205
- }, g = (e, t) => `${o(t)}:${a(e)}`, _ = (e) => e === void 0 ? null : !Number.isFinite(e) || !Number.isSafeInteger(Math.ceil(e)) ? n() : Math.max(0, Math.ceil(e)), v = (e) => {
206
- if (typeof e != "object" || !e || Array.isArray(e) || Object.getPrototypeOf(e) !== Object.prototype && Object.getPrototypeOf(e) !== null) return n();
226
+ return [e, ...[...r].sort()];
227
+ }, b = (e, t) => `${c(e)}:${s(t)}`, x = (e, t) => `${c(t)}:${s(e)}`, S = (e) => e === void 0 ? null : !Number.isFinite(e) || !Number.isSafeInteger(Math.ceil(e)) ? i() : Math.max(0, Math.ceil(e)), C = (e) => {
228
+ if (typeof e != "object" || !e || Array.isArray(e) || Object.getPrototypeOf(e) !== Object.prototype && Object.getPrototypeOf(e) !== null) return i();
207
229
  let t = e;
208
- if (Object.keys(t).some((e) => e !== "maxTagMembers" && e !== "maxReplyBytes")) return n();
209
- for (let [e, r] of Object.entries(t)) if (typeof r != "number" || !Number.isSafeInteger(r) || r < (e === "maxReplyBytes" ? 128 : 1)) return n();
230
+ if (Object.keys(t).some((e) => e !== "maxTagMembers" && e !== "maxReplyBytes")) return i();
231
+ for (let [e, n] of Object.entries(t)) if (typeof n != "number" || !Number.isSafeInteger(n) || n < (e === "maxReplyBytes" ? 128 : 1)) return i();
210
232
  return {
211
233
  ...Object.hasOwn(t, "maxTagMembers") ? { maxTagMembers: t.maxTagMembers } : {},
212
234
  ...Object.hasOwn(t, "maxReplyBytes") ? { maxReplyBytes: t.maxReplyBytes } : {}
213
235
  };
214
- }, y = (e) => {
215
- if (typeof e != "string") return n();
236
+ }, w = (e) => {
237
+ if (typeof e != "string") return i();
216
238
  let t;
217
239
  try {
218
240
  t = JSON.parse(e);
219
241
  } catch {
220
- return n();
242
+ return i();
221
243
  }
222
- let i = r(t, ["status", "value"]), a = i.status;
223
- return a !== "ok" && a !== "conflict" && a !== "limit" || a !== "ok" && i.value !== null ? n() : {
224
- status: a,
225
- value: i.value
244
+ let n = a(t, ["status", "value"]), r = n.status;
245
+ return r !== "ok" && r !== "conflict" && r !== "limit" || r !== "ok" && n.value !== null ? i() : {
246
+ status: r,
247
+ value: n.value
226
248
  };
227
- }, b = (e) => s(l(e), (e) => {
228
- let t = r(e, ["key", "snapshot"]);
229
- return {
230
- key: a(t.key),
231
- snapshot: u(t.snapshot)
232
- };
233
- }, (e) => e.key), x = (e, t) => {
234
- let n = r(t, ["cursor", "keys"]), a = i(n.cursor);
235
- m({
249
+ }, T = (e) => _(f(e)), E = (e, t) => {
250
+ let n = a(t, ["cursor", "keys"]), r = o(n.cursor);
251
+ v({
252
+ op: "scan",
253
+ cursor: r,
254
+ count: 1
255
+ }), y(e, {
236
256
  op: "scan",
237
- cursor: a
257
+ cursor: r,
258
+ count: 1
238
259
  });
239
- let o = e.slice(0, -2), s = l(n.keys).map((e) => `${o}${i(e)}`).filter((e) => e !== `${o}:s` && !e.startsWith(`${o}:e:`));
240
- return h(e, {
241
- op: "clear",
242
- keys: [...new Set(s)].sort(),
243
- revision: null
244
- }), {
245
- cursor: a,
246
- keys: s
260
+ let c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set();
261
+ for (let e of f(n.keys)) {
262
+ let t = o(e);
263
+ if (t.startsWith(":v:")) c.add(s(t.slice(3)));
264
+ else if (t.startsWith(":d:")) m(t.slice(3)), l.add(t.slice(3));
265
+ else if (t.startsWith(":t:") || t.startsWith(":e:")) s(t.slice(3));
266
+ else if (t !== ":r" && t !== ":s" && t !== ":g") return i();
267
+ }
268
+ return {
269
+ cursor: r,
270
+ values: [...c].sort(),
271
+ retired: [...l].sort()
247
272
  };
248
- }, S = (e) => [
249
- "revision",
273
+ }, D = (e) => [
250
274
  "fence",
251
275
  "inspect",
252
276
  "inspect-values",
253
277
  "read",
254
- "tag",
278
+ "retired",
255
279
  "scan"
256
280
  ].includes(e.op);
257
- export { t as CACHE_FENCE_RETENTION_MS, e as CacheAtomicProtocolError, l as cacheAtomicArray, f as cacheAtomicComponent, h as cacheAtomicKeys, d as cacheAtomicMember, g as cacheAtomicMembership, p as cacheAtomicRoot, x as cacheAtomicScanPage, u as cacheAtomicSnapshot, _ as cacheAtomicTtl, b as cacheAtomicValueSnapshots, m as decodeCacheAtomicCommand, v as decodeCacheAtomicPolicy, y as decodeCacheAtomicReply, S as isCacheAtomicRead };
281
+ export { n as CACHE_ATOMIC_PAGE, r as CACHE_ATOMIC_SCAN, t as CACHE_FENCE_RETENTION_MS, e as CacheAtomicProtocolError, f as cacheAtomicArray, h as cacheAtomicComponent, y as cacheAtomicKeys, m as cacheAtomicMember, x as cacheAtomicMembership, b as cacheAtomicRetired, g as cacheAtomicRoot, E as cacheAtomicScanPage, p as cacheAtomicSnapshot, S as cacheAtomicTtl, T as cacheAtomicValueSnapshots, v as decodeCacheAtomicCommand, C as decodeCacheAtomicPolicy, w as decodeCacheAtomicReply, D as isCacheAtomicRead };