@okf/ootils 1.8.6 → 1.8.7

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/node.d.mts CHANGED
@@ -829,9 +829,10 @@ declare namespace RedisCacheConnector {
829
829
  * @param env - Optional environment override (defaults to current environment)
830
830
  * @returns Mongoose Connection instance for the tenant-specific database
831
831
  */
832
- declare function getDbByTenant({ tenant, env: _env }: {
832
+ declare function getDbByTenant({ tenant, env: _env, CLUSTER_NAME }: {
833
833
  tenant: any;
834
834
  env: any;
835
+ CLUSTER_NAME: any;
835
836
  }): any;
836
837
 
837
838
  declare function getModelByTenant({ tenant, modelName, schema, env }: {
package/dist/node.d.ts CHANGED
@@ -829,9 +829,10 @@ declare namespace RedisCacheConnector {
829
829
  * @param env - Optional environment override (defaults to current environment)
830
830
  * @returns Mongoose Connection instance for the tenant-specific database
831
831
  */
832
- declare function getDbByTenant({ tenant, env: _env }: {
832
+ declare function getDbByTenant({ tenant, env: _env, CLUSTER_NAME }: {
833
833
  tenant: any;
834
834
  env: any;
835
+ CLUSTER_NAME: any;
835
836
  }): any;
836
837
 
837
838
  declare function getModelByTenant({ tenant, modelName, schema, env }: {
package/dist/node.js CHANGED
@@ -983,12 +983,13 @@ var init_getDbByTenant = __esm({
983
983
  import_MongoConnector = __toESM(require_MongoConnector());
984
984
  getDbByTenant = ({
985
985
  tenant,
986
- env: _env
986
+ env: _env,
987
+ CLUSTER_NAME
987
988
  }) => {
988
989
  if (!tenant) throw new Error("tenant id has not been provided");
989
990
  const env = _env || import_MongoConnector.MongoConnector.getEnv();
990
991
  const tenantToClusterMapping = import_MongoConnector.MongoConnector.getTenantToClusterMapping();
991
- const thisClusterName = tenantToClusterMapping[tenant]?.CLUSTER_NAME?.[env];
992
+ const thisClusterName = CLUSTER_NAME ? CLUSTER_NAME?.[env] : tenantToClusterMapping[tenant]?.CLUSTER_NAME?.[env];
992
993
  if (!thisClusterName) throw new Error("Could not find a CLUSTER_NAME mapped to this tenant + env");
993
994
  const clusterConnections = import_MongoConnector.MongoConnector.getClusterConnections();
994
995
  const dbName = `${tenant}_${env}`;
package/dist/node.mjs CHANGED
@@ -988,12 +988,13 @@ var init_getDbByTenant = __esm({
988
988
  import_MongoConnector = __toESM(require_MongoConnector());
989
989
  getDbByTenant = ({
990
990
  tenant,
991
- env: _env
991
+ env: _env,
992
+ CLUSTER_NAME
992
993
  }) => {
993
994
  if (!tenant) throw new Error("tenant id has not been provided");
994
995
  const env = _env || import_MongoConnector.MongoConnector.getEnv();
995
996
  const tenantToClusterMapping = import_MongoConnector.MongoConnector.getTenantToClusterMapping();
996
- const thisClusterName = tenantToClusterMapping[tenant]?.CLUSTER_NAME?.[env];
997
+ const thisClusterName = CLUSTER_NAME ? CLUSTER_NAME?.[env] : tenantToClusterMapping[tenant]?.CLUSTER_NAME?.[env];
997
998
  if (!thisClusterName) throw new Error("Could not find a CLUSTER_NAME mapped to this tenant + env");
998
999
  const clusterConnections = import_MongoConnector.MongoConnector.getClusterConnections();
999
1000
  const dbName = `${tenant}_${env}`;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.6",
6
+ "version": "1.8.7",
7
7
  "description": "Utility functions for both browser and Node.js",
8
8
  "main": "dist/index.js",
9
9
  "module": "dist/index.mjs",