@heyhru/business-dms-datasource 0.7.0 → 0.7.1

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/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { getPool, getDataSourceWithPassword, getPoolForDatabase, datasourceList, datasourceGet, datasourceCreate, datasourceUpdate, datasourceDelete, } from "./datasources.service.js";
1
+ export { getPool, getDataSourceWithPassword, getPoolForDatabase, getPoolStats, datasourceList, datasourceGet, datasourceCreate, datasourceUpdate, datasourceDelete, } from "./datasources.service.js";
2
2
  export type { DbPool, DataSourceWithPassword } from "./datasources.service.js";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,yBAAyB,EACzB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAElC,YAAY,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,yBAAyB,EACzB,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAElC,YAAY,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
package/dist/index.js CHANGED
@@ -27,7 +27,8 @@ __export(index_exports, {
27
27
  datasourceUpdate: () => datasourceUpdate,
28
28
  getDataSourceWithPassword: () => getDataSourceWithPassword,
29
29
  getPool: () => getPool,
30
- getPoolForDatabase: () => getPoolForDatabase
30
+ getPoolForDatabase: () => getPoolForDatabase,
31
+ getPoolStats: () => getPoolStats
31
32
  });
32
33
  module.exports = __toCommonJS(index_exports);
33
34
 
@@ -114,6 +115,15 @@ function removeDataSource(id) {
114
115
  // src/datasources.service.ts
115
116
  var logger = (0, import_common_util_logger.createLogger)({ name: "@heyhru/business-dms-datasource" });
116
117
  var pools = /* @__PURE__ */ new Map();
118
+ function getPoolStats() {
119
+ return Array.from(pools.entries()).map(([key, pool]) => {
120
+ const colonIdx = key.indexOf(":");
121
+ const dataSourceId = colonIdx >= 0 ? key.slice(0, colonIdx) : key;
122
+ const database = colonIdx >= 0 ? key.slice(colonIdx + 1) : null;
123
+ const s = pool.stats();
124
+ return { dataSourceId, database, active: s?.active ?? null, waiting: s?.waiting ?? null };
125
+ });
126
+ }
117
127
  function poolKey(id, database) {
118
128
  return database ? `${id}:${database}` : id;
119
129
  }
@@ -218,5 +228,6 @@ async function datasourceDelete(req, reply) {
218
228
  datasourceUpdate,
219
229
  getDataSourceWithPassword,
220
230
  getPool,
221
- getPoolForDatabase
231
+ getPoolForDatabase,
232
+ getPoolStats
222
233
  });
package/dist/index.mjs CHANGED
@@ -81,6 +81,15 @@ function removeDataSource(id) {
81
81
  // src/datasources.service.ts
82
82
  var logger = createLogger({ name: "@heyhru/business-dms-datasource" });
83
83
  var pools = /* @__PURE__ */ new Map();
84
+ function getPoolStats() {
85
+ return Array.from(pools.entries()).map(([key, pool]) => {
86
+ const colonIdx = key.indexOf(":");
87
+ const dataSourceId = colonIdx >= 0 ? key.slice(0, colonIdx) : key;
88
+ const database = colonIdx >= 0 ? key.slice(colonIdx + 1) : null;
89
+ const s = pool.stats();
90
+ return { dataSourceId, database, active: s?.active ?? null, waiting: s?.waiting ?? null };
91
+ });
92
+ }
84
93
  function poolKey(id, database) {
85
94
  return database ? `${id}:${database}` : id;
86
95
  }
@@ -184,5 +193,6 @@ export {
184
193
  datasourceUpdate,
185
194
  getDataSourceWithPassword,
186
195
  getPool,
187
- getPoolForDatabase
196
+ getPoolForDatabase,
197
+ getPoolStats
188
198
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.7.0",
6
+ "version": "0.7.1",
7
7
  "description": "DMS data source domain logic: service, model, sql, pool management",
8
8
  "main": "./dist/index.js",
9
9
  "module": "./dist/index.mjs",
@@ -37,5 +37,5 @@
37
37
  "typescript": "^6.0.2",
38
38
  "vitest": "^4.1.4"
39
39
  },
40
- "gitHead": "b9097b9ad29ac4c0c3610a39cb0db83f74a11fb8"
40
+ "gitHead": "b20e6c3e571bd4939fd32ece8f5bc6d8302a4c83"
41
41
  }