@amohamud23/notihub 1.0.186 → 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 +14 -28
- package/dist/index.d.cts +3 -7
- package/dist/index.d.ts +3 -7
- package/dist/index.js +14 -28
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -581,11 +581,9 @@ var NotiType = class _NotiType {
|
|
|
581
581
|
static async getAllNotiTypesByEntityId(entityId) {
|
|
582
582
|
const command = new import_lib_dynamodb6.QueryCommand({
|
|
583
583
|
TableName: _NotiType.TABLE_NAME,
|
|
584
|
-
|
|
585
|
-
// Assuming you have a GSI for entityId
|
|
586
|
-
KeyConditionExpression: "entityId = :entityId",
|
|
584
|
+
KeyConditionExpression: "customerId = :customerId",
|
|
587
585
|
ExpressionAttributeValues: {
|
|
588
|
-
":
|
|
586
|
+
":customerId": entityId
|
|
589
587
|
}
|
|
590
588
|
});
|
|
591
589
|
try {
|
|
@@ -982,7 +980,6 @@ var Views_default = Views;
|
|
|
982
980
|
|
|
983
981
|
// src/DynamoModels/SubscriptionType.ts
|
|
984
982
|
var import_lib_dynamodb10 = require("@aws-sdk/lib-dynamodb");
|
|
985
|
-
var import_date_fns = require("date-fns");
|
|
986
983
|
var SubscriptionType = class _SubscriptionType {
|
|
987
984
|
static ENV = process.env.ENV || "dev";
|
|
988
985
|
static TABLE_NAME = `NotiHub-SubscriptionTypes-v1-${_SubscriptionType.ENV}`;
|
|
@@ -1043,40 +1040,29 @@ var SubscriptionType = class _SubscriptionType {
|
|
|
1043
1040
|
}
|
|
1044
1041
|
}
|
|
1045
1042
|
/**
|
|
1046
|
-
* Get subscription types
|
|
1047
|
-
* @param
|
|
1043
|
+
* Get all subscription types by notifier ID.
|
|
1044
|
+
* @param notifierId - The ID of the notifier to retrieve subscription types for.
|
|
1048
1045
|
* @returns A promise that resolves to an array of subscription type objects or null if not found.
|
|
1049
1046
|
*/
|
|
1050
|
-
static async
|
|
1051
|
-
let lastKey;
|
|
1052
|
-
const dateMap = {};
|
|
1047
|
+
static async getSubscriptionTypesByNotifierId(notifierId) {
|
|
1053
1048
|
const command = new import_lib_dynamodb10.QueryCommand({
|
|
1054
1049
|
TableName: _SubscriptionType.TABLE_NAME,
|
|
1055
|
-
IndexName: "
|
|
1056
|
-
|
|
1050
|
+
IndexName: "NotifierIdIndex",
|
|
1051
|
+
// Assuming you have a GSI for notifierId
|
|
1052
|
+
KeyConditionExpression: "notifierId = :notifierId",
|
|
1057
1053
|
ExpressionAttributeValues: {
|
|
1058
|
-
":
|
|
1059
|
-
}
|
|
1060
|
-
ExclusiveStartKey: lastKey
|
|
1054
|
+
":notifierId": notifierId
|
|
1055
|
+
}
|
|
1061
1056
|
});
|
|
1062
1057
|
try {
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
const items = result.Items;
|
|
1066
|
-
items.forEach((item) => {
|
|
1067
|
-
const date = (0, import_date_fns.format)((0, import_date_fns.parseISO)(item.createdAt), "yyyy-MM-dd");
|
|
1068
|
-
dateMap[date] = (dateMap[date] || 0) + 1;
|
|
1069
|
-
});
|
|
1070
|
-
lastKey = result.LastEvaluatedKey;
|
|
1071
|
-
} while (lastKey);
|
|
1072
|
-
const chartData = Object.entries(dateMap).sort(([a], [b]) => a > b ? 1 : -1).map(([date, count]) => ({ date, count }));
|
|
1073
|
-
return chartData.length > 0 ? chartData : null;
|
|
1058
|
+
const result = await ddbDocClient.send(command);
|
|
1059
|
+
return result.Items || null;
|
|
1074
1060
|
} catch (error) {
|
|
1075
1061
|
console.error(
|
|
1076
|
-
`Error fetching subscription types by
|
|
1062
|
+
`Error fetching subscription types by notifierId: ${notifierId}`,
|
|
1077
1063
|
error
|
|
1078
1064
|
);
|
|
1079
|
-
throw new Error("Could not fetch subscription types by
|
|
1065
|
+
throw new Error("Could not fetch subscription types by notifierId");
|
|
1080
1066
|
}
|
|
1081
1067
|
}
|
|
1082
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
|
|
507
|
-
* @param
|
|
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
|
|
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
|
|
507
|
-
* @param
|
|
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
|
|
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
|
@@ -569,11 +569,9 @@ var NotiType = class _NotiType {
|
|
|
569
569
|
static async getAllNotiTypesByEntityId(entityId) {
|
|
570
570
|
const command = new QueryCommand5({
|
|
571
571
|
TableName: _NotiType.TABLE_NAME,
|
|
572
|
-
|
|
573
|
-
// Assuming you have a GSI for entityId
|
|
574
|
-
KeyConditionExpression: "entityId = :entityId",
|
|
572
|
+
KeyConditionExpression: "customerId = :customerId",
|
|
575
573
|
ExpressionAttributeValues: {
|
|
576
|
-
":
|
|
574
|
+
":customerId": entityId
|
|
577
575
|
}
|
|
578
576
|
});
|
|
579
577
|
try {
|
|
@@ -987,7 +985,6 @@ import {
|
|
|
987
985
|
GetCommand as GetCommand9,
|
|
988
986
|
QueryCommand as QueryCommand9
|
|
989
987
|
} from "@aws-sdk/lib-dynamodb";
|
|
990
|
-
import { format, parseISO } from "date-fns";
|
|
991
988
|
var SubscriptionType = class _SubscriptionType {
|
|
992
989
|
static ENV = process.env.ENV || "dev";
|
|
993
990
|
static TABLE_NAME = `NotiHub-SubscriptionTypes-v1-${_SubscriptionType.ENV}`;
|
|
@@ -1048,40 +1045,29 @@ var SubscriptionType = class _SubscriptionType {
|
|
|
1048
1045
|
}
|
|
1049
1046
|
}
|
|
1050
1047
|
/**
|
|
1051
|
-
* Get subscription types
|
|
1052
|
-
* @param
|
|
1048
|
+
* Get all subscription types by notifier ID.
|
|
1049
|
+
* @param notifierId - The ID of the notifier to retrieve subscription types for.
|
|
1053
1050
|
* @returns A promise that resolves to an array of subscription type objects or null if not found.
|
|
1054
1051
|
*/
|
|
1055
|
-
static async
|
|
1056
|
-
let lastKey;
|
|
1057
|
-
const dateMap = {};
|
|
1052
|
+
static async getSubscriptionTypesByNotifierId(notifierId) {
|
|
1058
1053
|
const command = new QueryCommand9({
|
|
1059
1054
|
TableName: _SubscriptionType.TABLE_NAME,
|
|
1060
|
-
IndexName: "
|
|
1061
|
-
|
|
1055
|
+
IndexName: "NotifierIdIndex",
|
|
1056
|
+
// Assuming you have a GSI for notifierId
|
|
1057
|
+
KeyConditionExpression: "notifierId = :notifierId",
|
|
1062
1058
|
ExpressionAttributeValues: {
|
|
1063
|
-
":
|
|
1064
|
-
}
|
|
1065
|
-
ExclusiveStartKey: lastKey
|
|
1059
|
+
":notifierId": notifierId
|
|
1060
|
+
}
|
|
1066
1061
|
});
|
|
1067
1062
|
try {
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
const items = result.Items;
|
|
1071
|
-
items.forEach((item) => {
|
|
1072
|
-
const date = format(parseISO(item.createdAt), "yyyy-MM-dd");
|
|
1073
|
-
dateMap[date] = (dateMap[date] || 0) + 1;
|
|
1074
|
-
});
|
|
1075
|
-
lastKey = result.LastEvaluatedKey;
|
|
1076
|
-
} while (lastKey);
|
|
1077
|
-
const chartData = Object.entries(dateMap).sort(([a], [b]) => a > b ? 1 : -1).map(([date, count]) => ({ date, count }));
|
|
1078
|
-
return chartData.length > 0 ? chartData : null;
|
|
1063
|
+
const result = await ddbDocClient.send(command);
|
|
1064
|
+
return result.Items || null;
|
|
1079
1065
|
} catch (error) {
|
|
1080
1066
|
console.error(
|
|
1081
|
-
`Error fetching subscription types by
|
|
1067
|
+
`Error fetching subscription types by notifierId: ${notifierId}`,
|
|
1082
1068
|
error
|
|
1083
1069
|
);
|
|
1084
|
-
throw new Error("Could not fetch subscription types by
|
|
1070
|
+
throw new Error("Could not fetch subscription types by notifierId");
|
|
1085
1071
|
}
|
|
1086
1072
|
}
|
|
1087
1073
|
};
|