@timardex/cluemart-server-shared 2.1.11 → 2.2.1
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/{chunk-HLRUWJLN.mjs → chunk-ZKHRT2PV.mjs} +16 -8
- package/dist/chunk-ZKHRT2PV.mjs.map +1 -0
- package/dist/index.cjs +36 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.mjs +36 -23
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +15 -7
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.mjs +1 -1
- package/dist/service/index.cjs +36 -23
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +6 -5
- package/dist/service/index.d.ts +6 -5
- package/dist/service/index.mjs +22 -17
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-HLRUWJLN.mjs.map +0 -1
package/dist/service/index.d.mts
CHANGED
|
@@ -127,9 +127,8 @@ declare function publishNotificationEvents(userId: ObjectId, pubsub: Notificatio
|
|
|
127
127
|
* is provided) publishes GraphQL subscription events for each affected user.
|
|
128
128
|
*
|
|
129
129
|
* Errors are logged and swallowed; this function never throws. Instead it
|
|
130
|
-
* returns `false` when notifications were not confirmed
|
|
131
|
-
*
|
|
132
|
-
* `userIds`), so callers can gate success logs/metrics on the result.
|
|
130
|
+
* returns `false` when notifications were not confirmed, so callers can gate
|
|
131
|
+
* success logs/metrics on the result.
|
|
133
132
|
*/
|
|
134
133
|
declare function notifyUsers({ payload, pubsub, }: {
|
|
135
134
|
payload: SchemaCreateBulkNotificationInput;
|
|
@@ -160,9 +159,11 @@ declare function isValidObjectId(value: string): boolean;
|
|
|
160
159
|
declare function convertObjectIdsToStrings(obj: any): any;
|
|
161
160
|
|
|
162
161
|
/**
|
|
163
|
-
* Updates the dateStatus field for a single DateTimeType object based on the current date/time
|
|
162
|
+
* Updates the dateStatus field for a single DateTimeType object based on the current date/time.
|
|
163
|
+
* Manual statuses (CANCELED, RE_SCHEDULED) are preserved and returned as-is.
|
|
164
164
|
* @param dateTime The date-time object to update
|
|
165
|
-
* @returns A new object with updated dateStatus value
|
|
165
|
+
* @returns A new object with an updated dateStatus value, or the original
|
|
166
|
+
* object when the stored status is a manual override
|
|
166
167
|
*/
|
|
167
168
|
declare function updateSingleDateTimeStatus<T extends DateTimeType>(dateTime: T, now?: dayjs.Dayjs): T;
|
|
168
169
|
/**
|
package/dist/service/index.d.ts
CHANGED
|
@@ -127,9 +127,8 @@ declare function publishNotificationEvents(userId: ObjectId, pubsub: Notificatio
|
|
|
127
127
|
* is provided) publishes GraphQL subscription events for each affected user.
|
|
128
128
|
*
|
|
129
129
|
* Errors are logged and swallowed; this function never throws. Instead it
|
|
130
|
-
* returns `false` when notifications were not confirmed
|
|
131
|
-
*
|
|
132
|
-
* `userIds`), so callers can gate success logs/metrics on the result.
|
|
130
|
+
* returns `false` when notifications were not confirmed, so callers can gate
|
|
131
|
+
* success logs/metrics on the result.
|
|
133
132
|
*/
|
|
134
133
|
declare function notifyUsers({ payload, pubsub, }: {
|
|
135
134
|
payload: SchemaCreateBulkNotificationInput;
|
|
@@ -160,9 +159,11 @@ declare function isValidObjectId(value: string): boolean;
|
|
|
160
159
|
declare function convertObjectIdsToStrings(obj: any): any;
|
|
161
160
|
|
|
162
161
|
/**
|
|
163
|
-
* Updates the dateStatus field for a single DateTimeType object based on the current date/time
|
|
162
|
+
* Updates the dateStatus field for a single DateTimeType object based on the current date/time.
|
|
163
|
+
* Manual statuses (CANCELED, RE_SCHEDULED) are preserved and returned as-is.
|
|
164
164
|
* @param dateTime The date-time object to update
|
|
165
|
-
* @returns A new object with updated dateStatus value
|
|
165
|
+
* @returns A new object with an updated dateStatus value, or the original
|
|
166
|
+
* object when the stored status is a manual override
|
|
166
167
|
*/
|
|
167
168
|
declare function updateSingleDateTimeStatus<T extends DateTimeType>(dateTime: T, now?: dayjs.Dayjs): T;
|
|
168
169
|
/**
|
package/dist/service/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
PushTokenModel,
|
|
11
11
|
UserModel,
|
|
12
12
|
VendorModel
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-ZKHRT2PV.mjs";
|
|
14
14
|
import "../chunk-6PNG5BI5.mjs";
|
|
15
15
|
|
|
16
16
|
// src/service/promoCode/constants.ts
|
|
@@ -39,25 +39,24 @@ import { createAffiliateReward } from "@timardex/cluemart-shared/utils";
|
|
|
39
39
|
// src/service/saveNotificationsInDb.ts
|
|
40
40
|
async function saveNotificationsInDb(payload) {
|
|
41
41
|
const { data, message, title, type, userIds } = payload;
|
|
42
|
-
|
|
42
|
+
const notifications = userIds.map((userId) => ({
|
|
43
|
+
data,
|
|
44
|
+
isRead: false,
|
|
45
|
+
message,
|
|
46
|
+
title,
|
|
47
|
+
type,
|
|
48
|
+
userId
|
|
49
|
+
}));
|
|
43
50
|
try {
|
|
44
|
-
const notifications = userIds.map((userId) => ({
|
|
45
|
-
data,
|
|
46
|
-
isRead: false,
|
|
47
|
-
message,
|
|
48
|
-
title,
|
|
49
|
-
type,
|
|
50
|
-
userId
|
|
51
|
-
}));
|
|
52
51
|
await NotificationModel.insertMany(notifications);
|
|
53
|
-
console.log(
|
|
54
|
-
`Created ${notifications.length} notifications for ${userIds.length} users`
|
|
55
|
-
);
|
|
56
|
-
return [...new Set(userIds)];
|
|
57
52
|
} catch (error) {
|
|
58
53
|
console.error("Failed to create notifications:", error);
|
|
59
|
-
|
|
54
|
+
throw error;
|
|
60
55
|
}
|
|
56
|
+
console.log(
|
|
57
|
+
`Created ${notifications.length} notifications for ${userIds.length} users`
|
|
58
|
+
);
|
|
59
|
+
return [...new Set(userIds)];
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
// src/service/sendPushNotifications.ts
|
|
@@ -81,7 +80,7 @@ function createPushMessages({
|
|
|
81
80
|
}
|
|
82
81
|
messages.push({
|
|
83
82
|
body: message,
|
|
84
|
-
data: { ...data },
|
|
83
|
+
...data ? { data: { ...data } } : {},
|
|
85
84
|
sound: "tui.wav",
|
|
86
85
|
title,
|
|
87
86
|
to: token
|
|
@@ -136,7 +135,6 @@ async function sendPushNotifications({
|
|
|
136
135
|
}) {
|
|
137
136
|
const pushTokens = await PushTokenModel.find({ userId: { $in: userIds } });
|
|
138
137
|
const expoTokens = pushTokens.map((token) => token.token);
|
|
139
|
-
if (!data) return;
|
|
140
138
|
const { messages, invalidTokens } = createPushMessages({
|
|
141
139
|
data,
|
|
142
140
|
message,
|
|
@@ -667,6 +665,10 @@ async function persistArchivedEventDates(eventId, slots) {
|
|
|
667
665
|
// src/service/event/updateAllEventDateTimeStatuses.ts
|
|
668
666
|
dayjs2.extend(customParseFormat);
|
|
669
667
|
dayjs2.extend(isoWeek);
|
|
668
|
+
var MANUAL_DATE_STATUSES = /* @__PURE__ */ new Set([
|
|
669
|
+
EnumEventDateStatus2.CANCELED,
|
|
670
|
+
EnumEventDateStatus2.RE_SCHEDULED
|
|
671
|
+
]);
|
|
670
672
|
function getFutureEventStatus(startDateTime, now) {
|
|
671
673
|
const hoursUntilStart = startDateTime.diff(now, "hour", true);
|
|
672
674
|
if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
|
|
@@ -687,6 +689,9 @@ function getFutureEventStatus(startDateTime, now) {
|
|
|
687
689
|
return EnumEventDateStatus2.UPCOMING;
|
|
688
690
|
}
|
|
689
691
|
function updateSingleDateTimeStatus(dateTime, now = dayjs2()) {
|
|
692
|
+
if (MANUAL_DATE_STATUSES.has(dateTime.dateStatus)) {
|
|
693
|
+
return dateTime;
|
|
694
|
+
}
|
|
690
695
|
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
|
|
691
696
|
const startDateTime = dayjs2(
|
|
692
697
|
`${dateTime.startDate} ${dateTime.startTime}`,
|