@amohamud23/notihub 1.1.9 → 1.1.11
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 +16 -5
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -940,13 +940,21 @@ var Subscription = class _Subscription {
|
|
|
940
940
|
* @returns A promise that resolves to the subscription object or null if not found.
|
|
941
941
|
*/
|
|
942
942
|
static async getSubscriptionBySubscriptionId(subscriptionId) {
|
|
943
|
-
const command = new import_lib_dynamodb7.
|
|
943
|
+
const command = new import_lib_dynamodb7.QueryCommand({
|
|
944
944
|
TableName: _Subscription.TABLE_NAME,
|
|
945
|
-
|
|
945
|
+
IndexName: "SubscriptionIdIndex",
|
|
946
|
+
// Assuming you have a GSI for userId
|
|
947
|
+
KeyConditionExpression: "subscriptionId = :subscriptionId",
|
|
948
|
+
ExpressionAttributeValues: {
|
|
949
|
+
":subscriptionId": subscriptionId
|
|
950
|
+
}
|
|
946
951
|
});
|
|
947
952
|
try {
|
|
948
953
|
const result = await ddbDocClient.send(command);
|
|
949
|
-
|
|
954
|
+
if (!result.Items || result.Items.length === 0) {
|
|
955
|
+
return null;
|
|
956
|
+
}
|
|
957
|
+
return result.Items[0] || null;
|
|
950
958
|
} catch (error) {
|
|
951
959
|
console.error("Error fetching subscription by SubscriptionId:", error);
|
|
952
960
|
throw new Error("Could not fetch subscription by SubscriptionId");
|
|
@@ -1113,10 +1121,13 @@ var SubscriptionType = class _SubscriptionType {
|
|
|
1113
1121
|
* @param id - The ID of the subscription type to retrieve.
|
|
1114
1122
|
* @returns A promise that resolves to the subscription type object or null if not found.
|
|
1115
1123
|
*/
|
|
1116
|
-
static async getSubscriptionTypeById(id) {
|
|
1124
|
+
static async getSubscriptionTypeById(id, userId) {
|
|
1117
1125
|
const command = new import_lib_dynamodb10.GetCommand({
|
|
1118
1126
|
TableName: _SubscriptionType.TABLE_NAME,
|
|
1119
|
-
Key: {
|
|
1127
|
+
Key: {
|
|
1128
|
+
id,
|
|
1129
|
+
userId
|
|
1130
|
+
}
|
|
1120
1131
|
});
|
|
1121
1132
|
try {
|
|
1122
1133
|
const result = await ddbDocClient.send(command);
|
package/dist/index.d.cts
CHANGED
|
@@ -530,7 +530,7 @@ declare class SubscriptionType {
|
|
|
530
530
|
* @param id - The ID of the subscription type to retrieve.
|
|
531
531
|
* @returns A promise that resolves to the subscription type object or null if not found.
|
|
532
532
|
*/
|
|
533
|
-
static getSubscriptionTypeById(id: string): Promise<IUserSubscribeNotifier | null>;
|
|
533
|
+
static getSubscriptionTypeById(id: string, userId: string): Promise<IUserSubscribeNotifier | null>;
|
|
534
534
|
static getSubscriptionTypesByUserId(userId: string): Promise<IUserSubscribeNotifier[] | null>;
|
|
535
535
|
/**
|
|
536
536
|
* Deletes a subscription type by its ID.
|
package/dist/index.d.ts
CHANGED
|
@@ -530,7 +530,7 @@ declare class SubscriptionType {
|
|
|
530
530
|
* @param id - The ID of the subscription type to retrieve.
|
|
531
531
|
* @returns A promise that resolves to the subscription type object or null if not found.
|
|
532
532
|
*/
|
|
533
|
-
static getSubscriptionTypeById(id: string): Promise<IUserSubscribeNotifier | null>;
|
|
533
|
+
static getSubscriptionTypeById(id: string, userId: string): Promise<IUserSubscribeNotifier | null>;
|
|
534
534
|
static getSubscriptionTypesByUserId(userId: string): Promise<IUserSubscribeNotifier[] | null>;
|
|
535
535
|
/**
|
|
536
536
|
* Deletes a subscription type by its ID.
|
package/dist/index.js
CHANGED
|
@@ -933,13 +933,21 @@ var Subscription = class _Subscription {
|
|
|
933
933
|
* @returns A promise that resolves to the subscription object or null if not found.
|
|
934
934
|
*/
|
|
935
935
|
static async getSubscriptionBySubscriptionId(subscriptionId) {
|
|
936
|
-
const command = new
|
|
936
|
+
const command = new QueryCommand6({
|
|
937
937
|
TableName: _Subscription.TABLE_NAME,
|
|
938
|
-
|
|
938
|
+
IndexName: "SubscriptionIdIndex",
|
|
939
|
+
// Assuming you have a GSI for userId
|
|
940
|
+
KeyConditionExpression: "subscriptionId = :subscriptionId",
|
|
941
|
+
ExpressionAttributeValues: {
|
|
942
|
+
":subscriptionId": subscriptionId
|
|
943
|
+
}
|
|
939
944
|
});
|
|
940
945
|
try {
|
|
941
946
|
const result = await ddbDocClient.send(command);
|
|
942
|
-
|
|
947
|
+
if (!result.Items || result.Items.length === 0) {
|
|
948
|
+
return null;
|
|
949
|
+
}
|
|
950
|
+
return result.Items[0] || null;
|
|
943
951
|
} catch (error) {
|
|
944
952
|
console.error("Error fetching subscription by SubscriptionId:", error);
|
|
945
953
|
throw new Error("Could not fetch subscription by SubscriptionId");
|
|
@@ -1119,10 +1127,13 @@ var SubscriptionType = class _SubscriptionType {
|
|
|
1119
1127
|
* @param id - The ID of the subscription type to retrieve.
|
|
1120
1128
|
* @returns A promise that resolves to the subscription type object or null if not found.
|
|
1121
1129
|
*/
|
|
1122
|
-
static async getSubscriptionTypeById(id) {
|
|
1130
|
+
static async getSubscriptionTypeById(id, userId) {
|
|
1123
1131
|
const command = new GetCommand9({
|
|
1124
1132
|
TableName: _SubscriptionType.TABLE_NAME,
|
|
1125
|
-
Key: {
|
|
1133
|
+
Key: {
|
|
1134
|
+
id,
|
|
1135
|
+
userId
|
|
1136
|
+
}
|
|
1126
1137
|
});
|
|
1127
1138
|
try {
|
|
1128
1139
|
const result = await ddbDocClient.send(command);
|