@amohamud23/notihub 1.1.52 → 1.1.54

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # NotiHubPackage
2
-
3
- ### How to publish package
4
-
5
- 1. Increment version
6
-
7
- 2. Run `npm publish`
1
+ # NotiHubPackage
2
+
3
+ ### How to publish package
4
+
5
+ 1. Increment version
6
+
7
+ 2. Run `npm publish`
package/dist/index.cjs CHANGED
@@ -28,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
33
  DocumentNotFoundException: () => DocumentNotFoundException,
34
34
  ErrorCode: () => errorcodes_exports,
35
35
  MongooseClient: () => MongooseClient_default,
@@ -41,7 +41,7 @@ __export(src_exports, {
41
41
  handleError: () => handleError,
42
42
  handleSuccess: () => handleSuccess
43
43
  });
44
- module.exports = __toCommonJS(src_exports);
44
+ module.exports = __toCommonJS(index_exports);
45
45
 
46
46
  // src/util/index.ts
47
47
  function getDate(dateStr) {
@@ -545,6 +545,23 @@ var Notifications = class _Notifications {
545
545
  throw new Error("Could not create notification");
546
546
  }
547
547
  }
548
+ /**
549
+ * Deletes a notification by its ID.
550
+ * @param id - The ID of the notification to delete.
551
+ * @returns A promise that resolves when the notification is deleted.
552
+ */
553
+ static async deleteNotificationById(id) {
554
+ const command = new import_lib_dynamodb4.DeleteCommand({
555
+ TableName: _Notifications.TABLE_NAME,
556
+ Key: { id }
557
+ });
558
+ try {
559
+ await ddbDocClient.send(command);
560
+ } catch (error) {
561
+ console.error("Error deleting notification:", error);
562
+ throw new Error("Could not delete notification");
563
+ }
564
+ }
548
565
  /**
549
566
  * Fetches and merges paginated notifications for multiple notiTypeIds, sorted by createdAt descending.
550
567
  * @param notiTypeIds - Array of notiTypeIds to fetch.
package/dist/index.d.cts CHANGED
@@ -70,7 +70,7 @@ type INotiHubCustomer = {
70
70
  type INotiHubCustomerMetadata = {
71
71
  id: string;
72
72
  customerId: string;
73
- paymentState: "ACTIVE" | "INACTIVE";
73
+ paymentState: "ACTIVE" | "INACTIVE" | "TRIAL";
74
74
  emailState: "VERIFIED" | "UNVERIFIED";
75
75
  isOnboarded: boolean;
76
76
  notiLimit: number;
@@ -370,6 +370,12 @@ declare class Notifications {
370
370
  * @returns A promise that resolves to the created notification object.
371
371
  */
372
372
  static createNotification(notification: INotiHubNotification): Promise<INotiHubNotification>;
373
+ /**
374
+ * Deletes a notification by its ID.
375
+ * @param id - The ID of the notification to delete.
376
+ * @returns A promise that resolves when the notification is deleted.
377
+ */
378
+ static deleteNotificationById(id: string): Promise<void>;
373
379
  /**
374
380
  * Fetches and merges paginated notifications for multiple notiTypeIds, sorted by createdAt descending.
375
381
  * @param notiTypeIds - Array of notiTypeIds to fetch.
package/dist/index.d.ts CHANGED
@@ -70,7 +70,7 @@ type INotiHubCustomer = {
70
70
  type INotiHubCustomerMetadata = {
71
71
  id: string;
72
72
  customerId: string;
73
- paymentState: "ACTIVE" | "INACTIVE";
73
+ paymentState: "ACTIVE" | "INACTIVE" | "TRIAL";
74
74
  emailState: "VERIFIED" | "UNVERIFIED";
75
75
  isOnboarded: boolean;
76
76
  notiLimit: number;
@@ -370,6 +370,12 @@ declare class Notifications {
370
370
  * @returns A promise that resolves to the created notification object.
371
371
  */
372
372
  static createNotification(notification: INotiHubNotification): Promise<INotiHubNotification>;
373
+ /**
374
+ * Deletes a notification by its ID.
375
+ * @param id - The ID of the notification to delete.
376
+ * @returns A promise that resolves when the notification is deleted.
377
+ */
378
+ static deleteNotificationById(id: string): Promise<void>;
373
379
  /**
374
380
  * Fetches and merges paginated notifications for multiple notiTypeIds, sorted by createdAt descending.
375
381
  * @param notiTypeIds - Array of notiTypeIds to fetch.
package/dist/index.js CHANGED
@@ -453,6 +453,7 @@ var Customer_default = Customer;
453
453
 
454
454
  // src/DynamoModels/Notifications.ts
455
455
  import {
456
+ DeleteCommand as DeleteCommand3,
456
457
  PutCommand as PutCommand3,
457
458
  QueryCommand as QueryCommand3
458
459
  } from "@aws-sdk/lib-dynamodb";
@@ -522,6 +523,23 @@ var Notifications = class _Notifications {
522
523
  throw new Error("Could not create notification");
523
524
  }
524
525
  }
526
+ /**
527
+ * Deletes a notification by its ID.
528
+ * @param id - The ID of the notification to delete.
529
+ * @returns A promise that resolves when the notification is deleted.
530
+ */
531
+ static async deleteNotificationById(id) {
532
+ const command = new DeleteCommand3({
533
+ TableName: _Notifications.TABLE_NAME,
534
+ Key: { id }
535
+ });
536
+ try {
537
+ await ddbDocClient.send(command);
538
+ } catch (error) {
539
+ console.error("Error deleting notification:", error);
540
+ throw new Error("Could not delete notification");
541
+ }
542
+ }
525
543
  /**
526
544
  * Fetches and merges paginated notifications for multiple notiTypeIds, sorted by createdAt descending.
527
545
  * @param notiTypeIds - Array of notiTypeIds to fetch.
package/package.json CHANGED
@@ -1,42 +1,42 @@
1
- {
2
- "name": "@amohamud23/notihub",
3
- "version": "1.1.52",
4
- "description": "Notihub Package",
5
- "main": "./dist/index.cjs",
6
- "types": "./dist/index.d.cts",
7
- "type": "module",
8
- "scripts": {
9
- "build": "tsup",
10
- "test": "jest"
11
- },
12
- "files": [
13
- "dist"
14
- ],
15
- "keywords": [
16
- "npm",
17
- "package",
18
- "util",
19
- "types"
20
- ],
21
- "author": "Abdi Mohamud",
22
- "license": "ISC",
23
- "devDependencies": {
24
- "@types/express": "^5.0.3",
25
- "@types/jest": "^29.5.14",
26
- "@types/node": "^22.8.4",
27
- "express": "^5.1.0",
28
- "jest": "^29.7.0",
29
- "ts-jest": "^29.3.4",
30
- "typescript": "^5.8.3"
31
- },
32
- "dependencies": {
33
- "@aws-sdk/client-dynamodb": "^3.821.0",
34
- "@aws-sdk/lib-dynamodb": "^3.821.0",
35
- "aws-sdk-client-mock": "^4.1.0",
36
- "date-fns": "^4.1.0",
37
- "mongoose": "^8.7.2",
38
- "ts-node": "^10.9.2",
39
- "tsup": "^8.3.5",
40
- "uuid": "^11.0.2"
41
- }
42
- }
1
+ {
2
+ "name": "@amohamud23/notihub",
3
+ "version": "1.1.54",
4
+ "description": "Notihub Package",
5
+ "main": "./dist/index.cjs",
6
+ "types": "./dist/index.d.cts",
7
+ "type": "module",
8
+ "scripts": {
9
+ "build": "tsup",
10
+ "test": "jest"
11
+ },
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "keywords": [
16
+ "npm",
17
+ "package",
18
+ "util",
19
+ "types"
20
+ ],
21
+ "author": "Abdi Mohamud",
22
+ "license": "ISC",
23
+ "devDependencies": {
24
+ "@types/express": "^5.0.3",
25
+ "@types/jest": "^29.5.14",
26
+ "@types/node": "^22.8.4",
27
+ "express": "^5.1.0",
28
+ "jest": "^29.7.0",
29
+ "ts-jest": "^29.3.4",
30
+ "tsup": "^8.5.1",
31
+ "typescript": "^5.8.3"
32
+ },
33
+ "dependencies": {
34
+ "@aws-sdk/client-dynamodb": "^3.821.0",
35
+ "@aws-sdk/lib-dynamodb": "^3.821.0",
36
+ "aws-sdk-client-mock": "^4.1.0",
37
+ "date-fns": "^4.1.0",
38
+ "mongoose": "^8.7.2",
39
+ "ts-node": "^10.9.2",
40
+ "uuid": "^11.0.2"
41
+ }
42
+ }