@platform-x/hep-push-notification-client 1.0.3 → 1.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.
@@ -5,5 +5,5 @@
5
5
  */
6
6
  export declare class pushNotificationManager {
7
7
  private notificationProvider;
8
- pushNotificationProvider(sitename: string): Promise<any>;
8
+ pushNotificationProvider(req: any): Promise<any>;
9
9
  }
@@ -8,30 +8,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
12
  exports.pushNotificationManager = void 0;
16
13
  const logger_1 = require("./common/util/logger");
17
14
  const constants_1 = require("./platform-x/constants");
18
15
  const fcmservices_1 = require("./platform-x/services/fcmservices");
19
- const site_domain_dao_1 = __importDefault(require("./platform-x/database/dao/site_domain.dao"));
16
+ // import SiteDomainDao from './platform-x/database/dao/site_domain.dao';
20
17
  /**
21
18
  * Push Notification Manager - supports multiple providers
22
19
  * Currently implemented: FCM
23
20
  * Future providers: SAP_EMARSYS
24
21
  */
25
22
  class pushNotificationManager {
26
- pushNotificationProvider(sitename) {
23
+ pushNotificationProvider(req) {
27
24
  return __awaiter(this, void 0, void 0, function* () {
28
- var _a, _b, _c;
29
25
  try {
26
+ let { sitename, provider } = req;
30
27
  logger_1.Logger.info('pushNotificationManager: Reached pushNotificationProvider', 'pushNotificationProvider');
31
- let pushConfig = yield new site_domain_dao_1.default().details({ sitename });
32
- let pushNotifyProvider = (_c = (_b = (_a = pushConfig === null || pushConfig === void 0 ? void 0 : pushConfig.providers) === null || _a === void 0 ? void 0 : _a.notification) === null || _b === void 0 ? void 0 : _b.active) !== null && _c !== void 0 ? _c : constants_1.PROVIDERS.FCM;
28
+ // let pushConfig: any = await new SiteDomainDao().details({sitename});
29
+ // let pushNotifyProvider: any = pushConfig?.providers?.notification?.active ?? PROVIDERS.FCM;
33
30
  logger_1.Logger.info(`pushNotificationManager: Initializing the provider for client ${sitename}`, '');
34
- switch (pushNotifyProvider) {
31
+ switch (provider) {
35
32
  case constants_1.PROVIDERS.FCM:
36
33
  this.notificationProvider = yield fcmservices_1.FcmClient.fcmClientObject(sitename);
37
34
  logger_1.Logger.info('pushNotificationManager: Initialized with FCM provider', 'constructor');
@@ -41,7 +38,7 @@ class pushNotificationManager {
41
38
  logger_1.Logger.info('pushNotificationManager: Initialized with SAP_EMARSYS provider', 'constructor');
42
39
  break;
43
40
  default:
44
- throw new Error(`Unsupported provider: ${pushNotifyProvider}. Supported providers: ${Object.values(constants_1.PROVIDERS).join(', ')}`);
41
+ throw new Error(`Unsupported provider: ${provider}. Supported providers: ${Object.values(constants_1.PROVIDERS).join(', ')}`);
45
42
  }
46
43
  return this.notificationProvider;
47
44
  }
@@ -9,4 +9,3 @@ export declare function getDynamicSecretdata(sitename: any, providerName: any, s
9
9
  * If no external MongoDB connection is found, it will initialize its own connection
10
10
  * Call this during your server startup to ensure proper MongoDB configuration
11
11
  */
12
- export declare const validateMongoInitialization: () => Promise<boolean>;
@@ -8,16 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.validateMongoInitialization = exports.base64ToString = void 0;
12
+ exports.base64ToString = void 0;
16
13
  exports.getDynamicSecretdata = getDynamicSecretdata;
17
14
  const __1 = require("../..");
18
15
  const constants_1 = require("../../platform-x/constants");
19
16
  const logger_1 = require("./logger");
20
- const connection_1 = __importDefault(require("../../platform-x/database/connection"));
17
+ // import MongoDbConnection from "../../platform-x/database/connection";
21
18
  /**
22
19
  * base64ToString - to convert base64 into string
23
20
  * @param {string} toDecode- string base64 request
@@ -49,20 +46,18 @@ function getDynamicSecretdata(sitename, providerName, secretKey) {
49
46
  * If no external MongoDB connection is found, it will initialize its own connection
50
47
  * Call this during your server startup to ensure proper MongoDB configuration
51
48
  */
52
- const validateMongoInitialization = () => __awaiter(void 0, void 0, void 0, function* () {
53
- // Check if MongoDB connection exists and is connected
54
- if (!connection_1.default.database || connection_1.default.database.readyState !== 1) {
55
- // If no external connection, try to initialize own connection
56
- if (!connection_1.default.isUsingExternalConnection()) {
57
- logger_1.Logger.info('Push Notification Package: No external MongoDB connection found, initializing own connection', 'validatePackageInitialization');
58
- yield connection_1.default.connect();
59
- }
60
- else {
61
- throw new Error('Push Notification Package: MongoDB connection not initialized. Please call initPushNotificationWithExternalMongo() or initPushNotificationWithOwnMongo() before starting the server.');
62
- }
63
- }
64
- logger_1.Logger.info('Push Notification Package: MongoDB validation passed - package is properly initialized', 'validatePackageInitialization');
65
- return true;
66
- });
67
- exports.validateMongoInitialization = validateMongoInitialization;
49
+ // export const validateMongoInitialization = async () => {
50
+ // // Check if MongoDB connection exists and is connected
51
+ // if (!MongoDbConnection.database || MongoDbConnection.database.readyState !== 1) {
52
+ // // If no external connection, try to initialize own connection
53
+ // if (!MongoDbConnection.isUsingExternalConnection()) {
54
+ // Logger.info('Push Notification Package: No external MongoDB connection found, initializing own connection', 'validatePackageInitialization');
55
+ // await MongoDbConnection.connect();
56
+ // } else {
57
+ // throw new Error('Push Notification Package: MongoDB connection not initialized. Please call initPushNotificationWithExternalMongo() or initPushNotificationWithOwnMongo() before starting the server.');
58
+ // }
59
+ // }
60
+ // Logger.info('Push Notification Package: MongoDB validation passed - package is properly initialized', 'validatePackageInitialization');
61
+ // return true;
62
+ // };
68
63
  //# sourceMappingURL=commonUtil.js.map
package/dist/src/index.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.pushNotificationManager = exports.getPushNotificationSecrets = exports.initPushNotificationSecrets = void 0;
4
4
  const PushNotificationManager_1 = require("./PushNotificationManager");
5
5
  Object.defineProperty(exports, "pushNotificationManager", { enumerable: true, get: function () { return PushNotificationManager_1.pushNotificationManager; } });
6
- const commonUtil_1 = require("./common/util/commonUtil");
6
+ // import { validateMongoInitialization } from "./common/util/commonUtil";
7
7
  let injectedSecretService;
8
8
  const initPushNotificationSecrets = (secretServiceIns) => {
9
9
  injectedSecretService = secretServiceIns;
@@ -17,7 +17,6 @@ const getPushNotificationSecrets = () => {
17
17
  // return new SecretKeyServices().getSecretKeys(); // for localpackage test
18
18
  };
19
19
  exports.getPushNotificationSecrets = getPushNotificationSecrets;
20
- (0, commonUtil_1.validateMongoInitialization)(); // Ensure MongoDB is initialized when the package is loaded
21
20
  // for testing
22
21
  // export const testval = async () => {
23
22
  // let id: any = new pushNotificationManager();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platform-x/hep-push-notification-client",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "@platform-x/hep-push-notification-client",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",