@voltro/kv 0.89.2 → 0.91.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.
@@ -1,11 +1,11 @@
1
1
  import { KvError as e } from "./errors.js";
2
- import { missingDriver as t } from "./driverModule.js";
3
- import { createNativeRedisConnection as n, disconnectNativeRedis as r, nativeRedisOptions as i, nativeRedisTopology as a } from "./nativeRedisTopology.js";
2
+ import { createNativeRedisConnection as t, disconnectNativeRedis as n, nativeRedisOptions as r, nativeRedisTopology as i } from "./nativeRedisTopology.js";
3
+ import { missingDriver as a } from "./driverModule.js";
4
4
  import { Effect as o } from "effect";
5
5
  // src/connectionSubscriber.ts
6
6
  var s = async (e, o) => {
7
7
  o.throwIfAborted();
8
- let s = await n(e, "subscriber"), c, l = () => Promise.all([r(s), c === void 0 ? Promise.resolve() : r({
8
+ let s = await t(e, "subscriber"), c, l = () => Promise.all([n(s), c === void 0 ? Promise.resolve() : n({
9
9
  kind: "standalone",
10
10
  client: c
11
11
  })]).then(() => void 0), u = () => {
@@ -17,19 +17,19 @@ var s = async (e, o) => {
17
17
  client: s.client,
18
18
  dispose: l
19
19
  };
20
- let n = s.client.nodes("master").find((e) => e.status === "ready");
21
- if (n === void 0) throw Error("No ready Cluster primary");
22
- let u = n.options.host, d = n.options.port;
20
+ let t = s.client.nodes("master").find((e) => e.status === "ready");
21
+ if (t === void 0) throw Error("No ready Cluster primary");
22
+ let u = t.options.host, d = t.options.port;
23
23
  if (u === void 0 || d === void 0) throw Error("Cluster primary endpoint missing");
24
- let f = a(e);
24
+ let f = i(e);
25
25
  if (f.kind !== "cluster") throw Error("Expected Cluster topology");
26
- let { default: p } = await import("ioredis").catch(t("ioredis", "A Redis subscriber connection"));
26
+ let { default: p } = await import("ioredis").catch(a("ioredis", "A Redis subscriber connection"));
27
27
  return o.throwIfAborted(), c = new p({
28
28
  ...f.options,
29
- ...i("subscriber"),
29
+ ...r("subscriber"),
30
30
  host: u,
31
31
  port: d
32
- }), c.on("error", () => {}), await c.connect(), o.throwIfAborted(), await r(s), o.throwIfAborted(), {
32
+ }), c.on("error", () => {}), await c.connect(), o.throwIfAborted(), await n(s), o.throwIfAborted(), {
33
33
  client: c,
34
34
  dispose: l
35
35
  };
@@ -1,6 +1,6 @@
1
1
  import { consumeHotRateLimit as e } from "./hotRateLimit.js";
2
- import { hotStoreFromRunner as t, validateHotOp as n } from "./hotOperations.js";
3
- import { applyHotOperations as r, compareHotMembers as i } from "./hotState.js";
2
+ import { applyHotOperations as t, compareHotMembers as n } from "./hotState.js";
3
+ import { hotStoreFromRunner as r, validateHotOp as i } from "./hotOperations.js";
4
4
  import { readHotStoreWithFallback as a } from "./hotReadAvailability.js";
5
5
  import { Context as o, Schema as s } from "effect";
6
6
  // src/HotStore.ts
@@ -14,4 +14,4 @@ var c = class extends s.TaggedError()("HotError", {
14
14
  "unavailable"
15
15
  ])
16
16
  }) {}, l = class extends o.Service()("@voltro/HotStore") {};
17
- export { c as HotError, l as HotStore, r as applyHotOperations, i as compareHotMembers, e as consumeHotRateLimit, t as hotStoreFromRunner, a as readHotStoreWithFallback, n as validateHotOp };
17
+ export { c as HotError, l as HotStore, t as applyHotOperations, n as compareHotMembers, e as consumeHotRateLimit, r as hotStoreFromRunner, a as readHotStoreWithFallback, i as validateHotOp };
@@ -6,6 +6,23 @@ import { Schema } from 'effect';
6
6
  import { Stream } from 'effect';
7
7
  import { YieldableError } from 'effect/Cause';
8
8
 
9
+ /** Tag and replacement path. A replacement backend proves itself with
10
+ * `conformance`, the same suite the memory and Redis backends run. */
11
+ export declare const hotBackendPortFixture: {
12
+ kind: "port";
13
+ tag: typeof HotStore;
14
+ fakeLayer: Layer.Layer<HotStore, HotError, never>;
15
+ conformance: (name: string, fixture: () => HotConformanceFixture, tests: HotConformanceTestApi) => void;
16
+ probe: {
17
+ run: () => Effect.Effect<number, HotError, never>;
18
+ expected: number;
19
+ };
20
+ overrideProbe: {
21
+ run: () => Effect.Effect<number, HotError, never>;
22
+ expected: number;
23
+ };
24
+ };
25
+
9
26
  declare interface HotBucketConfig {
10
27
  readonly capacity: number;
11
28
  readonly refillPerSec: number;
@@ -193,6 +210,9 @@ declare const HotStore_base: Context.ServiceClass<HotStore, "@voltro/HotStore",
193
210
  /** Run exactly the same behavioral contract against a backend or a replacement port. */
194
211
  export declare const hotStoreConformance: (name: string, fixture: () => HotConformanceFixture, tests: HotConformanceTestApi) => void;
195
212
 
213
+ /** The in-memory backend: one fresh store per provided scope. */
214
+ export declare const hotStoreFakeLayer: Layer.Layer<HotStore, HotError>;
215
+
196
216
  declare interface HotStoreShape {
197
217
  readonly zadd: (key: string, members: ReadonlyArray<HotMember>, options?: HotZaddOptions) => Effect.Effect<void, HotError>;
198
218
  readonly zrem: (key: string, members: ReadonlyArray<string>) => Effect.Effect<number, HotError>;
@@ -1 +1,3 @@
1
- export { hotStoreConformance } from "./hotStoreConformance.js";
1
+ import { hotStoreConformance as e } from "./hotStoreConformance.js";
2
+ import { hotBackendPortFixture as t, hotStoreFakeLayer as n } from "./hotStoreFixtures.js";
3
+ export { t as hotBackendPortFixture, e as hotStoreConformance, n as hotStoreFakeLayer };
package/dist/hot.d.ts CHANGED
@@ -280,7 +280,7 @@ declare interface ConnectionPoolSnapshot {
280
280
  readonly source: 'config' | 'environment' | 'override';
281
281
  readonly label?: string;
282
282
  readonly region?: string;
283
- readonly persistence?: RedisConnectionConfig['persistence'];
283
+ readonly persistence?: NonNullable<RedisConnectionConfig['persistence']>;
284
284
  }
285
285
 
286
286
  /** Borrowed Pub/Sub port. A consumer owns registrations, never broker sockets. */
@@ -608,6 +608,22 @@ export declare interface HotStoreShape {
608
608
  };
609
609
  }
610
610
 
611
+ /** Inventory of the hot store's replaceable part as actual exports: the backend
612
+ * behind the `HotStore` Tag. `hotSystemManifest.test.ts` runs the fixture and
613
+ * the shared conformance suite against a replacement. Routing is an option of
614
+ * `layerRoutedHotRedis`, not a slot. */
615
+ export declare const hotStoreSystemContractManifest: Readonly<{
616
+ slots: Readonly<{}>;
617
+ ports: Readonly<{
618
+ backend: Readonly<{
619
+ tagExport: "HotStore";
620
+ fakeLayerExport: "hotStoreFakeLayer";
621
+ fixtureExport: "hotBackendPortFixture";
622
+ }>;
623
+ }>;
624
+ events: readonly string[];
625
+ }>;
626
+
611
627
  export declare interface HotTtl {
612
628
  readonly ttlMs?: number;
613
629
  }
package/dist/hot.js CHANGED
@@ -1,7 +1,8 @@
1
- import { consumeHotRateLimit as e } from "./hotRateLimit.js";
2
- import { readHotStoreWithFallback as t } from "./hotReadAvailability.js";
3
- import { HotError as n, HotStore as r } from "./hot-contract.js";
4
- import { HOT_MEMORY_DEFAULTS as i, layerHotMemory as a, makeMemoryHotStore as o } from "./hotMemory.js";
5
- import { HOT_REDIS_DEFAULTS as s, layerHotRedis as c, makeRedisHotStore as l } from "./hotRedis.js";
6
- import { layerRoutedHotRedis as u } from "./hotRouting.js";
7
- export { i as HOT_MEMORY_DEFAULTS, s as HOT_REDIS_DEFAULTS, n as HotError, r as HotStore, e as consumeHotRateLimit, a as layerHotMemory, c as layerHotRedis, u as layerRoutedHotRedis, o as makeMemoryHotStore, l as makeRedisHotStore, t as readHotStoreWithFallback };
1
+ import { HotError as e, HotStore as t } from "./hot-contract.js";
2
+ import { consumeHotRateLimit as n } from "./hotRateLimit.js";
3
+ import { HOT_MEMORY_DEFAULTS as r, layerHotMemory as i, makeMemoryHotStore as a } from "./hotMemory.js";
4
+ import { HOT_REDIS_DEFAULTS as o, layerHotRedis as s, makeRedisHotStore as c } from "./hotRedis.js";
5
+ import { layerRoutedHotRedis as l } from "./hotRouting.js";
6
+ import { readHotStoreWithFallback as u } from "./hotReadAvailability.js";
7
+ import { hotStoreSystemContractManifest as d } from "./hotSystemManifest.js";
8
+ export { r as HOT_MEMORY_DEFAULTS, o as HOT_REDIS_DEFAULTS, e as HotError, t as HotStore, n as consumeHotRateLimit, d as hotStoreSystemContractManifest, i as layerHotMemory, s as layerHotRedis, l as layerRoutedHotRedis, a as makeMemoryHotStore, c as makeRedisHotStore, u as readHotStoreWithFallback };
package/dist/hotMemory.js CHANGED
@@ -1,27 +1,27 @@
1
- import { hotStoreFromRunner as e, validateHotOp as t } from "./hotOperations.js";
2
- import { applyHotOperations as n, compareHotMembers as r } from "./hotState.js";
3
- import { HotError as i, HotStore as a } from "./hot-contract.js";
1
+ import { HotError as e, HotStore as t } from "./hot-contract.js";
2
+ import { hotStoreFromRunner as n, validateHotOp as r } from "./hotOperations.js";
3
+ import { applyHotOperations as i, compareHotMembers as a } from "./hotState.js";
4
4
  import { Clock as o, Effect as s, Layer as c, Stream as l } from "effect";
5
5
  // src/hotMemory.ts
6
- var u = { sweepBatchSize: 32 }, d = (a = {}) => s.try({
6
+ var u = { sweepBatchSize: 32 }, d = (t = {}) => s.try({
7
7
  try: () => {
8
- let c = /* @__PURE__ */ new Map(), d = a.sweepBatchSize ?? u.sweepBatchSize;
8
+ let c = /* @__PURE__ */ new Map(), d = t.sweepBatchSize ?? u.sweepBatchSize;
9
9
  if (!Number.isSafeInteger(d) || d < 1) throw Error("HotStore sweepBatchSize must be a positive integer");
10
- let f = c.entries(), p = a.now === void 0 ? o.currentTimeMillis : s.sync(a.now);
11
- return e((e) => p.pipe(s.flatMap((r) => s.try({
10
+ let f = c.entries(), p = t.now === void 0 ? o.currentTimeMillis : s.sync(t.now);
11
+ return n((t) => p.pipe(s.flatMap((n) => s.try({
12
12
  try: () => {
13
- e.forEach(t);
13
+ t.forEach(r);
14
14
  for (let e = 0; e < d; e++) {
15
15
  let e = f.next();
16
16
  if (e.done) {
17
17
  f = c.entries();
18
18
  break;
19
19
  }
20
- e.value[1].expiresAt <= r && c.delete(e.value[0]);
20
+ e.value[1].expiresAt <= n && c.delete(e.value[0]);
21
21
  }
22
- return n(c, e, r);
22
+ return i(c, t, n);
23
23
  },
24
- catch: (e) => e instanceof i ? e : new i({
24
+ catch: (t) => t instanceof e ? t : new e({
25
25
  operation: "multi",
26
26
  key: "",
27
27
  reason: "invalid"
@@ -29,17 +29,17 @@ var u = { sweepBatchSize: 32 }, d = (a = {}) => s.try({
29
29
  }))), (e) => l.unwrap(p.pipe(s.map((t) => {
30
30
  let n = [];
31
31
  for (let [r, i] of c) i.expiresAt <= t ? c.delete(r) : r.startsWith(e) && n.push(r);
32
- return l.fromIterable(n.sort(r));
32
+ return l.fromIterable(n.sort(a));
33
33
  }))), {
34
34
  atomicMulti: !0,
35
35
  crossNode: !1,
36
36
  persistent: !1
37
37
  });
38
38
  },
39
- catch: () => new i({
39
+ catch: () => new e({
40
40
  operation: "connect",
41
41
  key: "",
42
42
  reason: "invalid"
43
43
  })
44
- }), f = (e = {}) => c.effect(a, d(e));
44
+ }), f = (e = {}) => c.effect(t, d(e));
45
45
  export { u as HOT_MEMORY_DEFAULTS, f as layerHotMemory, d as makeMemoryHotStore };
package/dist/hotRedis.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { RedisConnections as e } from "./connection.js";
2
- import { hotStoreFromRunner as t, isHotReadOperation as n, validateHotOp as r, validateHotReadOptions as i } from "./hotOperations.js";
3
- import { HotError as a, HotStore as o } from "./hot-contract.js";
2
+ import { HotError as t, HotStore as n } from "./hot-contract.js";
3
+ import { hotStoreFromRunner as r, isHotReadOperation as i, validateHotOp as a, validateHotReadOptions as o } from "./hotOperations.js";
4
4
  import { HOT_SCRIPT as s } from "./hotRedisScript.js";
5
5
  import { Effect as c, Layer as l, Option as u, Stream as d } from "effect";
6
6
  // src/hotRedis.ts
@@ -8,46 +8,46 @@ var f = {
8
8
  connectionName: "hot",
9
9
  namespace: "voltro:hot",
10
10
  scanCount: 200
11
- }, p = (e) => e.replace(/[\\*?\[\]]/g, "\\$&"), m = (e, o = f.namespace, l = f.scanCount) => {
12
- if (o.length === 0 || /[{}]/.test(o)) throw Error("HotStore namespace must be nonempty and contain no braces");
11
+ }, p = (e) => e.replace(/[\\*?\[\]]/g, "\\$&"), m = (e, n = f.namespace, l = f.scanCount) => {
12
+ if (n.length === 0 || /[{}]/.test(n)) throw Error("HotStore namespace must be nonempty and contain no braces");
13
13
  if (!Number.isSafeInteger(l) || l < 1) throw Error("HotStore scanCount must be a positive integer");
14
- let m = `{${o}}:`, h = (e) => m + e;
15
- return t((t, o) => c.gen(function* () {
14
+ let m = `{${n}}:`, h = (e) => m + e;
15
+ return r((n, r) => c.gen(function* () {
16
16
  if (yield* c.try({
17
17
  try: () => {
18
- if (t.forEach(r), i(o, t[0]?.op ?? "multi", t[0]?.key ?? ""), o?.consistency === "eventual" && (t.length !== 1 || !n(t[0]))) throw new a({
18
+ if (n.forEach(a), o(r, n[0]?.op ?? "multi", n[0]?.key ?? ""), r?.consistency === "eventual" && (n.length !== 1 || !i(n[0]))) throw new t({
19
19
  operation: "multi",
20
20
  key: "",
21
21
  reason: "invalid"
22
22
  });
23
23
  },
24
- catch: (e) => e instanceof a ? e : new a({
24
+ catch: (e) => e instanceof t ? e : new t({
25
25
  operation: "multi",
26
26
  key: "",
27
27
  reason: "invalid"
28
28
  })
29
- }), t.length === 0) return [];
29
+ }), n.length === 0) return [];
30
30
  let l = yield* c.tryPromise({
31
31
  try: () => {
32
- let n = o?.consistency === "eventual" ? e.readOnly : e;
33
- return n === void 0 ? Promise.reject(/* @__PURE__ */ Error("Read-only Lua is unavailable")) : n.eval(s, t.length, ...t.map((e) => h(e.key)), JSON.stringify(t));
32
+ let t = r?.consistency === "eventual" ? e.readOnly : e;
33
+ return t === void 0 ? Promise.reject(/* @__PURE__ */ Error("Read-only Lua is unavailable")) : t.eval(s, n.length, ...n.map((e) => h(e.key)), JSON.stringify(n));
34
34
  },
35
- catch: () => new a({
35
+ catch: () => new t({
36
36
  operation: "multi",
37
37
  key: "",
38
38
  reason: "unavailable"
39
39
  })
40
40
  }), u = yield* c.try({
41
41
  try: () => JSON.parse(String(l)),
42
- catch: () => new a({
42
+ catch: () => new t({
43
43
  operation: "multi",
44
44
  key: "",
45
45
  reason: "unavailable"
46
46
  })
47
47
  });
48
- return u.failure === void 0 ? u.results?.length === t.length ? yield* c.try({
49
- try: () => u.results.map(({ value: e }, n) => {
50
- let r = t[n];
48
+ return u.failure === void 0 ? u.results?.length === n.length ? yield* c.try({
49
+ try: () => u.results.map(({ value: e }, r) => {
50
+ let i = n[r];
51
51
  if ([
52
52
  "zrem",
53
53
  "zrank",
@@ -58,12 +58,12 @@ var f = {
58
58
  "hdel",
59
59
  "sadd",
60
60
  "srem"
61
- ].includes(r.op)) return e === null ? null : Number(e);
62
- if (r.op === "zrange") return Array.isArray(e) ? e.map((e) => ({
61
+ ].includes(i.op)) return e === null ? null : Number(e);
62
+ if (i.op === "zrange") return Array.isArray(e) ? e.map((e) => ({
63
63
  member: e.member,
64
64
  score: Number(e.score)
65
65
  })) : [];
66
- if (r.op === "tokenBucket") {
66
+ if (i.op === "tokenBucket") {
67
67
  let t = e;
68
68
  return {
69
69
  allowed: t.allowed,
@@ -71,48 +71,48 @@ var f = {
71
71
  retryAfterMs: Number(t.retryAfterMs)
72
72
  };
73
73
  }
74
- if (r.op === "rateLimit") {
75
- let t = e, n = {
76
- allowed: t.allowed,
77
- remaining: Number(t.remaining),
78
- resetAtMs: Number(t.resetAtMs),
79
- retryAfterMs: Number(t.retryAfterMs)
74
+ if (i.op === "rateLimit") {
75
+ let n = e, r = {
76
+ allowed: n.allowed,
77
+ remaining: Number(n.remaining),
78
+ resetAtMs: Number(n.resetAtMs),
79
+ retryAfterMs: Number(n.retryAfterMs)
80
80
  };
81
- if (typeof n.allowed != "boolean" || ![
82
- n.remaining,
83
- n.resetAtMs,
84
- n.retryAfterMs
85
- ].every(Number.isFinite)) throw new a({
81
+ if (typeof r.allowed != "boolean" || ![
82
+ r.remaining,
83
+ r.resetAtMs,
84
+ r.retryAfterMs
85
+ ].every(Number.isFinite)) throw new t({
86
86
  operation: "rateLimit",
87
- key: r.key,
87
+ key: i.key,
88
88
  reason: "unavailable"
89
89
  });
90
- return n;
90
+ return r;
91
91
  }
92
- return r.op === "smembers" && !Array.isArray(e) ? [] : e;
92
+ return i.op === "smembers" && !Array.isArray(e) ? [] : e;
93
93
  }),
94
- catch: (e) => e instanceof a ? e : new a({
94
+ catch: (e) => e instanceof t ? e : new t({
95
95
  operation: "multi",
96
96
  key: "",
97
97
  reason: "unavailable"
98
98
  })
99
- }) : yield* c.fail(new a({
99
+ }) : yield* c.fail(new t({
100
100
  operation: "multi",
101
101
  key: "",
102
102
  reason: "unavailable"
103
- })) : yield* c.fail(new a(u.failure));
104
- }), (t) => d.unwrap(c.sync(() => {
105
- let n = /* @__PURE__ */ new Set();
106
- return d.paginate("0", (r) => c.tryPromise({
107
- try: () => e.scan(r, `${p(m + t)}*`, l),
108
- catch: () => new a({
103
+ })) : yield* c.fail(new t(u.failure));
104
+ }), (n) => d.unwrap(c.sync(() => {
105
+ let r = /* @__PURE__ */ new Set();
106
+ return d.paginate("0", (i) => c.tryPromise({
107
+ try: () => e.scan(i, `${p(m + n)}*`, l),
108
+ catch: () => new t({
109
109
  operation: "scanPrefix",
110
- key: t,
110
+ key: n,
111
111
  reason: "unavailable"
112
112
  })
113
- }).pipe(c.map(({ cursor: e, keys: r }) => {
113
+ }).pipe(c.map(({ cursor: e, keys: t }) => {
114
114
  let i = [];
115
- for (let e of r) e.startsWith(m + t) && !n.has(e) && (n.add(e), i.push(e.slice(m.length)));
115
+ for (let e of t) e.startsWith(m + n) && !r.has(e) && (r.add(e), i.push(e.slice(m.length)));
116
116
  return [i, e === "0" ? u.none() : u.some(e)];
117
117
  })));
118
118
  })), {
@@ -120,15 +120,15 @@ var f = {
120
120
  crossNode: e.crossNode ?? !0,
121
121
  persistent: !1
122
122
  });
123
- }, h = (t = {}) => l.effect(o, c.gen(function* () {
124
- let n = yield* (yield* e).client(t.connectionName ?? f.connectionName).pipe(c.mapError(() => new a({
123
+ }, h = (r = {}) => l.effect(n, c.gen(function* () {
124
+ let n = yield* (yield* e).client(r.connectionName ?? f.connectionName).pipe(c.mapError(() => new t({
125
125
  operation: "connect",
126
126
  key: "",
127
127
  reason: "unavailable"
128
128
  })));
129
129
  return yield* c.try({
130
- try: () => m(n, t.namespace, t.scanCount),
131
- catch: () => new a({
130
+ try: () => m(n, r.namespace, r.scanCount),
131
+ catch: () => new t({
132
132
  operation: "connect",
133
133
  key: "",
134
134
  reason: "invalid"
@@ -1,20 +1,20 @@
1
1
  import { ConnectionRegistry as e } from "./connectionPool.js";
2
- import { hotStoreFromRunner as t, validateHotOp as n, validateHotReadOptions as r } from "./hotOperations.js";
3
- import { HotError as i, HotStore as a } from "./hot-contract.js";
2
+ import { HotError as t, HotStore as n } from "./hot-contract.js";
3
+ import { hotStoreFromRunner as r, validateHotOp as i, validateHotReadOptions as a } from "./hotOperations.js";
4
4
  import { makeRedisHotStore as o } from "./hotRedis.js";
5
5
  import { Effect as s, Layer as c, Stream as l } from "effect";
6
6
  // src/hotRouting.ts
7
- var u = (u) => c.effect(a, s.gen(function* () {
8
- let a = yield* e, c = u.routes?.[u.consumer], d = c?.select, f = u.context === void 0 ? void 0 : Object.freeze({ tenantId: u.context.tenantId }), p = u.consumers?.[u.consumer] ?? u.connection, m = [...new Set(c?.connections ?? [p ?? ""])], h = u.namespace, g = u.scanCount, _ = (e, t = "") => new i({
7
+ var u = (u) => c.effect(n, s.gen(function* () {
8
+ let n = yield* e, c = u.routes?.[u.consumer], d = c?.select, f = u.context === void 0 ? void 0 : Object.freeze({ tenantId: u.context.tenantId }), p = u.consumers?.[u.consumer] ?? u.connection, m = [...new Set(c?.connections ?? [p ?? ""])], h = u.namespace, g = u.scanCount, _ = (e, n = "") => new t({
9
9
  operation: e,
10
- key: t,
10
+ key: n,
11
11
  reason: "invalid"
12
12
  });
13
13
  if (!u.consumer || m.length === 0 || c !== void 0 && (c.keyAffinity !== !0 || typeof c.select != "function")) return yield* s.fail(_("route"));
14
14
  let v = !0;
15
15
  for (let e of m) {
16
16
  if (e !== "" && !/^redis:[A-Za-z][A-Za-z0-9_-]*$/.test(e)) return yield* s.fail(_("route"));
17
- (yield* a.validate(e).pipe(s.mapError(() => _("route")))).tenantScoped && f === void 0 || (yield* a.config(e, f).pipe(s.mapError(() => _("route")))).driver !== "memory" || (v = !1);
17
+ (yield* n.validate(e).pipe(s.mapError(() => _("route")))).tenantScoped && f === void 0 || (yield* n.config(e, f).pipe(s.mapError(() => _("route")))).driver !== "memory" || (v = !1);
18
18
  }
19
19
  if (h !== void 0 && (!h || /[{}]/.test(h)) || g !== void 0 && (!Number.isSafeInteger(g) || g < 1)) return yield* s.fail(_("route"));
20
20
  let y = (e) => s.try({
@@ -27,40 +27,40 @@ var u = (u) => c.effect(a, s.gen(function* () {
27
27
  return t;
28
28
  },
29
29
  catch: () => _("route", e)
30
- }), b = (e) => a.client(e, f).pipe(s.mapError(() => new i({
30
+ }), b = (e) => n.client(e, f).pipe(s.mapError(() => new t({
31
31
  operation: "connect",
32
32
  key: "",
33
33
  reason: "unavailable"
34
34
  })), s.map((e) => o(e, h, g)));
35
- return t((e, t) => s.gen(function* () {
35
+ return r((e, n) => s.gen(function* () {
36
36
  if (yield* s.try({
37
37
  try: () => {
38
- e.forEach(n), r(t, e[0]?.op ?? "multi", e[0]?.key ?? "");
38
+ e.forEach(i), a(n, e[0]?.op ?? "multi", e[0]?.key ?? "");
39
39
  },
40
- catch: (e) => e instanceof i ? e : _("multi")
40
+ catch: (e) => e instanceof t ? e : _("multi")
41
41
  }), e.length === 0) return [];
42
- let a = /* @__PURE__ */ new Map();
43
- for (let t of e) a.has(t.key) || a.set(t.key, yield* y(t.key));
44
- let o = new Set(a.values());
42
+ let r = /* @__PURE__ */ new Map();
43
+ for (let t of e) r.has(t.key) || r.set(t.key, yield* y(t.key));
44
+ let o = new Set(r.values());
45
45
  if (o.size !== 1) return yield* s.fail(_("multi"));
46
46
  let c = yield* b(o.values().next().value);
47
- if (t?.consistency === "eventual") {
47
+ if (n?.consistency === "eventual") {
48
48
  if (e.length !== 1) return yield* s.fail(_("multi"));
49
- let n = e[0];
49
+ let t = e[0];
50
50
  return [yield* s.gen(function* () {
51
- switch (n.op) {
52
- case "zrank": return yield* c.zrank(n.key, n.member, n.order, t).pipe(s.map((e) => e._tag === "Some" ? e.value : null));
53
- case "zscore": return yield* c.zscore(n.key, n.member, t).pipe(s.map((e) => e._tag === "Some" ? e.value : null));
54
- case "zrange": return yield* c.zrange(n.key, n.range, n.order, {
55
- ...n.options,
56
- ...t
51
+ switch (t.op) {
52
+ case "zrank": return yield* c.zrank(t.key, t.member, t.order, n).pipe(s.map((e) => e._tag === "Some" ? e.value : null));
53
+ case "zscore": return yield* c.zscore(t.key, t.member, n).pipe(s.map((e) => e._tag === "Some" ? e.value : null));
54
+ case "zrange": return yield* c.zrange(t.key, t.range, t.order, {
55
+ ...t.options,
56
+ ...n
57
57
  });
58
- case "zcard": return yield* c.zcard(n.key, t);
59
- case "hget": return yield* c.hget(n.key, n.field, t).pipe(s.map((e) => e._tag === "Some" ? e.value : null));
60
- case "hgetAll": return yield* c.hgetAll(n.key, t);
61
- case "smembers": return yield* c.smembers(n.key, t);
62
- case "sismember": return yield* c.sismember(n.key, n.member, t);
63
- default: return yield* s.fail(_(n.op, n.key));
58
+ case "zcard": return yield* c.zcard(t.key, n);
59
+ case "hget": return yield* c.hget(t.key, t.field, n).pipe(s.map((e) => e._tag === "Some" ? e.value : null));
60
+ case "hgetAll": return yield* c.hgetAll(t.key, n);
61
+ case "smembers": return yield* c.smembers(t.key, n);
62
+ case "sismember": return yield* c.sismember(t.key, t.member, n);
63
+ default: return yield* s.fail(_(t.op, t.key));
64
64
  }
65
65
  })];
66
66
  }
package/dist/hotState.js CHANGED
@@ -1,6 +1,6 @@
1
- import { consumeHotRateLimit as e } from "./hotRateLimit.js";
1
+ import { HotError as e } from "./hot-contract.js";
2
2
  import { validateHotOp as t } from "./hotOperations.js";
3
- import { HotError as n } from "./hot-contract.js";
3
+ import { consumeHotRateLimit as n } from "./hotRateLimit.js";
4
4
  // src/hotState.ts
5
5
  var r = (e, t) => {
6
6
  let n = Array.from(e, (e) => e.codePointAt(0) ?? 0), r = Array.from(t, (e) => e.codePointAt(0) ?? 0);
@@ -56,11 +56,11 @@ var r = (e, t) => {
56
56
  t !== void 0 && t.expiresAt > l && !u.has(e.key) && u.set(e.key, d.has(e.key) ? o(t) : t);
57
57
  }
58
58
  let f = c.map((t) => {
59
- let o = u.get(t.key), s = (e) => {
60
- throw new n({
59
+ let o = u.get(t.key), s = (n) => {
60
+ throw new e({
61
61
  operation: t.op,
62
62
  key: t.key,
63
- reason: e
63
+ reason: n
64
64
  });
65
65
  }, c = (e) => (o !== void 0 && o.kind !== e && s("wrongType"), o), d = (e) => (o = {
66
66
  ...e,
@@ -123,7 +123,7 @@ var r = (e, t) => {
123
123
  };
124
124
  }
125
125
  case "rateLimit": {
126
- let n = c("rateLimit")?.state, r = e(n, t.config, t.nowMs ?? l);
126
+ let e = c("rateLimit")?.state, r = n(e, t.config, t.nowMs ?? l);
127
127
  return d({
128
128
  kind: "rateLimit",
129
129
  state: r.state
@@ -0,0 +1,23 @@
1
+ import { HotStore as e } from "./hot-contract.js";
2
+ import { layerHotMemory as t, makeMemoryHotStore as n } from "./hotMemory.js";
3
+ import { hotStoreConformance as r } from "./hotStoreConformance.js";
4
+ import { Effect as i, Layer as a } from "effect";
5
+ // src/hotStoreFixtures.ts
6
+ var o = t(), s = (t) => e.pipe(i.flatMap((e) => e.incrBy("fixture:counter", 2)), i.provide(t)), c = {
7
+ kind: "port",
8
+ tag: e,
9
+ fakeLayer: o,
10
+ conformance: r,
11
+ probe: {
12
+ run: () => s(o),
13
+ expected: 2
14
+ },
15
+ overrideProbe: {
16
+ run: () => s(a.effect(e, i.map(n(), (e) => ({
17
+ ...e,
18
+ incrBy: (t, n, r) => e.incrBy(t, n * 10, r)
19
+ })))),
20
+ expected: 20
21
+ }
22
+ };
23
+ export { c as hotBackendPortFixture, o as hotStoreFakeLayer };
@@ -0,0 +1,11 @@
1
+ // src/hotSystemManifest.ts
2
+ var e = Object.freeze({
3
+ slots: Object.freeze({}),
4
+ ports: Object.freeze({ backend: Object.freeze({
5
+ tagExport: "HotStore",
6
+ fakeLayerExport: "hotStoreFakeLayer",
7
+ fixtureExport: "hotBackendPortFixture"
8
+ }) }),
9
+ events: Object.freeze([])
10
+ });
11
+ export { e as hotStoreSystemContractManifest };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { KvStore as e } from "./KvStore.js";
2
- import { Kv as t } from "./Kv.js";
1
+ import { Kv as e } from "./Kv.js";
2
+ import { KvStore as t } from "./KvStore.js";
3
3
  import { KvError as n } from "./errors.js";
4
4
  import { layerMemory as r } from "./backendMemory.js";
5
- import { RedisConnections as i, commandRetry as a, connect as o, connectionConfig as s, layerConnections as c } from "./connection.js";
6
- import { layerRedis as l, makeRedisKvStore as u } from "./backendRedis.js";
7
- export { t as Kv, n as KvError, e as KvStore, i as RedisConnections, a as commandRetry, o as connect, s as connectionConfig, c as layerConnections, r as layerMemory, l as layerRedis, u as makeRedisKvStore };
5
+ import { layerRedis as i, makeRedisKvStore as a } from "./backendRedis.js";
6
+ import { RedisConnections as o, commandRetry as s, connect as c, connectionConfig as l, layerConnections as u } from "./connection.js";
7
+ export { e as Kv, n as KvError, t as KvStore, o as RedisConnections, s as commandRetry, c as connect, l as connectionConfig, u as layerConnections, r as layerMemory, i as layerRedis, a as makeRedisKvStore };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/kv",
3
- "version": "0.89.2",
3
+ "version": "0.91.0",
4
4
  "description": "Named RESP connection registry + durable key-value primitive. One config surface for many Redis-family connections (Redis/Valkey/KeyDB/Dragonfly/Upstash) shared across cache, rate-limit, RYW and broadcast; plus a durable, tenant-scoped KV store distinct from the best-effort cache.",
5
5
  "keywords": [
6
6
  "voltro",
@@ -68,12 +68,12 @@
68
68
  "node": ">=24.0.0"
69
69
  },
70
70
  "dependencies": {
71
- "@voltro/shared": "0.89.2"
71
+ "@voltro/shared": "0.91.0"
72
72
  },
73
73
  "peerDependencies": {
74
- "effect": "4.1.2",
74
+ "effect": "4.1.4",
75
75
  "@nats-io/transport-node": "^3.4.0",
76
- "@upstash/redis": "^1.40.0",
76
+ "@upstash/redis": "^1.41.0",
77
77
  "ioredis": "^6.0.0"
78
78
  },
79
79
  "peerDependenciesMeta": {