@voltro/kv 0.87.0 → 0.88.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +169 -6
  2. package/THIRD-PARTY-NOTICES.md +2 -1345
  3. package/dist/Kv.js +1 -2
  4. package/dist/KvStore.js +1 -2
  5. package/dist/analytics.js +1 -2
  6. package/dist/backendMemory.js +1 -2
  7. package/dist/backendRedis.js +1 -2
  8. package/dist/cacheAtomicProtocol.js +34 -24
  9. package/dist/cacheAtomicScript.js +19 -2
  10. package/dist/cacheAtomicState.js +1 -2
  11. package/dist/connection.js +74 -70
  12. package/dist/connectionAnalyticsConfig.js +1 -2
  13. package/dist/connectionConfigError.js +10 -0
  14. package/dist/connectionConfigProvider.js +1 -2
  15. package/dist/connectionDefinitions.js +1 -2
  16. package/dist/connectionMemory.js +1 -2
  17. package/dist/connectionMetrics.js +1 -2
  18. package/dist/connectionNamespace.js +1 -2
  19. package/dist/connectionNats.js +44 -44
  20. package/dist/connectionNatsConfig.js +1 -2
  21. package/dist/connectionNatsSubjects.js +1 -2
  22. package/dist/connectionOwner.js +1 -2
  23. package/dist/connectionPool.js +252 -252
  24. package/dist/connectionPrefix.js +1 -2
  25. package/dist/connectionScripts.js +1 -2
  26. package/dist/connectionSqlConfig.js +1 -2
  27. package/dist/connectionStorageConfig.js +1 -2
  28. package/dist/connectionStorageFacade.js +1 -2
  29. package/dist/connectionSubscriber.js +47 -47
  30. package/dist/driverModule.js +9 -0
  31. package/dist/errors.js +1 -2
  32. package/dist/expirySweep.js +1 -2
  33. package/dist/hot-contract.js +1 -2
  34. package/dist/hot-testing.d.ts +14 -1
  35. package/dist/hotMemory.js +1 -2
  36. package/dist/hotOperations.js +1 -2
  37. package/dist/hotRateLimit.js +1 -2
  38. package/dist/hotReadAvailability.js +1 -2
  39. package/dist/hotRedis.js +1 -2
  40. package/dist/hotRedisScript.js +1 -2
  41. package/dist/hotRouting.js +2 -3
  42. package/dist/hotState.js +1 -2
  43. package/dist/hotStoreConformance.js +76 -78
  44. package/dist/nativeRedisReads.js +2 -3
  45. package/dist/nativeRedisTopology.js +64 -63
  46. package/dist/redisDiagnostics.js +1 -2
  47. package/dist/redisReadPolicy.js +1 -2
  48. package/dist/storage.js +1 -2
  49. package/dist/storageAddress.js +1 -2
  50. package/package.json +13 -10
@@ -1,8 +1,9 @@
1
1
  import { KvError as e } from "./errors.js";
2
- import { assertNatsSubject as t } from "./connectionNatsSubjects.js";
3
- import { Effect as n } from "effect";
4
- //#region src/connectionNats.ts
5
- var r = new TextEncoder(), i = new TextDecoder(), a = 5e3, o = 1e3, s = async (e, t) => {
2
+ import { missingDriver as t } from "./driverModule.js";
3
+ import { assertNatsSubject as n } from "./connectionNatsSubjects.js";
4
+ import { Effect as r } from "effect";
5
+ // src/connectionNats.ts
6
+ var i = new TextEncoder(), a = new TextDecoder(), o = 5e3, s = 1e3, c = async (e, t) => {
6
7
  let n;
7
8
  try {
8
9
  return await Promise.race([e, new Promise((e, r) => {
@@ -13,9 +14,9 @@ var r = new TextEncoder(), i = new TextDecoder(), a = 5e3, o = 1e3, s = async (e
13
14
  } finally {
14
15
  n !== void 0 && clearTimeout(n);
15
16
  }
16
- }, c = (e) => {
17
- let n = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map(), d = !0, f = !1, p, m = (e) => {
18
- for (let t of c) try {
17
+ }, l = (e) => {
18
+ let t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map(), d = !0, f = !1, p, m = (e) => {
19
+ for (let t of r) try {
19
20
  t(e);
20
21
  } catch {}
21
22
  }, h = () => {
@@ -40,29 +41,29 @@ var r = new TextEncoder(), i = new TextDecoder(), a = 5e3, o = 1e3, s = async (e
40
41
  t !== void 0 && (t.released = !0, u.delete(e), t.subscription.unsubscribe(), await t.done);
41
42
  };
42
43
  return {
43
- publish: async (n, i) => {
44
- t(n), v(), e.publish(n, r.encode(i));
44
+ publish: async (t, r) => {
45
+ n(t), v(), e.publish(t, i.encode(r));
45
46
  },
46
47
  flush: async () => {
47
- v(), await s(e.flush(), a);
48
+ v(), await c(e.flush(), o);
48
49
  },
49
50
  subscribe: async (r) => {
50
- t(r), v();
51
- let o = u.get(r);
52
- if (o !== void 0) return o.ready;
53
- let c = e.subscribe(r), d = {
54
- subscription: c,
51
+ n(r), v();
52
+ let i = u.get(r);
53
+ if (i !== void 0) return i.ready;
54
+ let s = e.subscribe(r), d = {
55
+ subscription: s,
55
56
  released: !1,
56
57
  done: Promise.resolve(),
57
58
  ready: Promise.resolve()
58
59
  };
59
60
  u.set(r, d), d.done = (async () => {
60
61
  try {
61
- for await (let e of c) {
62
+ for await (let e of s) {
62
63
  if (f || d.released) continue;
63
- let t = i.decode(e.data);
64
- for (let e of n) try {
65
- e(r, t);
64
+ let n = a.decode(e.data);
65
+ for (let e of t) try {
66
+ e(r, n);
66
67
  } catch {}
67
68
  }
68
69
  } finally {
@@ -72,7 +73,7 @@ var r = new TextEncoder(), i = new TextDecoder(), a = 5e3, o = 1e3, s = async (e
72
73
  d.released || h();
73
74
  }), l.add(d.done), d.done.then(() => {
74
75
  l.delete(d.done);
75
- }), d.ready = s(e.flush(), a).then(() => {
76
+ }), d.ready = c(e.flush(), o).then(() => {
76
77
  if (v(), d.released) throw Error("NATS subscription is closed");
77
78
  }).catch(async (e) => {
78
79
  throw u.get(r) === d && await y(r), e;
@@ -81,18 +82,18 @@ var r = new TextEncoder(), i = new TextDecoder(), a = 5e3, o = 1e3, s = async (e
81
82
  unsubscribe: y,
82
83
  onMessage: (e) => {
83
84
  if (f) throw Error("NATS transport is closed");
84
- return n.add(e), () => {
85
- n.delete(e);
85
+ return t.add(e), () => {
86
+ t.delete(e);
86
87
  };
87
88
  },
88
89
  onTransportEvent: (e) => {
89
90
  if (f) throw Error("NATS transport is closed");
90
- return c.add(e), () => {
91
- c.delete(e);
91
+ return r.add(e), () => {
92
+ r.delete(e);
92
93
  };
93
94
  },
94
95
  close: () => p ??= (async () => {
95
- f = !0, n.clear(), c.clear();
96
+ f = !0, t.clear(), r.clear();
96
97
  for (let e of u.values()) {
97
98
  e.released = !0;
98
99
  try {
@@ -101,48 +102,47 @@ var r = new TextEncoder(), i = new TextDecoder(), a = 5e3, o = 1e3, s = async (e
101
102
  }
102
103
  u.clear();
103
104
  try {
104
- await s(e.drain(), o);
105
+ await c(e.drain(), s);
105
106
  } catch {} finally {
106
107
  await e.close(), await g.return?.(), await Promise.all([...l]), await _;
107
108
  }
108
109
  })()
109
110
  };
110
- }, l = (t) => n.callback((r) => {
111
- let i = !1, o, s = (async () => {
112
- let e = await (await import("@nats-io/transport-node")).connect({
113
- servers: t.url.split(",").map((e) => e.trim()),
111
+ }, u = (n) => r.callback((i) => {
112
+ let a = !1, s, c = (async () => {
113
+ let e = await (await import("@nats-io/transport-node").catch(t("@nats-io/transport-node", "A NATS connection"))).connect({
114
+ servers: n.url.split(",").map((e) => e.trim()),
114
115
  maxReconnectAttempts: -1,
115
116
  waitOnFirstConnect: !0,
116
117
  reconnectTimeWait: 2e3,
117
- timeout: a,
118
- ...t.tls === "required" ? { tls: {} } : {},
119
- ...t.token === void 0 ? {} : { token: t.token },
120
- ...t.user === void 0 ? {} : { user: t.user },
121
- ...t.pass === void 0 ? {} : { pass: t.pass },
118
+ timeout: o,
119
+ ...n.tls === "required" ? { tls: {} } : {},
120
+ ...n.token === void 0 ? {} : { token: n.token },
121
+ ...n.user === void 0 ? {} : { user: n.user },
122
+ ...n.pass === void 0 ? {} : { pass: n.pass },
122
123
  reconnectToServer: () => {
123
- if (i) throw Error("NATS acquisition cancelled");
124
+ if (a) throw Error("NATS acquisition cancelled");
124
125
  return null;
125
126
  }
126
127
  });
127
- if (i) await e.close();
128
+ if (a) await e.close();
128
129
  else {
129
130
  try {
130
- o = c(e);
131
+ s = l(e);
131
132
  } catch (t) {
132
133
  throw await e.close(), t;
133
134
  }
134
- r(n.succeed(o));
135
+ i(r.succeed(s));
135
136
  }
136
137
  })().catch(() => {
137
- i || r(n.fail(new e({
138
+ a || i(r.fail(new e({
138
139
  operation: "connect",
139
140
  key: "",
140
141
  cause: "NATS driver could not be opened"
141
142
  })));
142
143
  });
143
- return n.promise(async () => {
144
- i = !0, await s, await o?.close();
144
+ return r.promise(async () => {
145
+ a = !0, await c, await s?.close();
145
146
  });
146
147
  });
147
- //#endregion
148
- export { l as connectNats };
148
+ export { u as connectNats };
@@ -1,6 +1,6 @@
1
1
  import { connectionDefinitionsProblem as e, natsConnectionName as t } from "./connectionDefinitions.js";
2
2
  import { Config as n, ConfigProvider as r, Effect as i, Option as a } from "effect";
3
- //#region src/connectionNatsConfig.ts
3
+ // src/connectionNatsConfig.ts
4
4
  var o = (e) => e.toUpperCase().replace(/[^A-Z0-9]+/g, "_"), s = (e) => {
5
5
  if (typeof e.url != "string" || !e.url.trim()) return "A NATS connection requires an endpoint";
6
6
  for (let t of e.url.split(",")) try {
@@ -83,5 +83,4 @@ var o = (e) => e.toUpperCase().replace(/[^A-Z0-9]+/g, "_"), s = (e) => {
83
83
  };
84
84
  });
85
85
  };
86
- //#endregion
87
86
  export { s as natsConfigProblem, c as natsConnectionConfig };
@@ -1,4 +1,4 @@
1
- //#region src/connectionNatsSubjects.ts
1
+ // src/connectionNatsSubjects.ts
2
2
  var e = (e) => {
3
3
  if (!e || /[\s*>]/u.test(e) || e.split(".").some((e) => !e)) throw Error("Registry NATS channels must be exact nonempty subjects");
4
4
  }, t = (e, t = "") => ({
@@ -12,5 +12,4 @@ var e = (e) => {
12
12
  flush: e.flush,
13
13
  close: e.close
14
14
  });
15
- //#endregion
16
15
  export { e as assertNatsSubject, t as withNatsSubjectPrefix };
@@ -1,6 +1,6 @@
1
1
  import { KvError as e } from "./errors.js";
2
2
  import { Deferred as t, Effect as n, Scope as r } from "effect";
3
- //#region src/connectionOwner.ts
3
+ // src/connectionOwner.ts
4
4
  var i = (i) => n.gen(function* () {
5
5
  let a = yield* n.scope, o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), c = !1, l = (e) => n.uninterruptible(n.suspend(() => e.closed ? t.await(e.closedSignal) : (e.closed = !0, i.dispose(e).pipe(n.ensuring(n.sync(() => {
6
6
  o.delete(e);
@@ -40,5 +40,4 @@ var i = (i) => n.gen(function* () {
40
40
  }))
41
41
  };
42
42
  });
43
- //#endregion
44
43
  export { i as makeConnectionOwner };