@healthzkit/redis 0.0.2 → 0.0.3

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,4 +1,4 @@
1
- import { n as HealthAdapter, t as BaseRedisOptions } from "./shared-Bt0JlNBM.mjs";
1
+ import { n as HealthAdapter, t as BaseRedisOptions } from "./shared-tv0dhEh3.mjs";
2
2
  import { Redis, RedisOptions } from "ioredis";
3
3
 
4
4
  //#region src/ioredis.d.ts
package/dist/ioredis.mjs CHANGED
@@ -1 +1 @@
1
- import{n as e,r as t}from"./shared-BA6-D1db.mjs";function n(n){let r=null;async function i(){if(`connectionString`in n&&n.connectionString){if(!r){let{Redis:e}=await import(`ioredis`);r=new e(n.connectionString,{maxRetriesPerRequest:1,enableReadyCheck:!1,...n.redisOptions})}return r}if(`client`in n&&n.client!==void 0)return n.client;throw Error(`ioredisAdapter: provide a non-empty connectionString or a client`)}return{async check(){try{let e=await i(),r=Date.now();return await e.call(n.command??`PING`),t(Date.now()-r,n.metadata?await n.metadata(e):void 0)}catch(t){return e(t)}}}}export{n as ioredisAdapter};
1
+ import{n as e,r as t}from"./shared-Ay4IMNoW.mjs";function n(n){let r=null;async function i(){if(`connectionString`in n&&n.connectionString){if(!r){let{Redis:e}=await import(`ioredis`);r=new e(n.connectionString,{maxRetriesPerRequest:1,enableReadyCheck:!1,...n.redisOptions})}return r}if(`client`in n&&n.client!==void 0)return n.client;throw Error(`ioredisAdapter: provide a non-empty connectionString or a client`)}return{async check(){try{let t=await i(),r=Date.now();await t.call(n.command??`PING`);let a=Date.now()-r,o=n.metadata?n.metadata(t):void 0;return e(a,o instanceof Promise?await o:o)}catch(e){return t(e)}}}}export{n as ioredisAdapter};
package/dist/redis.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as HealthAdapter, t as BaseRedisOptions } from "./shared-Bt0JlNBM.mjs";
1
+ import { n as HealthAdapter, t as BaseRedisOptions } from "./shared-tv0dhEh3.mjs";
2
2
  import { RedisClientOptions, RedisClientType, RespVersions } from "redis";
3
3
 
4
4
  //#region src/redis.d.ts
package/dist/redis.mjs CHANGED
@@ -1 +1 @@
1
- import{n as e,r as t}from"./shared-BA6-D1db.mjs";function n(n){let r=null;async function i(){if(`connectionString`in n&&n.connectionString){if(!r){let{createClient:e}=await import(`redis`),t=e({url:n.connectionString,...n.redisOptions});await t.connect(),r=t}return r}if(`client`in n&&n.client!==void 0){let e=n.client;return e.isOpen||await e.connect(),e}throw Error(`nodeRedisAdapter: provide a non-empty connectionString or a client`)}return{async check(){try{let e=await i(),r=Date.now();return await e.sendCommand((n.command??`PING`).split(` `)),t(Date.now()-r,n.metadata?await n.metadata(e):void 0)}catch(t){return e(t)}}}}export{n as nodeRedisAdapter};
1
+ import{n as e,r as t}from"./shared-Ay4IMNoW.mjs";function n(n){let r=null;async function i(){if(`connectionString`in n&&n.connectionString){if(!r){let{createClient:e}=await import(`redis`),t=e({url:n.connectionString,...n.redisOptions});await t.connect(),r=t}return r}if(`client`in n&&n.client!==void 0){let e=n.client;return e.isOpen||await e.connect(),e}throw Error(`nodeRedisAdapter: provide a non-empty connectionString or a client`)}return{async check(){try{let t=await i(),r=Date.now();await t.sendCommand((n.command??`PING`).split(` `));let a=Date.now()-r,o=n.metadata?n.metadata(t):void 0;return e(a,o instanceof Promise?await o:o)}catch(e){return t(e)}}}}export{n as nodeRedisAdapter};
@@ -0,0 +1 @@
1
+ function e(e,t){return{status:`ok`,metadata:{...t,latencyMs:e}}}function t(e){return{status:`fail`,error:e instanceof Error?e:Error(String(e))}}const n=`PING`;export{e as n,t as r,n as t};
@@ -1,17 +1,10 @@
1
- //#region ../healthzkit/dist/index.d.mts
2
- //#region src/types.d.ts
3
- type CheckStatus = "ok" | "degraded" | "fail";
4
- interface AdapterResult {
5
- status: CheckStatus;
6
- error?: Error | string;
7
- metadata?: Record<string, unknown>;
8
- }
9
- interface HealthAdapter {
10
- check(): Promise<AdapterResult>;
11
- }
1
+ import { HealthAdapter } from "healthzkit";
2
+
3
+ //#region ../../tools/shared/dist/index.d.mts
4
+ //#region src/index.d.ts
5
+ type MetadataFn<TClient> = (client: TClient) => Promise<Record<string, unknown>> | Record<string, unknown>;
12
6
  //#endregion
13
7
  //#region src/shared.d.ts
14
- type MetadataFn<TClient> = (client: TClient) => Promise<Record<string, unknown>>;
15
8
  interface BaseRedisOptions<TClient> {
16
9
  /**
17
10
  * Command to run as the healthcheck.
@@ -1,4 +1,4 @@
1
- import { n as HealthAdapter, t as BaseRedisOptions } from "./shared-Bt0JlNBM.mjs";
1
+ import { n as HealthAdapter, t as BaseRedisOptions } from "./shared-tv0dhEh3.mjs";
2
2
  import { Redis } from "@upstash/redis";
3
3
 
4
4
  //#region src/upstash.d.ts
package/dist/upstash.mjs CHANGED
@@ -1 +1 @@
1
- import{n as e,r as t}from"./shared-BA6-D1db.mjs";function n(n){let r=null;async function i(){if(`url`in n&&n.url){if(!r){let{Redis:e}=await import(`@upstash/redis`);r=new e({url:n.url,token:n.token})}return r}if(`client`in n&&n.client!==void 0)return n.client;throw Error(`upstashAdapter: provide url and token, or a client`)}return{async check(){try{let e=await i(),r=Date.now();if(n.command&&n.command!==`PING`){let[t,...r]=n.command.split(` `);await e.exec([t,...r])}else await e.ping();return t(Date.now()-r,n.metadata?await n.metadata(e):void 0)}catch(t){return e(t)}}}}export{n as upstashAdapter};
1
+ import{n as e,r as t}from"./shared-Ay4IMNoW.mjs";function n(n){let r=null;async function i(){if(`url`in n&&n.url){if(!r){let{Redis:e}=await import(`@upstash/redis`);r=new e({url:n.url,token:n.token})}return r}if(`client`in n&&n.client!==void 0)return n.client;throw Error(`upstashAdapter: provide url and token, or a client`)}return{async check(){try{let t=await i(),r=Date.now();if(n.command&&n.command!==`PING`){let[e,...r]=n.command.split(` `);await t.exec([e,...r])}else await t.ping();let a=Date.now()-r,o=n.metadata?n.metadata(t):void 0;return e(a,o instanceof Promise?await o:o)}catch(e){return t(e)}}}}export{n as upstashAdapter};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@healthzkit/redis",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "license": "AGPL-3.0-only",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,15 +22,16 @@
22
22
  "access": "public"
23
23
  },
24
24
  "devDependencies": {
25
- "@types/node": "^25.5.0",
25
+ "@types/node": "^24",
26
26
  "@typescript/native-preview": "7.0.0-dev.20260328.1",
27
27
  "@upstash/redis": "^1.38.0",
28
28
  "bumpp": "^11.0.1",
29
29
  "ioredis": "^5.10.1",
30
30
  "redis": "^5.12.1",
31
- "typescript": "^6.0.2",
32
- "vite-plus": "^0.1.14",
33
- "healthzkit": "0.0.2"
31
+ "typescript": "^5",
32
+ "vite-plus": "latest",
33
+ "@healthzkit/shared": "0.0.0",
34
+ "healthzkit": "0.0.3"
34
35
  },
35
36
  "peerDependencies": {
36
37
  "@upstash/redis": ">=1.0.0",
@@ -1 +0,0 @@
1
- const e=`PING`;function t(e,t){return{status:`ok`,metadata:{latencyMs:e,...t}}}function n(e){return{status:`fail`,error:e instanceof Error?e:Error(String(e))}}export{n,t as r,e as t};