@amohamud23/notihub 1.0.156 → 1.0.158

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
@@ -1282,6 +1282,112 @@ var SubscriptionType2 = class _SubscriptionType {
1282
1282
  };
1283
1283
  var SubscriptionType_default = SubscriptionType2;
1284
1284
 
1285
+ // src/DynamoModels/CustomerMetaData.ts
1286
+ var import_lib_dynamodb11 = require("@aws-sdk/lib-dynamodb");
1287
+ var CustomerMetaData = class _CustomerMetaData {
1288
+ static ENV = process.env.ENV || "dev";
1289
+ static TABLE_NAME = `NotiHub-CustomerMetaData-${_CustomerMetaData.ENV}`;
1290
+ /**
1291
+ * Retrieves customer metadata by its ID.
1292
+ * @param id - The ID of the customer metadata to retrieve.
1293
+ * @returns A promise that resolves to the customer metadata object or null if not found.
1294
+ */
1295
+ static async getCustomerMetaDataById(id) {
1296
+ const command = new import_lib_dynamodb11.GetCommand({
1297
+ TableName: _CustomerMetaData.TABLE_NAME,
1298
+ Key: { id }
1299
+ });
1300
+ try {
1301
+ const result = await ddbDocClient.send(command);
1302
+ return result.Item || null;
1303
+ } catch (error) {
1304
+ console.error("Error fetching customer metadata:", error);
1305
+ throw new Error("Could not fetch customer metadata");
1306
+ }
1307
+ }
1308
+ /**
1309
+ * Creates or updates customer metadata.
1310
+ * @param customerMetaData - The customer metadata object to create or update.
1311
+ * @returns A promise that resolves to the created or updated customer metadata object.
1312
+ */
1313
+ static async createOrUpdateCustomerMetaData(customerMetaData) {
1314
+ const command = new import_lib_dynamodb11.PutCommand({
1315
+ TableName: _CustomerMetaData.TABLE_NAME,
1316
+ Item: customerMetaData
1317
+ });
1318
+ try {
1319
+ await ddbDocClient.send(command);
1320
+ return customerMetaData;
1321
+ } catch (error) {
1322
+ console.error("Error creating or updating customer metadata:", error);
1323
+ throw new Error("Could not create or update customer metadata");
1324
+ }
1325
+ }
1326
+ };
1327
+ var CustomerMetaData_default = CustomerMetaData;
1328
+
1329
+ // src/DynamoModels/CustomerMinified.ts
1330
+ var import_lib_dynamodb12 = require("@aws-sdk/lib-dynamodb");
1331
+ var CustomerMinified2 = class _CustomerMinified {
1332
+ static ENV = process.env.ENV || "dev";
1333
+ static TABLE_NAME = `NotiHub-CustomersMinified-${_CustomerMinified.ENV}`;
1334
+ /**
1335
+ * Retrieves a customer by their ID.
1336
+ * @param id - The ID of the customer to retrieve.
1337
+ * @returns A promise that resolves to the customer object or null if not found.
1338
+ */
1339
+ static async getCustomerMinifiedById(id) {
1340
+ const command = new import_lib_dynamodb12.GetCommand({
1341
+ TableName: _CustomerMinified.TABLE_NAME,
1342
+ Key: { id }
1343
+ });
1344
+ try {
1345
+ const result = await ddbDocClient.send(command);
1346
+ return result.Item || null;
1347
+ } catch (error) {
1348
+ console.error("Error fetching customer:", error);
1349
+ throw new Error("Could not fetch customer");
1350
+ }
1351
+ }
1352
+ /**
1353
+ * Creates or updates a customer minified.
1354
+ * @param customer - The customer object to create or update.
1355
+ * @returns A promise that resolves to the created or updated customer object.
1356
+ */
1357
+ static async createOrUpdateCustomerMinified(customer) {
1358
+ const command = new import_lib_dynamodb12.PutCommand({
1359
+ TableName: _CustomerMinified.TABLE_NAME,
1360
+ Item: customer
1361
+ });
1362
+ try {
1363
+ await ddbDocClient.send(command);
1364
+ return customer;
1365
+ } catch (error) {
1366
+ console.error("Error creating or updating customer:", error);
1367
+ throw new Error("Could not create or update customer");
1368
+ }
1369
+ }
1370
+ /**
1371
+ * Delete customer minified by ID.
1372
+ * @param id - The ID of the customer to delete.
1373
+ * @returns A promise that resolves when the customer is deleted.
1374
+ */
1375
+ static async deleteCustomerMinifiedById(id) {
1376
+ const command = new import_lib_dynamodb12.DeleteCommand({
1377
+ TableName: _CustomerMinified.TABLE_NAME,
1378
+ Key: { id }
1379
+ });
1380
+ try {
1381
+ await ddbDocClient.send(command);
1382
+ console.log(`Customer with ID ${id} deleted successfully.`);
1383
+ } catch (error) {
1384
+ console.error(`Error deleting customer with ID ${id}:`, error);
1385
+ throw new Error("Could not delete customer");
1386
+ }
1387
+ }
1388
+ };
1389
+ var CustomerMinified_default = CustomerMinified2;
1390
+
1285
1391
  // src/DynamoModels/index.ts
1286
1392
  var TABLES = {
1287
1393
  User: User_default,
@@ -1292,7 +1398,9 @@ var TABLES = {
1292
1398
  Subscription: Subscription_default,
1293
1399
  NotiTypeStats: NotiTypeStats_default,
1294
1400
  Views: Views_default,
1295
- SubscriptionType: SubscriptionType_default
1401
+ SubscriptionType: SubscriptionType_default,
1402
+ CustomerMetaData: CustomerMetaData_default,
1403
+ CustomerMinified: CustomerMinified_default
1296
1404
  };
1297
1405
 
1298
1406
  // src/errorcodes.ts
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Response as Response$1 } from 'express';
2
2
  import * as mongoose from 'mongoose';
3
- import mongoose__default from 'mongoose';
3
+ import mongoose__default, { Types } from 'mongoose';
4
4
 
5
5
  type CreateNotiRequestBody = {
6
6
  entityId: string;
@@ -40,7 +40,7 @@ type Response = {
40
40
  timestamp?: string;
41
41
  };
42
42
  type INotiHubCustomerMinified = {
43
- _id: string;
43
+ id: string;
44
44
  name: string;
45
45
  img: INotiHubImage;
46
46
  username: string;
@@ -48,7 +48,7 @@ type INotiHubCustomerMinified = {
48
48
  updatedAt: string;
49
49
  };
50
50
  type INotiHubCustomer = {
51
- _id: string;
51
+ id: string;
52
52
  name: string;
53
53
  email: string;
54
54
  minified: INotiHubCustomerMinified;
@@ -64,7 +64,7 @@ type INotiHubCustomer = {
64
64
  updatedAt: string;
65
65
  };
66
66
  type INotiHubCustomerMetadata = {
67
- _id?: string;
67
+ id: string;
68
68
  customerId: string;
69
69
  paymentState: "ACTIVE" | "INACTIVE";
70
70
  emailState: "VERIFIED" | "UNVERIFIED";
@@ -75,7 +75,7 @@ type INotiHubCustomerMetadata = {
75
75
  website: string;
76
76
  };
77
77
  type INotiHubNotification = {
78
- _id?: string;
78
+ id: string;
79
79
  title: string;
80
80
  message: string;
81
81
  type: string;
@@ -89,7 +89,7 @@ type INotiHubNotification = {
89
89
  updatedAt: string;
90
90
  };
91
91
  type INotiHubNotificationStats = {
92
- _id?: string;
92
+ id: string;
93
93
  notification: INotiHubNotification;
94
94
  views: number;
95
95
  };
@@ -122,7 +122,7 @@ type INotiHubStatsHistory = {
122
122
  views: number;
123
123
  };
124
124
  type INotiType = {
125
- _id?: string;
125
+ id: string;
126
126
  type: string;
127
127
  entity: string;
128
128
  entityRef: INotiHubCustomer;
@@ -130,7 +130,7 @@ type INotiType = {
130
130
  updatedAt: string;
131
131
  };
132
132
  type INotiTypeStats = {
133
- _id?: string;
133
+ id: string;
134
134
  notiType: INotiType;
135
135
  subscribed: number;
136
136
  views: number;
@@ -156,13 +156,14 @@ type IUserSubscribeNotifier = {
156
156
  updatedAt: string;
157
157
  };
158
158
  type INotiHubUserView = {
159
+ id: string;
159
160
  userId: string;
160
161
  entityId: string;
161
162
  notificationId: string;
162
163
  createdAt: string;
163
164
  };
164
165
  type INotiHubSubscription = {
165
- _id?: string;
166
+ id: string;
166
167
  subscriptionId: string;
167
168
  entity: INotiHubCustomer;
168
169
  entityRef: INotiHubCustomer;
@@ -173,7 +174,7 @@ type INotiHubSubscription = {
173
174
  updatedAt: string;
174
175
  };
175
176
  type INotiHubSubscriptionActivity = {
176
- _id?: string;
177
+ id: string;
177
178
  entityId: string;
178
179
  userId: string;
179
180
  activity: "SUBSCRIBED" | "UNSUBSCRIBED";
@@ -243,15 +244,15 @@ declare const UserModel: mongoose.Model<INotiHubUser, {}, {}, {}, mongoose.Docum
243
244
  __v?: number;
244
245
  }, any>;
245
246
 
246
- declare const Subscription$1: mongoose__default.Model<INotiHubSubscription, {}, {}, {}, mongoose__default.Document<unknown, {}, INotiHubSubscription> & INotiHubSubscription & Required<{
247
- _id: string;
248
- }> & {
247
+ declare const Subscription$1: mongoose__default.Model<INotiHubSubscription, {}, {}, {}, mongoose__default.Document<unknown, {}, INotiHubSubscription> & INotiHubSubscription & {
248
+ _id: Types.ObjectId;
249
+ } & {
249
250
  __v?: number;
250
251
  }, any>;
251
252
 
252
- declare const NotiTypeModel: mongoose.Model<INotiType, {}, {}, {}, mongoose.Document<unknown, {}, INotiType> & INotiType & Required<{
253
- _id: string;
254
- }> & {
253
+ declare const NotiTypeModel: mongoose.Model<INotiType, {}, {}, {}, mongoose.Document<unknown, {}, INotiType> & INotiType & {
254
+ _id: mongoose.Types.ObjectId;
255
+ } & {
255
256
  __v?: number;
256
257
  }, any>;
257
258
 
@@ -261,27 +262,27 @@ declare const NotiHubStatsHistory: mongoose.Model<INotiHubStatsHistory, {}, {},
261
262
  __v?: number;
262
263
  }, any>;
263
264
 
264
- declare const NotificationStatsModel: mongoose.Model<INotiHubNotificationStats, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubNotificationStats> & INotiHubNotificationStats & Required<{
265
- _id: string;
266
- }> & {
265
+ declare const NotificationStatsModel: mongoose.Model<INotiHubNotificationStats, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubNotificationStats> & INotiHubNotificationStats & {
266
+ _id: mongoose.Types.ObjectId;
267
+ } & {
267
268
  __v?: number;
268
269
  }, any>;
269
270
 
270
- declare const NotificationModel: mongoose.Model<INotiHubNotification, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubNotification> & INotiHubNotification & Required<{
271
- _id: string;
272
- }> & {
271
+ declare const NotificationModel: mongoose.Model<INotiHubNotification, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubNotification> & INotiHubNotification & {
272
+ _id: mongoose.Types.ObjectId;
273
+ } & {
273
274
  __v?: number;
274
275
  }, any>;
275
276
 
276
- declare const Customer$1: mongoose.Model<INotiHubCustomer, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubCustomer> & INotiHubCustomer & Required<{
277
- _id: string;
278
- }> & {
277
+ declare const Customer$1: mongoose.Model<INotiHubCustomer, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubCustomer> & INotiHubCustomer & {
278
+ _id: mongoose.Types.ObjectId;
279
+ } & {
279
280
  __v?: number;
280
281
  }, any>;
281
282
 
282
- declare const CustomerMinified: mongoose.Model<INotiHubCustomerMinified, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubCustomerMinified> & INotiHubCustomerMinified & Required<{
283
- _id: string;
284
- }> & {
283
+ declare const CustomerMinified$1: mongoose.Model<INotiHubCustomerMinified, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubCustomerMinified> & INotiHubCustomerMinified & {
284
+ _id: mongoose.Types.ObjectId;
285
+ } & {
285
286
  __v?: number;
286
287
  }, any>;
287
288
 
@@ -303,9 +304,9 @@ declare const ViewsModel: mongoose.Model<INotiHubUserView, {}, {}, {}, mongoose.
303
304
  __v?: number;
304
305
  }, any>;
305
306
 
306
- declare const NotiTypeStatsModel: mongoose.Model<INotiTypeStats, {}, {}, {}, mongoose.Document<unknown, {}, INotiTypeStats> & INotiTypeStats & Required<{
307
- _id: string;
308
- }> & {
307
+ declare const NotiTypeStatsModel: mongoose.Model<INotiTypeStats, {}, {}, {}, mongoose.Document<unknown, {}, INotiTypeStats> & INotiTypeStats & {
308
+ _id: mongoose.Types.ObjectId;
309
+ } & {
309
310
  __v?: number;
310
311
  }, any>;
311
312
 
@@ -321,15 +322,15 @@ declare const PaymentSessionModel: mongoose.Model<INotiHubPaymentSession, {}, {}
321
322
  __v?: number;
322
323
  }, any>;
323
324
 
324
- declare const SubscriptionActivity: mongoose.Model<INotiHubSubscriptionActivity, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubSubscriptionActivity> & INotiHubSubscriptionActivity & Required<{
325
- _id: string;
326
- }> & {
325
+ declare const SubscriptionActivity: mongoose.Model<INotiHubSubscriptionActivity, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubSubscriptionActivity> & INotiHubSubscriptionActivity & {
326
+ _id: mongoose.Types.ObjectId;
327
+ } & {
327
328
  __v?: number;
328
329
  }, any>;
329
330
 
330
- declare const CustomerMetadata: mongoose.Model<INotiHubCustomerMetadata, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubCustomerMetadata> & INotiHubCustomerMetadata & Required<{
331
- _id: string;
332
- }> & {
331
+ declare const CustomerMetadata: mongoose.Model<INotiHubCustomerMetadata, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubCustomerMetadata> & INotiHubCustomerMetadata & {
332
+ _id: mongoose.Types.ObjectId;
333
+ } & {
333
334
  __v?: number;
334
335
  }, any>;
335
336
 
@@ -558,6 +559,46 @@ declare class SubscriptionType {
558
559
  static getSubscriptionTypesByUserId(userId: string): Promise<IUserSubscribeNotifier[] | null>;
559
560
  }
560
561
 
562
+ declare class CustomerMetaData {
563
+ static ENV: string;
564
+ static TABLE_NAME: string;
565
+ /**
566
+ * Retrieves customer metadata by its ID.
567
+ * @param id - The ID of the customer metadata to retrieve.
568
+ * @returns A promise that resolves to the customer metadata object or null if not found.
569
+ */
570
+ static getCustomerMetaDataById(id: string): Promise<INotiHubCustomerMetadata | null>;
571
+ /**
572
+ * Creates or updates customer metadata.
573
+ * @param customerMetaData - The customer metadata object to create or update.
574
+ * @returns A promise that resolves to the created or updated customer metadata object.
575
+ */
576
+ static createOrUpdateCustomerMetaData(customerMetaData: INotiHubCustomerMetadata): Promise<INotiHubCustomerMetadata>;
577
+ }
578
+
579
+ declare class CustomerMinified {
580
+ static ENV: string;
581
+ static TABLE_NAME: string;
582
+ /**
583
+ * Retrieves a customer by their ID.
584
+ * @param id - The ID of the customer to retrieve.
585
+ * @returns A promise that resolves to the customer object or null if not found.
586
+ */
587
+ static getCustomerMinifiedById(id: string): Promise<INotiHubCustomerMinified | null>;
588
+ /**
589
+ * Creates or updates a customer minified.
590
+ * @param customer - The customer object to create or update.
591
+ * @returns A promise that resolves to the created or updated customer object.
592
+ */
593
+ static createOrUpdateCustomerMinified(customer: INotiHubCustomerMinified): Promise<INotiHubCustomerMinified>;
594
+ /**
595
+ * Delete customer minified by ID.
596
+ * @param id - The ID of the customer to delete.
597
+ * @returns A promise that resolves when the customer is deleted.
598
+ */
599
+ static deleteCustomerMinifiedById(id: string): Promise<void>;
600
+ }
601
+
561
602
  declare const TABLES: {
562
603
  User: typeof User;
563
604
  Customer: typeof Customer;
@@ -568,6 +609,8 @@ declare const TABLES: {
568
609
  NotiTypeStats: typeof NotiTypeStats;
569
610
  Views: typeof Views;
570
611
  SubscriptionType: typeof SubscriptionType;
612
+ CustomerMetaData: typeof CustomerMetaData;
613
+ CustomerMinified: typeof CustomerMinified;
571
614
  };
572
615
 
573
616
  declare const DocumentNotFound = "4001";
@@ -589,4 +632,4 @@ declare namespace errorcodes {
589
632
  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 };
590
633
  }
591
634
 
592
- export { type CreateNotiRequestBody, type CreateSubscriptionRequestBody, type CreateUserRequestBody, Customer$1 as Customer, CustomerMetadata, CustomerMinified, CustomerNotiHubStats, 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, NotiHubStatsHistory, type NotiHubTypes, NotiTypeModel, NotiTypeStatsModel, NotificationModel, NotificationStatsModel as NotificationStats, PaymentSessionModel, type Response, StripScriptionModel, Subscription$1 as Subscription, SubscriptionActivity, SubscriptionType$1 as SubscriptionType, TABLES, UserModel, ViewsModel, addMonths, formatResponse, getDate, getDateFormat, handleError, handleSuccess };
635
+ export { type CreateNotiRequestBody, type CreateSubscriptionRequestBody, type CreateUserRequestBody, Customer$1 as Customer, CustomerMetadata, CustomerMinified$1 as CustomerMinified, CustomerNotiHubStats, 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, NotiHubStatsHistory, type NotiHubTypes, NotiTypeModel, NotiTypeStatsModel, NotificationModel, NotificationStatsModel as NotificationStats, PaymentSessionModel, type Response, StripScriptionModel, Subscription$1 as Subscription, SubscriptionActivity, SubscriptionType$1 as SubscriptionType, TABLES, UserModel, ViewsModel, addMonths, formatResponse, getDate, getDateFormat, handleError, handleSuccess };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Response as Response$1 } from 'express';
2
2
  import * as mongoose from 'mongoose';
3
- import mongoose__default from 'mongoose';
3
+ import mongoose__default, { Types } from 'mongoose';
4
4
 
5
5
  type CreateNotiRequestBody = {
6
6
  entityId: string;
@@ -40,7 +40,7 @@ type Response = {
40
40
  timestamp?: string;
41
41
  };
42
42
  type INotiHubCustomerMinified = {
43
- _id: string;
43
+ id: string;
44
44
  name: string;
45
45
  img: INotiHubImage;
46
46
  username: string;
@@ -48,7 +48,7 @@ type INotiHubCustomerMinified = {
48
48
  updatedAt: string;
49
49
  };
50
50
  type INotiHubCustomer = {
51
- _id: string;
51
+ id: string;
52
52
  name: string;
53
53
  email: string;
54
54
  minified: INotiHubCustomerMinified;
@@ -64,7 +64,7 @@ type INotiHubCustomer = {
64
64
  updatedAt: string;
65
65
  };
66
66
  type INotiHubCustomerMetadata = {
67
- _id?: string;
67
+ id: string;
68
68
  customerId: string;
69
69
  paymentState: "ACTIVE" | "INACTIVE";
70
70
  emailState: "VERIFIED" | "UNVERIFIED";
@@ -75,7 +75,7 @@ type INotiHubCustomerMetadata = {
75
75
  website: string;
76
76
  };
77
77
  type INotiHubNotification = {
78
- _id?: string;
78
+ id: string;
79
79
  title: string;
80
80
  message: string;
81
81
  type: string;
@@ -89,7 +89,7 @@ type INotiHubNotification = {
89
89
  updatedAt: string;
90
90
  };
91
91
  type INotiHubNotificationStats = {
92
- _id?: string;
92
+ id: string;
93
93
  notification: INotiHubNotification;
94
94
  views: number;
95
95
  };
@@ -122,7 +122,7 @@ type INotiHubStatsHistory = {
122
122
  views: number;
123
123
  };
124
124
  type INotiType = {
125
- _id?: string;
125
+ id: string;
126
126
  type: string;
127
127
  entity: string;
128
128
  entityRef: INotiHubCustomer;
@@ -130,7 +130,7 @@ type INotiType = {
130
130
  updatedAt: string;
131
131
  };
132
132
  type INotiTypeStats = {
133
- _id?: string;
133
+ id: string;
134
134
  notiType: INotiType;
135
135
  subscribed: number;
136
136
  views: number;
@@ -156,13 +156,14 @@ type IUserSubscribeNotifier = {
156
156
  updatedAt: string;
157
157
  };
158
158
  type INotiHubUserView = {
159
+ id: string;
159
160
  userId: string;
160
161
  entityId: string;
161
162
  notificationId: string;
162
163
  createdAt: string;
163
164
  };
164
165
  type INotiHubSubscription = {
165
- _id?: string;
166
+ id: string;
166
167
  subscriptionId: string;
167
168
  entity: INotiHubCustomer;
168
169
  entityRef: INotiHubCustomer;
@@ -173,7 +174,7 @@ type INotiHubSubscription = {
173
174
  updatedAt: string;
174
175
  };
175
176
  type INotiHubSubscriptionActivity = {
176
- _id?: string;
177
+ id: string;
177
178
  entityId: string;
178
179
  userId: string;
179
180
  activity: "SUBSCRIBED" | "UNSUBSCRIBED";
@@ -243,15 +244,15 @@ declare const UserModel: mongoose.Model<INotiHubUser, {}, {}, {}, mongoose.Docum
243
244
  __v?: number;
244
245
  }, any>;
245
246
 
246
- declare const Subscription$1: mongoose__default.Model<INotiHubSubscription, {}, {}, {}, mongoose__default.Document<unknown, {}, INotiHubSubscription> & INotiHubSubscription & Required<{
247
- _id: string;
248
- }> & {
247
+ declare const Subscription$1: mongoose__default.Model<INotiHubSubscription, {}, {}, {}, mongoose__default.Document<unknown, {}, INotiHubSubscription> & INotiHubSubscription & {
248
+ _id: Types.ObjectId;
249
+ } & {
249
250
  __v?: number;
250
251
  }, any>;
251
252
 
252
- declare const NotiTypeModel: mongoose.Model<INotiType, {}, {}, {}, mongoose.Document<unknown, {}, INotiType> & INotiType & Required<{
253
- _id: string;
254
- }> & {
253
+ declare const NotiTypeModel: mongoose.Model<INotiType, {}, {}, {}, mongoose.Document<unknown, {}, INotiType> & INotiType & {
254
+ _id: mongoose.Types.ObjectId;
255
+ } & {
255
256
  __v?: number;
256
257
  }, any>;
257
258
 
@@ -261,27 +262,27 @@ declare const NotiHubStatsHistory: mongoose.Model<INotiHubStatsHistory, {}, {},
261
262
  __v?: number;
262
263
  }, any>;
263
264
 
264
- declare const NotificationStatsModel: mongoose.Model<INotiHubNotificationStats, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubNotificationStats> & INotiHubNotificationStats & Required<{
265
- _id: string;
266
- }> & {
265
+ declare const NotificationStatsModel: mongoose.Model<INotiHubNotificationStats, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubNotificationStats> & INotiHubNotificationStats & {
266
+ _id: mongoose.Types.ObjectId;
267
+ } & {
267
268
  __v?: number;
268
269
  }, any>;
269
270
 
270
- declare const NotificationModel: mongoose.Model<INotiHubNotification, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubNotification> & INotiHubNotification & Required<{
271
- _id: string;
272
- }> & {
271
+ declare const NotificationModel: mongoose.Model<INotiHubNotification, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubNotification> & INotiHubNotification & {
272
+ _id: mongoose.Types.ObjectId;
273
+ } & {
273
274
  __v?: number;
274
275
  }, any>;
275
276
 
276
- declare const Customer$1: mongoose.Model<INotiHubCustomer, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubCustomer> & INotiHubCustomer & Required<{
277
- _id: string;
278
- }> & {
277
+ declare const Customer$1: mongoose.Model<INotiHubCustomer, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubCustomer> & INotiHubCustomer & {
278
+ _id: mongoose.Types.ObjectId;
279
+ } & {
279
280
  __v?: number;
280
281
  }, any>;
281
282
 
282
- declare const CustomerMinified: mongoose.Model<INotiHubCustomerMinified, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubCustomerMinified> & INotiHubCustomerMinified & Required<{
283
- _id: string;
284
- }> & {
283
+ declare const CustomerMinified$1: mongoose.Model<INotiHubCustomerMinified, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubCustomerMinified> & INotiHubCustomerMinified & {
284
+ _id: mongoose.Types.ObjectId;
285
+ } & {
285
286
  __v?: number;
286
287
  }, any>;
287
288
 
@@ -303,9 +304,9 @@ declare const ViewsModel: mongoose.Model<INotiHubUserView, {}, {}, {}, mongoose.
303
304
  __v?: number;
304
305
  }, any>;
305
306
 
306
- declare const NotiTypeStatsModel: mongoose.Model<INotiTypeStats, {}, {}, {}, mongoose.Document<unknown, {}, INotiTypeStats> & INotiTypeStats & Required<{
307
- _id: string;
308
- }> & {
307
+ declare const NotiTypeStatsModel: mongoose.Model<INotiTypeStats, {}, {}, {}, mongoose.Document<unknown, {}, INotiTypeStats> & INotiTypeStats & {
308
+ _id: mongoose.Types.ObjectId;
309
+ } & {
309
310
  __v?: number;
310
311
  }, any>;
311
312
 
@@ -321,15 +322,15 @@ declare const PaymentSessionModel: mongoose.Model<INotiHubPaymentSession, {}, {}
321
322
  __v?: number;
322
323
  }, any>;
323
324
 
324
- declare const SubscriptionActivity: mongoose.Model<INotiHubSubscriptionActivity, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubSubscriptionActivity> & INotiHubSubscriptionActivity & Required<{
325
- _id: string;
326
- }> & {
325
+ declare const SubscriptionActivity: mongoose.Model<INotiHubSubscriptionActivity, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubSubscriptionActivity> & INotiHubSubscriptionActivity & {
326
+ _id: mongoose.Types.ObjectId;
327
+ } & {
327
328
  __v?: number;
328
329
  }, any>;
329
330
 
330
- declare const CustomerMetadata: mongoose.Model<INotiHubCustomerMetadata, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubCustomerMetadata> & INotiHubCustomerMetadata & Required<{
331
- _id: string;
332
- }> & {
331
+ declare const CustomerMetadata: mongoose.Model<INotiHubCustomerMetadata, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubCustomerMetadata> & INotiHubCustomerMetadata & {
332
+ _id: mongoose.Types.ObjectId;
333
+ } & {
333
334
  __v?: number;
334
335
  }, any>;
335
336
 
@@ -558,6 +559,46 @@ declare class SubscriptionType {
558
559
  static getSubscriptionTypesByUserId(userId: string): Promise<IUserSubscribeNotifier[] | null>;
559
560
  }
560
561
 
562
+ declare class CustomerMetaData {
563
+ static ENV: string;
564
+ static TABLE_NAME: string;
565
+ /**
566
+ * Retrieves customer metadata by its ID.
567
+ * @param id - The ID of the customer metadata to retrieve.
568
+ * @returns A promise that resolves to the customer metadata object or null if not found.
569
+ */
570
+ static getCustomerMetaDataById(id: string): Promise<INotiHubCustomerMetadata | null>;
571
+ /**
572
+ * Creates or updates customer metadata.
573
+ * @param customerMetaData - The customer metadata object to create or update.
574
+ * @returns A promise that resolves to the created or updated customer metadata object.
575
+ */
576
+ static createOrUpdateCustomerMetaData(customerMetaData: INotiHubCustomerMetadata): Promise<INotiHubCustomerMetadata>;
577
+ }
578
+
579
+ declare class CustomerMinified {
580
+ static ENV: string;
581
+ static TABLE_NAME: string;
582
+ /**
583
+ * Retrieves a customer by their ID.
584
+ * @param id - The ID of the customer to retrieve.
585
+ * @returns A promise that resolves to the customer object or null if not found.
586
+ */
587
+ static getCustomerMinifiedById(id: string): Promise<INotiHubCustomerMinified | null>;
588
+ /**
589
+ * Creates or updates a customer minified.
590
+ * @param customer - The customer object to create or update.
591
+ * @returns A promise that resolves to the created or updated customer object.
592
+ */
593
+ static createOrUpdateCustomerMinified(customer: INotiHubCustomerMinified): Promise<INotiHubCustomerMinified>;
594
+ /**
595
+ * Delete customer minified by ID.
596
+ * @param id - The ID of the customer to delete.
597
+ * @returns A promise that resolves when the customer is deleted.
598
+ */
599
+ static deleteCustomerMinifiedById(id: string): Promise<void>;
600
+ }
601
+
561
602
  declare const TABLES: {
562
603
  User: typeof User;
563
604
  Customer: typeof Customer;
@@ -568,6 +609,8 @@ declare const TABLES: {
568
609
  NotiTypeStats: typeof NotiTypeStats;
569
610
  Views: typeof Views;
570
611
  SubscriptionType: typeof SubscriptionType;
612
+ CustomerMetaData: typeof CustomerMetaData;
613
+ CustomerMinified: typeof CustomerMinified;
571
614
  };
572
615
 
573
616
  declare const DocumentNotFound = "4001";
@@ -589,4 +632,4 @@ declare namespace errorcodes {
589
632
  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 };
590
633
  }
591
634
 
592
- export { type CreateNotiRequestBody, type CreateSubscriptionRequestBody, type CreateUserRequestBody, Customer$1 as Customer, CustomerMetadata, CustomerMinified, CustomerNotiHubStats, 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, NotiHubStatsHistory, type NotiHubTypes, NotiTypeModel, NotiTypeStatsModel, NotificationModel, NotificationStatsModel as NotificationStats, PaymentSessionModel, type Response, StripScriptionModel, Subscription$1 as Subscription, SubscriptionActivity, SubscriptionType$1 as SubscriptionType, TABLES, UserModel, ViewsModel, addMonths, formatResponse, getDate, getDateFormat, handleError, handleSuccess };
635
+ export { type CreateNotiRequestBody, type CreateSubscriptionRequestBody, type CreateUserRequestBody, Customer$1 as Customer, CustomerMetadata, CustomerMinified$1 as CustomerMinified, CustomerNotiHubStats, 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, NotiHubStatsHistory, type NotiHubTypes, NotiTypeModel, NotiTypeStatsModel, NotificationModel, NotificationStatsModel as NotificationStats, PaymentSessionModel, type Response, StripScriptionModel, Subscription$1 as Subscription, SubscriptionActivity, SubscriptionType$1 as SubscriptionType, TABLES, UserModel, ViewsModel, addMonths, formatResponse, getDate, getDateFormat, handleError, handleSuccess };
package/dist/index.js CHANGED
@@ -1265,6 +1265,119 @@ var SubscriptionType2 = class _SubscriptionType {
1265
1265
  };
1266
1266
  var SubscriptionType_default = SubscriptionType2;
1267
1267
 
1268
+ // src/DynamoModels/CustomerMetaData.ts
1269
+ import {
1270
+ GetCommand as GetCommand10,
1271
+ PutCommand as PutCommand10
1272
+ } from "@aws-sdk/lib-dynamodb";
1273
+ var CustomerMetaData = class _CustomerMetaData {
1274
+ static ENV = process.env.ENV || "dev";
1275
+ static TABLE_NAME = `NotiHub-CustomerMetaData-${_CustomerMetaData.ENV}`;
1276
+ /**
1277
+ * Retrieves customer metadata by its ID.
1278
+ * @param id - The ID of the customer metadata to retrieve.
1279
+ * @returns A promise that resolves to the customer metadata object or null if not found.
1280
+ */
1281
+ static async getCustomerMetaDataById(id) {
1282
+ const command = new GetCommand10({
1283
+ TableName: _CustomerMetaData.TABLE_NAME,
1284
+ Key: { id }
1285
+ });
1286
+ try {
1287
+ const result = await ddbDocClient.send(command);
1288
+ return result.Item || null;
1289
+ } catch (error) {
1290
+ console.error("Error fetching customer metadata:", error);
1291
+ throw new Error("Could not fetch customer metadata");
1292
+ }
1293
+ }
1294
+ /**
1295
+ * Creates or updates customer metadata.
1296
+ * @param customerMetaData - The customer metadata object to create or update.
1297
+ * @returns A promise that resolves to the created or updated customer metadata object.
1298
+ */
1299
+ static async createOrUpdateCustomerMetaData(customerMetaData) {
1300
+ const command = new PutCommand10({
1301
+ TableName: _CustomerMetaData.TABLE_NAME,
1302
+ Item: customerMetaData
1303
+ });
1304
+ try {
1305
+ await ddbDocClient.send(command);
1306
+ return customerMetaData;
1307
+ } catch (error) {
1308
+ console.error("Error creating or updating customer metadata:", error);
1309
+ throw new Error("Could not create or update customer metadata");
1310
+ }
1311
+ }
1312
+ };
1313
+ var CustomerMetaData_default = CustomerMetaData;
1314
+
1315
+ // src/DynamoModels/CustomerMinified.ts
1316
+ import {
1317
+ DeleteCommand as DeleteCommand11,
1318
+ GetCommand as GetCommand11,
1319
+ PutCommand as PutCommand11
1320
+ } from "@aws-sdk/lib-dynamodb";
1321
+ var CustomerMinified2 = class _CustomerMinified {
1322
+ static ENV = process.env.ENV || "dev";
1323
+ static TABLE_NAME = `NotiHub-CustomersMinified-${_CustomerMinified.ENV}`;
1324
+ /**
1325
+ * Retrieves a customer by their ID.
1326
+ * @param id - The ID of the customer to retrieve.
1327
+ * @returns A promise that resolves to the customer object or null if not found.
1328
+ */
1329
+ static async getCustomerMinifiedById(id) {
1330
+ const command = new GetCommand11({
1331
+ TableName: _CustomerMinified.TABLE_NAME,
1332
+ Key: { id }
1333
+ });
1334
+ try {
1335
+ const result = await ddbDocClient.send(command);
1336
+ return result.Item || null;
1337
+ } catch (error) {
1338
+ console.error("Error fetching customer:", error);
1339
+ throw new Error("Could not fetch customer");
1340
+ }
1341
+ }
1342
+ /**
1343
+ * Creates or updates a customer minified.
1344
+ * @param customer - The customer object to create or update.
1345
+ * @returns A promise that resolves to the created or updated customer object.
1346
+ */
1347
+ static async createOrUpdateCustomerMinified(customer) {
1348
+ const command = new PutCommand11({
1349
+ TableName: _CustomerMinified.TABLE_NAME,
1350
+ Item: customer
1351
+ });
1352
+ try {
1353
+ await ddbDocClient.send(command);
1354
+ return customer;
1355
+ } catch (error) {
1356
+ console.error("Error creating or updating customer:", error);
1357
+ throw new Error("Could not create or update customer");
1358
+ }
1359
+ }
1360
+ /**
1361
+ * Delete customer minified by ID.
1362
+ * @param id - The ID of the customer to delete.
1363
+ * @returns A promise that resolves when the customer is deleted.
1364
+ */
1365
+ static async deleteCustomerMinifiedById(id) {
1366
+ const command = new DeleteCommand11({
1367
+ TableName: _CustomerMinified.TABLE_NAME,
1368
+ Key: { id }
1369
+ });
1370
+ try {
1371
+ await ddbDocClient.send(command);
1372
+ console.log(`Customer with ID ${id} deleted successfully.`);
1373
+ } catch (error) {
1374
+ console.error(`Error deleting customer with ID ${id}:`, error);
1375
+ throw new Error("Could not delete customer");
1376
+ }
1377
+ }
1378
+ };
1379
+ var CustomerMinified_default = CustomerMinified2;
1380
+
1268
1381
  // src/DynamoModels/index.ts
1269
1382
  var TABLES = {
1270
1383
  User: User_default,
@@ -1275,7 +1388,9 @@ var TABLES = {
1275
1388
  Subscription: Subscription_default,
1276
1389
  NotiTypeStats: NotiTypeStats_default,
1277
1390
  Views: Views_default,
1278
- SubscriptionType: SubscriptionType_default
1391
+ SubscriptionType: SubscriptionType_default,
1392
+ CustomerMetaData: CustomerMetaData_default,
1393
+ CustomerMinified: CustomerMinified_default
1279
1394
  };
1280
1395
 
1281
1396
  // src/errorcodes.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amohamud23/notihub",
3
- "version": "1.0.156",
3
+ "version": "1.0.158",
4
4
  "description": "Notihub Package",
5
5
  "main": "./dist/index.cjs",
6
6
  "types": "./dist/index.d.cts",