@healthzkit/mongo 0.0.2 → 0.0.4

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 BaseMongoOptions } from "./shared-C_B8UrQ_.mjs";
1
+ import { n as HealthAdapter, t as BaseMongoOptions } from "./shared-D2N9p6gZ.mjs";
2
2
  import { MongoClient, MongoClientOptions } from "mongodb";
3
3
 
4
4
  //#region src/mongodb.d.ts
package/dist/mongodb.mjs CHANGED
@@ -1 +1 @@
1
- import{n as e,t}from"./shared-B-1hAtzF.mjs";function n(n){let r=null,i=null,a=null;async function o(e,t){return i??=(async()=>{let{MongoClient:n}=await import(`mongodb`),i=new n(e,t);return await i.connect(),r=i,i})().catch(e=>{throw i=null,r=null,e}),i}async function s(){if(`connectionString`in n&&n.connectionString)return o(n.connectionString,n.mongoOptions);if(`client`in n&&n.client)return a??=n.client.connect().then(()=>void 0).catch(e=>{throw a=null,e}),await a,n.client;throw Error(`mongoAdapter: provide a non-empty connectionString or a client`)}return{async check(){try{let t=await s(),r=Date.now();return await t.db(`admin`).command({ping:1}),e(Date.now()-r,n.metadata?await n.metadata(t):void 0)}catch(e){return t(e)}},async close(){r&&(await r.close(),r=null,i=null)}}}export{n as mongodbAdapter};
1
+ import{n as e,t}from"./shared-BiUsKU63.mjs";function n(n){let r=null,i=null,a=null;async function o(e,t){return i??=(async()=>{let{MongoClient:n}=await import(`mongodb`),i=new n(e,t);return await i.connect(),r=i,i})().catch(e=>{throw i=null,r=null,e}),i}async function s(){if(`connectionString`in n&&n.connectionString)return o(n.connectionString,n.mongoOptions);if(`client`in n&&n.client)return a??=n.client.connect().then(()=>void 0).catch(e=>{throw a=null,e}),await a,n.client;throw Error(`mongoAdapter: provide a non-empty connectionString or a client`)}return{async check(){try{let t=await s(),r=Date.now();await t.db(`admin`).command({ping:1});let i=Date.now()-r,a=n.metadata?n.metadata(t):void 0;return e(i,a instanceof Promise?await a:a)}catch(e){return t(e)}},async close(){r&&(await r.close(),r=null,i=null)}}}export{n as mongodbAdapter};
@@ -1,4 +1,4 @@
1
- import { n as HealthAdapter, t as BaseMongoOptions } from "./shared-C_B8UrQ_.mjs";
1
+ import { n as HealthAdapter, t as BaseMongoOptions } from "./shared-D2N9p6gZ.mjs";
2
2
  import { ConnectOptions, Connection, Mongoose } from "mongoose";
3
3
 
4
4
  //#region src/mongoose.d.ts
package/dist/mongoose.mjs CHANGED
@@ -1 +1 @@
1
- import{n as e,t}from"./shared-B-1hAtzF.mjs";function n(n){let r=null;async function i(e,t){return r??=(async()=>{let{default:n}=await import(`mongoose`);return await n.connect(e,t),n})().catch(e=>{throw r=null,e}),r}async function a(){if(`connectionString`in n&&n.connectionString)return i(n.connectionString,n.mongooseOptions);let e=n.connection;if(!e)throw Error(`mongoose adapter requires connection or connectionString`);return`readyState`in e&&e.readyState!==1&&await e.asPromise(),e}return{async check(){try{let t=await a(),r=Date.now(),i=`db`in t?t.db:t.connection.db;if(!i)throw Error(`mongoose adapter: database unavailable`);return await i.admin().command({ping:1}),e(Date.now()-r,n.metadata?await n.metadata(t):void 0)}catch(e){return t(e)}}}}export{n as mongooseAdapter};
1
+ import{n as e,t}from"./shared-BiUsKU63.mjs";function n(n){let r=null;async function i(e,t){return r??=(async()=>{let{default:n}=await import(`mongoose`);return await n.connect(e,t),n})().catch(e=>{throw r=null,e}),r}async function a(){if(`connectionString`in n&&n.connectionString)return i(n.connectionString,n.mongooseOptions);let e=n.connection;if(!e)throw Error(`mongoose adapter requires connection or connectionString`);return`readyState`in e&&e.readyState!==1&&await e.asPromise(),e}return{async check(){try{let t=await a(),r=Date.now(),i=`db`in t?t.db:t.connection.db;if(!i)throw Error(`mongoose adapter: database unavailable`);await i.admin().command({ping:1});let o=Date.now()-r,s=n.metadata?n.metadata(t):void 0;return e(o,s instanceof Promise?await s:s)}catch(e){return t(e)}}}}export{n as mongooseAdapter};
@@ -0,0 +1 @@
1
+ import{buildErrorResult as e,buildResult as t}from"@healthzkit/shared";export{t as n,e as t};
@@ -1,7 +1,6 @@
1
- import { HealthAdapter } from "healthzkit";
1
+ import { HealthAdapter, MetadataFn } from "@healthzkit/shared";
2
2
 
3
3
  //#region src/shared.d.ts
4
- type MetadataFn<TClient> = (client: TClient) => Promise<Record<string, unknown>>;
5
4
  interface BaseMongoOptions<TClient> {
6
5
  /**
7
6
  * Optional function to populate metadata in the check result.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@healthzkit/mongo",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "license": "AGPL-3.0-only",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,17 +20,20 @@
20
20
  "publishConfig": {
21
21
  "access": "public"
22
22
  },
23
+ "dependencies": {
24
+ "@healthzkit/shared": "0.0.0"
25
+ },
23
26
  "devDependencies": {
24
27
  "@types/mongodb": "^4.0.7",
25
28
  "@types/mongoose": "^5.11.97",
26
- "@types/node": "^25.6.2",
29
+ "@types/node": "^24",
27
30
  "@typescript/native-preview": "7.0.0-dev.20260509.2",
28
31
  "bumpp": "^11.1.0",
29
32
  "mongodb": "^7.2.0",
30
33
  "mongoose": "^9.6.2",
31
- "typescript": "^6.0.3",
32
- "vite-plus": "^0.1.20",
33
- "healthzkit": "0.0.2"
34
+ "typescript": "^5",
35
+ "vite-plus": "latest",
36
+ "healthzkit": "0.0.3"
34
37
  },
35
38
  "peerDependencies": {
36
39
  "mongodb": ">=6.0.0 || >=7.0.0",
@@ -1 +0,0 @@
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))}}export{e as n,t};