@platform-x/hep-push-notification-client 1.0.4 → 1.0.6

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(req: any): Promise<any>;
8
+ pushNotificationProvider(notificationReq: any): Promise<any>;
9
9
  }
@@ -13,20 +13,17 @@ exports.pushNotificationManager = void 0;
13
13
  const logger_1 = require("./common/util/logger");
14
14
  const constants_1 = require("./platform-x/constants");
15
15
  const fcmservices_1 = require("./platform-x/services/fcmservices");
16
- // import SiteDomainDao from './platform-x/database/dao/site_domain.dao';
17
16
  /**
18
17
  * Push Notification Manager - supports multiple providers
19
18
  * Currently implemented: FCM
20
19
  * Future providers: SAP_EMARSYS
21
20
  */
22
21
  class pushNotificationManager {
23
- pushNotificationProvider(req) {
22
+ pushNotificationProvider(notificationReq) {
24
23
  return __awaiter(this, void 0, void 0, function* () {
25
24
  try {
26
- let { sitename, provider } = req;
25
+ let { sitename, provider } = notificationReq;
27
26
  logger_1.Logger.info('pushNotificationManager: Reached pushNotificationProvider', 'pushNotificationProvider');
28
- // let pushConfig: any = await new SiteDomainDao().details({sitename});
29
- // let pushNotifyProvider: any = pushConfig?.providers?.notification?.active ?? PROVIDERS.FCM;
30
27
  logger_1.Logger.info(`pushNotificationManager: Initializing the provider for client ${sitename}`, '');
31
28
  switch (provider) {
32
29
  case constants_1.PROVIDERS.FCM:
@@ -4,8 +4,3 @@
4
4
  */
5
5
  export declare const base64ToString: (toDecode: string) => string;
6
6
  export declare function getDynamicSecretdata(sitename: any, providerName: any, secretKey: any): Promise<string>;
7
- /**
8
- * Validate that MongoDB connection is properly initialized for server startup
9
- * If no external MongoDB connection is found, it will initialize its own connection
10
- * Call this during your server startup to ensure proper MongoDB configuration
11
- */
@@ -14,7 +14,6 @@ exports.getDynamicSecretdata = getDynamicSecretdata;
14
14
  const __1 = require("../..");
15
15
  const constants_1 = require("../../platform-x/constants");
16
16
  const logger_1 = require("./logger");
17
- // import MongoDbConnection from "../../platform-x/database/connection";
18
17
  /**
19
18
  * base64ToString - to convert base64 into string
20
19
  * @param {string} toDecode- string base64 request
@@ -41,23 +40,4 @@ function getDynamicSecretdata(sitename, providerName, secretKey) {
41
40
  return finalValue;
42
41
  });
43
42
  }
44
- /**
45
- * Validate that MongoDB connection is properly initialized for server startup
46
- * If no external MongoDB connection is found, it will initialize its own connection
47
- * Call this during your server startup to ensure proper MongoDB configuration
48
- */
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
- // };
63
43
  //# sourceMappingURL=commonUtil.js.map
@@ -2,13 +2,6 @@ declare const _default: {
2
2
  LOG_LEVELS: string[];
3
3
  APP_NAME: string;
4
4
  NODE_ENV: string | undefined;
5
- MONGO: {
6
- HOST: string | undefined;
7
- PORT: string | undefined;
8
- DB_NAME: string | undefined;
9
- USER: string | undefined;
10
- PASS: string | undefined;
11
- };
12
5
  FCM: {
13
6
  PROJECT: string | undefined;
14
7
  TYPE: string | undefined;
@@ -12,13 +12,6 @@ exports.default = {
12
12
  LOG_LEVELS: ((_a = process.env.LOG_LEVELS) === null || _a === void 0 ? void 0 : _a.split(',')) || [],
13
13
  APP_NAME: process.env.npm_package_name || constants_1.DEFAULT_APP_NAME,
14
14
  NODE_ENV: process.env.NODE_ENV,
15
- MONGO: {
16
- HOST: process.env.MONGO_HOST,
17
- PORT: process.env.MONGO_PORT,
18
- DB_NAME: process.env.MONGO_DB,
19
- USER: process.env.MONGO_USER,
20
- PASS: process.env.MONGO_PASS,
21
- },
22
15
  FCM: {
23
16
  PROJECT: process.env.FCM_PROJECT,
24
17
  TYPE: process.env.FCM_TYPE,
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
- // import { validateMongoInitialization } from "./common/util/commonUtil";
6
+ // import { SecretKeyServices } from "./common/util/secretKeyManager";
7
7
  let injectedSecretService;
8
8
  const initPushNotificationSecrets = (secretServiceIns) => {
9
9
  injectedSecretService = secretServiceIns;
@@ -21,7 +21,7 @@ exports.getPushNotificationSecrets = getPushNotificationSecrets;
21
21
  // export const testval = async () => {
22
22
  // let id: any = new pushNotificationManager();
23
23
  // // // .iamAuthenticator('kiwi', false);
24
- // let client = await id.pushNotificationProvider('kiwi');
24
+ // let client = await id.pushNotificationProvider({sitename:"kiwi", provider: "fcm"});
25
25
  // // // getuserdetails
26
26
  // let validate: any = await client.sendNotificationsToTopics(['articles'], {
27
27
  // title: 'Test Title',
@@ -30,6 +30,12 @@ exports.getPushNotificationSecrets = getPushNotificationSecrets;
30
30
  // }
31
31
  // );
32
32
  // console.log('>>>>>>>>>>>>>idd>>>>', validate)
33
+ // let id: any = new pushNotificationManager();
34
+ // // // .iamAuthenticator('kiwi', false);
35
+ // let client = await id.pushNotificationProvider({sitename:"kiwi", provider: "fcm"});
36
+ // // // getuserdetails
37
+ // let validate: any = await client.fetchTopics();
38
+ // console.log('>>>>>>>>>>>>>idd>>>>', validate)
33
39
  // }
34
40
  // testval()
35
41
  //# sourceMappingURL=index.js.map
@@ -7,7 +7,7 @@ export declare class FcmClient implements PushNotifyProvider {
7
7
  sendPushNotification(token: string, notificationMessage: any): Promise<any>;
8
8
  sendChunkedPushNotification(tokens: string[], notificationMessage: string): Promise<unknown>;
9
9
  chunkTokens(tokens: string[], chunkSize: number): Promise<any>;
10
- fetchTopics(): Promise<any>;
10
+ fetchTopics(isArrayRes?: boolean): Promise<any>;
11
11
  /**
12
12
  * Method to send notification based on topics
13
13
  * @param topics
@@ -129,7 +129,7 @@ class FcmClient {
129
129
  }
130
130
  });
131
131
  }
132
- fetchTopics() {
132
+ fetchTopics(isArrayRes) {
133
133
  return __awaiter(this, void 0, void 0, function* () {
134
134
  try {
135
135
  const db = admin.firestore(); // Use Firestore// Firebase Realtime Database reference
@@ -140,7 +140,12 @@ class FcmClient {
140
140
  }
141
141
  const topics = [];
142
142
  snapshot.forEach((doc) => {
143
- topics.push({ name: doc.data().name }); // Assuming each topic has a 'name' field
143
+ if (isArrayRes) {
144
+ topics.push(doc.data().name); // Assuming each topic has a 'name' field
145
+ }
146
+ else {
147
+ topics.push({ name: doc.data().name }); // Assuming each topic has a 'name' field
148
+ }
144
149
  });
145
150
  return topics;
146
151
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platform-x/hep-push-notification-client",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "@platform-x/hep-push-notification-client",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",