@amohamud23/notihub 1.1.63 → 1.1.65
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 +5 -12
- package/dist/index.js +6 -12
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -461,21 +461,13 @@ var Notifications = class _Notifications {
|
|
|
461
461
|
* @returns A promise that resolves to the notification object or null if not found.
|
|
462
462
|
*/
|
|
463
463
|
static async getNotificationById(id) {
|
|
464
|
-
const
|
|
464
|
+
const command = new import_lib_dynamodb4.GetCommand({
|
|
465
465
|
TableName: _Notifications.TABLE_NAME,
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
ExpressionAttributeValues: {
|
|
469
|
-
":id": id
|
|
470
|
-
}
|
|
471
|
-
};
|
|
472
|
-
const command = new import_lib_dynamodb4.QueryCommand(params);
|
|
466
|
+
Key: { id }
|
|
467
|
+
});
|
|
473
468
|
try {
|
|
474
469
|
const response = await ddbDocClient.send(command);
|
|
475
|
-
|
|
476
|
-
return null;
|
|
477
|
-
}
|
|
478
|
-
return response.Items[0] ?? null;
|
|
470
|
+
return response.Item || null;
|
|
479
471
|
} catch (error) {
|
|
480
472
|
console.error("Error fetching notification:", error);
|
|
481
473
|
throw new Error("Could not fetch notification");
|
|
@@ -484,6 +476,7 @@ var Notifications = class _Notifications {
|
|
|
484
476
|
static async getAllNotificationsByEntityId(customerId) {
|
|
485
477
|
const command = new import_lib_dynamodb4.QueryCommand({
|
|
486
478
|
TableName: _Notifications.TABLE_NAME,
|
|
479
|
+
IndexName: "CustomerIdCreatedAtIndex",
|
|
487
480
|
KeyConditionExpression: "customerId = :customerId",
|
|
488
481
|
ExpressionAttributeValues: {
|
|
489
482
|
":customerId": customerId
|
package/dist/index.js
CHANGED
|
@@ -437,6 +437,7 @@ var Customer_default = Customer;
|
|
|
437
437
|
// src/DynamoModels/Notifications.ts
|
|
438
438
|
import {
|
|
439
439
|
DeleteCommand as DeleteCommand3,
|
|
440
|
+
GetCommand as GetCommand3,
|
|
440
441
|
PutCommand as PutCommand3,
|
|
441
442
|
QueryCommand as QueryCommand3
|
|
442
443
|
} from "@aws-sdk/lib-dynamodb";
|
|
@@ -449,21 +450,13 @@ var Notifications = class _Notifications {
|
|
|
449
450
|
* @returns A promise that resolves to the notification object or null if not found.
|
|
450
451
|
*/
|
|
451
452
|
static async getNotificationById(id) {
|
|
452
|
-
const
|
|
453
|
+
const command = new GetCommand3({
|
|
453
454
|
TableName: _Notifications.TABLE_NAME,
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
ExpressionAttributeValues: {
|
|
457
|
-
":id": id
|
|
458
|
-
}
|
|
459
|
-
};
|
|
460
|
-
const command = new QueryCommand3(params);
|
|
455
|
+
Key: { id }
|
|
456
|
+
});
|
|
461
457
|
try {
|
|
462
458
|
const response = await ddbDocClient.send(command);
|
|
463
|
-
|
|
464
|
-
return null;
|
|
465
|
-
}
|
|
466
|
-
return response.Items[0] ?? null;
|
|
459
|
+
return response.Item || null;
|
|
467
460
|
} catch (error) {
|
|
468
461
|
console.error("Error fetching notification:", error);
|
|
469
462
|
throw new Error("Could not fetch notification");
|
|
@@ -472,6 +465,7 @@ var Notifications = class _Notifications {
|
|
|
472
465
|
static async getAllNotificationsByEntityId(customerId) {
|
|
473
466
|
const command = new QueryCommand3({
|
|
474
467
|
TableName: _Notifications.TABLE_NAME,
|
|
468
|
+
IndexName: "CustomerIdCreatedAtIndex",
|
|
475
469
|
KeyConditionExpression: "customerId = :customerId",
|
|
476
470
|
ExpressionAttributeValues: {
|
|
477
471
|
":customerId": customerId
|