@amohamud23/notihub 1.0.78 → 1.0.79

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
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
6
10
  var __copyProps = (to, from, except, desc) => {
7
11
  if (from && typeof from === "object" || typeof from === "function") {
8
12
  for (let key of __getOwnPropNames(from))
@@ -15,4 +19,301 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
15
19
 
16
20
  // src/index.ts
17
21
  var src_exports = {};
22
+ __export(src_exports, {
23
+ Customer: () => CustomerModel_default,
24
+ CustomerMinified: () => CustomerMinifiedModel_default,
25
+ NotiHubStatsHistory: () => NotiHubStatsHistoryModel_default,
26
+ NotiTypeModel: () => NotiTypeModel_default,
27
+ NotificationModel: () => NotificationModel_default,
28
+ NotificationStatsModel: () => NotificationStatsModel_default,
29
+ Subscription: () => SubscriptionModel_default,
30
+ SubscriptionType: () => SubscriptionTypeModel_default,
31
+ UserModel: () => UserModel_default,
32
+ addMonths: () => addMonths,
33
+ getDate: () => getDate,
34
+ getDateFormat: () => getDateFormat
35
+ });
18
36
  module.exports = __toCommonJS(src_exports);
37
+
38
+ // src/util/index.ts
39
+ function getDate(dateStr) {
40
+ const date = new Date(dateStr);
41
+ const year = date.getFullYear();
42
+ const month = (date.getMonth() + 1).toString().padStart(2, "0");
43
+ const day = date.getDate().toString().padStart(2, "0");
44
+ const formattedDate = `${month}-${day}-${year}`;
45
+ return formattedDate;
46
+ }
47
+ function getDateFormat(dateStr) {
48
+ const date = new Date(dateStr);
49
+ const now = /* @__PURE__ */ new Date();
50
+ const seconds = Math.floor((now.getTime() - date.getTime()) / 1e3);
51
+ let interval = seconds / 31536e3;
52
+ if (interval > 1) {
53
+ return date.toLocaleDateString("en-US", {
54
+ year: "numeric",
55
+ month: "short",
56
+ day: "numeric"
57
+ });
58
+ }
59
+ interval = seconds / 2592e3;
60
+ if (interval > 1) {
61
+ return date.toLocaleDateString("en-US", {
62
+ year: "numeric",
63
+ month: "short",
64
+ day: "numeric"
65
+ });
66
+ }
67
+ interval = seconds / 86400;
68
+ if (interval > 7) {
69
+ return date.toLocaleDateString("en-US", {
70
+ year: "numeric",
71
+ month: "short",
72
+ day: "numeric"
73
+ });
74
+ } else if (interval > 1) {
75
+ return Math.floor(interval) + "d ago";
76
+ }
77
+ interval = seconds / 3600;
78
+ if (interval > 1) {
79
+ return Math.floor(interval) + "h ago";
80
+ }
81
+ interval = seconds / 60;
82
+ if (interval > 1) {
83
+ return Math.floor(interval) + "m ago";
84
+ }
85
+ return Math.floor(seconds) + "s ago";
86
+ }
87
+ function addMonths({ date, months }) {
88
+ date.setMonth(date.getMonth() + months);
89
+ return date;
90
+ }
91
+
92
+ // src/models/UserModel.ts
93
+ var import_mongoose2 = require("mongoose");
94
+
95
+ // src/models/schemas/UserSchema.ts
96
+ var import_mongoose = require("mongoose");
97
+ var UserSchema = {
98
+ id: { type: import_mongoose.Schema.Types.UUID, default: true },
99
+ name: { type: String, required: true },
100
+ email: { type: String, required: true },
101
+ pushToken: { type: String, required: true },
102
+ signedIn: { type: Boolean, required: true, default: false }
103
+ };
104
+ var UserSchema_default = UserSchema;
105
+
106
+ // src/models/UserModel.ts
107
+ var userSchema = new import_mongoose2.Schema(UserSchema_default, { timestamps: true });
108
+ var UserModel = (0, import_mongoose2.model)("User", userSchema);
109
+ var UserModel_default = UserModel;
110
+
111
+ // src/models/SubscriptionModel.ts
112
+ var import_mongoose6 = require("mongoose");
113
+
114
+ // src/models/schemas/SubscriptionSchema.ts
115
+ var import_mongoose5 = require("mongoose");
116
+
117
+ // src/models/schemas/CustomerSchema.ts
118
+ var import_mongoose4 = require("mongoose");
119
+
120
+ // src/models/schemas/CustomerMinifiedSchema.ts
121
+ var import_mongoose3 = require("mongoose");
122
+ var CustomerMinifiedSchema = {
123
+ id: { type: import_mongoose3.Schema.Types.UUID, default: true },
124
+ username: { type: String, required: true },
125
+ img: {
126
+ bucket: { type: String, required: true },
127
+ key: { type: String, required: true }
128
+ },
129
+ name: { type: String, required: true }
130
+ };
131
+ var CustomerMinifiedSchema_default = CustomerMinifiedSchema;
132
+
133
+ // src/models/schemas/CustomerSchema.ts
134
+ var CustomerSchema = {
135
+ id: { type: import_mongoose4.Schema.Types.UUID, default: true },
136
+ minified: CustomerMinifiedSchema_default,
137
+ paid: { type: Boolean, default: false },
138
+ email: { type: String, required: true },
139
+ verified: { type: Boolean, default: false },
140
+ confirmed: { type: Boolean, default: false }
141
+ };
142
+ var CustomerSchema_default = CustomerSchema;
143
+
144
+ // src/models/schemas/SubscriptionSchema.ts
145
+ var SubscriptionSchema = {
146
+ id: { type: import_mongoose5.Schema.Types.UUID, default: true },
147
+ subscriptionId: { type: String, required: true },
148
+ user: UserSchema_default,
149
+ entity: CustomerSchema_default
150
+ };
151
+ var SubscriptionSchema_default = SubscriptionSchema;
152
+
153
+ // src/models/SubscriptionModel.ts
154
+ var subscriptionSchema = new import_mongoose6.Schema(
155
+ SubscriptionSchema_default,
156
+ {
157
+ timestamps: true
158
+ }
159
+ );
160
+ var Subscription = (0, import_mongoose6.model)(
161
+ "Subscriptions",
162
+ subscriptionSchema
163
+ );
164
+ var SubscriptionModel_default = Subscription;
165
+
166
+ // src/models/NotiTypeModel.ts
167
+ var import_mongoose8 = require("mongoose");
168
+
169
+ // src/models/schemas/NotiTypeSchema.ts
170
+ var import_mongoose7 = require("mongoose");
171
+ var NotiTypeSchema = {
172
+ id: { type: import_mongoose7.Schema.Types.UUID, default: true },
173
+ entity: CustomerSchema_default,
174
+ type: { type: String, required: true }
175
+ };
176
+ var NotiTypeSchema_default = NotiTypeSchema;
177
+
178
+ // src/models/NotiTypeModel.ts
179
+ var notiTypeSchema = new import_mongoose8.Schema(NotiTypeSchema_default, {
180
+ timestamps: true
181
+ });
182
+ var NotiTypeModel = (0, import_mongoose8.model)("NotiTypes", notiTypeSchema);
183
+ var NotiTypeModel_default = NotiTypeModel;
184
+
185
+ // src/models/NotiHubStatsHistoryModel.ts
186
+ var import_mongoose10 = require("mongoose");
187
+
188
+ // src/models/schemas/NotificationStatsHistorySchema.ts
189
+ var import_mongoose9 = require("mongoose");
190
+ var NotihubStatsHistorySchema = {
191
+ id: { type: import_mongoose9.Schema.Types.UUID, default: true },
192
+ entityId: { type: String, required: true },
193
+ notifications: { type: Number, required: true },
194
+ subscription: { type: Number, required: true },
195
+ views: { type: Number, required: true },
196
+ type: { type: String, required: true }
197
+ };
198
+ var NotificationStatsHistorySchema_default = NotihubStatsHistorySchema;
199
+
200
+ // src/models/NotiHubStatsHistoryModel.ts
201
+ var notihubStatsHistorySchema = new import_mongoose10.Schema(
202
+ NotificationStatsHistorySchema_default,
203
+ {
204
+ timestamps: true
205
+ }
206
+ );
207
+ var NotiHubStatsHistory = (0, import_mongoose10.model)(
208
+ "INotiHubStatsHistories",
209
+ notihubStatsHistorySchema
210
+ );
211
+ var NotiHubStatsHistoryModel_default = NotiHubStatsHistory;
212
+
213
+ // src/models/NotificationStatsModel.ts
214
+ var import_mongoose12 = require("mongoose");
215
+
216
+ // src/models/schemas/NotificationSchema.ts
217
+ var import_mongoose11 = require("mongoose");
218
+ var NotificationSchema = {
219
+ id: { type: import_mongoose11.Schema.Types.UUID, default: true },
220
+ title: { type: String, required: true },
221
+ message: { type: String, required: true },
222
+ type: { type: String, required: true },
223
+ body: { type: String },
224
+ entityId: { type: String, required: true },
225
+ entityMinified: CustomerMinifiedSchema_default
226
+ };
227
+ var NotificationSchema_default = NotificationSchema;
228
+
229
+ // src/models/NotificationStatsModel.ts
230
+ var notificationSchema = new import_mongoose12.Schema(
231
+ {
232
+ notification: NotificationSchema_default,
233
+ views: { type: Number, default: 0 }
234
+ },
235
+ { timestamps: true }
236
+ );
237
+ var NotificationStatsModel = (0, import_mongoose12.model)(
238
+ "NotificationStats",
239
+ notificationSchema
240
+ );
241
+ var NotificationStatsModel_default = NotificationStatsModel;
242
+
243
+ // src/models/NotificationModel.ts
244
+ var import_mongoose13 = require("mongoose");
245
+ var notificationSchema2 = new import_mongoose13.Schema(
246
+ {
247
+ title: { type: String, required: true },
248
+ message: { type: String, required: true },
249
+ type: { type: String, required: true },
250
+ body: { type: String },
251
+ entityId: { type: String, required: true },
252
+ entityMinified: CustomerSchema_default
253
+ },
254
+ { timestamps: true }
255
+ );
256
+ var NotificationModel = (0, import_mongoose13.model)(
257
+ "Notification",
258
+ notificationSchema2
259
+ );
260
+ var NotificationModel_default = NotificationModel;
261
+
262
+ // src/models/CustomerModel.ts
263
+ var import_mongoose14 = require("mongoose");
264
+ var customerSchema = new import_mongoose14.Schema(CustomerSchema_default, {
265
+ timestamps: true
266
+ });
267
+ var Customer = (0, import_mongoose14.model)("Customer", customerSchema);
268
+ var CustomerModel_default = Customer;
269
+
270
+ // src/models/CustomerMinifiedModel.ts
271
+ var import_mongoose15 = require("mongoose");
272
+ var customerMinifiedSchema = new import_mongoose15.Schema(
273
+ CustomerMinifiedSchema_default,
274
+ { timestamps: true }
275
+ );
276
+ var CustomerMinified = (0, import_mongoose15.model)(
277
+ "CustomerMinified",
278
+ customerMinifiedSchema
279
+ );
280
+ var CustomerMinifiedModel_default = CustomerMinified;
281
+
282
+ // src/models/SubscriptionTypeModel.ts
283
+ var import_mongoose16 = require("mongoose");
284
+
285
+ // src/models/schemas/SubscriptionTypeSchema.ts
286
+ var SubscriptionSchema2 = {
287
+ userId: { type: String, required: true },
288
+ entityId: { type: String, required: true },
289
+ notiTypeId: { type: String, required: true }
290
+ };
291
+ var SubscriptionTypeSchema_default = SubscriptionSchema2;
292
+
293
+ // src/models/SubscriptionTypeModel.ts
294
+ var subscriptionSchema2 = new import_mongoose16.Schema(
295
+ SubscriptionTypeSchema_default,
296
+ {
297
+ timestamps: true
298
+ }
299
+ );
300
+ var SubscriptionType = (0, import_mongoose16.model)(
301
+ "SubscriptionTypes",
302
+ subscriptionSchema2
303
+ );
304
+ var SubscriptionTypeModel_default = SubscriptionType;
305
+ // Annotate the CommonJS export names for ESM import in node:
306
+ 0 && (module.exports = {
307
+ Customer,
308
+ CustomerMinified,
309
+ NotiHubStatsHistory,
310
+ NotiTypeModel,
311
+ NotificationModel,
312
+ NotificationStatsModel,
313
+ Subscription,
314
+ SubscriptionType,
315
+ UserModel,
316
+ addMonths,
317
+ getDate,
318
+ getDateFormat
319
+ });
package/dist/index.d.cts CHANGED
@@ -1,2 +1,208 @@
1
+ import * as mongoose from 'mongoose';
2
+ import mongoose__default from 'mongoose';
1
3
 
2
- export { }
4
+ type CreateNotiRequestBody = {
5
+ subscriptionId: string;
6
+ userId: string;
7
+ title: string;
8
+ message: string;
9
+ type: string;
10
+ };
11
+ type CreateSubscriptionRequestBody = {
12
+ subscriptionId: string;
13
+ type: string;
14
+ };
15
+ type CreateUserRequestBody = {
16
+ name: string;
17
+ email: string;
18
+ token: string;
19
+ };
20
+ type ICreateCustomerRequestBody = {
21
+ email: string;
22
+ username: string;
23
+ name: string;
24
+ };
25
+ type ICreateNotiRequestBody = {};
26
+ type INotiHubCustomerMinified = {
27
+ _id: string;
28
+ name: string;
29
+ img: INotiHubImage;
30
+ username: string;
31
+ createdAt: string;
32
+ updatedAt: string;
33
+ };
34
+ type INotiHubCustomer = {
35
+ _id: string;
36
+ name: string;
37
+ email: string;
38
+ minified: INotiHubCustomerMinified;
39
+ verified: boolean;
40
+ paid: boolean;
41
+ confirmed: boolean;
42
+ createdAt: string;
43
+ updatedAt: string;
44
+ };
45
+ type INotiHubNotification = {
46
+ _id?: string;
47
+ title: string;
48
+ message: string;
49
+ type: string;
50
+ entityId: string;
51
+ entityMinified: INotiHubCustomerMinified;
52
+ body: string;
53
+ createdAt: string;
54
+ updatedAt: string;
55
+ };
56
+ type INotiHubNotificationStats = {
57
+ _id?: string;
58
+ notification: INotiHubNotification;
59
+ views: number;
60
+ };
61
+ type INotiHubUser = {
62
+ _id?: string;
63
+ pushToken: string;
64
+ name: string;
65
+ email: string;
66
+ subscriptions: number;
67
+ events: number;
68
+ };
69
+ type INotiHubImage = {
70
+ bucket: string;
71
+ key: string;
72
+ };
73
+ type INotiHubStats = {
74
+ entityRef: string;
75
+ entity: INotiHubCustomer;
76
+ subscription: number;
77
+ notifications: number;
78
+ views: number;
79
+ };
80
+ type INotiHubStatsHistory = {
81
+ entityId: string;
82
+ type: "MONTH" | "YEAR";
83
+ subscription: number;
84
+ notifications: number;
85
+ views: number;
86
+ };
87
+ type INotiType = {
88
+ _id?: string;
89
+ type: string;
90
+ entity: string;
91
+ createdAt: string;
92
+ updatedAt: string;
93
+ };
94
+ type INotiTypeStats = {
95
+ _id?: string;
96
+ notiTypeId: string;
97
+ subscribed: number;
98
+ createdAt: string;
99
+ };
100
+ type IUserSubscription = {
101
+ user: INotiHubUser;
102
+ entity: INotiHubCustomer;
103
+ subscriptionId: string;
104
+ type: "SUBSCRIBED" | "UNSUBSCRIBED";
105
+ createdAt: string;
106
+ updatedAt: string;
107
+ };
108
+ type IUserSubscribeNotifier = {
109
+ userId: string;
110
+ entityId: string;
111
+ notiTypeId: string;
112
+ createdAt: string;
113
+ updatedAt: string;
114
+ };
115
+ type INotiHubUserView = {
116
+ userId: string;
117
+ entityId: string;
118
+ notificationId: string;
119
+ createdAt: string;
120
+ };
121
+ type INotiHubSubscription = {
122
+ _id?: string;
123
+ subscriptionId: string;
124
+ entity: INotiHubCustomer;
125
+ user: INotiHubUser;
126
+ type: "SUBSCRIBED" | "UNSUBSCRIBED";
127
+ createdAt: string;
128
+ updatedAt: string;
129
+ };
130
+ type NotiHubTypes = {
131
+ INotiHubUserView: INotiHubUserView;
132
+ IUserSubscribeNotifier: IUserSubscribeNotifier;
133
+ IUserSubscription: IUserSubscription;
134
+ INotiHubUser: INotiHubUser;
135
+ INotiTypeStats: INotiTypeStats;
136
+ INotiHubImage: INotiHubImage;
137
+ INotiHubSubscription: INotiHubSubscription;
138
+ INotiHubNotificationStats: INotiHubNotificationStats;
139
+ INotiHubNotification: INotiHubNotification;
140
+ INotiHubCustomer: INotiHubCustomer;
141
+ INotiHubCustomerMinified: INotiHubCustomerMinified;
142
+ INotiHubStatsHistory: INotiHubStatsHistory;
143
+ };
144
+
145
+ type AddMonths = {
146
+ date: Date;
147
+ months: number;
148
+ };
149
+
150
+ declare function getDate(dateStr: string): string;
151
+ declare function getDateFormat(dateStr: string): string;
152
+ declare function addMonths({ date, months }: AddMonths): Date;
153
+
154
+ declare const UserModel: mongoose.Model<INotiHubUser, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubUser> & INotiHubUser & Required<{
155
+ _id: string;
156
+ }> & {
157
+ __v?: number | undefined;
158
+ }, any>;
159
+
160
+ declare const Subscription: mongoose__default.Model<INotiHubSubscription, {}, {}, {}, mongoose__default.Document<unknown, {}, INotiHubSubscription> & INotiHubSubscription & Required<{
161
+ _id: string;
162
+ }> & {
163
+ __v?: number | undefined;
164
+ }, any>;
165
+
166
+ declare const NotiTypeModel: mongoose.Model<INotiType, {}, {}, {}, mongoose.Document<unknown, {}, INotiType> & INotiType & Required<{
167
+ _id: string;
168
+ }> & {
169
+ __v?: number | undefined;
170
+ }, any>;
171
+
172
+ declare const NotiHubStatsHistory: mongoose.Model<INotiHubStatsHistory, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubStatsHistory> & INotiHubStatsHistory & {
173
+ _id: mongoose.Types.ObjectId;
174
+ } & {
175
+ __v?: number | undefined;
176
+ }, any>;
177
+
178
+ declare const NotificationStatsModel: mongoose.Model<INotiHubNotificationStats, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubNotificationStats> & INotiHubNotificationStats & Required<{
179
+ _id: string;
180
+ }> & {
181
+ __v?: number | undefined;
182
+ }, any>;
183
+
184
+ declare const NotificationModel: mongoose.Model<INotiHubNotification, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubNotification> & INotiHubNotification & Required<{
185
+ _id: string;
186
+ }> & {
187
+ __v?: number | undefined;
188
+ }, any>;
189
+
190
+ declare const Customer: mongoose.Model<INotiHubCustomer, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubCustomer> & INotiHubCustomer & Required<{
191
+ _id: string;
192
+ }> & {
193
+ __v?: number | undefined;
194
+ }, any>;
195
+
196
+ declare const CustomerMinified: mongoose.Model<INotiHubCustomerMinified, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubCustomerMinified> & INotiHubCustomerMinified & Required<{
197
+ _id: string;
198
+ }> & {
199
+ __v?: number | undefined;
200
+ }, any>;
201
+
202
+ declare const SubscriptionType: mongoose.Model<IUserSubscribeNotifier, {}, {}, {}, mongoose.Document<unknown, {}, IUserSubscribeNotifier> & IUserSubscribeNotifier & {
203
+ _id: mongoose.Types.ObjectId;
204
+ } & {
205
+ __v?: number | undefined;
206
+ }, any>;
207
+
208
+ export { type CreateNotiRequestBody, type CreateSubscriptionRequestBody, type CreateUserRequestBody, Customer, CustomerMinified, type ICreateCustomerRequestBody, type ICreateNotiRequestBody, type INotiHubCustomer, type INotiHubCustomerMinified, type INotiHubImage, type INotiHubNotification, type INotiHubNotificationStats, type INotiHubStats, type INotiHubStatsHistory, type INotiHubSubscription, type INotiHubUser, type INotiHubUserView, type INotiType, type INotiTypeStats, type IUserSubscribeNotifier, type IUserSubscription, NotiHubStatsHistory, type NotiHubTypes, NotiTypeModel, NotificationModel, NotificationStatsModel, Subscription, SubscriptionType, UserModel, addMonths, getDate, getDateFormat };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,208 @@
1
+ import * as mongoose from 'mongoose';
2
+ import mongoose__default from 'mongoose';
1
3
 
2
- export { }
4
+ type CreateNotiRequestBody = {
5
+ subscriptionId: string;
6
+ userId: string;
7
+ title: string;
8
+ message: string;
9
+ type: string;
10
+ };
11
+ type CreateSubscriptionRequestBody = {
12
+ subscriptionId: string;
13
+ type: string;
14
+ };
15
+ type CreateUserRequestBody = {
16
+ name: string;
17
+ email: string;
18
+ token: string;
19
+ };
20
+ type ICreateCustomerRequestBody = {
21
+ email: string;
22
+ username: string;
23
+ name: string;
24
+ };
25
+ type ICreateNotiRequestBody = {};
26
+ type INotiHubCustomerMinified = {
27
+ _id: string;
28
+ name: string;
29
+ img: INotiHubImage;
30
+ username: string;
31
+ createdAt: string;
32
+ updatedAt: string;
33
+ };
34
+ type INotiHubCustomer = {
35
+ _id: string;
36
+ name: string;
37
+ email: string;
38
+ minified: INotiHubCustomerMinified;
39
+ verified: boolean;
40
+ paid: boolean;
41
+ confirmed: boolean;
42
+ createdAt: string;
43
+ updatedAt: string;
44
+ };
45
+ type INotiHubNotification = {
46
+ _id?: string;
47
+ title: string;
48
+ message: string;
49
+ type: string;
50
+ entityId: string;
51
+ entityMinified: INotiHubCustomerMinified;
52
+ body: string;
53
+ createdAt: string;
54
+ updatedAt: string;
55
+ };
56
+ type INotiHubNotificationStats = {
57
+ _id?: string;
58
+ notification: INotiHubNotification;
59
+ views: number;
60
+ };
61
+ type INotiHubUser = {
62
+ _id?: string;
63
+ pushToken: string;
64
+ name: string;
65
+ email: string;
66
+ subscriptions: number;
67
+ events: number;
68
+ };
69
+ type INotiHubImage = {
70
+ bucket: string;
71
+ key: string;
72
+ };
73
+ type INotiHubStats = {
74
+ entityRef: string;
75
+ entity: INotiHubCustomer;
76
+ subscription: number;
77
+ notifications: number;
78
+ views: number;
79
+ };
80
+ type INotiHubStatsHistory = {
81
+ entityId: string;
82
+ type: "MONTH" | "YEAR";
83
+ subscription: number;
84
+ notifications: number;
85
+ views: number;
86
+ };
87
+ type INotiType = {
88
+ _id?: string;
89
+ type: string;
90
+ entity: string;
91
+ createdAt: string;
92
+ updatedAt: string;
93
+ };
94
+ type INotiTypeStats = {
95
+ _id?: string;
96
+ notiTypeId: string;
97
+ subscribed: number;
98
+ createdAt: string;
99
+ };
100
+ type IUserSubscription = {
101
+ user: INotiHubUser;
102
+ entity: INotiHubCustomer;
103
+ subscriptionId: string;
104
+ type: "SUBSCRIBED" | "UNSUBSCRIBED";
105
+ createdAt: string;
106
+ updatedAt: string;
107
+ };
108
+ type IUserSubscribeNotifier = {
109
+ userId: string;
110
+ entityId: string;
111
+ notiTypeId: string;
112
+ createdAt: string;
113
+ updatedAt: string;
114
+ };
115
+ type INotiHubUserView = {
116
+ userId: string;
117
+ entityId: string;
118
+ notificationId: string;
119
+ createdAt: string;
120
+ };
121
+ type INotiHubSubscription = {
122
+ _id?: string;
123
+ subscriptionId: string;
124
+ entity: INotiHubCustomer;
125
+ user: INotiHubUser;
126
+ type: "SUBSCRIBED" | "UNSUBSCRIBED";
127
+ createdAt: string;
128
+ updatedAt: string;
129
+ };
130
+ type NotiHubTypes = {
131
+ INotiHubUserView: INotiHubUserView;
132
+ IUserSubscribeNotifier: IUserSubscribeNotifier;
133
+ IUserSubscription: IUserSubscription;
134
+ INotiHubUser: INotiHubUser;
135
+ INotiTypeStats: INotiTypeStats;
136
+ INotiHubImage: INotiHubImage;
137
+ INotiHubSubscription: INotiHubSubscription;
138
+ INotiHubNotificationStats: INotiHubNotificationStats;
139
+ INotiHubNotification: INotiHubNotification;
140
+ INotiHubCustomer: INotiHubCustomer;
141
+ INotiHubCustomerMinified: INotiHubCustomerMinified;
142
+ INotiHubStatsHistory: INotiHubStatsHistory;
143
+ };
144
+
145
+ type AddMonths = {
146
+ date: Date;
147
+ months: number;
148
+ };
149
+
150
+ declare function getDate(dateStr: string): string;
151
+ declare function getDateFormat(dateStr: string): string;
152
+ declare function addMonths({ date, months }: AddMonths): Date;
153
+
154
+ declare const UserModel: mongoose.Model<INotiHubUser, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubUser> & INotiHubUser & Required<{
155
+ _id: string;
156
+ }> & {
157
+ __v?: number | undefined;
158
+ }, any>;
159
+
160
+ declare const Subscription: mongoose__default.Model<INotiHubSubscription, {}, {}, {}, mongoose__default.Document<unknown, {}, INotiHubSubscription> & INotiHubSubscription & Required<{
161
+ _id: string;
162
+ }> & {
163
+ __v?: number | undefined;
164
+ }, any>;
165
+
166
+ declare const NotiTypeModel: mongoose.Model<INotiType, {}, {}, {}, mongoose.Document<unknown, {}, INotiType> & INotiType & Required<{
167
+ _id: string;
168
+ }> & {
169
+ __v?: number | undefined;
170
+ }, any>;
171
+
172
+ declare const NotiHubStatsHistory: mongoose.Model<INotiHubStatsHistory, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubStatsHistory> & INotiHubStatsHistory & {
173
+ _id: mongoose.Types.ObjectId;
174
+ } & {
175
+ __v?: number | undefined;
176
+ }, any>;
177
+
178
+ declare const NotificationStatsModel: mongoose.Model<INotiHubNotificationStats, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubNotificationStats> & INotiHubNotificationStats & Required<{
179
+ _id: string;
180
+ }> & {
181
+ __v?: number | undefined;
182
+ }, any>;
183
+
184
+ declare const NotificationModel: mongoose.Model<INotiHubNotification, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubNotification> & INotiHubNotification & Required<{
185
+ _id: string;
186
+ }> & {
187
+ __v?: number | undefined;
188
+ }, any>;
189
+
190
+ declare const Customer: mongoose.Model<INotiHubCustomer, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubCustomer> & INotiHubCustomer & Required<{
191
+ _id: string;
192
+ }> & {
193
+ __v?: number | undefined;
194
+ }, any>;
195
+
196
+ declare const CustomerMinified: mongoose.Model<INotiHubCustomerMinified, {}, {}, {}, mongoose.Document<unknown, {}, INotiHubCustomerMinified> & INotiHubCustomerMinified & Required<{
197
+ _id: string;
198
+ }> & {
199
+ __v?: number | undefined;
200
+ }, any>;
201
+
202
+ declare const SubscriptionType: mongoose.Model<IUserSubscribeNotifier, {}, {}, {}, mongoose.Document<unknown, {}, IUserSubscribeNotifier> & IUserSubscribeNotifier & {
203
+ _id: mongoose.Types.ObjectId;
204
+ } & {
205
+ __v?: number | undefined;
206
+ }, any>;
207
+
208
+ export { type CreateNotiRequestBody, type CreateSubscriptionRequestBody, type CreateUserRequestBody, Customer, CustomerMinified, type ICreateCustomerRequestBody, type ICreateNotiRequestBody, type INotiHubCustomer, type INotiHubCustomerMinified, type INotiHubImage, type INotiHubNotification, type INotiHubNotificationStats, type INotiHubStats, type INotiHubStatsHistory, type INotiHubSubscription, type INotiHubUser, type INotiHubUserView, type INotiType, type INotiTypeStats, type IUserSubscribeNotifier, type IUserSubscription, NotiHubStatsHistory, type NotiHubTypes, NotiTypeModel, NotificationModel, NotificationStatsModel, Subscription, SubscriptionType, UserModel, addMonths, getDate, getDateFormat };
package/dist/index.js CHANGED
@@ -0,0 +1,281 @@
1
+ // src/util/index.ts
2
+ function getDate(dateStr) {
3
+ const date = new Date(dateStr);
4
+ const year = date.getFullYear();
5
+ const month = (date.getMonth() + 1).toString().padStart(2, "0");
6
+ const day = date.getDate().toString().padStart(2, "0");
7
+ const formattedDate = `${month}-${day}-${year}`;
8
+ return formattedDate;
9
+ }
10
+ function getDateFormat(dateStr) {
11
+ const date = new Date(dateStr);
12
+ const now = /* @__PURE__ */ new Date();
13
+ const seconds = Math.floor((now.getTime() - date.getTime()) / 1e3);
14
+ let interval = seconds / 31536e3;
15
+ if (interval > 1) {
16
+ return date.toLocaleDateString("en-US", {
17
+ year: "numeric",
18
+ month: "short",
19
+ day: "numeric"
20
+ });
21
+ }
22
+ interval = seconds / 2592e3;
23
+ if (interval > 1) {
24
+ return date.toLocaleDateString("en-US", {
25
+ year: "numeric",
26
+ month: "short",
27
+ day: "numeric"
28
+ });
29
+ }
30
+ interval = seconds / 86400;
31
+ if (interval > 7) {
32
+ return date.toLocaleDateString("en-US", {
33
+ year: "numeric",
34
+ month: "short",
35
+ day: "numeric"
36
+ });
37
+ } else if (interval > 1) {
38
+ return Math.floor(interval) + "d ago";
39
+ }
40
+ interval = seconds / 3600;
41
+ if (interval > 1) {
42
+ return Math.floor(interval) + "h ago";
43
+ }
44
+ interval = seconds / 60;
45
+ if (interval > 1) {
46
+ return Math.floor(interval) + "m ago";
47
+ }
48
+ return Math.floor(seconds) + "s ago";
49
+ }
50
+ function addMonths({ date, months }) {
51
+ date.setMonth(date.getMonth() + months);
52
+ return date;
53
+ }
54
+
55
+ // src/models/UserModel.ts
56
+ import { Schema as Schema2, model } from "mongoose";
57
+
58
+ // src/models/schemas/UserSchema.ts
59
+ import { Schema } from "mongoose";
60
+ var UserSchema = {
61
+ id: { type: Schema.Types.UUID, default: true },
62
+ name: { type: String, required: true },
63
+ email: { type: String, required: true },
64
+ pushToken: { type: String, required: true },
65
+ signedIn: { type: Boolean, required: true, default: false }
66
+ };
67
+ var UserSchema_default = UserSchema;
68
+
69
+ // src/models/UserModel.ts
70
+ var userSchema = new Schema2(UserSchema_default, { timestamps: true });
71
+ var UserModel = model("User", userSchema);
72
+ var UserModel_default = UserModel;
73
+
74
+ // src/models/SubscriptionModel.ts
75
+ import { Schema as Schema6, model as model3 } from "mongoose";
76
+
77
+ // src/models/schemas/SubscriptionSchema.ts
78
+ import { Schema as Schema5 } from "mongoose";
79
+
80
+ // src/models/schemas/CustomerSchema.ts
81
+ import { Schema as Schema4 } from "mongoose";
82
+
83
+ // src/models/schemas/CustomerMinifiedSchema.ts
84
+ import { Schema as Schema3 } from "mongoose";
85
+ var CustomerMinifiedSchema = {
86
+ id: { type: Schema3.Types.UUID, default: true },
87
+ username: { type: String, required: true },
88
+ img: {
89
+ bucket: { type: String, required: true },
90
+ key: { type: String, required: true }
91
+ },
92
+ name: { type: String, required: true }
93
+ };
94
+ var CustomerMinifiedSchema_default = CustomerMinifiedSchema;
95
+
96
+ // src/models/schemas/CustomerSchema.ts
97
+ var CustomerSchema = {
98
+ id: { type: Schema4.Types.UUID, default: true },
99
+ minified: CustomerMinifiedSchema_default,
100
+ paid: { type: Boolean, default: false },
101
+ email: { type: String, required: true },
102
+ verified: { type: Boolean, default: false },
103
+ confirmed: { type: Boolean, default: false }
104
+ };
105
+ var CustomerSchema_default = CustomerSchema;
106
+
107
+ // src/models/schemas/SubscriptionSchema.ts
108
+ var SubscriptionSchema = {
109
+ id: { type: Schema5.Types.UUID, default: true },
110
+ subscriptionId: { type: String, required: true },
111
+ user: UserSchema_default,
112
+ entity: CustomerSchema_default
113
+ };
114
+ var SubscriptionSchema_default = SubscriptionSchema;
115
+
116
+ // src/models/SubscriptionModel.ts
117
+ var subscriptionSchema = new Schema6(
118
+ SubscriptionSchema_default,
119
+ {
120
+ timestamps: true
121
+ }
122
+ );
123
+ var Subscription = model3(
124
+ "Subscriptions",
125
+ subscriptionSchema
126
+ );
127
+ var SubscriptionModel_default = Subscription;
128
+
129
+ // src/models/NotiTypeModel.ts
130
+ import { Schema as Schema8, model as model4 } from "mongoose";
131
+
132
+ // src/models/schemas/NotiTypeSchema.ts
133
+ import { Schema as Schema7 } from "mongoose";
134
+ var NotiTypeSchema = {
135
+ id: { type: Schema7.Types.UUID, default: true },
136
+ entity: CustomerSchema_default,
137
+ type: { type: String, required: true }
138
+ };
139
+ var NotiTypeSchema_default = NotiTypeSchema;
140
+
141
+ // src/models/NotiTypeModel.ts
142
+ var notiTypeSchema = new Schema8(NotiTypeSchema_default, {
143
+ timestamps: true
144
+ });
145
+ var NotiTypeModel = model4("NotiTypes", notiTypeSchema);
146
+ var NotiTypeModel_default = NotiTypeModel;
147
+
148
+ // src/models/NotiHubStatsHistoryModel.ts
149
+ import { Schema as Schema10, model as model5 } from "mongoose";
150
+
151
+ // src/models/schemas/NotificationStatsHistorySchema.ts
152
+ import { Schema as Schema9 } from "mongoose";
153
+ var NotihubStatsHistorySchema = {
154
+ id: { type: Schema9.Types.UUID, default: true },
155
+ entityId: { type: String, required: true },
156
+ notifications: { type: Number, required: true },
157
+ subscription: { type: Number, required: true },
158
+ views: { type: Number, required: true },
159
+ type: { type: String, required: true }
160
+ };
161
+ var NotificationStatsHistorySchema_default = NotihubStatsHistorySchema;
162
+
163
+ // src/models/NotiHubStatsHistoryModel.ts
164
+ var notihubStatsHistorySchema = new Schema10(
165
+ NotificationStatsHistorySchema_default,
166
+ {
167
+ timestamps: true
168
+ }
169
+ );
170
+ var NotiHubStatsHistory = model5(
171
+ "INotiHubStatsHistories",
172
+ notihubStatsHistorySchema
173
+ );
174
+ var NotiHubStatsHistoryModel_default = NotiHubStatsHistory;
175
+
176
+ // src/models/NotificationStatsModel.ts
177
+ import { Schema as Schema12, model as model6 } from "mongoose";
178
+
179
+ // src/models/schemas/NotificationSchema.ts
180
+ import { Schema as Schema11 } from "mongoose";
181
+ var NotificationSchema = {
182
+ id: { type: Schema11.Types.UUID, default: true },
183
+ title: { type: String, required: true },
184
+ message: { type: String, required: true },
185
+ type: { type: String, required: true },
186
+ body: { type: String },
187
+ entityId: { type: String, required: true },
188
+ entityMinified: CustomerMinifiedSchema_default
189
+ };
190
+ var NotificationSchema_default = NotificationSchema;
191
+
192
+ // src/models/NotificationStatsModel.ts
193
+ var notificationSchema = new Schema12(
194
+ {
195
+ notification: NotificationSchema_default,
196
+ views: { type: Number, default: 0 }
197
+ },
198
+ { timestamps: true }
199
+ );
200
+ var NotificationStatsModel = model6(
201
+ "NotificationStats",
202
+ notificationSchema
203
+ );
204
+ var NotificationStatsModel_default = NotificationStatsModel;
205
+
206
+ // src/models/NotificationModel.ts
207
+ import { Schema as Schema13, model as model7 } from "mongoose";
208
+ var notificationSchema2 = new Schema13(
209
+ {
210
+ title: { type: String, required: true },
211
+ message: { type: String, required: true },
212
+ type: { type: String, required: true },
213
+ body: { type: String },
214
+ entityId: { type: String, required: true },
215
+ entityMinified: CustomerSchema_default
216
+ },
217
+ { timestamps: true }
218
+ );
219
+ var NotificationModel = model7(
220
+ "Notification",
221
+ notificationSchema2
222
+ );
223
+ var NotificationModel_default = NotificationModel;
224
+
225
+ // src/models/CustomerModel.ts
226
+ import { Schema as Schema14, model as model8 } from "mongoose";
227
+ var customerSchema = new Schema14(CustomerSchema_default, {
228
+ timestamps: true
229
+ });
230
+ var Customer = model8("Customer", customerSchema);
231
+ var CustomerModel_default = Customer;
232
+
233
+ // src/models/CustomerMinifiedModel.ts
234
+ import { Schema as Schema15, model as model9 } from "mongoose";
235
+ var customerMinifiedSchema = new Schema15(
236
+ CustomerMinifiedSchema_default,
237
+ { timestamps: true }
238
+ );
239
+ var CustomerMinified = model9(
240
+ "CustomerMinified",
241
+ customerMinifiedSchema
242
+ );
243
+ var CustomerMinifiedModel_default = CustomerMinified;
244
+
245
+ // src/models/SubscriptionTypeModel.ts
246
+ import { Schema as Schema16, model as model10 } from "mongoose";
247
+
248
+ // src/models/schemas/SubscriptionTypeSchema.ts
249
+ var SubscriptionSchema2 = {
250
+ userId: { type: String, required: true },
251
+ entityId: { type: String, required: true },
252
+ notiTypeId: { type: String, required: true }
253
+ };
254
+ var SubscriptionTypeSchema_default = SubscriptionSchema2;
255
+
256
+ // src/models/SubscriptionTypeModel.ts
257
+ var subscriptionSchema2 = new Schema16(
258
+ SubscriptionTypeSchema_default,
259
+ {
260
+ timestamps: true
261
+ }
262
+ );
263
+ var SubscriptionType = model10(
264
+ "SubscriptionTypes",
265
+ subscriptionSchema2
266
+ );
267
+ var SubscriptionTypeModel_default = SubscriptionType;
268
+ export {
269
+ CustomerModel_default as Customer,
270
+ CustomerMinifiedModel_default as CustomerMinified,
271
+ NotiHubStatsHistoryModel_default as NotiHubStatsHistory,
272
+ NotiTypeModel_default as NotiTypeModel,
273
+ NotificationModel_default as NotificationModel,
274
+ NotificationStatsModel_default as NotificationStatsModel,
275
+ SubscriptionModel_default as Subscription,
276
+ SubscriptionTypeModel_default as SubscriptionType,
277
+ UserModel_default as UserModel,
278
+ addMonths,
279
+ getDate,
280
+ getDateFormat
281
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amohamud23/notihub",
3
- "version": "1.0.78",
3
+ "version": "1.0.79",
4
4
  "description": "Notihub Package",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",