@amohamud23/notihub 1.0.187 → 1.0.188

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
@@ -980,7 +980,6 @@ var Views_default = Views;
980
980
 
981
981
  // src/DynamoModels/SubscriptionType.ts
982
982
  var import_lib_dynamodb10 = require("@aws-sdk/lib-dynamodb");
983
- var import_date_fns = require("date-fns");
984
983
  var SubscriptionType = class _SubscriptionType {
985
984
  static ENV = process.env.ENV || "dev";
986
985
  static TABLE_NAME = `NotiHub-SubscriptionTypes-v1-${_SubscriptionType.ENV}`;
@@ -1041,40 +1040,29 @@ var SubscriptionType = class _SubscriptionType {
1041
1040
  }
1042
1041
  }
1043
1042
  /**
1044
- * Get subscription types chart by customerId.
1045
- * @param customerId - The ID of the customer to retrieve subscription types for.
1043
+ * Get all subscription types by notifier ID.
1044
+ * @param notifierId - The ID of the notifier to retrieve subscription types for.
1046
1045
  * @returns A promise that resolves to an array of subscription type objects or null if not found.
1047
1046
  */
1048
- static async getSubscriptionTypesChartByCustomerId(customerId) {
1049
- let lastKey;
1050
- const dateMap = {};
1047
+ static async getSubscriptionTypesByNotifierId(notifierId) {
1051
1048
  const command = new import_lib_dynamodb10.QueryCommand({
1052
1049
  TableName: _SubscriptionType.TABLE_NAME,
1053
- IndexName: "CustomerIdIndex",
1054
- KeyConditionExpression: "customerId = :customerId",
1050
+ IndexName: "NotifierIdIndex",
1051
+ // Assuming you have a GSI for notifierId
1052
+ KeyConditionExpression: "notifierId = :notifierId",
1055
1053
  ExpressionAttributeValues: {
1056
- ":customerId": customerId
1057
- },
1058
- ExclusiveStartKey: lastKey
1054
+ ":notifierId": notifierId
1055
+ }
1059
1056
  });
1060
1057
  try {
1061
- do {
1062
- const result = await ddbDocClient.send(command);
1063
- const items = result.Items;
1064
- items.forEach((item) => {
1065
- const date = (0, import_date_fns.format)((0, import_date_fns.parseISO)(item.createdAt), "yyyy-MM-dd");
1066
- dateMap[date] = (dateMap[date] || 0) + 1;
1067
- });
1068
- lastKey = result.LastEvaluatedKey;
1069
- } while (lastKey);
1070
- const chartData = Object.entries(dateMap).sort(([a], [b]) => a > b ? 1 : -1).map(([date, count]) => ({ date, count }));
1071
- return chartData.length > 0 ? chartData : null;
1058
+ const result = await ddbDocClient.send(command);
1059
+ return result.Items || null;
1072
1060
  } catch (error) {
1073
1061
  console.error(
1074
- `Error fetching subscription types by customerId: ${customerId}`,
1062
+ `Error fetching subscription types by notifierId: ${notifierId}`,
1075
1063
  error
1076
1064
  );
1077
- throw new Error("Could not fetch subscription types by customerId");
1065
+ throw new Error("Could not fetch subscription types by notifierId");
1078
1066
  }
1079
1067
  }
1080
1068
  };
package/dist/index.d.cts CHANGED
@@ -162,7 +162,6 @@ type IUserSubscription = {
162
162
  type IUserSubscribeNotifier = {
163
163
  userId: string;
164
164
  customerId: string;
165
- customer: INotiHubCustomer;
166
165
  notiTypeId: string;
167
166
  notiType: INotiType;
168
167
  subscriptionId: string;
@@ -503,14 +502,11 @@ declare class SubscriptionType {
503
502
  */
504
503
  static deleteSubscriptionTypeById(id: string): Promise<void>;
505
504
  /**
506
- * Get subscription types chart by customerId.
507
- * @param customerId - The ID of the customer to retrieve subscription types for.
505
+ * Get all subscription types by notifier ID.
506
+ * @param notifierId - The ID of the notifier to retrieve subscription types for.
508
507
  * @returns A promise that resolves to an array of subscription type objects or null if not found.
509
508
  */
510
- static getSubscriptionTypesChartByCustomerId(customerId: string): Promise<{
511
- date: string;
512
- count: number;
513
- }[] | null>;
509
+ static getSubscriptionTypesByNotifierId(notifierId: string): Promise<IUserSubscribeNotifier[] | null>;
514
510
  }
515
511
 
516
512
  declare class CustomerMetaData {
package/dist/index.d.ts CHANGED
@@ -162,7 +162,6 @@ type IUserSubscription = {
162
162
  type IUserSubscribeNotifier = {
163
163
  userId: string;
164
164
  customerId: string;
165
- customer: INotiHubCustomer;
166
165
  notiTypeId: string;
167
166
  notiType: INotiType;
168
167
  subscriptionId: string;
@@ -503,14 +502,11 @@ declare class SubscriptionType {
503
502
  */
504
503
  static deleteSubscriptionTypeById(id: string): Promise<void>;
505
504
  /**
506
- * Get subscription types chart by customerId.
507
- * @param customerId - The ID of the customer to retrieve subscription types for.
505
+ * Get all subscription types by notifier ID.
506
+ * @param notifierId - The ID of the notifier to retrieve subscription types for.
508
507
  * @returns A promise that resolves to an array of subscription type objects or null if not found.
509
508
  */
510
- static getSubscriptionTypesChartByCustomerId(customerId: string): Promise<{
511
- date: string;
512
- count: number;
513
- }[] | null>;
509
+ static getSubscriptionTypesByNotifierId(notifierId: string): Promise<IUserSubscribeNotifier[] | null>;
514
510
  }
515
511
 
516
512
  declare class CustomerMetaData {
package/dist/index.js CHANGED
@@ -985,7 +985,6 @@ import {
985
985
  GetCommand as GetCommand9,
986
986
  QueryCommand as QueryCommand9
987
987
  } from "@aws-sdk/lib-dynamodb";
988
- import { format, parseISO } from "date-fns";
989
988
  var SubscriptionType = class _SubscriptionType {
990
989
  static ENV = process.env.ENV || "dev";
991
990
  static TABLE_NAME = `NotiHub-SubscriptionTypes-v1-${_SubscriptionType.ENV}`;
@@ -1046,40 +1045,29 @@ var SubscriptionType = class _SubscriptionType {
1046
1045
  }
1047
1046
  }
1048
1047
  /**
1049
- * Get subscription types chart by customerId.
1050
- * @param customerId - The ID of the customer to retrieve subscription types for.
1048
+ * Get all subscription types by notifier ID.
1049
+ * @param notifierId - The ID of the notifier to retrieve subscription types for.
1051
1050
  * @returns A promise that resolves to an array of subscription type objects or null if not found.
1052
1051
  */
1053
- static async getSubscriptionTypesChartByCustomerId(customerId) {
1054
- let lastKey;
1055
- const dateMap = {};
1052
+ static async getSubscriptionTypesByNotifierId(notifierId) {
1056
1053
  const command = new QueryCommand9({
1057
1054
  TableName: _SubscriptionType.TABLE_NAME,
1058
- IndexName: "CustomerIdIndex",
1059
- KeyConditionExpression: "customerId = :customerId",
1055
+ IndexName: "NotifierIdIndex",
1056
+ // Assuming you have a GSI for notifierId
1057
+ KeyConditionExpression: "notifierId = :notifierId",
1060
1058
  ExpressionAttributeValues: {
1061
- ":customerId": customerId
1062
- },
1063
- ExclusiveStartKey: lastKey
1059
+ ":notifierId": notifierId
1060
+ }
1064
1061
  });
1065
1062
  try {
1066
- do {
1067
- const result = await ddbDocClient.send(command);
1068
- const items = result.Items;
1069
- items.forEach((item) => {
1070
- const date = format(parseISO(item.createdAt), "yyyy-MM-dd");
1071
- dateMap[date] = (dateMap[date] || 0) + 1;
1072
- });
1073
- lastKey = result.LastEvaluatedKey;
1074
- } while (lastKey);
1075
- const chartData = Object.entries(dateMap).sort(([a], [b]) => a > b ? 1 : -1).map(([date, count]) => ({ date, count }));
1076
- return chartData.length > 0 ? chartData : null;
1063
+ const result = await ddbDocClient.send(command);
1064
+ return result.Items || null;
1077
1065
  } catch (error) {
1078
1066
  console.error(
1079
- `Error fetching subscription types by customerId: ${customerId}`,
1067
+ `Error fetching subscription types by notifierId: ${notifierId}`,
1080
1068
  error
1081
1069
  );
1082
- throw new Error("Could not fetch subscription types by customerId");
1070
+ throw new Error("Could not fetch subscription types by notifierId");
1083
1071
  }
1084
1072
  }
1085
1073
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amohamud23/notihub",
3
- "version": "1.0.187",
3
+ "version": "1.0.188",
4
4
  "description": "Notihub Package",
5
5
  "main": "./dist/index.cjs",
6
6
  "types": "./dist/index.d.cts",