@amohamud23/notihub 1.1.27 → 1.1.29

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.cjs CHANGED
@@ -1026,6 +1026,32 @@ var Subscription = class _Subscription {
1026
1026
  await Promise.all(deletePromises);
1027
1027
  }
1028
1028
  }
1029
+ /**
1030
+ * Fetch all subscriptions by customer ID.
1031
+ * @param customerId - The ID of the customer whose subscriptions to retrieve.
1032
+ * @returns A promise that resolves to an array of subscription objects or null if not found.
1033
+ */
1034
+ static async getSubscriptionsByCustomerId(customerId) {
1035
+ const command = new import_lib_dynamodb7.QueryCommand({
1036
+ TableName: _Subscription.TABLE_NAME,
1037
+ IndexName: "CustomerIdIndex",
1038
+ // Assuming you have a GSI for customerId
1039
+ KeyConditionExpression: "customerId = :customerId",
1040
+ ExpressionAttributeValues: {
1041
+ ":customerId": customerId
1042
+ }
1043
+ });
1044
+ try {
1045
+ const result = await ddbDocClient.send(command);
1046
+ return result.Items || null;
1047
+ } catch (error) {
1048
+ console.error(
1049
+ `Error fetching subscriptions by customerId: ${customerId}`,
1050
+ error
1051
+ );
1052
+ throw new Error("Could not fetch subscriptions by customerId");
1053
+ }
1054
+ }
1029
1055
  };
1030
1056
  var Subscription_default = Subscription;
1031
1057
 
@@ -1597,6 +1623,28 @@ var NotificationStats = class _NotificationStats {
1597
1623
  throw new Error("Could not delete notification stats");
1598
1624
  }
1599
1625
  }
1626
+ /**
1627
+ * Increments the view count for a notification stats entry.
1628
+ * @param id - The ID of the notification stats entry.
1629
+ */
1630
+ static async incrementViewCount(id) {
1631
+ const command = new import_lib_dynamodb13.UpdateCommand({
1632
+ TableName: _NotificationStats.TABLE_NAME,
1633
+ Key: { id },
1634
+ UpdateExpression: "ADD viewCount :inc",
1635
+ ExpressionAttributeValues: {
1636
+ ":inc": 1
1637
+ },
1638
+ ReturnValues: "ALL_NEW"
1639
+ });
1640
+ try {
1641
+ const result = await ddbDocClient.send(command);
1642
+ return result.Attributes;
1643
+ } catch (error) {
1644
+ console.error("Error incrementing view count:", error);
1645
+ throw new Error("Could not increment view count");
1646
+ }
1647
+ }
1600
1648
  };
1601
1649
  var NotificationStats_default = NotificationStats;
1602
1650
 
package/dist/index.d.cts CHANGED
@@ -484,6 +484,12 @@ declare class Subscription {
484
484
  * @returns A promise that resolves when all subscriptions are deleted.
485
485
  */
486
486
  static deleteAllSubscriptionsByUserId(userId: string): Promise<void>;
487
+ /**
488
+ * Fetch all subscriptions by customer ID.
489
+ * @param customerId - The ID of the customer whose subscriptions to retrieve.
490
+ * @returns A promise that resolves to an array of subscription objects or null if not found.
491
+ */
492
+ static getSubscriptionsByCustomerId(customerId: string): Promise<INotiHubSubscription[] | null>;
487
493
  }
488
494
 
489
495
  declare class NotiTypeStats {
@@ -662,6 +668,11 @@ declare class NotificationStats {
662
668
  * @returns A promise that resolves when the deletion is complete.
663
669
  */
664
670
  static deleteNotificationStatsById(id: string): Promise<void>;
671
+ /**
672
+ * Increments the view count for a notification stats entry.
673
+ * @param id - The ID of the notification stats entry.
674
+ */
675
+ static incrementViewCount(id: string): Promise<INotiHubNotificationStats>;
665
676
  }
666
677
 
667
678
  declare class NotiHubStatsHistory {
package/dist/index.d.ts CHANGED
@@ -484,6 +484,12 @@ declare class Subscription {
484
484
  * @returns A promise that resolves when all subscriptions are deleted.
485
485
  */
486
486
  static deleteAllSubscriptionsByUserId(userId: string): Promise<void>;
487
+ /**
488
+ * Fetch all subscriptions by customer ID.
489
+ * @param customerId - The ID of the customer whose subscriptions to retrieve.
490
+ * @returns A promise that resolves to an array of subscription objects or null if not found.
491
+ */
492
+ static getSubscriptionsByCustomerId(customerId: string): Promise<INotiHubSubscription[] | null>;
487
493
  }
488
494
 
489
495
  declare class NotiTypeStats {
@@ -662,6 +668,11 @@ declare class NotificationStats {
662
668
  * @returns A promise that resolves when the deletion is complete.
663
669
  */
664
670
  static deleteNotificationStatsById(id: string): Promise<void>;
671
+ /**
672
+ * Increments the view count for a notification stats entry.
673
+ * @param id - The ID of the notification stats entry.
674
+ */
675
+ static incrementViewCount(id: string): Promise<INotiHubNotificationStats>;
665
676
  }
666
677
 
667
678
  declare class NotiHubStatsHistory {
package/dist/index.js CHANGED
@@ -1020,6 +1020,32 @@ var Subscription = class _Subscription {
1020
1020
  await Promise.all(deletePromises);
1021
1021
  }
1022
1022
  }
1023
+ /**
1024
+ * Fetch all subscriptions by customer ID.
1025
+ * @param customerId - The ID of the customer whose subscriptions to retrieve.
1026
+ * @returns A promise that resolves to an array of subscription objects or null if not found.
1027
+ */
1028
+ static async getSubscriptionsByCustomerId(customerId) {
1029
+ const command = new QueryCommand6({
1030
+ TableName: _Subscription.TABLE_NAME,
1031
+ IndexName: "CustomerIdIndex",
1032
+ // Assuming you have a GSI for customerId
1033
+ KeyConditionExpression: "customerId = :customerId",
1034
+ ExpressionAttributeValues: {
1035
+ ":customerId": customerId
1036
+ }
1037
+ });
1038
+ try {
1039
+ const result = await ddbDocClient.send(command);
1040
+ return result.Items || null;
1041
+ } catch (error) {
1042
+ console.error(
1043
+ `Error fetching subscriptions by customerId: ${customerId}`,
1044
+ error
1045
+ );
1046
+ throw new Error("Could not fetch subscriptions by customerId");
1047
+ }
1048
+ }
1023
1049
  };
1024
1050
  var Subscription_default = Subscription;
1025
1051
 
@@ -1556,7 +1582,12 @@ var CustomerMinified = class _CustomerMinified {
1556
1582
  var CustomerMinified_default = CustomerMinified;
1557
1583
 
1558
1584
  // src/DynamoModels/NotificationStats.ts
1559
- import { DeleteCommand as DeleteCommand11, GetCommand as GetCommand11, PutCommand as PutCommand12 } from "@aws-sdk/lib-dynamodb";
1585
+ import {
1586
+ DeleteCommand as DeleteCommand11,
1587
+ GetCommand as GetCommand11,
1588
+ PutCommand as PutCommand12,
1589
+ UpdateCommand as UpdateCommand11
1590
+ } from "@aws-sdk/lib-dynamodb";
1560
1591
  var NotificationStats = class _NotificationStats {
1561
1592
  static ENV = process.env.ENV || "dev";
1562
1593
  static TABLE_NAME = `NotiHub-NotificationStats-v1-${_NotificationStats.ENV}`;
@@ -1613,6 +1644,28 @@ var NotificationStats = class _NotificationStats {
1613
1644
  throw new Error("Could not delete notification stats");
1614
1645
  }
1615
1646
  }
1647
+ /**
1648
+ * Increments the view count for a notification stats entry.
1649
+ * @param id - The ID of the notification stats entry.
1650
+ */
1651
+ static async incrementViewCount(id) {
1652
+ const command = new UpdateCommand11({
1653
+ TableName: _NotificationStats.TABLE_NAME,
1654
+ Key: { id },
1655
+ UpdateExpression: "ADD viewCount :inc",
1656
+ ExpressionAttributeValues: {
1657
+ ":inc": 1
1658
+ },
1659
+ ReturnValues: "ALL_NEW"
1660
+ });
1661
+ try {
1662
+ const result = await ddbDocClient.send(command);
1663
+ return result.Attributes;
1664
+ } catch (error) {
1665
+ console.error("Error incrementing view count:", error);
1666
+ throw new Error("Could not increment view count");
1667
+ }
1668
+ }
1616
1669
  };
1617
1670
  var NotificationStats_default = NotificationStats;
1618
1671
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amohamud23/notihub",
3
- "version": "1.1.27",
3
+ "version": "1.1.29",
4
4
  "description": "Notihub Package",
5
5
  "main": "./dist/index.cjs",
6
6
  "types": "./dist/index.d.cts",