@amohamud23/notihub 1.0.159 → 1.0.161

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
@@ -276,10 +276,15 @@ var User = class _User {
276
276
  throw new Error("Could not update user");
277
277
  }
278
278
  }
279
- static async deleteUser(userId) {
279
+ /**
280
+ * Deletes a user by their ID.
281
+ * @param id - The ID of the user to delete.
282
+ * @returns A promise that resolves when the user is deleted.
283
+ */
284
+ static async deleteUser(id) {
280
285
  const command = new import_lib_dynamodb2.DeleteCommand({
281
286
  TableName: _User.TABLE_NAME,
282
- Key: { userId }
287
+ Key: { id }
283
288
  });
284
289
  try {
285
290
  await ddbDocClient.send(command);
@@ -469,6 +474,24 @@ var import_lib_dynamodb5 = require("@aws-sdk/lib-dynamodb");
469
474
  var NotiHubStats = class _NotiHubStats {
470
475
  static ENV = process.env.ENV || "dev";
471
476
  static TABLE_NAME = `NotiHub-Stats-${_NotiHubStats.ENV}`;
477
+ /**
478
+ * Creates a new NotiHub stats entry.
479
+ * @param stats - The statistics object to create.
480
+ * @returns A promise that resolves to the created statistics object.
481
+ */
482
+ static async createStats(stats) {
483
+ const command = new import_lib_dynamodb5.PutCommand({
484
+ TableName: _NotiHubStats.TABLE_NAME,
485
+ Item: stats
486
+ });
487
+ try {
488
+ const result = await ddbDocClient.send(command);
489
+ return result.Attributes;
490
+ } catch (error) {
491
+ console.error("Error creating NotiHub stats:", error);
492
+ throw new Error("Could not create NotiHub stats");
493
+ }
494
+ }
472
495
  /**
473
496
  * Retrieves the statistics for NotiHub.
474
497
  * @returns A promise that resolves to the statistics object or null if not found.
@@ -1003,9 +1026,11 @@ var errorcodes_exports = {};
1003
1026
  __export(errorcodes_exports, {
1004
1027
  CustomerNotFound: () => CustomerNotFound,
1005
1028
  DocumentNotFound: () => DocumentNotFound,
1029
+ InvalidDate: () => InvalidDate,
1006
1030
  InvalidEmail: () => InvalidEmail,
1007
1031
  InvalidName: () => InvalidName,
1008
1032
  InvalidPassword: () => InvalidPassword,
1033
+ InvalidPhoneNumber: () => InvalidPhoneNumber,
1009
1034
  InvalidPushToken: () => InvalidPushToken,
1010
1035
  UserNotFound: () => UserNotFound
1011
1036
  });
@@ -1016,6 +1041,8 @@ var InvalidEmail = "4006";
1016
1041
  var InvalidPassword = "4007";
1017
1042
  var InvalidName = "4008";
1018
1043
  var InvalidPushToken = "4009";
1044
+ var InvalidPhoneNumber = "4010";
1045
+ var InvalidDate = "4011";
1019
1046
  // Annotate the CommonJS export names for ESM import in node:
1020
1047
  0 && (module.exports = {
1021
1048
  DocumentNotFoundException,
package/dist/index.d.cts CHANGED
@@ -138,8 +138,7 @@ type INotiHubStatsHistory = {
138
138
  type INotiType = {
139
139
  id: string;
140
140
  type: string;
141
- customer: string;
142
- customerRef: INotiHubCustomer;
141
+ customerId: string;
143
142
  createdAt: string;
144
143
  updatedAt: string;
145
144
  };
@@ -291,7 +290,12 @@ declare class User {
291
290
  * @returns A promise that resolves to the updated user object.
292
291
  */
293
292
  static updateUser(id: string, user: INotiHubUser): Promise<INotiHubUser>;
294
- static deleteUser(userId: string): Promise<void>;
293
+ /**
294
+ * Deletes a user by their ID.
295
+ * @param id - The ID of the user to delete.
296
+ * @returns A promise that resolves when the user is deleted.
297
+ */
298
+ static deleteUser(id: string): Promise<void>;
295
299
  }
296
300
 
297
301
  declare class Customer {
@@ -351,6 +355,12 @@ declare class Notifications {
351
355
  declare class NotiHubStats {
352
356
  static ENV: string;
353
357
  static TABLE_NAME: string;
358
+ /**
359
+ * Creates a new NotiHub stats entry.
360
+ * @param stats - The statistics object to create.
361
+ * @returns A promise that resolves to the created statistics object.
362
+ */
363
+ static createStats(stats: INotiHubStats): Promise<INotiHubStats>;
354
364
  /**
355
365
  * Retrieves the statistics for NotiHub.
356
366
  * @returns A promise that resolves to the statistics object or null if not found.
@@ -541,16 +551,20 @@ declare const InvalidEmail = "4006";
541
551
  declare const InvalidPassword = "4007";
542
552
  declare const InvalidName = "4008";
543
553
  declare const InvalidPushToken = "4009";
554
+ declare const InvalidPhoneNumber = "4010";
555
+ declare const InvalidDate = "4011";
544
556
 
545
557
  declare const errorcodes_CustomerNotFound: typeof CustomerNotFound;
546
558
  declare const errorcodes_DocumentNotFound: typeof DocumentNotFound;
559
+ declare const errorcodes_InvalidDate: typeof InvalidDate;
547
560
  declare const errorcodes_InvalidEmail: typeof InvalidEmail;
548
561
  declare const errorcodes_InvalidName: typeof InvalidName;
549
562
  declare const errorcodes_InvalidPassword: typeof InvalidPassword;
563
+ declare const errorcodes_InvalidPhoneNumber: typeof InvalidPhoneNumber;
550
564
  declare const errorcodes_InvalidPushToken: typeof InvalidPushToken;
551
565
  declare const errorcodes_UserNotFound: typeof UserNotFound;
552
566
  declare namespace errorcodes {
553
- export { errorcodes_CustomerNotFound as CustomerNotFound, errorcodes_DocumentNotFound as DocumentNotFound, errorcodes_InvalidEmail as InvalidEmail, errorcodes_InvalidName as InvalidName, errorcodes_InvalidPassword as InvalidPassword, errorcodes_InvalidPushToken as InvalidPushToken, errorcodes_UserNotFound as UserNotFound };
567
+ export { errorcodes_CustomerNotFound as CustomerNotFound, errorcodes_DocumentNotFound as DocumentNotFound, errorcodes_InvalidDate as InvalidDate, errorcodes_InvalidEmail as InvalidEmail, errorcodes_InvalidName as InvalidName, errorcodes_InvalidPassword as InvalidPassword, errorcodes_InvalidPhoneNumber as InvalidPhoneNumber, errorcodes_InvalidPushToken as InvalidPushToken, errorcodes_UserNotFound as UserNotFound };
554
568
  }
555
569
 
556
570
  export { type CreateNotiRequestBody, type CreateSubscriptionRequestBody, type CreateUserRequestBody, type DBMetaData, DocumentNotFoundException, errorcodes as ErrorCode, type ICreateCustomerRequestBody, type ICreateNotiRequestBody, type INotiHubCustomer, type INotiHubCustomerMetadata, type INotiHubCustomerMinified, type INotiHubImage, type INotiHubNotification, type INotiHubNotificationStats, type INotiHubPaymentSession, type INotiHubStats, type INotiHubStatsHistory, type INotiHubStripeSubscription, type INotiHubSubscription, type INotiHubSubscriptionActivity, type INotiHubUser, type INotiHubUserView, type INotiType, type INotiTypeStats, type IUserSubscribeNotifier, type IUserSubscription, client as MongooseClient, type NotiHubTypes, type Response, TABLES, addMonths, formatResponse, getDate, getDateFormat, handleError, handleSuccess };
package/dist/index.d.ts CHANGED
@@ -138,8 +138,7 @@ type INotiHubStatsHistory = {
138
138
  type INotiType = {
139
139
  id: string;
140
140
  type: string;
141
- customer: string;
142
- customerRef: INotiHubCustomer;
141
+ customerId: string;
143
142
  createdAt: string;
144
143
  updatedAt: string;
145
144
  };
@@ -291,7 +290,12 @@ declare class User {
291
290
  * @returns A promise that resolves to the updated user object.
292
291
  */
293
292
  static updateUser(id: string, user: INotiHubUser): Promise<INotiHubUser>;
294
- static deleteUser(userId: string): Promise<void>;
293
+ /**
294
+ * Deletes a user by their ID.
295
+ * @param id - The ID of the user to delete.
296
+ * @returns A promise that resolves when the user is deleted.
297
+ */
298
+ static deleteUser(id: string): Promise<void>;
295
299
  }
296
300
 
297
301
  declare class Customer {
@@ -351,6 +355,12 @@ declare class Notifications {
351
355
  declare class NotiHubStats {
352
356
  static ENV: string;
353
357
  static TABLE_NAME: string;
358
+ /**
359
+ * Creates a new NotiHub stats entry.
360
+ * @param stats - The statistics object to create.
361
+ * @returns A promise that resolves to the created statistics object.
362
+ */
363
+ static createStats(stats: INotiHubStats): Promise<INotiHubStats>;
354
364
  /**
355
365
  * Retrieves the statistics for NotiHub.
356
366
  * @returns A promise that resolves to the statistics object or null if not found.
@@ -541,16 +551,20 @@ declare const InvalidEmail = "4006";
541
551
  declare const InvalidPassword = "4007";
542
552
  declare const InvalidName = "4008";
543
553
  declare const InvalidPushToken = "4009";
554
+ declare const InvalidPhoneNumber = "4010";
555
+ declare const InvalidDate = "4011";
544
556
 
545
557
  declare const errorcodes_CustomerNotFound: typeof CustomerNotFound;
546
558
  declare const errorcodes_DocumentNotFound: typeof DocumentNotFound;
559
+ declare const errorcodes_InvalidDate: typeof InvalidDate;
547
560
  declare const errorcodes_InvalidEmail: typeof InvalidEmail;
548
561
  declare const errorcodes_InvalidName: typeof InvalidName;
549
562
  declare const errorcodes_InvalidPassword: typeof InvalidPassword;
563
+ declare const errorcodes_InvalidPhoneNumber: typeof InvalidPhoneNumber;
550
564
  declare const errorcodes_InvalidPushToken: typeof InvalidPushToken;
551
565
  declare const errorcodes_UserNotFound: typeof UserNotFound;
552
566
  declare namespace errorcodes {
553
- export { errorcodes_CustomerNotFound as CustomerNotFound, errorcodes_DocumentNotFound as DocumentNotFound, errorcodes_InvalidEmail as InvalidEmail, errorcodes_InvalidName as InvalidName, errorcodes_InvalidPassword as InvalidPassword, errorcodes_InvalidPushToken as InvalidPushToken, errorcodes_UserNotFound as UserNotFound };
567
+ export { errorcodes_CustomerNotFound as CustomerNotFound, errorcodes_DocumentNotFound as DocumentNotFound, errorcodes_InvalidDate as InvalidDate, errorcodes_InvalidEmail as InvalidEmail, errorcodes_InvalidName as InvalidName, errorcodes_InvalidPassword as InvalidPassword, errorcodes_InvalidPhoneNumber as InvalidPhoneNumber, errorcodes_InvalidPushToken as InvalidPushToken, errorcodes_UserNotFound as UserNotFound };
554
568
  }
555
569
 
556
570
  export { type CreateNotiRequestBody, type CreateSubscriptionRequestBody, type CreateUserRequestBody, type DBMetaData, DocumentNotFoundException, errorcodes as ErrorCode, type ICreateCustomerRequestBody, type ICreateNotiRequestBody, type INotiHubCustomer, type INotiHubCustomerMetadata, type INotiHubCustomerMinified, type INotiHubImage, type INotiHubNotification, type INotiHubNotificationStats, type INotiHubPaymentSession, type INotiHubStats, type INotiHubStatsHistory, type INotiHubStripeSubscription, type INotiHubSubscription, type INotiHubSubscriptionActivity, type INotiHubUser, type INotiHubUserView, type INotiType, type INotiTypeStats, type IUserSubscribeNotifier, type IUserSubscription, client as MongooseClient, type NotiHubTypes, type Response, TABLES, addMonths, formatResponse, getDate, getDateFormat, handleError, handleSuccess };
package/dist/index.js CHANGED
@@ -243,10 +243,15 @@ var User = class _User {
243
243
  throw new Error("Could not update user");
244
244
  }
245
245
  }
246
- static async deleteUser(userId) {
246
+ /**
247
+ * Deletes a user by their ID.
248
+ * @param id - The ID of the user to delete.
249
+ * @returns A promise that resolves when the user is deleted.
250
+ */
251
+ static async deleteUser(id) {
247
252
  const command = new DeleteCommand({
248
253
  TableName: _User.TABLE_NAME,
249
- Key: { userId }
254
+ Key: { id }
250
255
  });
251
256
  try {
252
257
  await ddbDocClient.send(command);
@@ -443,11 +448,30 @@ var Notifications_default = Notifications;
443
448
  // src/DynamoModels/NotiHubStats.ts
444
449
  import {
445
450
  GetCommand as GetCommand4,
451
+ PutCommand as PutCommand4,
446
452
  UpdateCommand as UpdateCommand4
447
453
  } from "@aws-sdk/lib-dynamodb";
448
454
  var NotiHubStats = class _NotiHubStats {
449
455
  static ENV = process.env.ENV || "dev";
450
456
  static TABLE_NAME = `NotiHub-Stats-${_NotiHubStats.ENV}`;
457
+ /**
458
+ * Creates a new NotiHub stats entry.
459
+ * @param stats - The statistics object to create.
460
+ * @returns A promise that resolves to the created statistics object.
461
+ */
462
+ static async createStats(stats) {
463
+ const command = new PutCommand4({
464
+ TableName: _NotiHubStats.TABLE_NAME,
465
+ Item: stats
466
+ });
467
+ try {
468
+ const result = await ddbDocClient.send(command);
469
+ return result.Attributes;
470
+ } catch (error) {
471
+ console.error("Error creating NotiHub stats:", error);
472
+ throw new Error("Could not create NotiHub stats");
473
+ }
474
+ }
451
475
  /**
452
476
  * Retrieves the statistics for NotiHub.
453
477
  * @returns A promise that resolves to the statistics object or null if not found.
@@ -1009,9 +1033,11 @@ var errorcodes_exports = {};
1009
1033
  __export(errorcodes_exports, {
1010
1034
  CustomerNotFound: () => CustomerNotFound,
1011
1035
  DocumentNotFound: () => DocumentNotFound,
1036
+ InvalidDate: () => InvalidDate,
1012
1037
  InvalidEmail: () => InvalidEmail,
1013
1038
  InvalidName: () => InvalidName,
1014
1039
  InvalidPassword: () => InvalidPassword,
1040
+ InvalidPhoneNumber: () => InvalidPhoneNumber,
1015
1041
  InvalidPushToken: () => InvalidPushToken,
1016
1042
  UserNotFound: () => UserNotFound
1017
1043
  });
@@ -1022,6 +1048,8 @@ var InvalidEmail = "4006";
1022
1048
  var InvalidPassword = "4007";
1023
1049
  var InvalidName = "4008";
1024
1050
  var InvalidPushToken = "4009";
1051
+ var InvalidPhoneNumber = "4010";
1052
+ var InvalidDate = "4011";
1025
1053
  export {
1026
1054
  DocumentNotFoundException,
1027
1055
  errorcodes_exports as ErrorCode,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amohamud23/notihub",
3
- "version": "1.0.159",
3
+ "version": "1.0.161",
4
4
  "description": "Notihub Package",
5
5
  "main": "./dist/index.cjs",
6
6
  "types": "./dist/index.d.cts",