@amohamud23/notihub 1.1.25 → 1.1.26

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
@@ -347,6 +347,22 @@ var import_lib_dynamodb3 = require("@aws-sdk/lib-dynamodb");
347
347
  var Customer = class _Customer {
348
348
  static ENV = process.env.ENV || "dev";
349
349
  static TABLE_NAME = `NotiHub-Customers-v1-${_Customer.ENV}`;
350
+ /**
351
+ * Retrieves a list of all customers.
352
+ * @returns A promise that resolves to an array of customer objects.
353
+ */
354
+ static async getAllCustomers() {
355
+ const command = new import_lib_dynamodb3.ScanCommand({
356
+ TableName: _Customer.TABLE_NAME
357
+ });
358
+ try {
359
+ const result = await ddbDocClient.send(command);
360
+ return result.Items || [];
361
+ } catch (error) {
362
+ console.error("Error fetching all customers:", error);
363
+ throw new Error("Could not fetch customers");
364
+ }
365
+ }
350
366
  /**
351
367
  * Retrieves a customer by their ID.
352
368
  * @param id - The ID of the customer to retrieve.
@@ -1166,28 +1182,6 @@ var NotiTypeStats = class _NotiTypeStats {
1166
1182
  throw new Error("Could not increment views");
1167
1183
  }
1168
1184
  }
1169
- /**
1170
- * Decrement the count of views for a specific notification type.
1171
- * @param id - The ID of the notification type stats entry.
1172
- */
1173
- static async decrementViews(id) {
1174
- const command = new import_lib_dynamodb8.UpdateCommand({
1175
- TableName: _NotiTypeStats.TABLE_NAME,
1176
- Key: { id },
1177
- UpdateExpression: "ADD views :dec",
1178
- ExpressionAttributeValues: {
1179
- ":dec": -1
1180
- },
1181
- ReturnValues: "ALL_NEW"
1182
- });
1183
- try {
1184
- const result = await ddbDocClient.send(command);
1185
- return result.Attributes;
1186
- } catch (error) {
1187
- console.error("Error decrementing views:", error);
1188
- throw new Error("Could not decrement views");
1189
- }
1190
- }
1191
1185
  };
1192
1186
  var NotiTypeStats_default = NotiTypeStats;
1193
1187
 
package/dist/index.d.cts CHANGED
@@ -307,6 +307,11 @@ declare class User {
307
307
  declare class Customer {
308
308
  static ENV: string;
309
309
  static TABLE_NAME: string;
310
+ /**
311
+ * Retrieves a list of all customers.
312
+ * @returns A promise that resolves to an array of customer objects.
313
+ */
314
+ static getAllCustomers(): Promise<INotiHubCustomer[]>;
310
315
  /**
311
316
  * Retrieves a customer by their ID.
312
317
  * @param id - The ID of the customer to retrieve.
@@ -523,11 +528,6 @@ declare class NotiTypeStats {
523
528
  * @param id - The ID of the notification type stats entry.
524
529
  */
525
530
  static incrementViews(id: string): Promise<INotiTypeStats>;
526
- /**
527
- * Decrement the count of views for a specific notification type.
528
- * @param id - The ID of the notification type stats entry.
529
- */
530
- static decrementViews(id: string): Promise<INotiTypeStats>;
531
531
  }
532
532
 
533
533
  declare class Views {
package/dist/index.d.ts CHANGED
@@ -307,6 +307,11 @@ declare class User {
307
307
  declare class Customer {
308
308
  static ENV: string;
309
309
  static TABLE_NAME: string;
310
+ /**
311
+ * Retrieves a list of all customers.
312
+ * @returns A promise that resolves to an array of customer objects.
313
+ */
314
+ static getAllCustomers(): Promise<INotiHubCustomer[]>;
310
315
  /**
311
316
  * Retrieves a customer by their ID.
312
317
  * @param id - The ID of the customer to retrieve.
@@ -523,11 +528,6 @@ declare class NotiTypeStats {
523
528
  * @param id - The ID of the notification type stats entry.
524
529
  */
525
530
  static incrementViews(id: string): Promise<INotiTypeStats>;
526
- /**
527
- * Decrement the count of views for a specific notification type.
528
- * @param id - The ID of the notification type stats entry.
529
- */
530
- static decrementViews(id: string): Promise<INotiTypeStats>;
531
531
  }
532
532
 
533
533
  declare class Views {
package/dist/index.js CHANGED
@@ -315,11 +315,28 @@ import {
315
315
  GetCommand as GetCommand2,
316
316
  PutCommand as PutCommand2,
317
317
  QueryCommand as QueryCommand2,
318
- UpdateCommand as UpdateCommand2
318
+ UpdateCommand as UpdateCommand2,
319
+ ScanCommand
319
320
  } from "@aws-sdk/lib-dynamodb";
320
321
  var Customer = class _Customer {
321
322
  static ENV = process.env.ENV || "dev";
322
323
  static TABLE_NAME = `NotiHub-Customers-v1-${_Customer.ENV}`;
324
+ /**
325
+ * Retrieves a list of all customers.
326
+ * @returns A promise that resolves to an array of customer objects.
327
+ */
328
+ static async getAllCustomers() {
329
+ const command = new ScanCommand({
330
+ TableName: _Customer.TABLE_NAME
331
+ });
332
+ try {
333
+ const result = await ddbDocClient.send(command);
334
+ return result.Items || [];
335
+ } catch (error) {
336
+ console.error("Error fetching all customers:", error);
337
+ throw new Error("Could not fetch customers");
338
+ }
339
+ }
323
340
  /**
324
341
  * Retrieves a customer by their ID.
325
342
  * @param id - The ID of the customer to retrieve.
@@ -690,7 +707,7 @@ import {
690
707
  DeleteCommand as DeleteCommand5,
691
708
  PutCommand as PutCommand5,
692
709
  QueryCommand as QueryCommand5,
693
- ScanCommand,
710
+ ScanCommand as ScanCommand2,
694
711
  UpdateCommand as UpdateCommand5
695
712
  } from "@aws-sdk/lib-dynamodb";
696
713
  var NotiType = class _NotiType {
@@ -821,7 +838,7 @@ var NotiType = class _NotiType {
821
838
  do {
822
839
  const scanResult = await ddbDocClient.send(
823
840
  // TODO: update type
824
- new ScanCommand({
841
+ new ScanCommand2({
825
842
  TableName: _NotiType.TABLE_NAME,
826
843
  FilterExpression: "customerId = :customerId",
827
844
  ExpressionAttributeValues: {
@@ -1165,28 +1182,6 @@ var NotiTypeStats = class _NotiTypeStats {
1165
1182
  throw new Error("Could not increment views");
1166
1183
  }
1167
1184
  }
1168
- /**
1169
- * Decrement the count of views for a specific notification type.
1170
- * @param id - The ID of the notification type stats entry.
1171
- */
1172
- static async decrementViews(id) {
1173
- const command = new UpdateCommand7({
1174
- TableName: _NotiTypeStats.TABLE_NAME,
1175
- Key: { id },
1176
- UpdateExpression: "ADD views :dec",
1177
- ExpressionAttributeValues: {
1178
- ":dec": -1
1179
- },
1180
- ReturnValues: "ALL_NEW"
1181
- });
1182
- try {
1183
- const result = await ddbDocClient.send(command);
1184
- return result.Attributes;
1185
- } catch (error) {
1186
- console.error("Error decrementing views:", error);
1187
- throw new Error("Could not decrement views");
1188
- }
1189
- }
1190
1185
  };
1191
1186
  var NotiTypeStats_default = NotiTypeStats;
1192
1187
 
@@ -1452,7 +1447,7 @@ import {
1452
1447
  GetCommand as GetCommand10,
1453
1448
  PutCommand as PutCommand11,
1454
1449
  QueryCommand as QueryCommand11,
1455
- ScanCommand as ScanCommand2
1450
+ ScanCommand as ScanCommand3
1456
1451
  } from "@aws-sdk/lib-dynamodb";
1457
1452
  var CustomerMinified = class _CustomerMinified {
1458
1453
  static ENV = process.env.ENV || "dev";
@@ -1481,7 +1476,7 @@ var CustomerMinified = class _CustomerMinified {
1481
1476
  * @returns A promise that resolves to an array of customer objects or an empty array if not found.
1482
1477
  */
1483
1478
  static async searchCustomersByUsername(username) {
1484
- const command = new ScanCommand2({
1479
+ const command = new ScanCommand3({
1485
1480
  TableName: _CustomerMinified.TABLE_NAME,
1486
1481
  FilterExpression: "begins_with(username, :uname)",
1487
1482
  ExpressionAttributeValues: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amohamud23/notihub",
3
- "version": "1.1.25",
3
+ "version": "1.1.26",
4
4
  "description": "Notihub Package",
5
5
  "main": "./dist/index.cjs",
6
6
  "types": "./dist/index.d.cts",