@amohamud23/notihub 1.0.177 → 1.0.178
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 +15 -3
- package/dist/index.js +32 -19
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -323,13 +323,25 @@ var Customer = class _Customer {
|
|
|
323
323
|
* @returns A promise that resolves to the customer object or null if not found.
|
|
324
324
|
*/
|
|
325
325
|
static async getCustomerByEmail(email) {
|
|
326
|
-
const command = new import_lib_dynamodb3.
|
|
326
|
+
const command = new import_lib_dynamodb3.QueryCommand({
|
|
327
327
|
TableName: _Customer.TABLE_NAME,
|
|
328
|
-
|
|
328
|
+
IndexName: "EmailIndex",
|
|
329
|
+
KeyConditionExpression: "#email = :email",
|
|
330
|
+
ExpressionAttributeNames: {
|
|
331
|
+
"#email": "email"
|
|
332
|
+
},
|
|
333
|
+
ExpressionAttributeValues: {
|
|
334
|
+
":email": email
|
|
335
|
+
},
|
|
336
|
+
Limit: 1
|
|
337
|
+
// Optional, assuming email is unique
|
|
329
338
|
});
|
|
330
339
|
try {
|
|
331
340
|
const result = await ddbDocClient.send(command);
|
|
332
|
-
|
|
341
|
+
if (!result.Items || result.Items.length === 0) {
|
|
342
|
+
return null;
|
|
343
|
+
}
|
|
344
|
+
return result.Items[0] || null;
|
|
333
345
|
} catch (error) {
|
|
334
346
|
console.error(`Error fetching customer by email: ${email}`, error);
|
|
335
347
|
throw new Error("Could not fetch customer by email");
|
package/dist/index.js
CHANGED
|
@@ -266,6 +266,7 @@ import {
|
|
|
266
266
|
DeleteCommand as DeleteCommand2,
|
|
267
267
|
GetCommand as GetCommand2,
|
|
268
268
|
PutCommand as PutCommand2,
|
|
269
|
+
QueryCommand as QueryCommand2,
|
|
269
270
|
UpdateCommand as UpdateCommand2
|
|
270
271
|
} from "@aws-sdk/lib-dynamodb";
|
|
271
272
|
var Customer = class _Customer {
|
|
@@ -295,13 +296,25 @@ var Customer = class _Customer {
|
|
|
295
296
|
* @returns A promise that resolves to the customer object or null if not found.
|
|
296
297
|
*/
|
|
297
298
|
static async getCustomerByEmail(email) {
|
|
298
|
-
const command = new
|
|
299
|
+
const command = new QueryCommand2({
|
|
299
300
|
TableName: _Customer.TABLE_NAME,
|
|
300
|
-
|
|
301
|
+
IndexName: "EmailIndex",
|
|
302
|
+
KeyConditionExpression: "#email = :email",
|
|
303
|
+
ExpressionAttributeNames: {
|
|
304
|
+
"#email": "email"
|
|
305
|
+
},
|
|
306
|
+
ExpressionAttributeValues: {
|
|
307
|
+
":email": email
|
|
308
|
+
},
|
|
309
|
+
Limit: 1
|
|
310
|
+
// Optional, assuming email is unique
|
|
301
311
|
});
|
|
302
312
|
try {
|
|
303
313
|
const result = await ddbDocClient.send(command);
|
|
304
|
-
|
|
314
|
+
if (!result.Items || result.Items.length === 0) {
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
return result.Items[0] || null;
|
|
305
318
|
} catch (error) {
|
|
306
319
|
console.error(`Error fetching customer by email: ${email}`, error);
|
|
307
320
|
throw new Error("Could not fetch customer by email");
|
|
@@ -376,7 +389,7 @@ var Customer_default = Customer;
|
|
|
376
389
|
// src/DynamoModels/Notifications.ts
|
|
377
390
|
import {
|
|
378
391
|
PutCommand as PutCommand3,
|
|
379
|
-
QueryCommand as
|
|
392
|
+
QueryCommand as QueryCommand3
|
|
380
393
|
} from "@aws-sdk/lib-dynamodb";
|
|
381
394
|
var Notifications = class _Notifications {
|
|
382
395
|
static ENV = process.env.ENV || "dev";
|
|
@@ -395,7 +408,7 @@ var Notifications = class _Notifications {
|
|
|
395
408
|
":id": id
|
|
396
409
|
}
|
|
397
410
|
};
|
|
398
|
-
const command = new
|
|
411
|
+
const command = new QueryCommand3(params);
|
|
399
412
|
try {
|
|
400
413
|
const response = await ddbDocClient.send(command);
|
|
401
414
|
if (!response.Items || response.Items.length === 0) {
|
|
@@ -408,7 +421,7 @@ var Notifications = class _Notifications {
|
|
|
408
421
|
}
|
|
409
422
|
}
|
|
410
423
|
static async getNotificationsByEntityId(entityId) {
|
|
411
|
-
const command = new
|
|
424
|
+
const command = new QueryCommand3({
|
|
412
425
|
TableName: _Notifications.TABLE_NAME,
|
|
413
426
|
IndexName: "EntityIdIndex",
|
|
414
427
|
// Assuming you have a GSI for entityId
|
|
@@ -454,7 +467,7 @@ var Notifications_default = Notifications;
|
|
|
454
467
|
import {
|
|
455
468
|
GetCommand as GetCommand4,
|
|
456
469
|
PutCommand as PutCommand4,
|
|
457
|
-
QueryCommand as
|
|
470
|
+
QueryCommand as QueryCommand4,
|
|
458
471
|
UpdateCommand as UpdateCommand4
|
|
459
472
|
} from "@aws-sdk/lib-dynamodb";
|
|
460
473
|
var NotiHubStats = class _NotiHubStats {
|
|
@@ -490,7 +503,7 @@ var NotiHubStats = class _NotiHubStats {
|
|
|
490
503
|
return result.Attributes;
|
|
491
504
|
}
|
|
492
505
|
static async getStatsInDateRange(customerId, startDate, endDate) {
|
|
493
|
-
const command = new
|
|
506
|
+
const command = new QueryCommand4({
|
|
494
507
|
TableName: _NotiHubStats.TABLE_NAME,
|
|
495
508
|
IndexName: "CustomerCreatedAtIndex",
|
|
496
509
|
KeyConditionExpression: "customerId = :customerId AND createdAt BETWEEN :start_date AND :end_date",
|
|
@@ -513,7 +526,7 @@ import {
|
|
|
513
526
|
DeleteCommand as DeleteCommand4,
|
|
514
527
|
GetCommand as GetCommand5,
|
|
515
528
|
PutCommand as PutCommand5,
|
|
516
|
-
QueryCommand as
|
|
529
|
+
QueryCommand as QueryCommand5,
|
|
517
530
|
ScanCommand,
|
|
518
531
|
UpdateCommand as UpdateCommand5
|
|
519
532
|
} from "@aws-sdk/lib-dynamodb";
|
|
@@ -543,7 +556,7 @@ var NotiType = class _NotiType {
|
|
|
543
556
|
* @returns A promise that resolves to an array of notification type objects.
|
|
544
557
|
*/
|
|
545
558
|
static async getAllNotiTypesByEntityId(entityId) {
|
|
546
|
-
const command = new
|
|
559
|
+
const command = new QueryCommand5({
|
|
547
560
|
TableName: _NotiType.TABLE_NAME,
|
|
548
561
|
IndexName: "EntityIdIndex",
|
|
549
562
|
// Assuming you have a GSI for entityId
|
|
@@ -699,7 +712,7 @@ import {
|
|
|
699
712
|
DeleteCommand as DeleteCommand5,
|
|
700
713
|
GetCommand as GetCommand6,
|
|
701
714
|
PutCommand as PutCommand6,
|
|
702
|
-
QueryCommand as
|
|
715
|
+
QueryCommand as QueryCommand6
|
|
703
716
|
} from "@aws-sdk/lib-dynamodb";
|
|
704
717
|
var Subscription = class _Subscription {
|
|
705
718
|
static ENV = process.env.ENV || "dev";
|
|
@@ -728,7 +741,7 @@ var Subscription = class _Subscription {
|
|
|
728
741
|
* @returns A promise that resolves to an array of subscription objects or null if not found.
|
|
729
742
|
*/
|
|
730
743
|
static async getSubscriptionsByUserId(userId) {
|
|
731
|
-
const command = new
|
|
744
|
+
const command = new QueryCommand6({
|
|
732
745
|
TableName: _Subscription.TABLE_NAME,
|
|
733
746
|
IndexName: "UserIdIndex",
|
|
734
747
|
// Assuming you have a GSI for userId
|
|
@@ -820,7 +833,7 @@ import {
|
|
|
820
833
|
DeleteCommand as DeleteCommand6,
|
|
821
834
|
GetCommand as GetCommand7,
|
|
822
835
|
PutCommand as PutCommand7,
|
|
823
|
-
QueryCommand as
|
|
836
|
+
QueryCommand as QueryCommand7
|
|
824
837
|
} from "@aws-sdk/lib-dynamodb";
|
|
825
838
|
var NotiTypeStats = class _NotiTypeStats {
|
|
826
839
|
static ENV = process.env.ENV || "dev";
|
|
@@ -849,7 +862,7 @@ var NotiTypeStats = class _NotiTypeStats {
|
|
|
849
862
|
* @returns A promise that resolves to an array of notification type stats objects or null if not found.
|
|
850
863
|
*/
|
|
851
864
|
static async getNotiTypeStatsByNotiTypeId(notiTypeId) {
|
|
852
|
-
const command = new
|
|
865
|
+
const command = new QueryCommand7({
|
|
853
866
|
TableName: _NotiTypeStats.TABLE_NAME,
|
|
854
867
|
IndexName: "NotiTypeIdIndex",
|
|
855
868
|
// Assuming you have a GSI for notiTypeId
|
|
@@ -961,7 +974,7 @@ var Views_default = Views;
|
|
|
961
974
|
import {
|
|
962
975
|
DeleteCommand as DeleteCommand8,
|
|
963
976
|
GetCommand as GetCommand9,
|
|
964
|
-
QueryCommand as
|
|
977
|
+
QueryCommand as QueryCommand9
|
|
965
978
|
} from "@aws-sdk/lib-dynamodb";
|
|
966
979
|
var SubscriptionType = class _SubscriptionType {
|
|
967
980
|
static ENV = process.env.ENV || "dev";
|
|
@@ -985,7 +998,7 @@ var SubscriptionType = class _SubscriptionType {
|
|
|
985
998
|
}
|
|
986
999
|
}
|
|
987
1000
|
static async getSubscriptionTypesByUserId(userId) {
|
|
988
|
-
const command = new
|
|
1001
|
+
const command = new QueryCommand9({
|
|
989
1002
|
TableName: _SubscriptionType.TABLE_NAME,
|
|
990
1003
|
IndexName: "UserIdIndex",
|
|
991
1004
|
// Assuming you have a GSI for userId
|
|
@@ -1238,7 +1251,7 @@ var NotificationStats_default = NotificationStats;
|
|
|
1238
1251
|
// src/DynamoModels/NotiHubStatsHistory.ts
|
|
1239
1252
|
import {
|
|
1240
1253
|
PutCommand as PutCommand13,
|
|
1241
|
-
QueryCommand as
|
|
1254
|
+
QueryCommand as QueryCommand10
|
|
1242
1255
|
} from "@aws-sdk/lib-dynamodb";
|
|
1243
1256
|
var NotiHubStatsHistory = class _NotiHubStatsHistory {
|
|
1244
1257
|
static ENV = process.env.ENV || "dev";
|
|
@@ -1271,7 +1284,7 @@ var NotiHubStatsHistory = class _NotiHubStatsHistory {
|
|
|
1271
1284
|
Date.now() - 365 * 24 * 60 * 60 * 1e3
|
|
1272
1285
|
).toISOString();
|
|
1273
1286
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1274
|
-
const command = new
|
|
1287
|
+
const command = new QueryCommand10({
|
|
1275
1288
|
TableName: _NotiHubStatsHistory.TABLE_NAME,
|
|
1276
1289
|
IndexName: "CustomerIdIndex",
|
|
1277
1290
|
KeyConditionExpression: "customerId = :customerId AND createdAt BETWEEN :start AND :end",
|
|
@@ -1302,7 +1315,7 @@ var NotiHubStatsHistory = class _NotiHubStatsHistory {
|
|
|
1302
1315
|
Date.now() - 182 * 24 * 60 * 60 * 1e3
|
|
1303
1316
|
).toISOString();
|
|
1304
1317
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1305
|
-
const command = new
|
|
1318
|
+
const command = new QueryCommand10({
|
|
1306
1319
|
TableName: _NotiHubStatsHistory.TABLE_NAME,
|
|
1307
1320
|
IndexName: "CustomerIdIndex",
|
|
1308
1321
|
KeyConditionExpression: "customerId = :customerId AND createdAt BETWEEN :start AND :end",
|