@amohamud23/notihub 1.0.162 → 1.0.163
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 +129 -1
- package/dist/index.d.cts +32 -2
- package/dist/index.d.ts +32 -2
- package/dist/index.js +134 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -630,6 +630,87 @@ var NotiType = class _NotiType {
|
|
|
630
630
|
throw new Error("Could not update notification type");
|
|
631
631
|
}
|
|
632
632
|
}
|
|
633
|
+
/**
|
|
634
|
+
* Deletes a notification type by its ID.
|
|
635
|
+
* @param id - The ID of the notification type to delete.
|
|
636
|
+
* @returns A promise that resolves when the notification type is deleted.
|
|
637
|
+
*/
|
|
638
|
+
static async deleteNotiType(id) {
|
|
639
|
+
const command = new import_lib_dynamodb6.DeleteCommand({
|
|
640
|
+
TableName: _NotiType.TABLE_NAME,
|
|
641
|
+
Key: { id }
|
|
642
|
+
});
|
|
643
|
+
try {
|
|
644
|
+
await ddbDocClient.send(command);
|
|
645
|
+
} catch (error) {
|
|
646
|
+
console.error("Error deleting notification type:", error);
|
|
647
|
+
throw new Error("Could not delete notification type");
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Delete all notification types for a given customerId
|
|
652
|
+
* Uses Query + BatchWrite with chunking
|
|
653
|
+
*/
|
|
654
|
+
static async deleteAllNotiTypesByCustomerId(customerId) {
|
|
655
|
+
try {
|
|
656
|
+
const itemsToDelete = [];
|
|
657
|
+
let lastEvaluatedKey;
|
|
658
|
+
do {
|
|
659
|
+
const scanResult = await ddbDocClient.send(
|
|
660
|
+
// TODO: update type
|
|
661
|
+
new import_lib_dynamodb6.ScanCommand({
|
|
662
|
+
TableName: _NotiType.TABLE_NAME,
|
|
663
|
+
FilterExpression: "customerId = :customerId",
|
|
664
|
+
ExpressionAttributeValues: {
|
|
665
|
+
":customerId": customerId
|
|
666
|
+
},
|
|
667
|
+
ExclusiveStartKey: lastEvaluatedKey
|
|
668
|
+
})
|
|
669
|
+
);
|
|
670
|
+
if (scanResult.Items) {
|
|
671
|
+
itemsToDelete.push(...scanResult.Items);
|
|
672
|
+
}
|
|
673
|
+
lastEvaluatedKey = scanResult.LastEvaluatedKey;
|
|
674
|
+
} while (lastEvaluatedKey);
|
|
675
|
+
if (itemsToDelete.length === 0) {
|
|
676
|
+
console.log(
|
|
677
|
+
`No notification types found for customerId: ${customerId}`
|
|
678
|
+
);
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
console.log(
|
|
682
|
+
`Found ${itemsToDelete.length} notification types for customerId: ${customerId}. Deleting...`
|
|
683
|
+
);
|
|
684
|
+
const chunkSize = 25;
|
|
685
|
+
for (let i = 0; i < itemsToDelete.length; i += chunkSize) {
|
|
686
|
+
const chunk = itemsToDelete.slice(i, i + chunkSize);
|
|
687
|
+
const deleteRequests = chunk.map((item) => ({
|
|
688
|
+
DeleteRequest: {
|
|
689
|
+
Key: {
|
|
690
|
+
id: item.id,
|
|
691
|
+
customerId: item.customerId
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}));
|
|
695
|
+
await ddbDocClient.send(
|
|
696
|
+
new import_lib_dynamodb6.BatchWriteCommand({
|
|
697
|
+
RequestItems: {
|
|
698
|
+
[_NotiType.TABLE_NAME]: deleteRequests
|
|
699
|
+
}
|
|
700
|
+
})
|
|
701
|
+
);
|
|
702
|
+
}
|
|
703
|
+
console.log(
|
|
704
|
+
`Successfully deleted ${itemsToDelete.length} notification types for customerId: ${customerId}`
|
|
705
|
+
);
|
|
706
|
+
} catch (error) {
|
|
707
|
+
console.error(
|
|
708
|
+
`Failed to delete notification types for customerId: ${customerId}`,
|
|
709
|
+
error
|
|
710
|
+
);
|
|
711
|
+
throw new Error("Could not delete notification types for customerId");
|
|
712
|
+
}
|
|
713
|
+
}
|
|
633
714
|
};
|
|
634
715
|
var NotiType_default = NotiType;
|
|
635
716
|
|
|
@@ -732,6 +813,20 @@ var Subscription = class _Subscription {
|
|
|
732
813
|
throw new Error("Could not fetch subscription by SubscriptionId");
|
|
733
814
|
}
|
|
734
815
|
}
|
|
816
|
+
/**
|
|
817
|
+
* Delete all subscriptions by user ID.
|
|
818
|
+
* @param userId - The ID of the user whose subscriptions to delete.
|
|
819
|
+
* @returns A promise that resolves when all subscriptions are deleted.
|
|
820
|
+
*/
|
|
821
|
+
static async deleteAllSubscriptionsByUserId(userId) {
|
|
822
|
+
const subscriptions = await this.getSubscriptionsByUserId(userId);
|
|
823
|
+
if (subscriptions && subscriptions.length > 0) {
|
|
824
|
+
const deletePromises = subscriptions.map(
|
|
825
|
+
(sub) => this.deleteSubscriptionById(sub.id)
|
|
826
|
+
);
|
|
827
|
+
await Promise.all(deletePromises);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
735
830
|
};
|
|
736
831
|
var Subscription_default = Subscription;
|
|
737
832
|
|
|
@@ -805,6 +900,23 @@ var NotiTypeStats = class _NotiTypeStats {
|
|
|
805
900
|
throw new Error("Could not create or update notification type stats");
|
|
806
901
|
}
|
|
807
902
|
}
|
|
903
|
+
/**
|
|
904
|
+
* Deletes notification type stats by their ID.
|
|
905
|
+
* @param id - The ID of the notification type stats to delete.
|
|
906
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
907
|
+
*/
|
|
908
|
+
static async deleteNotiTypeStatsById(id) {
|
|
909
|
+
const command = new import_lib_dynamodb8.DeleteCommand({
|
|
910
|
+
TableName: _NotiTypeStats.TABLE_NAME,
|
|
911
|
+
Key: { id }
|
|
912
|
+
});
|
|
913
|
+
try {
|
|
914
|
+
await ddbDocClient.send(command);
|
|
915
|
+
} catch (error) {
|
|
916
|
+
console.error("Error deleting notification type stats:", error);
|
|
917
|
+
throw new Error("Could not delete notification type stats");
|
|
918
|
+
}
|
|
919
|
+
}
|
|
808
920
|
};
|
|
809
921
|
var NotiTypeStats_default = NotiTypeStats;
|
|
810
922
|
|
|
@@ -896,7 +1008,23 @@ var SubscriptionType = class _SubscriptionType {
|
|
|
896
1008
|
throw new Error("Could not fetch subscription types by userId");
|
|
897
1009
|
}
|
|
898
1010
|
}
|
|
899
|
-
|
|
1011
|
+
/**
|
|
1012
|
+
* Deletes a subscription type by its ID.
|
|
1013
|
+
* @param id - The ID of the subscription type to delete.
|
|
1014
|
+
* @returns A promise that resolves when the subscription type is deleted.
|
|
1015
|
+
*/
|
|
1016
|
+
static async deleteSubscriptionTypeById(id) {
|
|
1017
|
+
const command = new import_lib_dynamodb10.DeleteCommand({
|
|
1018
|
+
TableName: _SubscriptionType.TABLE_NAME,
|
|
1019
|
+
Key: { id }
|
|
1020
|
+
});
|
|
1021
|
+
try {
|
|
1022
|
+
await ddbDocClient.send(command);
|
|
1023
|
+
} catch (error) {
|
|
1024
|
+
console.error("Error deleting subscription type:", error);
|
|
1025
|
+
throw new Error("Could not delete subscription type");
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
900
1028
|
};
|
|
901
1029
|
var SubscriptionType_default = SubscriptionType;
|
|
902
1030
|
|
package/dist/index.d.cts
CHANGED
|
@@ -139,12 +139,13 @@ type INotiType = {
|
|
|
139
139
|
id: string;
|
|
140
140
|
type: string;
|
|
141
141
|
customerId: string;
|
|
142
|
+
statsId: string;
|
|
142
143
|
createdAt: string;
|
|
143
144
|
updatedAt: string;
|
|
144
145
|
};
|
|
145
146
|
type INotiTypeStats = {
|
|
146
147
|
id: string;
|
|
147
|
-
|
|
148
|
+
notiTypeId: string;
|
|
148
149
|
subscribed: number;
|
|
149
150
|
views: number;
|
|
150
151
|
createdAt: string;
|
|
@@ -154,6 +155,7 @@ type IUserSubscription = {
|
|
|
154
155
|
id: string;
|
|
155
156
|
user: INotiHubUser;
|
|
156
157
|
customer: INotiHubCustomer;
|
|
158
|
+
customerId: string;
|
|
157
159
|
subscriptionId: string;
|
|
158
160
|
type: "SUBSCRIBED" | "UNSUBSCRIBED";
|
|
159
161
|
createdAt: string;
|
|
@@ -163,7 +165,7 @@ type IUserSubscribeNotifier = {
|
|
|
163
165
|
userId: string;
|
|
164
166
|
userRef: INotiHubUser;
|
|
165
167
|
customerId: string;
|
|
166
|
-
|
|
168
|
+
customer: INotiHubCustomer;
|
|
167
169
|
notiTypeId: string;
|
|
168
170
|
notiTypeRef: INotiType;
|
|
169
171
|
subscriptionId: string;
|
|
@@ -401,6 +403,16 @@ declare class NotiType {
|
|
|
401
403
|
* @returns A promise that resolves to the updated notification type object.
|
|
402
404
|
*/
|
|
403
405
|
static updateNotiType(id: string, updates: Partial<INotiType>): Promise<INotiType>;
|
|
406
|
+
/**
|
|
407
|
+
* Deletes a notification type by its ID.
|
|
408
|
+
* @param id - The ID of the notification type to delete.
|
|
409
|
+
* @returns A promise that resolves when the notification type is deleted.
|
|
410
|
+
*/ static deleteNotiType(id: string): Promise<void>;
|
|
411
|
+
/**
|
|
412
|
+
* Delete all notification types for a given customerId
|
|
413
|
+
* Uses Query + BatchWrite with chunking
|
|
414
|
+
*/
|
|
415
|
+
static deleteAllNotiTypesByCustomerId(customerId: string): Promise<void>;
|
|
404
416
|
}
|
|
405
417
|
|
|
406
418
|
declare class Subscription {
|
|
@@ -436,6 +448,12 @@ declare class Subscription {
|
|
|
436
448
|
* @returns A promise that resolves to the subscription object or null if not found.
|
|
437
449
|
*/
|
|
438
450
|
static getSubscriptionBySubscriptionId(subscriptionId: string): Promise<INotiHubSubscription | null>;
|
|
451
|
+
/**
|
|
452
|
+
* Delete all subscriptions by user ID.
|
|
453
|
+
* @param userId - The ID of the user whose subscriptions to delete.
|
|
454
|
+
* @returns A promise that resolves when all subscriptions are deleted.
|
|
455
|
+
*/
|
|
456
|
+
static deleteAllSubscriptionsByUserId(userId: string): Promise<void>;
|
|
439
457
|
}
|
|
440
458
|
|
|
441
459
|
declare class NotiTypeStats {
|
|
@@ -459,6 +477,12 @@ declare class NotiTypeStats {
|
|
|
459
477
|
* @returns A promise that resolves to the created or updated notification type stats object.
|
|
460
478
|
*/
|
|
461
479
|
static createOrUpdateNotiTypeStats(notiTypeStats: INotiTypeStats): Promise<INotiTypeStats>;
|
|
480
|
+
/**
|
|
481
|
+
* Deletes notification type stats by their ID.
|
|
482
|
+
* @param id - The ID of the notification type stats to delete.
|
|
483
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
484
|
+
*/
|
|
485
|
+
static deleteNotiTypeStatsById(id: string): Promise<void>;
|
|
462
486
|
}
|
|
463
487
|
|
|
464
488
|
declare class Views {
|
|
@@ -488,6 +512,12 @@ declare class SubscriptionType {
|
|
|
488
512
|
*/
|
|
489
513
|
static getSubscriptionTypeById(id: string): Promise<IUserSubscribeNotifier | null>;
|
|
490
514
|
static getSubscriptionTypesByUserId(userId: string): Promise<IUserSubscribeNotifier[] | null>;
|
|
515
|
+
/**
|
|
516
|
+
* Deletes a subscription type by its ID.
|
|
517
|
+
* @param id - The ID of the subscription type to delete.
|
|
518
|
+
* @returns A promise that resolves when the subscription type is deleted.
|
|
519
|
+
*/
|
|
520
|
+
static deleteSubscriptionTypeById(id: string): Promise<void>;
|
|
491
521
|
}
|
|
492
522
|
|
|
493
523
|
declare class CustomerMetaData {
|
package/dist/index.d.ts
CHANGED
|
@@ -139,12 +139,13 @@ type INotiType = {
|
|
|
139
139
|
id: string;
|
|
140
140
|
type: string;
|
|
141
141
|
customerId: string;
|
|
142
|
+
statsId: string;
|
|
142
143
|
createdAt: string;
|
|
143
144
|
updatedAt: string;
|
|
144
145
|
};
|
|
145
146
|
type INotiTypeStats = {
|
|
146
147
|
id: string;
|
|
147
|
-
|
|
148
|
+
notiTypeId: string;
|
|
148
149
|
subscribed: number;
|
|
149
150
|
views: number;
|
|
150
151
|
createdAt: string;
|
|
@@ -154,6 +155,7 @@ type IUserSubscription = {
|
|
|
154
155
|
id: string;
|
|
155
156
|
user: INotiHubUser;
|
|
156
157
|
customer: INotiHubCustomer;
|
|
158
|
+
customerId: string;
|
|
157
159
|
subscriptionId: string;
|
|
158
160
|
type: "SUBSCRIBED" | "UNSUBSCRIBED";
|
|
159
161
|
createdAt: string;
|
|
@@ -163,7 +165,7 @@ type IUserSubscribeNotifier = {
|
|
|
163
165
|
userId: string;
|
|
164
166
|
userRef: INotiHubUser;
|
|
165
167
|
customerId: string;
|
|
166
|
-
|
|
168
|
+
customer: INotiHubCustomer;
|
|
167
169
|
notiTypeId: string;
|
|
168
170
|
notiTypeRef: INotiType;
|
|
169
171
|
subscriptionId: string;
|
|
@@ -401,6 +403,16 @@ declare class NotiType {
|
|
|
401
403
|
* @returns A promise that resolves to the updated notification type object.
|
|
402
404
|
*/
|
|
403
405
|
static updateNotiType(id: string, updates: Partial<INotiType>): Promise<INotiType>;
|
|
406
|
+
/**
|
|
407
|
+
* Deletes a notification type by its ID.
|
|
408
|
+
* @param id - The ID of the notification type to delete.
|
|
409
|
+
* @returns A promise that resolves when the notification type is deleted.
|
|
410
|
+
*/ static deleteNotiType(id: string): Promise<void>;
|
|
411
|
+
/**
|
|
412
|
+
* Delete all notification types for a given customerId
|
|
413
|
+
* Uses Query + BatchWrite with chunking
|
|
414
|
+
*/
|
|
415
|
+
static deleteAllNotiTypesByCustomerId(customerId: string): Promise<void>;
|
|
404
416
|
}
|
|
405
417
|
|
|
406
418
|
declare class Subscription {
|
|
@@ -436,6 +448,12 @@ declare class Subscription {
|
|
|
436
448
|
* @returns A promise that resolves to the subscription object or null if not found.
|
|
437
449
|
*/
|
|
438
450
|
static getSubscriptionBySubscriptionId(subscriptionId: string): Promise<INotiHubSubscription | null>;
|
|
451
|
+
/**
|
|
452
|
+
* Delete all subscriptions by user ID.
|
|
453
|
+
* @param userId - The ID of the user whose subscriptions to delete.
|
|
454
|
+
* @returns A promise that resolves when all subscriptions are deleted.
|
|
455
|
+
*/
|
|
456
|
+
static deleteAllSubscriptionsByUserId(userId: string): Promise<void>;
|
|
439
457
|
}
|
|
440
458
|
|
|
441
459
|
declare class NotiTypeStats {
|
|
@@ -459,6 +477,12 @@ declare class NotiTypeStats {
|
|
|
459
477
|
* @returns A promise that resolves to the created or updated notification type stats object.
|
|
460
478
|
*/
|
|
461
479
|
static createOrUpdateNotiTypeStats(notiTypeStats: INotiTypeStats): Promise<INotiTypeStats>;
|
|
480
|
+
/**
|
|
481
|
+
* Deletes notification type stats by their ID.
|
|
482
|
+
* @param id - The ID of the notification type stats to delete.
|
|
483
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
484
|
+
*/
|
|
485
|
+
static deleteNotiTypeStatsById(id: string): Promise<void>;
|
|
462
486
|
}
|
|
463
487
|
|
|
464
488
|
declare class Views {
|
|
@@ -488,6 +512,12 @@ declare class SubscriptionType {
|
|
|
488
512
|
*/
|
|
489
513
|
static getSubscriptionTypeById(id: string): Promise<IUserSubscribeNotifier | null>;
|
|
490
514
|
static getSubscriptionTypesByUserId(userId: string): Promise<IUserSubscribeNotifier[] | null>;
|
|
515
|
+
/**
|
|
516
|
+
* Deletes a subscription type by its ID.
|
|
517
|
+
* @param id - The ID of the subscription type to delete.
|
|
518
|
+
* @returns A promise that resolves when the subscription type is deleted.
|
|
519
|
+
*/
|
|
520
|
+
static deleteSubscriptionTypeById(id: string): Promise<void>;
|
|
491
521
|
}
|
|
492
522
|
|
|
493
523
|
declare class CustomerMetaData {
|
package/dist/index.js
CHANGED
|
@@ -517,9 +517,12 @@ var NotiHubStats_default = NotiHubStats;
|
|
|
517
517
|
|
|
518
518
|
// src/DynamoModels/NotiType.ts
|
|
519
519
|
import {
|
|
520
|
+
BatchWriteCommand,
|
|
521
|
+
DeleteCommand as DeleteCommand5,
|
|
520
522
|
GetCommand as GetCommand5,
|
|
521
523
|
PutCommand as PutCommand5,
|
|
522
524
|
QueryCommand as QueryCommand4,
|
|
525
|
+
ScanCommand,
|
|
523
526
|
UpdateCommand as UpdateCommand5
|
|
524
527
|
} from "@aws-sdk/lib-dynamodb";
|
|
525
528
|
var NotiType = class _NotiType {
|
|
@@ -615,6 +618,87 @@ var NotiType = class _NotiType {
|
|
|
615
618
|
throw new Error("Could not update notification type");
|
|
616
619
|
}
|
|
617
620
|
}
|
|
621
|
+
/**
|
|
622
|
+
* Deletes a notification type by its ID.
|
|
623
|
+
* @param id - The ID of the notification type to delete.
|
|
624
|
+
* @returns A promise that resolves when the notification type is deleted.
|
|
625
|
+
*/
|
|
626
|
+
static async deleteNotiType(id) {
|
|
627
|
+
const command = new DeleteCommand5({
|
|
628
|
+
TableName: _NotiType.TABLE_NAME,
|
|
629
|
+
Key: { id }
|
|
630
|
+
});
|
|
631
|
+
try {
|
|
632
|
+
await ddbDocClient.send(command);
|
|
633
|
+
} catch (error) {
|
|
634
|
+
console.error("Error deleting notification type:", error);
|
|
635
|
+
throw new Error("Could not delete notification type");
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Delete all notification types for a given customerId
|
|
640
|
+
* Uses Query + BatchWrite with chunking
|
|
641
|
+
*/
|
|
642
|
+
static async deleteAllNotiTypesByCustomerId(customerId) {
|
|
643
|
+
try {
|
|
644
|
+
const itemsToDelete = [];
|
|
645
|
+
let lastEvaluatedKey;
|
|
646
|
+
do {
|
|
647
|
+
const scanResult = await ddbDocClient.send(
|
|
648
|
+
// TODO: update type
|
|
649
|
+
new ScanCommand({
|
|
650
|
+
TableName: _NotiType.TABLE_NAME,
|
|
651
|
+
FilterExpression: "customerId = :customerId",
|
|
652
|
+
ExpressionAttributeValues: {
|
|
653
|
+
":customerId": customerId
|
|
654
|
+
},
|
|
655
|
+
ExclusiveStartKey: lastEvaluatedKey
|
|
656
|
+
})
|
|
657
|
+
);
|
|
658
|
+
if (scanResult.Items) {
|
|
659
|
+
itemsToDelete.push(...scanResult.Items);
|
|
660
|
+
}
|
|
661
|
+
lastEvaluatedKey = scanResult.LastEvaluatedKey;
|
|
662
|
+
} while (lastEvaluatedKey);
|
|
663
|
+
if (itemsToDelete.length === 0) {
|
|
664
|
+
console.log(
|
|
665
|
+
`No notification types found for customerId: ${customerId}`
|
|
666
|
+
);
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
console.log(
|
|
670
|
+
`Found ${itemsToDelete.length} notification types for customerId: ${customerId}. Deleting...`
|
|
671
|
+
);
|
|
672
|
+
const chunkSize = 25;
|
|
673
|
+
for (let i = 0; i < itemsToDelete.length; i += chunkSize) {
|
|
674
|
+
const chunk = itemsToDelete.slice(i, i + chunkSize);
|
|
675
|
+
const deleteRequests = chunk.map((item) => ({
|
|
676
|
+
DeleteRequest: {
|
|
677
|
+
Key: {
|
|
678
|
+
id: item.id,
|
|
679
|
+
customerId: item.customerId
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}));
|
|
683
|
+
await ddbDocClient.send(
|
|
684
|
+
new BatchWriteCommand({
|
|
685
|
+
RequestItems: {
|
|
686
|
+
[_NotiType.TABLE_NAME]: deleteRequests
|
|
687
|
+
}
|
|
688
|
+
})
|
|
689
|
+
);
|
|
690
|
+
}
|
|
691
|
+
console.log(
|
|
692
|
+
`Successfully deleted ${itemsToDelete.length} notification types for customerId: ${customerId}`
|
|
693
|
+
);
|
|
694
|
+
} catch (error) {
|
|
695
|
+
console.error(
|
|
696
|
+
`Failed to delete notification types for customerId: ${customerId}`,
|
|
697
|
+
error
|
|
698
|
+
);
|
|
699
|
+
throw new Error("Could not delete notification types for customerId");
|
|
700
|
+
}
|
|
701
|
+
}
|
|
618
702
|
};
|
|
619
703
|
var NotiType_default = NotiType;
|
|
620
704
|
|
|
@@ -722,11 +806,26 @@ var Subscription = class _Subscription {
|
|
|
722
806
|
throw new Error("Could not fetch subscription by SubscriptionId");
|
|
723
807
|
}
|
|
724
808
|
}
|
|
809
|
+
/**
|
|
810
|
+
* Delete all subscriptions by user ID.
|
|
811
|
+
* @param userId - The ID of the user whose subscriptions to delete.
|
|
812
|
+
* @returns A promise that resolves when all subscriptions are deleted.
|
|
813
|
+
*/
|
|
814
|
+
static async deleteAllSubscriptionsByUserId(userId) {
|
|
815
|
+
const subscriptions = await this.getSubscriptionsByUserId(userId);
|
|
816
|
+
if (subscriptions && subscriptions.length > 0) {
|
|
817
|
+
const deletePromises = subscriptions.map(
|
|
818
|
+
(sub) => this.deleteSubscriptionById(sub.id)
|
|
819
|
+
);
|
|
820
|
+
await Promise.all(deletePromises);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
725
823
|
};
|
|
726
824
|
var Subscription_default = Subscription;
|
|
727
825
|
|
|
728
826
|
// src/DynamoModels/NotiTypeStats.ts
|
|
729
827
|
import {
|
|
828
|
+
DeleteCommand as DeleteCommand7,
|
|
730
829
|
GetCommand as GetCommand7,
|
|
731
830
|
PutCommand as PutCommand7,
|
|
732
831
|
QueryCommand as QueryCommand6
|
|
@@ -799,6 +898,23 @@ var NotiTypeStats = class _NotiTypeStats {
|
|
|
799
898
|
throw new Error("Could not create or update notification type stats");
|
|
800
899
|
}
|
|
801
900
|
}
|
|
901
|
+
/**
|
|
902
|
+
* Deletes notification type stats by their ID.
|
|
903
|
+
* @param id - The ID of the notification type stats to delete.
|
|
904
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
905
|
+
*/
|
|
906
|
+
static async deleteNotiTypeStatsById(id) {
|
|
907
|
+
const command = new DeleteCommand7({
|
|
908
|
+
TableName: _NotiTypeStats.TABLE_NAME,
|
|
909
|
+
Key: { id }
|
|
910
|
+
});
|
|
911
|
+
try {
|
|
912
|
+
await ddbDocClient.send(command);
|
|
913
|
+
} catch (error) {
|
|
914
|
+
console.error("Error deleting notification type stats:", error);
|
|
915
|
+
throw new Error("Could not delete notification type stats");
|
|
916
|
+
}
|
|
917
|
+
}
|
|
802
918
|
};
|
|
803
919
|
var NotiTypeStats_default = NotiTypeStats;
|
|
804
920
|
|
|
@@ -851,6 +967,7 @@ var Views_default = Views;
|
|
|
851
967
|
|
|
852
968
|
// src/DynamoModels/SubscriptionType.ts
|
|
853
969
|
import {
|
|
970
|
+
DeleteCommand as DeleteCommand9,
|
|
854
971
|
GetCommand as GetCommand9,
|
|
855
972
|
QueryCommand as QueryCommand8
|
|
856
973
|
} from "@aws-sdk/lib-dynamodb";
|
|
@@ -896,7 +1013,23 @@ var SubscriptionType = class _SubscriptionType {
|
|
|
896
1013
|
throw new Error("Could not fetch subscription types by userId");
|
|
897
1014
|
}
|
|
898
1015
|
}
|
|
899
|
-
|
|
1016
|
+
/**
|
|
1017
|
+
* Deletes a subscription type by its ID.
|
|
1018
|
+
* @param id - The ID of the subscription type to delete.
|
|
1019
|
+
* @returns A promise that resolves when the subscription type is deleted.
|
|
1020
|
+
*/
|
|
1021
|
+
static async deleteSubscriptionTypeById(id) {
|
|
1022
|
+
const command = new DeleteCommand9({
|
|
1023
|
+
TableName: _SubscriptionType.TABLE_NAME,
|
|
1024
|
+
Key: { id }
|
|
1025
|
+
});
|
|
1026
|
+
try {
|
|
1027
|
+
await ddbDocClient.send(command);
|
|
1028
|
+
} catch (error) {
|
|
1029
|
+
console.error("Error deleting subscription type:", error);
|
|
1030
|
+
throw new Error("Could not delete subscription type");
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
900
1033
|
};
|
|
901
1034
|
var SubscriptionType_default = SubscriptionType;
|
|
902
1035
|
|