@timardex/cluemart-server-shared 1.0.280 → 1.0.284

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.
@@ -1,11 +1,89 @@
1
- import { f as SchemaCreateBulkNotificationInput, O as ObjectId } from '../Chat-DYkhie3G.mjs';
2
- import { EnumUserLicence, DateTimeType, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
1
+ import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
2
+ import { EnumAffiliateRewardType, AffiliateRewardType, PromoCodeType, EnumUserLicence, DateTimeType, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
3
+ import * as mongoose from 'mongoose';
4
+ import { o as SchemaAffiliateResourceType, S as SchemaOwnerType, j as SchemaRelationType } from '../Affiliate-CmS0A1gU.mjs';
5
+ import { f as SchemaCreateBulkNotificationInput, O as ObjectId } from '../Chat-Bnqec74U.mjs';
3
6
  import dayjs from 'dayjs';
4
7
  import { DateTimeType as DateTimeType$1 } from '@timardex/cluemart-shared/types';
5
- import { S as SchemaRelationType } from '../Relation-BjYghDE9.mjs';
6
- import 'mongoose';
7
8
  import 'express';
8
9
 
10
+ /**
11
+ * Checks whether an affiliate code is already taken by an active, non-deleted affiliate.
12
+ *
13
+ * Used when generating new affiliate codes so collisions are avoided before insert.
14
+ * Matches the partial unique index on `affiliateCode` for active documents.
15
+ *
16
+ * @param affiliateCode - Candidate affiliate promo code to check.
17
+ * @returns `true` when an active, non-deleted affiliate already uses this code.
18
+ */
19
+ declare function activeAffiliateCodeExists(affiliateCode: string): Promise<boolean>;
20
+
21
+ declare const AFFILIATE_REWARDS: {
22
+ NEW_EVENT_REGISTRATION: {
23
+ description: string;
24
+ value: number;
25
+ };
26
+ NEW_VENDOR_REGISTRATION: {
27
+ description: string;
28
+ value: number;
29
+ };
30
+ ACTIVE_VENDOR_PRO_SUBSCRIPTION: {
31
+ description: string;
32
+ value: number;
33
+ };
34
+ ACTIVE_VENDOR_STANDARD_SUBSCRIPTION: {
35
+ description: string;
36
+ value: number;
37
+ };
38
+ ACTIVE_VENDOR_BONUS_REWARD: {
39
+ description: string;
40
+ value: number;
41
+ };
42
+ ACTIVE_EVENT_WITH_VENDOR_REGISTRATIONS: {
43
+ description: string;
44
+ value: number;
45
+ };
46
+ };
47
+ /**
48
+ * Create an affiliate reward
49
+ * @param rewardType - The type of reward
50
+ * @param createdAt - The date the reward was received
51
+ * @returns The affiliate reward
52
+ * @example
53
+ * const reward = createAffiliateReward(EnumAffiliateRewardType.NEW_EVENT_REGISTRATION, new Date());
54
+ * console.log(reward);
55
+ */
56
+ declare function createAffiliateReward(rewardType: EnumAffiliateRewardType, createdAt: Date): AffiliateRewardType;
57
+
58
+ /**
59
+ * Loads the affiliate whose `affiliateCode` matches the given promo code.
60
+ *
61
+ * Includes inactive affiliates (`active: false`) so resource referrals work before
62
+ * admin approval. Soft-deleted affiliates (`deletedAt` set) are excluded.
63
+ *
64
+ * @param promoCode - Normalized affiliate promo code to resolve.
65
+ * @returns The matching affiliate document, or `null` when not found.
66
+ */
67
+ declare function findAffiliateByPromoCode(promoCode: PromoCodeType): Promise<(mongoose.Document<unknown, {}, Omit<_timardex_cluemart_shared.AffiliateType, "_id" | "owner" | "affiliateResources"> & {
68
+ affiliateResources: SchemaAffiliateResourceType[];
69
+ owner: SchemaOwnerType;
70
+ }, {}, {}> & Omit<_timardex_cluemart_shared.AffiliateType, "_id" | "owner" | "affiliateResources"> & {
71
+ affiliateResources: SchemaAffiliateResourceType[];
72
+ owner: SchemaOwnerType;
73
+ } & {
74
+ _id: mongoose.Types.ObjectId;
75
+ } & {
76
+ __v: number;
77
+ }) | null>;
78
+
79
+ /**
80
+ * Normalizes, trims, uppercases, and deduplicates resource promo codes.
81
+ *
82
+ * @param promoCodes - Raw promo codes from a create-resource mutation input.
83
+ * @returns Unique normalized codes; empty strings and whitespace-only values are removed.
84
+ */
85
+ declare function normalizeAffiliatePromoCodes(promoCodes: PromoCodeType[] | null | undefined): PromoCodeType[];
86
+
9
87
  /**
10
88
  * Connect to MongoDB using Mongoose.
11
89
  * Supports both local MongoDB (via MONGODB_URI) and MongoDB Atlas (via individual env vars).
@@ -18,6 +96,14 @@ declare const connectToDatabase: ({ appName, dbName, dbPassword, dbUser, mongodb
18
96
  mongodbUri: string;
19
97
  }) => Promise<void>;
20
98
 
99
+ /** Matches partial unique indexes for promo/affiliate codes on active documents. */
100
+ declare const ACTIVE_NOT_DELETED_FILTER: {
101
+ readonly active: true;
102
+ readonly deletedAt: null;
103
+ };
104
+
105
+ declare function normalizePromoCode(decoratedPromoCode: string | null | undefined): string | null;
106
+
21
107
  /**
22
108
  * Create notifications in the database for multiple users
23
109
  * This is typically called when sending push notifications
@@ -73,4 +159,4 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
73
159
  */
74
160
  declare function updateRelationDatesToUnavailable(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
75
161
 
76
- export { connectToDatabase, convertObjectIdsToStrings, didRemoveAnyEventDates, findEventOrImportedMarketById, saveNotificationsInDb, sendPushNotifications, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense };
162
+ export { ACTIVE_NOT_DELETED_FILTER, AFFILIATE_REWARDS, activeAffiliateCodeExists, connectToDatabase, convertObjectIdsToStrings, createAffiliateReward, didRemoveAnyEventDates, findAffiliateByPromoCode, findEventOrImportedMarketById, normalizeAffiliatePromoCodes, normalizePromoCode, saveNotificationsInDb, sendPushNotifications, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense };
@@ -1,11 +1,89 @@
1
- import { f as SchemaCreateBulkNotificationInput, O as ObjectId } from '../Chat-DYkhie3G.js';
2
- import { EnumUserLicence, DateTimeType, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
1
+ import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
2
+ import { EnumAffiliateRewardType, AffiliateRewardType, PromoCodeType, EnumUserLicence, DateTimeType, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
3
+ import * as mongoose from 'mongoose';
4
+ import { o as SchemaAffiliateResourceType, S as SchemaOwnerType, j as SchemaRelationType } from '../Affiliate-C_g6TdeG.js';
5
+ import { f as SchemaCreateBulkNotificationInput, O as ObjectId } from '../Chat-Bnqec74U.js';
3
6
  import dayjs from 'dayjs';
4
7
  import { DateTimeType as DateTimeType$1 } from '@timardex/cluemart-shared/types';
5
- import { S as SchemaRelationType } from '../Relation-6t3Gn4pM.js';
6
- import 'mongoose';
7
8
  import 'express';
8
9
 
10
+ /**
11
+ * Checks whether an affiliate code is already taken by an active, non-deleted affiliate.
12
+ *
13
+ * Used when generating new affiliate codes so collisions are avoided before insert.
14
+ * Matches the partial unique index on `affiliateCode` for active documents.
15
+ *
16
+ * @param affiliateCode - Candidate affiliate promo code to check.
17
+ * @returns `true` when an active, non-deleted affiliate already uses this code.
18
+ */
19
+ declare function activeAffiliateCodeExists(affiliateCode: string): Promise<boolean>;
20
+
21
+ declare const AFFILIATE_REWARDS: {
22
+ NEW_EVENT_REGISTRATION: {
23
+ description: string;
24
+ value: number;
25
+ };
26
+ NEW_VENDOR_REGISTRATION: {
27
+ description: string;
28
+ value: number;
29
+ };
30
+ ACTIVE_VENDOR_PRO_SUBSCRIPTION: {
31
+ description: string;
32
+ value: number;
33
+ };
34
+ ACTIVE_VENDOR_STANDARD_SUBSCRIPTION: {
35
+ description: string;
36
+ value: number;
37
+ };
38
+ ACTIVE_VENDOR_BONUS_REWARD: {
39
+ description: string;
40
+ value: number;
41
+ };
42
+ ACTIVE_EVENT_WITH_VENDOR_REGISTRATIONS: {
43
+ description: string;
44
+ value: number;
45
+ };
46
+ };
47
+ /**
48
+ * Create an affiliate reward
49
+ * @param rewardType - The type of reward
50
+ * @param createdAt - The date the reward was received
51
+ * @returns The affiliate reward
52
+ * @example
53
+ * const reward = createAffiliateReward(EnumAffiliateRewardType.NEW_EVENT_REGISTRATION, new Date());
54
+ * console.log(reward);
55
+ */
56
+ declare function createAffiliateReward(rewardType: EnumAffiliateRewardType, createdAt: Date): AffiliateRewardType;
57
+
58
+ /**
59
+ * Loads the affiliate whose `affiliateCode` matches the given promo code.
60
+ *
61
+ * Includes inactive affiliates (`active: false`) so resource referrals work before
62
+ * admin approval. Soft-deleted affiliates (`deletedAt` set) are excluded.
63
+ *
64
+ * @param promoCode - Normalized affiliate promo code to resolve.
65
+ * @returns The matching affiliate document, or `null` when not found.
66
+ */
67
+ declare function findAffiliateByPromoCode(promoCode: PromoCodeType): Promise<(mongoose.Document<unknown, {}, Omit<_timardex_cluemart_shared.AffiliateType, "_id" | "owner" | "affiliateResources"> & {
68
+ affiliateResources: SchemaAffiliateResourceType[];
69
+ owner: SchemaOwnerType;
70
+ }, {}, {}> & Omit<_timardex_cluemart_shared.AffiliateType, "_id" | "owner" | "affiliateResources"> & {
71
+ affiliateResources: SchemaAffiliateResourceType[];
72
+ owner: SchemaOwnerType;
73
+ } & {
74
+ _id: mongoose.Types.ObjectId;
75
+ } & {
76
+ __v: number;
77
+ }) | null>;
78
+
79
+ /**
80
+ * Normalizes, trims, uppercases, and deduplicates resource promo codes.
81
+ *
82
+ * @param promoCodes - Raw promo codes from a create-resource mutation input.
83
+ * @returns Unique normalized codes; empty strings and whitespace-only values are removed.
84
+ */
85
+ declare function normalizeAffiliatePromoCodes(promoCodes: PromoCodeType[] | null | undefined): PromoCodeType[];
86
+
9
87
  /**
10
88
  * Connect to MongoDB using Mongoose.
11
89
  * Supports both local MongoDB (via MONGODB_URI) and MongoDB Atlas (via individual env vars).
@@ -18,6 +96,14 @@ declare const connectToDatabase: ({ appName, dbName, dbPassword, dbUser, mongodb
18
96
  mongodbUri: string;
19
97
  }) => Promise<void>;
20
98
 
99
+ /** Matches partial unique indexes for promo/affiliate codes on active documents. */
100
+ declare const ACTIVE_NOT_DELETED_FILTER: {
101
+ readonly active: true;
102
+ readonly deletedAt: null;
103
+ };
104
+
105
+ declare function normalizePromoCode(decoratedPromoCode: string | null | undefined): string | null;
106
+
21
107
  /**
22
108
  * Create notifications in the database for multiple users
23
109
  * This is typically called when sending push notifications
@@ -73,4 +159,4 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
73
159
  */
74
160
  declare function updateRelationDatesToUnavailable(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
75
161
 
76
- export { connectToDatabase, convertObjectIdsToStrings, didRemoveAnyEventDates, findEventOrImportedMarketById, saveNotificationsInDb, sendPushNotifications, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense };
162
+ export { ACTIVE_NOT_DELETED_FILTER, AFFILIATE_REWARDS, activeAffiliateCodeExists, connectToDatabase, convertObjectIdsToStrings, createAffiliateReward, didRemoveAnyEventDates, findAffiliateByPromoCode, findEventOrImportedMarketById, normalizeAffiliatePromoCodes, normalizePromoCode, saveNotificationsInDb, sendPushNotifications, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense };
@@ -1,7 +1,9 @@
1
1
  import {
2
2
  AdModel,
3
+ AffiliateModel,
3
4
  ChatModel,
4
5
  EnumAdStatus,
6
+ EnumAffiliateRewardType,
5
7
  EnumChatType,
6
8
  EnumEventDateStatus,
7
9
  EnumInviteStatus,
@@ -15,7 +17,80 @@ import {
15
17
  VendorModel,
16
18
  dateFormat,
17
19
  timeFormat
18
- } from "../chunk-EH7TOKEH.mjs";
20
+ } from "../chunk-4FWW5CDC.mjs";
21
+
22
+ // src/service/promoCode/constants.ts
23
+ var ACTIVE_NOT_DELETED_FILTER = {
24
+ active: true,
25
+ deletedAt: null
26
+ };
27
+
28
+ // src/service/affiliate/activeAffiliateCodeExists.ts
29
+ async function activeAffiliateCodeExists(affiliateCode) {
30
+ const existing = await AffiliateModel.exists({
31
+ ...ACTIVE_NOT_DELETED_FILTER,
32
+ affiliateCode
33
+ }).exec();
34
+ return existing !== null;
35
+ }
36
+
37
+ // src/service/affiliate/createAffiliateReward.ts
38
+ var AFFILIATE_REWARDS = {
39
+ [EnumAffiliateRewardType.NEW_EVENT_REGISTRATION]: {
40
+ description: "10 points for new event registration (one-time reward)",
41
+ value: 10
42
+ },
43
+ [EnumAffiliateRewardType.NEW_VENDOR_REGISTRATION]: {
44
+ description: "5 points for new vendor registration (one-time reward)",
45
+ value: 5
46
+ },
47
+ [EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION]: {
48
+ description: "3 points for active vendor pro subscription (monthly reward)",
49
+ value: 3
50
+ },
51
+ [EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION]: {
52
+ description: "1 point for active vendor standard subscription (monthly reward)",
53
+ value: 1
54
+ },
55
+ [EnumAffiliateRewardType.ACTIVE_VENDOR_BONUS_REWARD]: {
56
+ description: "5 bonus points for every 10th active vendor (one-time reward)",
57
+ value: 5
58
+ },
59
+ [EnumAffiliateRewardType.ACTIVE_EVENT_WITH_VENDOR_REGISTRATIONS]: {
60
+ description: "50 points for active event with vendor registrations (one-time reward)",
61
+ value: 50
62
+ }
63
+ };
64
+ function createAffiliateReward(rewardType, createdAt) {
65
+ const reward = AFFILIATE_REWARDS[rewardType];
66
+ return {
67
+ createdAt,
68
+ redeemedAt: null,
69
+ rewardDescription: reward.description,
70
+ rewardType,
71
+ rewardValue: reward.value
72
+ };
73
+ }
74
+
75
+ // src/service/affiliate/findAffiliateByPromoCode.ts
76
+ async function findAffiliateByPromoCode(promoCode) {
77
+ return AffiliateModel.findOne({
78
+ affiliateCode: promoCode,
79
+ deletedAt: null
80
+ }).exec();
81
+ }
82
+
83
+ // src/service/promoCode/normalizePromoCode.ts
84
+ function normalizePromoCode(decoratedPromoCode) {
85
+ const normalized = decoratedPromoCode?.trim().toUpperCase();
86
+ return normalized || null;
87
+ }
88
+
89
+ // src/service/affiliate/normalizeAffiliatePromoCodes.ts
90
+ function normalizeAffiliatePromoCodes(promoCodes) {
91
+ const normalized = (promoCodes ?? []).map((code) => normalizePromoCode(code)).filter((code) => code !== null);
92
+ return [...new Set(normalized)];
93
+ }
19
94
 
20
95
  // src/service/database.ts
21
96
  import mongoose from "mongoose";
@@ -552,10 +627,17 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
552
627
  });
553
628
  }
554
629
  export {
630
+ ACTIVE_NOT_DELETED_FILTER,
631
+ AFFILIATE_REWARDS,
632
+ activeAffiliateCodeExists,
555
633
  connectToDatabase,
556
634
  convertObjectIdsToStrings,
635
+ createAffiliateReward,
557
636
  didRemoveAnyEventDates,
637
+ findAffiliateByPromoCode,
558
638
  findEventOrImportedMarketById,
639
+ normalizeAffiliatePromoCodes,
640
+ normalizePromoCode,
559
641
  saveNotificationsInDb,
560
642
  sendPushNotifications,
561
643
  updateAdStatuses,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/service/database.ts","../../src/service/saveNotificationsInDb.ts","../../src/service/sendPushNotifications.ts","../../src/service/updateAdStatus.ts","../../src/service/associate.ts","../../src/service/vendor.ts","../../src/service/objectIdToString.ts","../../src/service/event/updateAllEventDateTimeStatuses.ts","../../src/service/event/findEventOrImportedMarketById.ts","../../src/service/relations.ts"],"sourcesContent":["import mongoose from \"mongoose\";\n\n/**\n * Connect to MongoDB using Mongoose.\n * Supports both local MongoDB (via MONGODB_URI) and MongoDB Atlas (via individual env vars).\n */\nexport const connectToDatabase = async ({\n appName,\n dbName,\n dbPassword,\n dbUser,\n mongodbUri,\n}: {\n appName: string;\n dbName: string;\n dbPassword: string;\n dbUser: string;\n mongodbUri: string;\n}) => {\n try {\n // Check if MONGODB_URI is provided (for local Docker MongoDB)\n const mongoUri = mongodbUri\n ? mongodbUri\n : // Fallback to MongoDB Atlas connection string\n `mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`;\n\n await mongoose.connect(mongoUri);\n\n const connectionType = mongodbUri ? \"Local MongoDB\" : \"MongoDB Atlas\";\n console.log(\n `${connectionType} connected from server/src/service/database.ts`,\n );\n } catch (err) {\n console.error(\"Error connecting to MongoDB:\", err);\n throw err; // You can throw the error if you want to stop the server in case of connection failure\n }\n};\n","import {\n SchemaCreateBulkNotificationInput,\n NotificationModel,\n} from \"src/mongoose/Notification\";\nimport { ObjectId } from \"src/types\";\n\n/**\n * Create notifications in the database for multiple users\n * This is typically called when sending push notifications\n */\nexport async function saveNotificationsInDb(\n payload: SchemaCreateBulkNotificationInput,\n): Promise<ObjectId[]> {\n const { data, message, title, type, userIds } = payload;\n console.log('NOTIFICATION DATA', JSON.stringify(payload, null, 2));\n try {\n const notifications = userIds.map((userId) => ({\n data,\n isRead: false,\n message,\n title,\n type,\n userId,\n }));\n\n // Save notifications to database\n await NotificationModel.insertMany(notifications);\n console.log(\n `Created ${notifications.length} notifications for ${userIds.length} users`,\n );\n\n return [...new Set(userIds)];\n } catch (error) {\n console.error(\"Failed to create notifications:\", error);\n return [];\n //throw new Error(`Failed to create notifications: ${error}`);\n }\n}\n","import { NotificationDataType } from \"@timardex/cluemart-shared\";\nimport { Expo, ExpoPushMessage, ExpoPushTicket } from \"expo-server-sdk\";\n\nimport { SchemaCreateBulkNotificationInput } from \"src/mongoose/Notification\";\nimport { PushTokenModel } from \"src/mongoose/PushToken\";\n\nconst expo = new Expo();\n\n/**\n * Safely extract tokens from ExpoPushMessage handling both string and array cases\n */\nfunction extractTokensFromMessage(message: ExpoPushMessage): string[] {\n return Array.isArray(message.to) ? message.to : [message.to];\n}\n\ninterface CreatePushMessagesOptions {\n tokens: string[];\n message: string;\n title: string;\n data: NotificationDataType;\n}\n\n/**\n * Create push messages from valid tokens\n */\nfunction createPushMessages({\n tokens,\n message,\n title,\n data,\n}: CreatePushMessagesOptions): {\n messages: ExpoPushMessage[];\n invalidTokens: string[];\n} {\n const messages: ExpoPushMessage[] = [];\n const invalidTokens: string[] = [];\n\n for (const token of tokens) {\n if (!Expo.isExpoPushToken(token)) {\n invalidTokens.push(token);\n continue;\n }\n\n messages.push({\n body: message,\n data: { ...data },\n sound: \"tui.wav\",\n title,\n to: token,\n });\n }\n\n return { invalidTokens, messages };\n}\n\n/**\n * Process chunk results and extract failed tokens\n */\nfunction processChunkResults(\n tickets: ExpoPushTicket[],\n chunk: ExpoPushMessage[],\n): { successCount: number; failedTokens: string[] } {\n let successCount = 0;\n const failedTokens: string[] = [];\n\n for (const [ticketIndex, ticket] of tickets.entries()) {\n if (ticket.status === \"error\") {\n const message = chunk[ticketIndex];\n if (message) {\n const tokens = extractTokensFromMessage(message);\n if (ticket.details?.error === \"DeviceNotRegistered\") {\n failedTokens.push(...tokens);\n }\n console.log(\"Push notification error\", {\n error: ticket.details?.error,\n tokens,\n });\n }\n } else {\n successCount++;\n }\n }\n\n return { failedTokens, successCount };\n}\n\n/**\n * Send a single chunk of push notifications\n */\nasync function sendChunk(\n chunk: ExpoPushMessage[],\n chunkIndex: number,\n): Promise<{ successCount: number; failedTokens: string[] }> {\n try {\n const tickets = await expo.sendPushNotificationsAsync(chunk);\n const { successCount, failedTokens } = processChunkResults(tickets, chunk);\n\n console.log(\n `Chunk ${chunkIndex + 1}: Sent ${successCount}/${chunk.length} notifications successfully`,\n );\n\n return { failedTokens, successCount };\n } catch (error) {\n console.log(\"Error sending Expo push notification chunk\", {\n chunkIndex,\n chunkSize: chunk.length,\n error: error instanceof Error ? error.message : String(error),\n });\n return { failedTokens: [], successCount: 0 };\n }\n}\n\nexport async function sendPushNotifications({\n data,\n message,\n title,\n userIds,\n}: SchemaCreateBulkNotificationInput) {\n const pushTokens = await PushTokenModel.find({ userId: { $in: userIds } });\n const expoTokens = pushTokens.map((token) => token.token);\n\n if (!data) return;\n\n const { messages, invalidTokens } = createPushMessages({\n data,\n message,\n title,\n tokens: expoTokens,\n });\n\n // Log invalid tokens\n if (invalidTokens.length > 0) {\n console.log(`Found ${invalidTokens.length} invalid push tokens`);\n }\n\n if (messages.length === 0) {\n console.log(\"No valid messages to send after filtering tokens\");\n return;\n }\n\n // Send notifications in chunks\n const chunks = expo.chunkPushNotifications(messages);\n let totalSuccessCount = 0;\n const allFailedTokens: string[] = [];\n\n for (const [chunkIndex, chunk] of chunks.entries()) {\n const { successCount, failedTokens } = await sendChunk(\n chunk,\n chunkIndex + 1,\n );\n totalSuccessCount += successCount;\n allFailedTokens.push(...failedTokens);\n }\n\n // Log final results\n console.log(\n `Sent push notification to ${totalSuccessCount}/${messages.length} tokens across ${chunks.length} chunks`,\n );\n\n if (allFailedTokens.length > 0) {\n console.log(`Found ${allFailedTokens.length} failed push tokens`);\n }\n}\n","import { EnumAdStatus } from \"@timardex/cluemart-shared\";\n\nimport { AdModel } from \"src/mongoose\";\n\n/**\n * Updates ad statuses based on start/end dates and validity\n */\nexport async function updateAdStatuses(): Promise<void> {\n const now = new Date();\n\n // invalid\n const invalidResult = await AdModel.updateMany(\n {\n $or: [\n { start: { $exists: false } },\n { end: { $exists: false } },\n { $expr: { $gt: [\"$start\", \"$end\"] } },\n ],\n status: { $ne: EnumAdStatus.PAUSED },\n },\n { $set: { status: EnumAdStatus.PAUSED } },\n );\n\n // expired\n const expiredResult = await AdModel.updateMany(\n { end: { $lte: now }, status: { $ne: EnumAdStatus.EXPIRED } },\n { $set: { status: EnumAdStatus.EXPIRED } },\n );\n\n // active\n const activeResult = await AdModel.updateMany(\n {\n end: { $gt: now },\n start: { $lte: now },\n status: { $ne: EnumAdStatus.ACTIVE },\n },\n { $set: { status: EnumAdStatus.ACTIVE } },\n );\n\n // paused\n const pausedResult = await AdModel.updateMany(\n { start: { $gt: now }, status: { $ne: EnumAdStatus.PAUSED } },\n { $set: { status: EnumAdStatus.PAUSED } },\n );\n\n console.log(\n `✅ Ad statuses updated: invalid=${invalidResult.modifiedCount}, expired=${expiredResult.modifiedCount}, active=${activeResult.modifiedCount}, paused=${pausedResult.modifiedCount}`,\n );\n}\n","import { EnumChatType, EnumResourceType } from \"@timardex/cluemart-shared\";\nimport mongoose from \"mongoose\";\n\nimport { ChatModel, UserModel } from \"src/mongoose\";\nimport { ObjectId } from \"src/types\";\n\ninterface RemoveAssociateFromResourceParams {\n resourceId: string | ObjectId;\n resourceOwnerId: string | ObjectId;\n resourceType: EnumResourceType;\n}\n\ninterface ResourceAssociateScope {\n normalizedResourceId: string;\n resourceType: EnumResourceType;\n}\n\nfunction normalizeObjectId(id: string | ObjectId): ObjectId {\n return typeof id === \"string\" ? new mongoose.Types.ObjectId(id) : id;\n}\n\nasync function getAssociateEmailsForResource({\n normalizedResourceId,\n resourceType,\n}: ResourceAssociateScope): Promise<string[]> {\n const usersWithAssociates = await UserModel.find(\n {\n associates: {\n $elemMatch: {\n resourceId: normalizedResourceId,\n resourceType,\n },\n },\n },\n {\n associates: 1,\n },\n ).lean();\n\n return [\n ...new Set(\n usersWithAssociates.flatMap((user) =>\n (user.associates ?? [])\n .filter(\n (associate) =>\n associate.resourceId === normalizedResourceId &&\n associate.resourceType === resourceType,\n )\n .map((associate) => associate.email),\n ),\n ),\n ];\n}\n\nasync function pullAssociatesFromUsers({\n normalizedResourceId,\n resourceType,\n}: ResourceAssociateScope): Promise<void> {\n await UserModel.updateMany(\n {\n associates: {\n $elemMatch: {\n resourceId: normalizedResourceId,\n resourceType,\n },\n },\n },\n {\n $pull: {\n associates: {\n resourceId: normalizedResourceId,\n resourceType,\n },\n },\n },\n );\n}\n\nasync function pullAssociateParticipantsFromChats(\n resourceOwnerId: ObjectId,\n associateEmails: string[],\n): Promise<void> {\n await ChatModel.updateMany(\n {\n active: true,\n chatType: EnumChatType.RELATION,\n deletedAt: null,\n participants: {\n $elemMatch: {\n userId: resourceOwnerId,\n },\n },\n },\n {\n $pull: {\n participants: {\n isAssociate: true,\n userEmail: {\n $in: associateEmails,\n },\n },\n },\n },\n );\n}\n\n/**\n * Removes all associates linked to a resource\n * and removes related associate chat participants.\n */\nexport async function removeAssociateFromResource({\n resourceId,\n resourceOwnerId,\n resourceType,\n}: RemoveAssociateFromResourceParams): Promise<void> {\n try {\n const scope: ResourceAssociateScope = {\n normalizedResourceId: resourceId.toString(),\n resourceType,\n };\n\n const associateEmails = await getAssociateEmailsForResource(scope);\n\n if (associateEmails.length === 0) {\n return;\n }\n\n await pullAssociatesFromUsers(scope);\n await pullAssociateParticipantsFromChats(\n normalizeObjectId(resourceOwnerId),\n associateEmails,\n );\n } catch (error) {\n console.error(\n `[removeAssociateFromResource] Failed for resourceId=${resourceId}, resourceType=${resourceType}`,\n error,\n );\n }\n}\n","import { EnumResourceType, EnumUserLicence } from \"@timardex/cluemart-shared\";\n\nimport { UserModel, VendorModel, SchemaVendorType } from \"src/mongoose\";\nimport { ObjectId } from \"src/types\";\n\nimport { removeAssociateFromResource } from \"./associate\";\n\nexport async function updateVendorBasedOnUserLicense(\n userId: ObjectId,\n licenceType: EnumUserLicence,\n): Promise<void> {\n try {\n /**\n * Fetch user vendor reference\n */\n const user = await UserModel.findById(userId)\n .select(\"vendor\")\n .lean()\n .exec();\n\n if (!user?.vendor) {\n console.warn(`[updateVendor] No vendor found for userId=${userId}`);\n return;\n }\n\n /**\n * Fetch vendor\n */\n const vendor = await VendorModel.findById(user.vendor)\n .lean<SchemaVendorType>()\n .exec();\n\n if (!vendor) {\n console.warn(`[updateVendor] Vendor not found for id=${user.vendor}`);\n return;\n }\n\n /**\n * Build vendor update payload\n */\n const updateData: Partial<SchemaVendorType> = {};\n\n const isStandardVendor = licenceType === EnumUserLicence.STANDARD_VENDOR;\n\n if (isStandardVendor) {\n updateData.associates = [];\n\n updateData.availability = {\n corporate: false,\n private: false,\n school: false,\n };\n\n updateData.products = {\n active: false,\n productsList: vendor.products?.productsList ?? [],\n };\n\n updateData.calendar = {\n active: false,\n calendarData: vendor.calendar?.calendarData ?? [],\n };\n }\n\n /**\n * Image rules\n * STANDARD_VENDOR => only first 6 active, 6 is the default image limit for standard vendors\n * PRO_VENDOR => all active\n */\n updateData.images = (vendor.images ?? []).map((image, index) => ({\n ...image,\n active: isStandardVendor ? index < 6 : true,\n }));\n\n /**\n * Persist vendor updates\n */\n await VendorModel.updateOne({ _id: vendor._id }, { $set: updateData });\n\n /**\n * Cleanup associates for STANDARD licence\n */\n if (isStandardVendor) {\n await removeAssociateFromResource({\n resourceId: vendor._id,\n resourceOwnerId: vendor.owner.userId,\n resourceType: EnumResourceType.VENDOR,\n });\n }\n } catch (error) {\n console.error(\"[updateVendorBasedOnUserLicense] Failed:\", error);\n }\n}\n","import mongoose from \"mongoose\";\n\n/**\n * Recursively converts all ObjectId fields to strings in an object\n * This is needed because GraphQL expects string IDs, not ObjectIds\n */\nexport function convertObjectIdsToStrings(obj: any): any {\n if (obj === null || obj === undefined) {\n return obj;\n }\n\n if (obj instanceof mongoose.Types.ObjectId) {\n return obj.toString();\n }\n\n if (obj instanceof Date) {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(convertObjectIdsToStrings);\n }\n\n if (typeof obj === \"object\") {\n const converted: any = {};\n for (const [key, value] of Object.entries(obj)) {\n converted[key] = convertObjectIdsToStrings(value);\n }\n return converted;\n }\n\n return obj;\n}\n","import {\n dateFormat,\n DateTimeType,\n EnumEventDateStatus,\n timeFormat,\n} from \"@timardex/cluemart-shared\";\nimport dayjs from \"dayjs\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat\";\nimport isoWeek from \"dayjs/plugin/isoWeek\";\n\nimport { EventModel, GoogleImportedMarketModel } from \"src/mongoose\";\n\n// Enable dayjs plugins used by event date parsing/status logic\ndayjs.extend(customParseFormat);\ndayjs.extend(isoWeek);\n\n/**\n * Determines the dateStatus for a future event date\n * @param startDateTime The start date-time of the event\n * @param now The current date-time\n * @returns The appropriate EnumEventDateStatus\n */\nexport function getFutureEventStatus(\n startDateTime: dayjs.Dayjs,\n now: dayjs.Dayjs,\n): EnumEventDateStatus {\n const hoursUntilStart = startDateTime.diff(now, \"hour\", true);\n if (hoursUntilStart > 0 && hoursUntilStart <= 4) {\n return EnumEventDateStatus.STARTING_SOON;\n }\n\n if (startDateTime.isSame(now, \"day\")) {\n return EnumEventDateStatus.TODAY;\n }\n\n if (startDateTime.isSame(now.add(1, \"day\"), \"day\")) {\n return EnumEventDateStatus.TOMORROW;\n }\n\n if (startDateTime.isSame(now, \"isoWeek\")) {\n return EnumEventDateStatus.THIS_WEEK;\n }\n\n if (startDateTime.isSame(now.add(1, \"week\"), \"isoWeek\")) {\n return EnumEventDateStatus.NEXT_WEEK;\n }\n\n return EnumEventDateStatus.UPCOMING;\n}\n\n/**\n * Updates the dateStatus field for a single DateTimeType object based on the current date/time\n * @param dateTime The date-time object to update\n * @returns A new object with updated dateStatus value\n */\nexport function updateSingleDateTimeStatus<T extends DateTimeType>(\n dateTime: T,\n now: dayjs.Dayjs = dayjs(),\n): T {\n // Parse start and end date-time\n const dateTimeFormat = `${dateFormat} ${timeFormat}`;\n const startDateTime = dayjs(\n `${dateTime.startDate} ${dateTime.startTime}`,\n dateTimeFormat,\n true,\n );\n const endDateTime = dayjs(\n `${dateTime.endDate} ${dateTime.endTime}`,\n dateTimeFormat,\n true,\n );\n\n // Skip if dates are invalid\n if (!startDateTime.isValid() || !endDateTime.isValid()) {\n return {\n ...dateTime,\n dateStatus: EnumEventDateStatus.INVALID,\n };\n }\n\n if (endDateTime.isBefore(startDateTime)) {\n return {\n ...dateTime,\n dateStatus: EnumEventDateStatus.INVALID,\n };\n }\n\n let dateStatus: EnumEventDateStatus;\n\n if (endDateTime.isAfter(now)) {\n if (startDateTime.isAfter(now)) {\n // Event has not started yet\n dateStatus = getFutureEventStatus(startDateTime, now);\n } else {\n // Event is in progress\n dateStatus = EnumEventDateStatus.STARTED;\n }\n } else {\n // Event has ended\n dateStatus = EnumEventDateStatus.ENDED;\n }\n\n return {\n ...dateTime,\n dateStatus,\n };\n}\n\nconst dateTimeStatusFilter = {\n dateTime: { $ne: [], $type: \"array\" },\n deletedAt: null,\n} as const;\n\nconst CURSOR_BATCH_SIZE = 50;\n\ntype DocWithDateTime = {\n _id: unknown;\n dateTime: DateTimeType[];\n};\n\ntype DateTimeBulkWriteOp = {\n updateOne: {\n filter: { _id: unknown };\n update: { $set: { dateTime: DateTimeType[] } };\n };\n};\n\ntype DateTimeCursor = AsyncIterable<DocWithDateTime> & {\n close: () => Promise<unknown>;\n};\n\ntype DateTimeUpdatableModel = {\n bulkWrite: (ops: DateTimeBulkWriteOp[]) => Promise<unknown>;\n find: (filter: typeof dateTimeStatusFilter) => {\n select: (fields: { _id: 1; dateTime: 1 }) => {\n lean: () => {\n cursor: (opts: { batchSize: number }) => DateTimeCursor;\n };\n };\n };\n};\n\nfunction hasDateTimeStatusChanges(\n stored: DateTimeType[],\n updated: DateTimeType[],\n): boolean {\n if (stored.length !== updated.length) {\n return true;\n }\n\n return stored.some(\n (slot, index) => slot.dateStatus !== updated[index].dateStatus,\n );\n}\n\nasync function updateModelDateTimeStatuses(\n model: DateTimeUpdatableModel,\n now: dayjs.Dayjs,\n): Promise<number> {\n let updated = 0;\n const cursor = model\n .find(dateTimeStatusFilter)\n .select({ _id: 1, dateTime: 1 })\n .lean()\n .cursor({ batchSize: CURSOR_BATCH_SIZE });\n\n let bulkOps: DateTimeBulkWriteOp[] = [];\n\n const flushBulkWrites = async (): Promise<void> => {\n if (!bulkOps.length) {\n return;\n }\n\n await model.bulkWrite(bulkOps);\n updated += bulkOps.length;\n bulkOps = [];\n };\n\n try {\n for await (const doc of cursor) {\n const dateTime = doc.dateTime.map((slot) =>\n updateSingleDateTimeStatus(slot, now),\n );\n\n if (!hasDateTimeStatusChanges(doc.dateTime, dateTime)) {\n continue;\n }\n\n bulkOps.push({\n updateOne: {\n filter: { _id: doc._id },\n update: { $set: { dateTime } },\n },\n });\n\n if (bulkOps.length >= CURSOR_BATCH_SIZE) {\n await flushBulkWrites();\n }\n }\n\n await flushBulkWrites();\n } finally {\n await cursor.close().catch(() => undefined);\n }\n\n return updated;\n}\n\n/**\n * Recomputes dateStatus for every dateTime slot on events and google imported markets.\n */\nexport async function updateAllEventDateTimeStatuses(): Promise<void> {\n const now = dayjs();\n const [eventCount, marketCount] = await Promise.all([\n updateModelDateTimeStatuses(EventModel as DateTimeUpdatableModel, now),\n updateModelDateTimeStatuses(\n GoogleImportedMarketModel as DateTimeUpdatableModel,\n now,\n ),\n ]);\n\n console.log(\n `✅ Event dateTime statuses updated: events=${eventCount} changed, google imported markets=${marketCount} changed`,\n );\n}\n","import { EventListItemType } from \"@timardex/cluemart-shared\";\n\nimport { EventModel, GoogleImportedMarketModel } from \"src/mongoose\";\nimport { ObjectId } from \"src/types\";\n\nimport { convertObjectIdsToStrings } from \"../objectIdToString\";\n\ntype EventOrMarket = Pick<EventListItemType, \"_id\" | \"name\"> | null;\n\n/**\n * This function attempts to find an Event or a Google Imported Market by the given resource ID.\n * It first normalizes the resource ID to a string format, then performs parallel queries to both collections.\n * If an Event is found, it returns that; otherwise, it checks for a Google Imported Market and returns it if found.\n * If neither is found, it returns null.\n * @param resourceId - The ID of the resource to find, which can be an ObjectId, string, null, or undefined.\n * @returns A promise that resolves to either an Event or a Google Imported Market object containing _id and name, or null if not found.\n */\n\nexport async function findEventOrImportedMarketById(\n resourceId: ObjectId | string | null | undefined,\n): Promise<EventOrMarket> {\n if (!resourceId) {\n return null;\n }\n\n const normalizedId = convertObjectIdsToStrings(resourceId) as string;\n\n const [eventDoc, googleImportedDoc] = await Promise.all([\n EventModel.findById(normalizedId)\n .select(\"_id name\")\n .lean<Pick<EventListItemType, \"_id\" | \"name\">>()\n .exec(),\n GoogleImportedMarketModel.findById(normalizedId)\n .select(\"_id name\")\n .lean<Pick<EventListItemType, \"_id\" | \"name\">>()\n .exec(),\n ]);\n\n return eventDoc ?? googleImportedDoc;\n}\n","import {\n DateTimeWithPriceType,\n EnumInviteStatus,\n} from \"@timardex/cluemart-shared\";\nimport { DateTimeType } from \"@timardex/cluemart-shared/types\";\n\nimport { SchemaRelationType } from \"src/mongoose/Relation\";\n\ntype EventDateSlot = Pick<DateTimeType, \"startDate\" | \"startTime\">;\n\n/**\n * Returns true when at least one startDate/startTime slot from the previous\n * schedule is absent from the next schedule (i.e. a date was removed).\n */\nexport function didRemoveAnyEventDates(\n previousDateTime: EventDateSlot[] | undefined,\n nextDateTime: EventDateSlot[] | undefined,\n): boolean {\n if (!previousDateTime?.length) {\n return false;\n }\n\n return previousDateTime.some(\n (prev) =>\n !nextDateTime?.some(\n (next) =>\n next.startDate === prev.startDate &&\n next.startTime === prev.startTime,\n ),\n );\n}\n\n/**\n * Helper: Update relationDates based on event's dateTime\n * Marks dates as UNAVAILABLE if they no longer exist in the event's dateTime.\n */\nexport function updateRelationDatesToUnavailable(\n relationDates: SchemaRelationType[\"relationDates\"],\n eventDateTime: DateTimeWithPriceType[] | undefined,\n): SchemaRelationType[\"relationDates\"] {\n return relationDates.map((relationDate) => {\n // Check if this relationDate exists in the event's dateTime\n const existsInEvent =\n eventDateTime?.some(\n (dt) =>\n dt.startDate === relationDate.dateTime.startDate &&\n dt.startTime === relationDate.dateTime.startTime,\n ) ?? false;\n\n return {\n ...relationDate,\n status: existsInEvent\n ? relationDate.status\n : EnumInviteStatus.UNAVAILABLE,\n };\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,OAAO,cAAc;AAMd,IAAM,oBAAoB,OAAO;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAMM;AACJ,MAAI;AAEF,UAAM,WAAW,aACb;AAAA;AAAA,MAEA,iBAAiB,MAAM,IAAI,UAAU,IAAI,MAAM,qDAAqD,OAAO;AAAA;AAE/G,UAAM,SAAS,QAAQ,QAAQ;AAE/B,UAAM,iBAAiB,aAAa,kBAAkB;AACtD,YAAQ;AAAA,MACN,GAAG,cAAc;AAAA,IACnB;AAAA,EACF,SAAS,KAAK;AACZ,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AAC;AAED,SAAO,YAAY;AACrB;;;ACzBO,SAAS,uBACd,kBACA,cACS;AACT,MAAI,CAAC,kBAAkB,QAAQ;AAC7B,WAAO;AAAA,EACT;AAEA,SAAO,iBAAiB;AAAA,IACtB,CAAC,SACC,CAAC,cAAc;AAAA,MACb,CAAC,SACC,KAAK,cAAc,KAAK,aACxB,KAAK,cAAc,KAAK;AAAA,IAC5B;AAAA,EACJ;AACF;AAMO,SAAS,iCACd,eACA,eACqC;AACrC,SAAO,cAAc,IAAI,CAAC,iBAAiB;AAEzC,UAAM,gBACJ,eAAe;AAAA,MACb,CAAC,OACC,GAAG,cAAc,aAAa,SAAS,aACvC,GAAG,cAAc,aAAa,SAAS;AAAA,IAC3C,KAAK;AAEP,WAAO;AAAA,MACL,GAAG;AAAA,MACH,QAAQ,gBACJ,aAAa,SACb,iBAAiB;AAAA,IACvB;AAAA,EACF,CAAC;AACH;","names":["mongoose","mongoose","mongoose"]}
1
+ {"version":3,"sources":["../../src/service/promoCode/constants.ts","../../src/service/affiliate/activeAffiliateCodeExists.ts","../../src/service/affiliate/createAffiliateReward.ts","../../src/service/affiliate/findAffiliateByPromoCode.ts","../../src/service/promoCode/normalizePromoCode.ts","../../src/service/affiliate/normalizeAffiliatePromoCodes.ts","../../src/service/database.ts","../../src/service/saveNotificationsInDb.ts","../../src/service/sendPushNotifications.ts","../../src/service/updateAdStatus.ts","../../src/service/associate.ts","../../src/service/vendor.ts","../../src/service/objectIdToString.ts","../../src/service/event/updateAllEventDateTimeStatuses.ts","../../src/service/event/findEventOrImportedMarketById.ts","../../src/service/relations.ts"],"sourcesContent":["/** Matches partial unique indexes for promo/affiliate codes on active documents. */\nexport const ACTIVE_NOT_DELETED_FILTER = {\n active: true,\n deletedAt: null,\n} as const;\n","import { AffiliateModel } from \"src/mongoose\";\n\nimport { ACTIVE_NOT_DELETED_FILTER } from \"../promoCode/constants\";\n\n/**\n * Checks whether an affiliate code is already taken by an active, non-deleted affiliate.\n *\n * Used when generating new affiliate codes so collisions are avoided before insert.\n * Matches the partial unique index on `affiliateCode` for active documents.\n *\n * @param affiliateCode - Candidate affiliate promo code to check.\n * @returns `true` when an active, non-deleted affiliate already uses this code.\n */\nexport async function activeAffiliateCodeExists(\n affiliateCode: string,\n): Promise<boolean> {\n const existing = await AffiliateModel.exists({\n ...ACTIVE_NOT_DELETED_FILTER,\n affiliateCode,\n }).exec();\n\n return existing !== null;\n}\n","import {\n AffiliateRewardType,\n EnumAffiliateRewardType,\n} from \"@timardex/cluemart-shared\";\n\ntype AffiliateRewardConfig = {\n description: string;\n value: number;\n};\n\nexport const AFFILIATE_REWARDS = {\n [EnumAffiliateRewardType.NEW_EVENT_REGISTRATION]: {\n description: \"10 points for new event registration (one-time reward)\",\n value: 10,\n },\n [EnumAffiliateRewardType.NEW_VENDOR_REGISTRATION]: {\n description: \"5 points for new vendor registration (one-time reward)\",\n value: 5,\n },\n [EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION]: {\n description: \"3 points for active vendor pro subscription (monthly reward)\",\n value: 3,\n },\n [EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION]: {\n description:\n \"1 point for active vendor standard subscription (monthly reward)\",\n value: 1,\n },\n [EnumAffiliateRewardType.ACTIVE_VENDOR_BONUS_REWARD]: {\n description:\n \"5 bonus points for every 10th active vendor (one-time reward)\",\n value: 5,\n },\n [EnumAffiliateRewardType.ACTIVE_EVENT_WITH_VENDOR_REGISTRATIONS]: {\n description:\n \"50 points for active event with vendor registrations (one-time reward)\",\n value: 50,\n },\n} satisfies Record<EnumAffiliateRewardType, AffiliateRewardConfig>;\n\n/**\n * Create an affiliate reward\n * @param rewardType - The type of reward\n * @param createdAt - The date the reward was received\n * @returns The affiliate reward\n * @example\n * const reward = createAffiliateReward(EnumAffiliateRewardType.NEW_EVENT_REGISTRATION, new Date());\n * console.log(reward);\n */\nexport function createAffiliateReward(\n rewardType: EnumAffiliateRewardType,\n createdAt: Date,\n): AffiliateRewardType {\n const reward = AFFILIATE_REWARDS[rewardType];\n\n return {\n createdAt,\n redeemedAt: null,\n rewardDescription: reward.description,\n rewardType,\n rewardValue: reward.value,\n };\n}\n","import { PromoCodeType } from \"@timardex/cluemart-shared\";\n\nimport { AffiliateModel } from \"src/mongoose\";\n\n/**\n * Loads the affiliate whose `affiliateCode` matches the given promo code.\n *\n * Includes inactive affiliates (`active: false`) so resource referrals work before\n * admin approval. Soft-deleted affiliates (`deletedAt` set) are excluded.\n *\n * @param promoCode - Normalized affiliate promo code to resolve.\n * @returns The matching affiliate document, or `null` when not found.\n */\nexport async function findAffiliateByPromoCode(promoCode: PromoCodeType) {\n return AffiliateModel.findOne({\n affiliateCode: promoCode,\n deletedAt: null,\n }).exec();\n}\n","export function normalizePromoCode(\n decoratedPromoCode: string | null | undefined,\n): string | null {\n const normalized = decoratedPromoCode?.trim().toUpperCase();\n return normalized || null;\n}\n","import { PromoCodeType } from \"@timardex/cluemart-shared\";\n\nimport { normalizePromoCode } from \"../promoCode/normalizePromoCode\";\n\n/**\n * Normalizes, trims, uppercases, and deduplicates resource promo codes.\n *\n * @param promoCodes - Raw promo codes from a create-resource mutation input.\n * @returns Unique normalized codes; empty strings and whitespace-only values are removed.\n */\nexport function normalizeAffiliatePromoCodes(\n promoCodes: PromoCodeType[] | null | undefined,\n): PromoCodeType[] {\n const normalized = (promoCodes ?? [])\n .map((code) => normalizePromoCode(code))\n .filter((code): code is PromoCodeType => code !== null);\n\n return [...new Set(normalized)];\n}\n","import mongoose from \"mongoose\";\n\n/**\n * Connect to MongoDB using Mongoose.\n * Supports both local MongoDB (via MONGODB_URI) and MongoDB Atlas (via individual env vars).\n */\nexport const connectToDatabase = async ({\n appName,\n dbName,\n dbPassword,\n dbUser,\n mongodbUri,\n}: {\n appName: string;\n dbName: string;\n dbPassword: string;\n dbUser: string;\n mongodbUri: string;\n}) => {\n try {\n // Check if MONGODB_URI is provided (for local Docker MongoDB)\n const mongoUri = mongodbUri\n ? mongodbUri\n : // Fallback to MongoDB Atlas connection string\n `mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`;\n\n await mongoose.connect(mongoUri);\n\n const connectionType = mongodbUri ? \"Local MongoDB\" : \"MongoDB Atlas\";\n console.log(\n `${connectionType} connected from server/src/service/database.ts`,\n );\n } catch (err) {\n console.error(\"Error connecting to MongoDB:\", err);\n throw err; // You can throw the error if you want to stop the server in case of connection failure\n }\n};\n","import {\n SchemaCreateBulkNotificationInput,\n NotificationModel,\n} from \"src/mongoose/Notification\";\nimport { ObjectId } from \"src/types\";\n\n/**\n * Create notifications in the database for multiple users\n * This is typically called when sending push notifications\n */\nexport async function saveNotificationsInDb(\n payload: SchemaCreateBulkNotificationInput,\n): Promise<ObjectId[]> {\n const { data, message, title, type, userIds } = payload;\n console.log('NOTIFICATION DATA', JSON.stringify(payload, null, 2));\n try {\n const notifications = userIds.map((userId) => ({\n data,\n isRead: false,\n message,\n title,\n type,\n userId,\n }));\n\n // Save notifications to database\n await NotificationModel.insertMany(notifications);\n console.log(\n `Created ${notifications.length} notifications for ${userIds.length} users`,\n );\n\n return [...new Set(userIds)];\n } catch (error) {\n console.error(\"Failed to create notifications:\", error);\n return [];\n //throw new Error(`Failed to create notifications: ${error}`);\n }\n}\n","import { NotificationDataType } from \"@timardex/cluemart-shared\";\nimport { Expo, ExpoPushMessage, ExpoPushTicket } from \"expo-server-sdk\";\n\nimport { SchemaCreateBulkNotificationInput } from \"src/mongoose/Notification\";\nimport { PushTokenModel } from \"src/mongoose/PushToken\";\n\nconst expo = new Expo();\n\n/**\n * Safely extract tokens from ExpoPushMessage handling both string and array cases\n */\nfunction extractTokensFromMessage(message: ExpoPushMessage): string[] {\n return Array.isArray(message.to) ? message.to : [message.to];\n}\n\ninterface CreatePushMessagesOptions {\n tokens: string[];\n message: string;\n title: string;\n data: NotificationDataType;\n}\n\n/**\n * Create push messages from valid tokens\n */\nfunction createPushMessages({\n tokens,\n message,\n title,\n data,\n}: CreatePushMessagesOptions): {\n messages: ExpoPushMessage[];\n invalidTokens: string[];\n} {\n const messages: ExpoPushMessage[] = [];\n const invalidTokens: string[] = [];\n\n for (const token of tokens) {\n if (!Expo.isExpoPushToken(token)) {\n invalidTokens.push(token);\n continue;\n }\n\n messages.push({\n body: message,\n data: { ...data },\n sound: \"tui.wav\",\n title,\n to: token,\n });\n }\n\n return { invalidTokens, messages };\n}\n\n/**\n * Process chunk results and extract failed tokens\n */\nfunction processChunkResults(\n tickets: ExpoPushTicket[],\n chunk: ExpoPushMessage[],\n): { successCount: number; failedTokens: string[] } {\n let successCount = 0;\n const failedTokens: string[] = [];\n\n for (const [ticketIndex, ticket] of tickets.entries()) {\n if (ticket.status === \"error\") {\n const message = chunk[ticketIndex];\n if (message) {\n const tokens = extractTokensFromMessage(message);\n if (ticket.details?.error === \"DeviceNotRegistered\") {\n failedTokens.push(...tokens);\n }\n console.log(\"Push notification error\", {\n error: ticket.details?.error,\n tokens,\n });\n }\n } else {\n successCount++;\n }\n }\n\n return { failedTokens, successCount };\n}\n\n/**\n * Send a single chunk of push notifications\n */\nasync function sendChunk(\n chunk: ExpoPushMessage[],\n chunkIndex: number,\n): Promise<{ successCount: number; failedTokens: string[] }> {\n try {\n const tickets = await expo.sendPushNotificationsAsync(chunk);\n const { successCount, failedTokens } = processChunkResults(tickets, chunk);\n\n console.log(\n `Chunk ${chunkIndex + 1}: Sent ${successCount}/${chunk.length} notifications successfully`,\n );\n\n return { failedTokens, successCount };\n } catch (error) {\n console.log(\"Error sending Expo push notification chunk\", {\n chunkIndex,\n chunkSize: chunk.length,\n error: error instanceof Error ? error.message : String(error),\n });\n return { failedTokens: [], successCount: 0 };\n }\n}\n\nexport async function sendPushNotifications({\n data,\n message,\n title,\n userIds,\n}: SchemaCreateBulkNotificationInput) {\n const pushTokens = await PushTokenModel.find({ userId: { $in: userIds } });\n const expoTokens = pushTokens.map((token) => token.token);\n\n if (!data) return;\n\n const { messages, invalidTokens } = createPushMessages({\n data,\n message,\n title,\n tokens: expoTokens,\n });\n\n // Log invalid tokens\n if (invalidTokens.length > 0) {\n console.log(`Found ${invalidTokens.length} invalid push tokens`);\n }\n\n if (messages.length === 0) {\n console.log(\"No valid messages to send after filtering tokens\");\n return;\n }\n\n // Send notifications in chunks\n const chunks = expo.chunkPushNotifications(messages);\n let totalSuccessCount = 0;\n const allFailedTokens: string[] = [];\n\n for (const [chunkIndex, chunk] of chunks.entries()) {\n const { successCount, failedTokens } = await sendChunk(\n chunk,\n chunkIndex + 1,\n );\n totalSuccessCount += successCount;\n allFailedTokens.push(...failedTokens);\n }\n\n // Log final results\n console.log(\n `Sent push notification to ${totalSuccessCount}/${messages.length} tokens across ${chunks.length} chunks`,\n );\n\n if (allFailedTokens.length > 0) {\n console.log(`Found ${allFailedTokens.length} failed push tokens`);\n }\n}\n","import { EnumAdStatus } from \"@timardex/cluemart-shared\";\n\nimport { AdModel } from \"src/mongoose\";\n\n/**\n * Updates ad statuses based on start/end dates and validity\n */\nexport async function updateAdStatuses(): Promise<void> {\n const now = new Date();\n\n // invalid\n const invalidResult = await AdModel.updateMany(\n {\n $or: [\n { start: { $exists: false } },\n { end: { $exists: false } },\n { $expr: { $gt: [\"$start\", \"$end\"] } },\n ],\n status: { $ne: EnumAdStatus.PAUSED },\n },\n { $set: { status: EnumAdStatus.PAUSED } },\n );\n\n // expired\n const expiredResult = await AdModel.updateMany(\n { end: { $lte: now }, status: { $ne: EnumAdStatus.EXPIRED } },\n { $set: { status: EnumAdStatus.EXPIRED } },\n );\n\n // active\n const activeResult = await AdModel.updateMany(\n {\n end: { $gt: now },\n start: { $lte: now },\n status: { $ne: EnumAdStatus.ACTIVE },\n },\n { $set: { status: EnumAdStatus.ACTIVE } },\n );\n\n // paused\n const pausedResult = await AdModel.updateMany(\n { start: { $gt: now }, status: { $ne: EnumAdStatus.PAUSED } },\n { $set: { status: EnumAdStatus.PAUSED } },\n );\n\n console.log(\n `✅ Ad statuses updated: invalid=${invalidResult.modifiedCount}, expired=${expiredResult.modifiedCount}, active=${activeResult.modifiedCount}, paused=${pausedResult.modifiedCount}`,\n );\n}\n","import { EnumChatType, EnumResourceType } from \"@timardex/cluemart-shared\";\nimport mongoose from \"mongoose\";\n\nimport { ChatModel, UserModel } from \"src/mongoose\";\nimport { ObjectId } from \"src/types\";\n\ninterface RemoveAssociateFromResourceParams {\n resourceId: string | ObjectId;\n resourceOwnerId: string | ObjectId;\n resourceType: EnumResourceType;\n}\n\ninterface ResourceAssociateScope {\n normalizedResourceId: string;\n resourceType: EnumResourceType;\n}\n\nfunction normalizeObjectId(id: string | ObjectId): ObjectId {\n return typeof id === \"string\" ? new mongoose.Types.ObjectId(id) : id;\n}\n\nasync function getAssociateEmailsForResource({\n normalizedResourceId,\n resourceType,\n}: ResourceAssociateScope): Promise<string[]> {\n const usersWithAssociates = await UserModel.find(\n {\n associates: {\n $elemMatch: {\n resourceId: normalizedResourceId,\n resourceType,\n },\n },\n },\n {\n associates: 1,\n },\n ).lean();\n\n return [\n ...new Set(\n usersWithAssociates.flatMap((user) =>\n (user.associates ?? [])\n .filter(\n (associate) =>\n associate.resourceId === normalizedResourceId &&\n associate.resourceType === resourceType,\n )\n .map((associate) => associate.email),\n ),\n ),\n ];\n}\n\nasync function pullAssociatesFromUsers({\n normalizedResourceId,\n resourceType,\n}: ResourceAssociateScope): Promise<void> {\n await UserModel.updateMany(\n {\n associates: {\n $elemMatch: {\n resourceId: normalizedResourceId,\n resourceType,\n },\n },\n },\n {\n $pull: {\n associates: {\n resourceId: normalizedResourceId,\n resourceType,\n },\n },\n },\n );\n}\n\nasync function pullAssociateParticipantsFromChats(\n resourceOwnerId: ObjectId,\n associateEmails: string[],\n): Promise<void> {\n await ChatModel.updateMany(\n {\n active: true,\n chatType: EnumChatType.RELATION,\n deletedAt: null,\n participants: {\n $elemMatch: {\n userId: resourceOwnerId,\n },\n },\n },\n {\n $pull: {\n participants: {\n isAssociate: true,\n userEmail: {\n $in: associateEmails,\n },\n },\n },\n },\n );\n}\n\n/**\n * Removes all associates linked to a resource\n * and removes related associate chat participants.\n */\nexport async function removeAssociateFromResource({\n resourceId,\n resourceOwnerId,\n resourceType,\n}: RemoveAssociateFromResourceParams): Promise<void> {\n try {\n const scope: ResourceAssociateScope = {\n normalizedResourceId: resourceId.toString(),\n resourceType,\n };\n\n const associateEmails = await getAssociateEmailsForResource(scope);\n\n if (associateEmails.length === 0) {\n return;\n }\n\n await pullAssociatesFromUsers(scope);\n await pullAssociateParticipantsFromChats(\n normalizeObjectId(resourceOwnerId),\n associateEmails,\n );\n } catch (error) {\n console.error(\n `[removeAssociateFromResource] Failed for resourceId=${resourceId}, resourceType=${resourceType}`,\n error,\n );\n }\n}\n","import { EnumResourceType, EnumUserLicence } from \"@timardex/cluemart-shared\";\n\nimport { UserModel, VendorModel, SchemaVendorType } from \"src/mongoose\";\nimport { ObjectId } from \"src/types\";\n\nimport { removeAssociateFromResource } from \"./associate\";\n\nexport async function updateVendorBasedOnUserLicense(\n userId: ObjectId,\n licenceType: EnumUserLicence,\n): Promise<void> {\n try {\n /**\n * Fetch user vendor reference\n */\n const user = await UserModel.findById(userId)\n .select(\"vendor\")\n .lean()\n .exec();\n\n if (!user?.vendor) {\n console.warn(`[updateVendor] No vendor found for userId=${userId}`);\n return;\n }\n\n /**\n * Fetch vendor\n */\n const vendor = await VendorModel.findById(user.vendor)\n .lean<SchemaVendorType>()\n .exec();\n\n if (!vendor) {\n console.warn(`[updateVendor] Vendor not found for id=${user.vendor}`);\n return;\n }\n\n /**\n * Build vendor update payload\n */\n const updateData: Partial<SchemaVendorType> = {};\n\n const isStandardVendor = licenceType === EnumUserLicence.STANDARD_VENDOR;\n\n if (isStandardVendor) {\n updateData.associates = [];\n\n updateData.availability = {\n corporate: false,\n private: false,\n school: false,\n };\n\n updateData.products = {\n active: false,\n productsList: vendor.products?.productsList ?? [],\n };\n\n updateData.calendar = {\n active: false,\n calendarData: vendor.calendar?.calendarData ?? [],\n };\n }\n\n /**\n * Image rules\n * STANDARD_VENDOR => only first 6 active, 6 is the default image limit for standard vendors\n * PRO_VENDOR => all active\n */\n updateData.images = (vendor.images ?? []).map((image, index) => ({\n ...image,\n active: isStandardVendor ? index < 6 : true,\n }));\n\n /**\n * Persist vendor updates\n */\n await VendorModel.updateOne({ _id: vendor._id }, { $set: updateData });\n\n /**\n * Cleanup associates for STANDARD licence\n */\n if (isStandardVendor) {\n await removeAssociateFromResource({\n resourceId: vendor._id,\n resourceOwnerId: vendor.owner.userId,\n resourceType: EnumResourceType.VENDOR,\n });\n }\n } catch (error) {\n console.error(\"[updateVendorBasedOnUserLicense] Failed:\", error);\n }\n}\n","import mongoose from \"mongoose\";\n\n/**\n * Recursively converts all ObjectId fields to strings in an object\n * This is needed because GraphQL expects string IDs, not ObjectIds\n */\nexport function convertObjectIdsToStrings(obj: any): any {\n if (obj === null || obj === undefined) {\n return obj;\n }\n\n if (obj instanceof mongoose.Types.ObjectId) {\n return obj.toString();\n }\n\n if (obj instanceof Date) {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(convertObjectIdsToStrings);\n }\n\n if (typeof obj === \"object\") {\n const converted: any = {};\n for (const [key, value] of Object.entries(obj)) {\n converted[key] = convertObjectIdsToStrings(value);\n }\n return converted;\n }\n\n return obj;\n}\n","import {\n dateFormat,\n DateTimeType,\n EnumEventDateStatus,\n timeFormat,\n} from \"@timardex/cluemart-shared\";\nimport dayjs from \"dayjs\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat\";\nimport isoWeek from \"dayjs/plugin/isoWeek\";\n\nimport { EventModel, GoogleImportedMarketModel } from \"src/mongoose\";\n\n// Enable dayjs plugins used by event date parsing/status logic\ndayjs.extend(customParseFormat);\ndayjs.extend(isoWeek);\n\n/**\n * Determines the dateStatus for a future event date\n * @param startDateTime The start date-time of the event\n * @param now The current date-time\n * @returns The appropriate EnumEventDateStatus\n */\nexport function getFutureEventStatus(\n startDateTime: dayjs.Dayjs,\n now: dayjs.Dayjs,\n): EnumEventDateStatus {\n const hoursUntilStart = startDateTime.diff(now, \"hour\", true);\n if (hoursUntilStart > 0 && hoursUntilStart <= 4) {\n return EnumEventDateStatus.STARTING_SOON;\n }\n\n if (startDateTime.isSame(now, \"day\")) {\n return EnumEventDateStatus.TODAY;\n }\n\n if (startDateTime.isSame(now.add(1, \"day\"), \"day\")) {\n return EnumEventDateStatus.TOMORROW;\n }\n\n if (startDateTime.isSame(now, \"isoWeek\")) {\n return EnumEventDateStatus.THIS_WEEK;\n }\n\n if (startDateTime.isSame(now.add(1, \"week\"), \"isoWeek\")) {\n return EnumEventDateStatus.NEXT_WEEK;\n }\n\n return EnumEventDateStatus.UPCOMING;\n}\n\n/**\n * Updates the dateStatus field for a single DateTimeType object based on the current date/time\n * @param dateTime The date-time object to update\n * @returns A new object with updated dateStatus value\n */\nexport function updateSingleDateTimeStatus<T extends DateTimeType>(\n dateTime: T,\n now: dayjs.Dayjs = dayjs(),\n): T {\n // Parse start and end date-time\n const dateTimeFormat = `${dateFormat} ${timeFormat}`;\n const startDateTime = dayjs(\n `${dateTime.startDate} ${dateTime.startTime}`,\n dateTimeFormat,\n true,\n );\n const endDateTime = dayjs(\n `${dateTime.endDate} ${dateTime.endTime}`,\n dateTimeFormat,\n true,\n );\n\n // Skip if dates are invalid\n if (!startDateTime.isValid() || !endDateTime.isValid()) {\n return {\n ...dateTime,\n dateStatus: EnumEventDateStatus.INVALID,\n };\n }\n\n if (endDateTime.isBefore(startDateTime)) {\n return {\n ...dateTime,\n dateStatus: EnumEventDateStatus.INVALID,\n };\n }\n\n let dateStatus: EnumEventDateStatus;\n\n if (endDateTime.isAfter(now)) {\n if (startDateTime.isAfter(now)) {\n // Event has not started yet\n dateStatus = getFutureEventStatus(startDateTime, now);\n } else {\n // Event is in progress\n dateStatus = EnumEventDateStatus.STARTED;\n }\n } else {\n // Event has ended\n dateStatus = EnumEventDateStatus.ENDED;\n }\n\n return {\n ...dateTime,\n dateStatus,\n };\n}\n\nconst dateTimeStatusFilter = {\n dateTime: { $ne: [], $type: \"array\" },\n deletedAt: null,\n} as const;\n\nconst CURSOR_BATCH_SIZE = 50;\n\ntype DocWithDateTime = {\n _id: unknown;\n dateTime: DateTimeType[];\n};\n\ntype DateTimeBulkWriteOp = {\n updateOne: {\n filter: { _id: unknown };\n update: { $set: { dateTime: DateTimeType[] } };\n };\n};\n\ntype DateTimeCursor = AsyncIterable<DocWithDateTime> & {\n close: () => Promise<unknown>;\n};\n\ntype DateTimeUpdatableModel = {\n bulkWrite: (ops: DateTimeBulkWriteOp[]) => Promise<unknown>;\n find: (filter: typeof dateTimeStatusFilter) => {\n select: (fields: { _id: 1; dateTime: 1 }) => {\n lean: () => {\n cursor: (opts: { batchSize: number }) => DateTimeCursor;\n };\n };\n };\n};\n\nfunction hasDateTimeStatusChanges(\n stored: DateTimeType[],\n updated: DateTimeType[],\n): boolean {\n if (stored.length !== updated.length) {\n return true;\n }\n\n return stored.some(\n (slot, index) => slot.dateStatus !== updated[index].dateStatus,\n );\n}\n\nasync function updateModelDateTimeStatuses(\n model: DateTimeUpdatableModel,\n now: dayjs.Dayjs,\n): Promise<number> {\n let updated = 0;\n const cursor = model\n .find(dateTimeStatusFilter)\n .select({ _id: 1, dateTime: 1 })\n .lean()\n .cursor({ batchSize: CURSOR_BATCH_SIZE });\n\n let bulkOps: DateTimeBulkWriteOp[] = [];\n\n const flushBulkWrites = async (): Promise<void> => {\n if (!bulkOps.length) {\n return;\n }\n\n await model.bulkWrite(bulkOps);\n updated += bulkOps.length;\n bulkOps = [];\n };\n\n try {\n for await (const doc of cursor) {\n const dateTime = doc.dateTime.map((slot) =>\n updateSingleDateTimeStatus(slot, now),\n );\n\n if (!hasDateTimeStatusChanges(doc.dateTime, dateTime)) {\n continue;\n }\n\n bulkOps.push({\n updateOne: {\n filter: { _id: doc._id },\n update: { $set: { dateTime } },\n },\n });\n\n if (bulkOps.length >= CURSOR_BATCH_SIZE) {\n await flushBulkWrites();\n }\n }\n\n await flushBulkWrites();\n } finally {\n await cursor.close().catch(() => undefined);\n }\n\n return updated;\n}\n\n/**\n * Recomputes dateStatus for every dateTime slot on events and google imported markets.\n */\nexport async function updateAllEventDateTimeStatuses(): Promise<void> {\n const now = dayjs();\n const [eventCount, marketCount] = await Promise.all([\n updateModelDateTimeStatuses(EventModel as DateTimeUpdatableModel, now),\n updateModelDateTimeStatuses(\n GoogleImportedMarketModel as DateTimeUpdatableModel,\n now,\n ),\n ]);\n\n console.log(\n `✅ Event dateTime statuses updated: events=${eventCount} changed, google imported markets=${marketCount} changed`,\n );\n}\n","import { EventListItemType } from \"@timardex/cluemart-shared\";\n\nimport { EventModel, GoogleImportedMarketModel } from \"src/mongoose\";\nimport { ObjectId } from \"src/types\";\n\nimport { convertObjectIdsToStrings } from \"../objectIdToString\";\n\ntype EventOrMarket = Pick<EventListItemType, \"_id\" | \"name\"> | null;\n\n/**\n * This function attempts to find an Event or a Google Imported Market by the given resource ID.\n * It first normalizes the resource ID to a string format, then performs parallel queries to both collections.\n * If an Event is found, it returns that; otherwise, it checks for a Google Imported Market and returns it if found.\n * If neither is found, it returns null.\n * @param resourceId - The ID of the resource to find, which can be an ObjectId, string, null, or undefined.\n * @returns A promise that resolves to either an Event or a Google Imported Market object containing _id and name, or null if not found.\n */\n\nexport async function findEventOrImportedMarketById(\n resourceId: ObjectId | string | null | undefined,\n): Promise<EventOrMarket> {\n if (!resourceId) {\n return null;\n }\n\n const normalizedId = convertObjectIdsToStrings(resourceId) as string;\n\n const [eventDoc, googleImportedDoc] = await Promise.all([\n EventModel.findById(normalizedId)\n .select(\"_id name\")\n .lean<Pick<EventListItemType, \"_id\" | \"name\">>()\n .exec(),\n GoogleImportedMarketModel.findById(normalizedId)\n .select(\"_id name\")\n .lean<Pick<EventListItemType, \"_id\" | \"name\">>()\n .exec(),\n ]);\n\n return eventDoc ?? googleImportedDoc;\n}\n","import {\n DateTimeWithPriceType,\n EnumInviteStatus,\n} from \"@timardex/cluemart-shared\";\nimport { DateTimeType } from \"@timardex/cluemart-shared/types\";\n\nimport { SchemaRelationType } from \"src/mongoose/Relation\";\n\ntype EventDateSlot = Pick<DateTimeType, \"startDate\" | \"startTime\">;\n\n/**\n * Returns true when at least one startDate/startTime slot from the previous\n * schedule is absent from the next schedule (i.e. a date was removed).\n */\nexport function didRemoveAnyEventDates(\n previousDateTime: EventDateSlot[] | undefined,\n nextDateTime: EventDateSlot[] | undefined,\n): boolean {\n if (!previousDateTime?.length) {\n return false;\n }\n\n return previousDateTime.some(\n (prev) =>\n !nextDateTime?.some(\n (next) =>\n next.startDate === prev.startDate &&\n next.startTime === prev.startTime,\n ),\n );\n}\n\n/**\n * Helper: Update relationDates based on event's dateTime\n * Marks dates as UNAVAILABLE if they no longer exist in the event's dateTime.\n */\nexport function updateRelationDatesToUnavailable(\n relationDates: SchemaRelationType[\"relationDates\"],\n eventDateTime: DateTimeWithPriceType[] | undefined,\n): SchemaRelationType[\"relationDates\"] {\n return relationDates.map((relationDate) => {\n // Check if this relationDate exists in the event's dateTime\n const existsInEvent =\n eventDateTime?.some(\n (dt) =>\n dt.startDate === relationDate.dateTime.startDate &&\n dt.startTime === relationDate.dateTime.startTime,\n ) ?? false;\n\n return {\n ...relationDate,\n status: existsInEvent\n ? relationDate.status\n : EnumInviteStatus.UNAVAILABLE,\n };\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACO,IAAM,4BAA4B;AAAA,EACvC,QAAQ;AAAA,EACR,WAAW;AACb;;;ACSA,eAAsB,0BACpB,eACkB;AAClB,QAAM,WAAW,MAAM,eAAe,OAAO;AAAA,IAC3C,GAAG;AAAA,IACH;AAAA,EACF,CAAC,EAAE,KAAK;AAER,SAAO,aAAa;AACtB;;;ACZO,IAAM,oBAAoB;AAAA,EAC/B,CAAC,wBAAwB,sBAAsB,GAAG;AAAA,IAChD,aAAa;AAAA,IACb,OAAO;AAAA,EACT;AAAA,EACA,CAAC,wBAAwB,uBAAuB,GAAG;AAAA,I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AU,EACjB,KAA8C,EAC9C,KAAK;AAAA,IACR,0BAA0B,SAAS,YAAY,EAC5C,OAAO,UAAU,EACjB,KAA8C,EAC9C,KAAK;AAAA,EACV,CAAC;AAED,SAAO,YAAY;AACrB;;;ACzBO,SAAS,uBACd,kBACA,cACS;AACT,MAAI,CAAC,kBAAkB,QAAQ;AAC7B,WAAO;AAAA,EACT;AAEA,SAAO,iBAAiB;AAAA,IACtB,CAAC,SACC,CAAC,cAAc;AAAA,MACb,CAAC,SACC,KAAK,cAAc,KAAK,aACxB,KAAK,cAAc,KAAK;AAAA,IAC5B;AAAA,EACJ;AACF;AAMO,SAAS,iCACd,eACA,eACqC;AACrC,SAAO,cAAc,IAAI,CAAC,iBAAiB;AAEzC,UAAM,gBACJ,eAAe;AAAA,MACb,CAAC,OACC,GAAG,cAAc,aAAa,SAAS,aACvC,GAAG,cAAc,aAAa,SAAS;AAAA,IAC3C,KAAK;AAEP,WAAO;AAAA,MACL,GAAG;AAAA,MACH,QAAQ,gBACJ,aAAa,SACb,iBAAiB;AAAA,IACvB;AAAA,EACF,CAAC;AACH;","names":["mongoose","mongoose","mongoose"]}
@@ -2,4 +2,4 @@ import '@timardex/cluemart-shared';
2
2
  import '@timardex/cluemart-shared/types';
3
3
  export { default as express } from 'express';
4
4
  export { default as mongoose } from 'mongoose';
5
- export { A as AuthUser, E as EnumPubSubEvents, G as GraphQLContext, O as ObjectId, h as SubscriptionPayload } from '../Chat-DYkhie3G.mjs';
5
+ export { A as AuthUser, E as EnumPubSubEvents, G as GraphQLContext, O as ObjectId, h as SubscriptionPayload } from '../Chat-Bnqec74U.mjs';
@@ -2,4 +2,4 @@ import '@timardex/cluemart-shared';
2
2
  import '@timardex/cluemart-shared/types';
3
3
  export { default as express } from 'express';
4
4
  export { default as mongoose } from 'mongoose';
5
- export { A as AuthUser, E as EnumPubSubEvents, G as GraphQLContext, O as ObjectId, h as SubscriptionPayload } from '../Chat-DYkhie3G.js';
5
+ export { A as AuthUser, E as EnumPubSubEvents, G as GraphQLContext, O as ObjectId, h as SubscriptionPayload } from '../Chat-Bnqec74U.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timardex/cluemart-server-shared",
3
- "version": "1.0.280",
3
+ "version": "1.0.284",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -44,7 +44,7 @@
44
44
  "author": "Csaba Timár",
45
45
  "license": "ISC",
46
46
  "devDependencies": {
47
- "@timardex/cluemart-shared": "^1.5.796",
47
+ "@timardex/cluemart-shared": "^1.5.799",
48
48
  "@types/express": "^5.0.5",
49
49
  "@types/node": "^22.13.4",
50
50
  "@typescript-eslint/eslint-plugin": "^8.20.0",
@@ -1,47 +0,0 @@
1
- import { RelationDate, RelationType } from '@timardex/cluemart-shared';
2
- import mongoose from 'mongoose';
3
- import { O as ObjectId } from './Chat-DYkhie3G.js';
4
-
5
- declare const relationDatesSchema: mongoose.Schema<RelationDate, mongoose.Model<RelationDate, any, any, any, mongoose.Document<unknown, any, RelationDate, any, {}> & RelationDate & {
6
- _id: mongoose.Types.ObjectId;
7
- } & {
8
- __v: number;
9
- }, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, RelationDate, mongoose.Document<unknown, {}, mongoose.FlatRecord<RelationDate>, {}, mongoose.ResolveSchemaOptions<mongoose.DefaultSchemaOptions>> & mongoose.FlatRecord<RelationDate> & {
10
- _id: mongoose.Types.ObjectId;
11
- } & {
12
- __v: number;
13
- }>;
14
- type SchemaRelationType = Omit<RelationType, "eventId" | "vendorId" | "chatId"> & {
15
- eventId: ObjectId;
16
- vendorId: ObjectId;
17
- chatId: ObjectId;
18
- };
19
- /**
20
- * This is the schema for the relation type.
21
- * It is used to define the structure of the relation type in the database.
22
- * The schema is used by Mongoose to create a model for the relation type.
23
- */
24
- declare const RelationTypeSchema: mongoose.Schema<SchemaRelationType, mongoose.Model<SchemaRelationType, any, any, any, mongoose.Document<unknown, any, SchemaRelationType, any, {}> & Omit<RelationType, "chatId" | "eventId" | "vendorId"> & {
25
- eventId: ObjectId;
26
- vendorId: ObjectId;
27
- chatId: ObjectId;
28
- } & Required<{
29
- _id: string;
30
- }> & {
31
- __v: number;
32
- }, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, SchemaRelationType, mongoose.Document<unknown, {}, mongoose.FlatRecord<SchemaRelationType>, {}, mongoose.ResolveSchemaOptions<mongoose.DefaultSchemaOptions>> & mongoose.FlatRecord<SchemaRelationType> & Required<{
33
- _id: string;
34
- }> & {
35
- __v: number;
36
- }>;
37
- declare const RelationModel: mongoose.Model<SchemaRelationType, {}, {}, {}, mongoose.Document<unknown, {}, SchemaRelationType, {}, {}> & Omit<RelationType, "chatId" | "eventId" | "vendorId"> & {
38
- eventId: ObjectId;
39
- vendorId: ObjectId;
40
- chatId: ObjectId;
41
- } & Required<{
42
- _id: string;
43
- }> & {
44
- __v: number;
45
- }, any>;
46
-
47
- export { RelationTypeSchema as R, type SchemaRelationType as S, RelationModel as a, relationDatesSchema as r };