@timardex/cluemart-server-shared 3.0.2 → 4.0.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.
@@ -97,7 +97,7 @@ __export(service_exports, {
97
97
  updateAdStatuses: () => updateAdStatuses,
98
98
  updateAllEventDateTimeStatuses: () => updateAllEventDateTimeStatuses,
99
99
  updateRelationDatesToCanceled: () => updateRelationDatesToCanceled,
100
- updateSingleDateTimeStatus: () => import_cluemart_shared36.updateSingleDateTimeStatus,
100
+ updateSingleDateTimeStatus: () => import_cluemart_shared37.updateSingleDateTimeStatus,
101
101
  upgradeUserToLicence: () => upgradeUserToLicence,
102
102
  vendorOwnerHasProLicence: () => vendorOwnerHasProLicence
103
103
  });
@@ -1004,15 +1004,15 @@ function syncSearchNameInUpdate(update) {
1004
1004
  }
1005
1005
  return null;
1006
1006
  }
1007
- function searchNamePlugin(schema26) {
1008
- schema26.add({ searchName: { default: "", required: false, type: String } });
1009
- schema26.index({ searchName: 1 });
1010
- schema26.pre("save", function syncSearchNameOnSave(next) {
1007
+ function searchNamePlugin(schema27) {
1008
+ schema27.add({ searchName: { default: "", required: false, type: String } });
1009
+ schema27.index({ searchName: 1 });
1010
+ schema27.pre("save", function syncSearchNameOnSave(next) {
1011
1011
  const doc = this;
1012
1012
  doc.searchName = deriveSearchName(doc.name);
1013
1013
  next();
1014
1014
  });
1015
- schema26.pre("insertMany", function syncSearchNameOnInsertMany(next, docs) {
1015
+ schema27.pre("insertMany", function syncSearchNameOnInsertMany(next, docs) {
1016
1016
  const list = Array.isArray(docs) ? docs : [docs];
1017
1017
  for (const doc of list) {
1018
1018
  if (doc && typeof doc.name === "string") {
@@ -1021,7 +1021,7 @@ function searchNamePlugin(schema26) {
1021
1021
  }
1022
1022
  next();
1023
1023
  });
1024
- schema26.pre("bulkWrite", function syncSearchNameOnBulkWrite(next, ops) {
1024
+ schema27.pre("bulkWrite", function syncSearchNameOnBulkWrite(next, ops) {
1025
1025
  for (const op of ops) {
1026
1026
  const doc = op.insertOne?.document ?? op.replaceOne?.replacement;
1027
1027
  if (doc && typeof doc.name === "string") {
@@ -1047,7 +1047,7 @@ function searchNamePlugin(schema26) {
1047
1047
  }
1048
1048
  next();
1049
1049
  };
1050
- schema26.pre(
1050
+ schema27.pre(
1051
1051
  ["findOneAndUpdate", "updateOne", "updateMany"],
1052
1052
  syncSearchNameOnUpdate
1053
1053
  );
@@ -1084,6 +1084,7 @@ var schema7 = new MongooseSchema6(
1084
1084
  dateTime: [dateTimeSchema],
1085
1085
  deletedAt: { default: null, required: false, type: Date },
1086
1086
  description: { required: true, type: String },
1087
+ earliestStartDate: { default: null, required: false, type: Date },
1087
1088
  eventId: {
1088
1089
  ref: "Event",
1089
1090
  required: false,
@@ -1126,28 +1127,151 @@ schema7.index({ name: 1 });
1126
1127
  schema7.index({ region: 1 });
1127
1128
  schema7.index({ deletedAt: 1 });
1128
1129
  schema7.index({ "dateTime.dateStatus": 1 });
1130
+ schema7.index({ earliestStartDate: 1, _id: 1 });
1129
1131
  schema7.index({ slug: 1 });
1130
1132
  schema7.index({ description: "text", name: "text" });
1131
1133
  schema7.plugin(searchNamePlugin);
1132
1134
  var GoogleImportedMarketModel = import_mongoose10.default.models.GoogleImportedMarket || import_mongoose10.default.model("GoogleImportedMarket", schema7);
1133
1135
 
1134
- // src/mongoose/Notification.ts
1136
+ // src/mongoose/AiImportedMarket.ts
1135
1137
  var import_cluemart_shared10 = require("@timardex/cluemart-shared");
1136
1138
  var import_mongoose11 = __toESM(require("mongoose"));
1137
1139
  var MongooseSchema7 = import_mongoose11.default.Schema;
1138
- var notificationDataSchema = new MongooseSchema7(
1140
+ var addressComponentSchema2 = new MongooseSchema7(
1141
+ {
1142
+ longName: { required: false, type: String },
1143
+ shortName: { required: false, type: String },
1144
+ types: { required: false, type: [String] }
1145
+ },
1146
+ { _id: false }
1147
+ );
1148
+ var schema8 = new MongooseSchema7(
1149
+ {
1150
+ active: { default: false, required: true, type: Boolean },
1151
+ address: { required: true, type: String },
1152
+ addressComponents: { required: false, type: [addressComponentSchema2] },
1153
+ approvedAt: { default: null, required: false, type: Date },
1154
+ claimed: { default: false, required: true, type: Boolean },
1155
+ claimedAt: { default: null, required: false, type: Date },
1156
+ claimedByUserId: {
1157
+ ref: "User",
1158
+ required: false,
1159
+ type: import_mongoose11.default.Schema.Types.ObjectId
1160
+ },
1161
+ cover: {
1162
+ required: false,
1163
+ type: ResourceImageTypeSchema
1164
+ },
1165
+ dateTime: [dateTimeSchema],
1166
+ deletedAt: { default: null, required: false, type: Date },
1167
+ description: { required: true, type: String },
1168
+ earliestStartDate: { default: null, required: false, type: Date },
1169
+ eventId: {
1170
+ ref: "Event",
1171
+ required: false,
1172
+ type: import_mongoose11.default.Schema.Types.ObjectId
1173
+ },
1174
+ eventType: {
1175
+ enum: Object.values(import_cluemart_shared10.EnumEventType),
1176
+ required: true,
1177
+ type: String
1178
+ },
1179
+ images: { required: false, type: [ResourceImageTypeSchema] },
1180
+ location: {
1181
+ required: true,
1182
+ type: locationsSchema
1183
+ },
1184
+ logo: { required: false, type: ResourceImageTypeSchema },
1185
+ name: { required: true, type: String },
1186
+ openingHours: { required: false, type: [String] },
1187
+ rainOrShine: { required: true, type: Boolean },
1188
+ rating: { required: false, type: Number },
1189
+ region: { required: false, type: String },
1190
+ rejectReason: { required: false, type: String },
1191
+ reviewCount: { required: false, type: Number },
1192
+ reviewedAt: { default: null, required: false, type: Date },
1193
+ reviewedByUserId: {
1194
+ ref: "User",
1195
+ required: false,
1196
+ type: import_mongoose11.default.Schema.Types.ObjectId
1197
+ },
1198
+ reviewStatus: {
1199
+ default: import_cluemart_shared10.EnumImportedMarketReviewStatus.PENDING,
1200
+ enum: Object.values(import_cluemart_shared10.EnumImportedMarketReviewStatus),
1201
+ required: true,
1202
+ type: String
1203
+ },
1204
+ scrapedAt: { default: () => /* @__PURE__ */ new Date(), required: true, type: Date },
1205
+ slug: { required: true, type: String },
1206
+ sourceKey: {
1207
+ required: true,
1208
+ type: String,
1209
+ unique: true
1210
+ // unique, indexed
1211
+ },
1212
+ sourceName: { required: true, type: String },
1213
+ sourceUrl: { required: true, type: String },
1214
+ website: { required: false, type: String }
1215
+ },
1216
+ { timestamps: true }
1217
+ );
1218
+ schema8.index({ "location.geo": "2dsphere" });
1219
+ schema8.index({ name: 1 });
1220
+ schema8.index({ region: 1 });
1221
+ schema8.index({ deletedAt: 1 });
1222
+ schema8.index({ "dateTime.dateStatus": 1 });
1223
+ schema8.index({ earliestStartDate: 1, _id: 1 });
1224
+ schema8.index({ slug: 1 });
1225
+ schema8.index({ reviewStatus: 1 });
1226
+ schema8.index({ description: "text", name: "text" });
1227
+ schema8.plugin(searchNamePlugin);
1228
+ var AiImportedMarketModel = import_mongoose11.default.models.AiImportedMarket || import_mongoose11.default.model("AiImportedMarket", schema8);
1229
+
1230
+ // src/mongoose/ScrapeSite.ts
1231
+ var import_mongoose12 = __toESM(require("mongoose"));
1232
+ var MongooseSchema8 = import_mongoose12.default.Schema;
1233
+ var scrapeSiteItemSchema = new MongooseSchema8(
1234
+ {
1235
+ enabled: { default: true, required: true, type: Boolean },
1236
+ lastError: { required: false, type: String },
1237
+ lastScrapedAt: { required: false, type: Date },
1238
+ lastScrapeStatus: { required: false, type: String },
1239
+ name: { required: true, type: String },
1240
+ regionHint: { required: false, type: String },
1241
+ url: { required: true, type: String }
1242
+ },
1243
+ { timestamps: true }
1244
+ );
1245
+ var configSchema = new MongooseSchema8(
1246
+ {
1247
+ key: { required: true, type: String, unique: true },
1248
+ sites: {
1249
+ default: [],
1250
+ required: true,
1251
+ type: [scrapeSiteItemSchema]
1252
+ }
1253
+ },
1254
+ { timestamps: true }
1255
+ );
1256
+ var ScrapeSiteConfigModel = import_mongoose12.default.models.ScrapeSiteConfig || import_mongoose12.default.model("ScrapeSiteConfig", configSchema);
1257
+
1258
+ // src/mongoose/Notification.ts
1259
+ var import_cluemart_shared11 = require("@timardex/cluemart-shared");
1260
+ var import_mongoose13 = __toESM(require("mongoose"));
1261
+ var MongooseSchema9 = import_mongoose13.default.Schema;
1262
+ var notificationDataSchema = new MongooseSchema9(
1139
1263
  {
1140
1264
  resourceId: { required: true, type: String },
1141
1265
  resourceName: { required: true, type: String },
1142
1266
  resourceType: {
1143
- enum: Object.values(import_cluemart_shared10.EnumNotificationResourceType),
1267
+ enum: Object.values(import_cluemart_shared11.EnumNotificationResourceType),
1144
1268
  required: true,
1145
1269
  type: String
1146
1270
  }
1147
1271
  },
1148
1272
  { _id: false }
1149
1273
  );
1150
- var schema8 = new MongooseSchema7(
1274
+ var schema9 = new MongooseSchema9(
1151
1275
  {
1152
1276
  data: {
1153
1277
  default: null,
@@ -1158,28 +1282,28 @@ var schema8 = new MongooseSchema7(
1158
1282
  message: { required: true, type: String },
1159
1283
  title: { required: true, type: String },
1160
1284
  type: {
1161
- default: import_cluemart_shared10.EnumNotificationType.SYSTEM,
1162
- enum: Object.values(import_cluemart_shared10.EnumNotificationType),
1285
+ default: import_cluemart_shared11.EnumNotificationType.SYSTEM,
1286
+ enum: Object.values(import_cluemart_shared11.EnumNotificationType),
1163
1287
  required: true,
1164
1288
  type: String
1165
1289
  },
1166
1290
  userId: {
1167
1291
  ref: "User",
1168
1292
  required: true,
1169
- type: import_mongoose11.default.Schema.Types.ObjectId
1293
+ type: import_mongoose13.default.Schema.Types.ObjectId
1170
1294
  }
1171
1295
  },
1172
1296
  { timestamps: true }
1173
1297
  );
1174
- schema8.index({ isRead: 1, userId: 1 });
1175
- schema8.index({ createdAt: -1, userId: 1 });
1176
- var NotificationModel = import_mongoose11.default.models.Notification || import_mongoose11.default.model("Notification", schema8);
1298
+ schema9.index({ isRead: 1, userId: 1 });
1299
+ schema9.index({ createdAt: -1, userId: 1 });
1300
+ var NotificationModel = import_mongoose13.default.models.Notification || import_mongoose13.default.model("Notification", schema9);
1177
1301
 
1178
1302
  // src/mongoose/PushToken.ts
1179
1303
  var import_enums = require("@timardex/cluemart-shared/enums");
1180
- var import_mongoose12 = __toESM(require("mongoose"));
1181
- var MongooseSchema8 = import_mongoose12.default.Schema;
1182
- var schema9 = new MongooseSchema8(
1304
+ var import_mongoose14 = __toESM(require("mongoose"));
1305
+ var MongooseSchema10 = import_mongoose14.default.Schema;
1306
+ var schema10 = new MongooseSchema10(
1183
1307
  {
1184
1308
  platform: {
1185
1309
  enum: Object.values(import_enums.EnumOSPlatform),
@@ -1190,22 +1314,22 @@ var schema9 = new MongooseSchema8(
1190
1314
  userId: {
1191
1315
  ref: "User",
1192
1316
  required: true,
1193
- type: import_mongoose12.default.Schema.Types.ObjectId
1317
+ type: import_mongoose14.default.Schema.Types.ObjectId
1194
1318
  }
1195
1319
  },
1196
1320
  { timestamps: true }
1197
1321
  );
1198
- var PushTokenModel = import_mongoose12.default.models.PushToken || import_mongoose12.default.model("PushToken", schema9);
1322
+ var PushTokenModel = import_mongoose14.default.models.PushToken || import_mongoose14.default.model("PushToken", schema10);
1199
1323
 
1200
1324
  // src/mongoose/Relation.ts
1201
- var import_cluemart_shared12 = require("@timardex/cluemart-shared");
1202
- var import_mongoose14 = __toESM(require("mongoose"));
1325
+ var import_cluemart_shared13 = require("@timardex/cluemart-shared");
1326
+ var import_mongoose16 = __toESM(require("mongoose"));
1203
1327
 
1204
1328
  // src/mongoose/event/EventInfo.ts
1205
- var import_cluemart_shared11 = require("@timardex/cluemart-shared");
1206
- var import_mongoose13 = __toESM(require("mongoose"));
1207
- var MongooseSchema9 = import_mongoose13.default.Schema;
1208
- var StallTypeSchema = new MongooseSchema9(
1329
+ var import_cluemart_shared12 = require("@timardex/cluemart-shared");
1330
+ var import_mongoose15 = __toESM(require("mongoose"));
1331
+ var MongooseSchema11 = import_mongoose15.default.Schema;
1332
+ var StallTypeSchema = new MongooseSchema11(
1209
1333
  {
1210
1334
  label: { required: false, type: String },
1211
1335
  price: { required: false, type: Number },
@@ -1216,10 +1340,10 @@ var StallTypeSchema = new MongooseSchema9(
1216
1340
  // Prevents Mongoose from creating an additional _id field for subdocuments
1217
1341
  }
1218
1342
  );
1219
- var dateTimeSchema2 = new MongooseSchema9(
1343
+ var dateTimeSchema2 = new MongooseSchema11(
1220
1344
  {
1221
1345
  dateStatus: {
1222
- enum: Object.values(import_cluemart_shared11.EnumEventDateStatus),
1346
+ enum: Object.values(import_cluemart_shared12.EnumEventDateStatus),
1223
1347
  required: false,
1224
1348
  type: String
1225
1349
  },
@@ -1232,13 +1356,13 @@ var dateTimeSchema2 = new MongooseSchema9(
1232
1356
  { _id: false }
1233
1357
  // Prevents Mongoose from creating an additional _id field for subdocuments
1234
1358
  );
1235
- var paymentInfoSchema = new MongooseSchema9(
1359
+ var paymentInfoSchema = new MongooseSchema11(
1236
1360
  {
1237
1361
  accountHolderName: { required: false, type: String },
1238
1362
  accountNumber: { required: false, type: String },
1239
1363
  link: { required: false, type: String },
1240
1364
  paymentMethod: {
1241
- enum: Object.values(import_cluemart_shared11.EnumPaymentMethod),
1365
+ enum: Object.values(import_cluemart_shared12.EnumPaymentMethod),
1242
1366
  required: true,
1243
1367
  type: String
1244
1368
  }
@@ -1246,7 +1370,7 @@ var paymentInfoSchema = new MongooseSchema9(
1246
1370
  { _id: false }
1247
1371
  // Prevents Mongoose from creating an additional _id field
1248
1372
  );
1249
- var requirementsSchema = new MongooseSchema9(
1373
+ var requirementsSchema = new MongooseSchema11(
1250
1374
  {
1251
1375
  category: { required: true, type: String },
1252
1376
  label: { required: true, type: String },
@@ -1257,7 +1381,7 @@ var requirementsSchema = new MongooseSchema9(
1257
1381
  // Prevents Mongoose from creating an additional _id field for
1258
1382
  }
1259
1383
  );
1260
- var refundPolicySchema = new MongooseSchema9(
1384
+ var refundPolicySchema = new MongooseSchema11(
1261
1385
  {
1262
1386
  category: { required: true, type: String },
1263
1387
  label: { required: true, type: String },
@@ -1265,7 +1389,7 @@ var refundPolicySchema = new MongooseSchema9(
1265
1389
  },
1266
1390
  { _id: false }
1267
1391
  );
1268
- var schema10 = new MongooseSchema9(
1392
+ var schema11 = new MongooseSchema11(
1269
1393
  {
1270
1394
  active: { default: true, type: Boolean },
1271
1395
  applicationDeadlineHours: { required: true, type: Number },
@@ -1273,7 +1397,7 @@ var schema10 = new MongooseSchema9(
1273
1397
  eventId: {
1274
1398
  ref: "Event",
1275
1399
  required: true,
1276
- type: import_mongoose13.default.Schema.Types.ObjectId
1400
+ type: import_mongoose15.default.Schema.Types.ObjectId
1277
1401
  },
1278
1402
  packInTime: { required: true, type: Number },
1279
1403
  paymentDueHours: { required: true, type: Number },
@@ -1283,15 +1407,15 @@ var schema10 = new MongooseSchema9(
1283
1407
  },
1284
1408
  { timestamps: true }
1285
1409
  );
1286
- schema10.index({ eventId: 1 });
1287
- var EventInfoModel = import_mongoose13.default.models.EventInfo || import_mongoose13.default.model("EventInfo", schema10);
1410
+ schema11.index({ eventId: 1 });
1411
+ var EventInfoModel = import_mongoose15.default.models.EventInfo || import_mongoose15.default.model("EventInfo", schema11);
1288
1412
 
1289
1413
  // src/mongoose/Relation.ts
1290
- var MongooseSchema10 = import_mongoose14.default.Schema;
1291
- var relationDateTimeSchema = new MongooseSchema10(
1414
+ var MongooseSchema12 = import_mongoose16.default.Schema;
1415
+ var relationDateTimeSchema = new MongooseSchema12(
1292
1416
  {
1293
1417
  dateStatus: {
1294
- enum: Object.values(import_cluemart_shared12.EnumEventDateStatus),
1418
+ enum: Object.values(import_cluemart_shared13.EnumEventDateStatus),
1295
1419
  required: true,
1296
1420
  type: String
1297
1421
  },
@@ -1303,7 +1427,7 @@ var relationDateTimeSchema = new MongooseSchema10(
1303
1427
  },
1304
1428
  { _id: false }
1305
1429
  );
1306
- var relationDatesSchema = new MongooseSchema10(
1430
+ var relationDatesSchema = new MongooseSchema12(
1307
1431
  {
1308
1432
  dateTime: {
1309
1433
  required: true,
@@ -1315,42 +1439,42 @@ var relationDatesSchema = new MongooseSchema10(
1315
1439
  },
1316
1440
  paymentReference: { required: false, type: String },
1317
1441
  status: {
1318
- enum: Object.values(import_cluemart_shared12.EnumInviteStatus),
1442
+ enum: Object.values(import_cluemart_shared13.EnumInviteStatus),
1319
1443
  required: false,
1320
1444
  type: String
1321
1445
  }
1322
1446
  },
1323
1447
  { _id: false }
1324
1448
  );
1325
- var RelationTypeSchema = new MongooseSchema10(
1449
+ var RelationTypeSchema = new MongooseSchema12(
1326
1450
  {
1327
1451
  active: { default: true, required: true, type: Boolean },
1328
1452
  chatId: {
1329
1453
  ref: "Chat",
1330
1454
  required: true,
1331
- type: import_mongoose14.default.Schema.Types.ObjectId
1455
+ type: import_mongoose16.default.Schema.Types.ObjectId
1332
1456
  },
1333
1457
  deletedAt: { default: null, required: false, type: Date },
1334
1458
  eventId: {
1335
1459
  ref: "Event",
1336
1460
  required: true,
1337
- type: import_mongoose14.default.Schema.Types.ObjectId
1461
+ type: import_mongoose16.default.Schema.Types.ObjectId
1338
1462
  },
1339
1463
  lastUpdateBy: {
1340
- enum: Object.values(import_cluemart_shared12.EnumResourceType),
1464
+ enum: Object.values(import_cluemart_shared13.EnumResourceType),
1341
1465
  required: true,
1342
1466
  type: String
1343
1467
  },
1344
1468
  relationDates: [relationDatesSchema],
1345
1469
  relationType: {
1346
- enum: Object.values(import_cluemart_shared12.EnumRelationResource),
1470
+ enum: Object.values(import_cluemart_shared13.EnumRelationResource),
1347
1471
  required: true,
1348
1472
  type: String
1349
1473
  },
1350
1474
  vendorId: {
1351
1475
  ref: "Vendor",
1352
1476
  required: true,
1353
- type: import_mongoose14.default.Schema.Types.ObjectId
1477
+ type: import_mongoose16.default.Schema.Types.ObjectId
1354
1478
  }
1355
1479
  },
1356
1480
  { timestamps: true }
@@ -1362,21 +1486,21 @@ RelationTypeSchema.index({
1362
1486
  "relationDates.status": 1,
1363
1487
  vendorId: 1
1364
1488
  });
1365
- var RelationModel = import_mongoose14.default.models.Relation || import_mongoose14.default.model("Relation", RelationTypeSchema);
1489
+ var RelationModel = import_mongoose16.default.models.Relation || import_mongoose16.default.model("Relation", RelationTypeSchema);
1366
1490
 
1367
1491
  // src/mongoose/ResourceActivity.ts
1368
- var import_cluemart_shared13 = require("@timardex/cluemart-shared");
1369
- var import_mongoose15 = __toESM(require("mongoose"));
1370
- var MongooseSchema11 = import_mongoose15.default.Schema;
1371
- var ActivitySchema = new MongooseSchema11(
1492
+ var import_cluemart_shared14 = require("@timardex/cluemart-shared");
1493
+ var import_mongoose17 = __toESM(require("mongoose"));
1494
+ var MongooseSchema13 = import_mongoose17.default.Schema;
1495
+ var ActivitySchema = new MongooseSchema13(
1372
1496
  {
1373
1497
  activityType: {
1374
- enum: Object.values(import_cluemart_shared13.EnumActivity),
1498
+ enum: Object.values(import_cluemart_shared14.EnumActivity),
1375
1499
  required: true,
1376
1500
  type: String
1377
1501
  },
1378
1502
  dateStatus: {
1379
- enum: Object.values(import_cluemart_shared13.EnumEventDateStatus),
1503
+ enum: Object.values(import_cluemart_shared14.EnumEventDateStatus),
1380
1504
  required: false,
1381
1505
  type: String
1382
1506
  },
@@ -1388,7 +1512,7 @@ var ActivitySchema = new MongooseSchema11(
1388
1512
  startTime: { required: false, type: String },
1389
1513
  timestamp: { default: Date.now, type: Date },
1390
1514
  userAgent: {
1391
- enum: Object.values(import_cluemart_shared13.EnumOSPlatform),
1515
+ enum: Object.values(import_cluemart_shared14.EnumOSPlatform),
1392
1516
  required: true,
1393
1517
  type: String
1394
1518
  },
@@ -1396,61 +1520,61 @@ var ActivitySchema = new MongooseSchema11(
1396
1520
  },
1397
1521
  { _id: false }
1398
1522
  );
1399
- var schema11 = new MongooseSchema11(
1523
+ var schema12 = new MongooseSchema13(
1400
1524
  {
1401
1525
  activity: { default: [], type: [ActivitySchema] },
1402
1526
  resourceId: { required: true, type: String },
1403
1527
  resourceType: {
1404
- enum: Object.values(import_cluemart_shared13.EnumResourceType),
1528
+ enum: Object.values(import_cluemart_shared14.EnumResourceType),
1405
1529
  required: true,
1406
1530
  type: String
1407
1531
  }
1408
1532
  },
1409
1533
  { timestamps: true }
1410
1534
  );
1411
- schema11.index({ resourceId: 1, resourceType: 1 }, { unique: true });
1412
- schema11.index({ "views.location": "2dsphere" });
1413
- var ResourceActivityModel = import_mongoose15.default.models.ResourceActivity || import_mongoose15.default.model("ResourceActivity", schema11);
1535
+ schema12.index({ resourceId: 1, resourceType: 1 }, { unique: true });
1536
+ schema12.index({ "views.location": "2dsphere" });
1537
+ var ResourceActivityModel = import_mongoose17.default.models.ResourceActivity || import_mongoose17.default.model("ResourceActivity", schema12);
1414
1538
 
1415
1539
  // src/mongoose/User.ts
1416
- var import_cluemart_shared14 = require("@timardex/cluemart-shared");
1417
- var import_mongoose16 = __toESM(require("mongoose"));
1418
- var MongooseSchema12 = import_mongoose16.default.Schema;
1419
- var userActivityEventSchema = new MongooseSchema12(
1540
+ var import_cluemart_shared15 = require("@timardex/cluemart-shared");
1541
+ var import_mongoose18 = __toESM(require("mongoose"));
1542
+ var MongooseSchema14 = import_mongoose18.default.Schema;
1543
+ var userActivityEventSchema = new MongooseSchema14(
1420
1544
  {
1421
1545
  dateTime: dateTimeSchema,
1422
1546
  resourceId: {
1423
1547
  ref: "Event",
1424
1548
  required: false,
1425
- type: import_mongoose16.default.Schema.Types.ObjectId
1549
+ type: import_mongoose18.default.Schema.Types.ObjectId
1426
1550
  }
1427
1551
  },
1428
1552
  { _id: false }
1429
1553
  );
1430
- var userActivityFavouritesSchema = new MongooseSchema12(
1554
+ var userActivityFavouritesSchema = new MongooseSchema14(
1431
1555
  {
1432
1556
  events: {
1433
1557
  ref: "Event",
1434
1558
  required: false,
1435
- type: [import_mongoose16.default.Schema.Types.ObjectId]
1559
+ type: [import_mongoose18.default.Schema.Types.ObjectId]
1436
1560
  },
1437
1561
  partners: {
1438
1562
  ref: "Partner",
1439
1563
  required: false,
1440
- type: [import_mongoose16.default.Schema.Types.ObjectId]
1564
+ type: [import_mongoose18.default.Schema.Types.ObjectId]
1441
1565
  },
1442
1566
  vendors: {
1443
1567
  ref: "Vendor",
1444
1568
  required: false,
1445
- type: [import_mongoose16.default.Schema.Types.ObjectId]
1569
+ type: [import_mongoose18.default.Schema.Types.ObjectId]
1446
1570
  }
1447
1571
  },
1448
1572
  { _id: false }
1449
1573
  );
1450
- var stripeSchema = new MongooseSchema12(
1574
+ var stripeSchema = new MongooseSchema14(
1451
1575
  {
1452
1576
  billingPeriod: {
1453
- enum: Object.values(import_cluemart_shared14.EnumBillingPeriod),
1577
+ enum: Object.values(import_cluemart_shared15.EnumBillingPeriod),
1454
1578
  required: false,
1455
1579
  type: String
1456
1580
  },
@@ -1459,7 +1583,7 @@ var stripeSchema = new MongooseSchema12(
1459
1583
  type: Boolean
1460
1584
  },
1461
1585
  currentPlan: {
1462
- enum: Object.values(import_cluemart_shared14.EnumUserLicence),
1586
+ enum: Object.values(import_cluemart_shared15.EnumUserLicence),
1463
1587
  required: false,
1464
1588
  type: String
1465
1589
  },
@@ -1484,7 +1608,7 @@ var stripeSchema = new MongooseSchema12(
1484
1608
  type: String
1485
1609
  },
1486
1610
  pendingBillingPeriod: {
1487
- enum: Object.values(import_cluemart_shared14.EnumBillingPeriod),
1611
+ enum: Object.values(import_cluemart_shared15.EnumBillingPeriod),
1488
1612
  required: false,
1489
1613
  type: String
1490
1614
  },
@@ -1493,7 +1617,7 @@ var stripeSchema = new MongooseSchema12(
1493
1617
  type: Date
1494
1618
  },
1495
1619
  pendingPlan: {
1496
- enum: Object.values(import_cluemart_shared14.EnumUserLicence),
1620
+ enum: Object.values(import_cluemart_shared15.EnumUserLicence),
1497
1621
  required: false,
1498
1622
  type: String
1499
1623
  },
@@ -1510,7 +1634,7 @@ var stripeSchema = new MongooseSchema12(
1510
1634
  type: Date
1511
1635
  },
1512
1636
  status: {
1513
- enum: Object.values(import_cluemart_shared14.EnumSubscriptionStatus),
1637
+ enum: Object.values(import_cluemart_shared15.EnumSubscriptionStatus),
1514
1638
  required: false,
1515
1639
  type: String
1516
1640
  },
@@ -1529,10 +1653,10 @@ var stripeSchema = new MongooseSchema12(
1529
1653
  },
1530
1654
  { _id: false }
1531
1655
  );
1532
- var redeemedRewardSchema = new MongooseSchema12(
1656
+ var redeemedRewardSchema = new MongooseSchema14(
1533
1657
  {
1534
1658
  name: {
1535
- enum: Object.values(import_cluemart_shared14.EnumReward),
1659
+ enum: Object.values(import_cluemart_shared15.EnumReward),
1536
1660
  required: true,
1537
1661
  type: String
1538
1662
  },
@@ -1541,12 +1665,12 @@ var redeemedRewardSchema = new MongooseSchema12(
1541
1665
  },
1542
1666
  { _id: false }
1543
1667
  );
1544
- var userOverallPointsSchema = new MongooseSchema12(
1668
+ var userOverallPointsSchema = new MongooseSchema14(
1545
1669
  {
1546
1670
  createdAt: { required: true, type: Date },
1547
1671
  points: { default: 0, required: true, type: Number },
1548
1672
  pointType: {
1549
- enum: Object.values(import_cluemart_shared14.EnumPointType),
1673
+ enum: Object.values(import_cluemart_shared15.EnumPointType),
1550
1674
  required: true,
1551
1675
  type: String
1552
1676
  },
@@ -1554,13 +1678,13 @@ var userOverallPointsSchema = new MongooseSchema12(
1554
1678
  },
1555
1679
  { _id: false }
1556
1680
  );
1557
- var schema12 = new MongooseSchema12(
1681
+ var schema13 = new MongooseSchema14(
1558
1682
  {
1559
1683
  active: { default: false, required: true, type: Boolean },
1560
1684
  affiliate: {
1561
1685
  ref: "Affiliate",
1562
1686
  required: false,
1563
- type: import_mongoose16.default.Schema.Types.ObjectId
1687
+ type: import_mongoose18.default.Schema.Types.ObjectId
1564
1688
  },
1565
1689
  avatar: {
1566
1690
  required: false,
@@ -1569,28 +1693,28 @@ var schema12 = new MongooseSchema12(
1569
1693
  coupon: {
1570
1694
  ref: "Coupon",
1571
1695
  required: false,
1572
- type: import_mongoose16.default.Schema.Types.ObjectId
1696
+ type: import_mongoose18.default.Schema.Types.ObjectId
1573
1697
  },
1574
1698
  deletedAt: { default: null, required: false, type: Date },
1575
1699
  email: { required: true, type: String },
1576
1700
  emailSentFor: {
1577
- enum: Object.values(import_cluemart_shared14.EnumNotificationResourceType),
1701
+ enum: Object.values(import_cluemart_shared15.EnumNotificationResourceType),
1578
1702
  required: false,
1579
1703
  type: [String]
1580
1704
  },
1581
1705
  events: {
1582
1706
  ref: "Event",
1583
1707
  required: false,
1584
- type: [import_mongoose16.default.Schema.Types.ObjectId]
1708
+ type: [import_mongoose18.default.Schema.Types.ObjectId]
1585
1709
  },
1586
1710
  firstName: { required: true, type: String },
1587
1711
  game: {
1588
1712
  ref: "Game",
1589
1713
  required: false,
1590
- type: import_mongoose16.default.Schema.Types.ObjectId
1714
+ type: import_mongoose18.default.Schema.Types.ObjectId
1591
1715
  },
1592
1716
  interests: {
1593
- enum: Object.values(import_cluemart_shared14.EnumResourceType),
1717
+ enum: Object.values(import_cluemart_shared15.EnumResourceType),
1594
1718
  required: false,
1595
1719
  type: [String]
1596
1720
  },
@@ -1613,11 +1737,11 @@ var schema12 = new MongooseSchema12(
1613
1737
  partner: {
1614
1738
  ref: "Partner",
1615
1739
  required: false,
1616
- type: import_mongoose16.default.Schema.Types.ObjectId
1740
+ type: import_mongoose18.default.Schema.Types.ObjectId
1617
1741
  },
1618
1742
  password: { required: true, type: String },
1619
1743
  platform: {
1620
- enum: Object.values(import_cluemart_shared14.EnumOSPlatform),
1744
+ enum: Object.values(import_cluemart_shared15.EnumOSPlatform),
1621
1745
  required: false,
1622
1746
  type: String
1623
1747
  },
@@ -1646,15 +1770,15 @@ var schema12 = new MongooseSchema12(
1646
1770
  type: String
1647
1771
  },
1648
1772
  roles: {
1649
- default: [import_cluemart_shared14.EnumUserRole.CUSTOMER],
1650
- enum: Object.values(import_cluemart_shared14.EnumUserRole),
1773
+ default: [import_cluemart_shared15.EnumUserRole.CUSTOMER],
1774
+ enum: Object.values(import_cluemart_shared15.EnumUserRole),
1651
1775
  required: true,
1652
1776
  type: [String]
1653
1777
  },
1654
1778
  school: {
1655
1779
  ref: "School",
1656
1780
  required: false,
1657
- type: import_mongoose16.default.Schema.Types.ObjectId
1781
+ type: import_mongoose18.default.Schema.Types.ObjectId
1658
1782
  },
1659
1783
  stripe: {
1660
1784
  required: false,
@@ -1679,21 +1803,21 @@ var schema12 = new MongooseSchema12(
1679
1803
  vendor: {
1680
1804
  ref: "Vendor",
1681
1805
  required: false,
1682
- type: import_mongoose16.default.Schema.Types.ObjectId
1806
+ type: import_mongoose18.default.Schema.Types.ObjectId
1683
1807
  }
1684
1808
  },
1685
1809
  { strict: false, timestamps: true }
1686
1810
  );
1687
- schema12.index({ "licences.expiryDate": 1 });
1688
- schema12.index({ "licences.licenceType": 1 });
1689
- schema12.index({ promoCodes: 1, active: 1, deletedAt: 1 });
1690
- schema12.index({ email: "text", firstName: "text", lastName: "text" });
1691
- var UserModel = import_mongoose16.default.models.User || import_mongoose16.default.model("User", schema12);
1811
+ schema13.index({ "licences.expiryDate": 1 });
1812
+ schema13.index({ "licences.licenceType": 1 });
1813
+ schema13.index({ promoCodes: 1, active: 1, deletedAt: 1 });
1814
+ schema13.index({ email: "text", firstName: "text", lastName: "text" });
1815
+ var UserModel = import_mongoose18.default.models.User || import_mongoose18.default.model("User", schema13);
1692
1816
 
1693
1817
  // src/mongoose/VerificationToken.ts
1694
- var import_mongoose17 = __toESM(require("mongoose"));
1695
- var MongooseSchema13 = import_mongoose17.default.Schema;
1696
- var schema13 = new MongooseSchema13(
1818
+ var import_mongoose19 = __toESM(require("mongoose"));
1819
+ var MongooseSchema15 = import_mongoose19.default.Schema;
1820
+ var schema14 = new MongooseSchema15(
1697
1821
  {
1698
1822
  createdAt: {
1699
1823
  default: Date.now,
@@ -1708,13 +1832,13 @@ var schema13 = new MongooseSchema13(
1708
1832
  },
1709
1833
  { timestamps: true }
1710
1834
  );
1711
- var VerificationTokenModel = import_mongoose17.default.models.VerificationToken || import_mongoose17.default.model("VerificationToken", schema13);
1835
+ var VerificationTokenModel = import_mongoose19.default.models.VerificationToken || import_mongoose19.default.model("VerificationToken", schema14);
1712
1836
 
1713
1837
  // src/mongoose/vendor/Vendor.ts
1714
- var import_cluemart_shared15 = require("@timardex/cluemart-shared");
1715
- var import_mongoose18 = __toESM(require("mongoose"));
1716
- var MongooseSchema14 = import_mongoose18.default.Schema;
1717
- var vendorProductTypeSchema = new MongooseSchema14(
1838
+ var import_cluemart_shared16 = require("@timardex/cluemart-shared");
1839
+ var import_mongoose20 = __toESM(require("mongoose"));
1840
+ var MongooseSchema16 = import_mongoose20.default.Schema;
1841
+ var vendorProductTypeSchema = new MongooseSchema16(
1718
1842
  {
1719
1843
  description: { required: false, type: String },
1720
1844
  name: { required: true, type: String },
@@ -1725,18 +1849,18 @@ var vendorProductTypeSchema = new MongooseSchema14(
1725
1849
  },
1726
1850
  { timestamps: true }
1727
1851
  );
1728
- var productWrapperSchema = new MongooseSchema14(
1852
+ var productWrapperSchema = new MongooseSchema16(
1729
1853
  {
1730
1854
  active: { default: false, required: false, type: Boolean },
1731
1855
  productsList: { required: false, type: [vendorProductTypeSchema] }
1732
1856
  },
1733
1857
  { _id: false }
1734
1858
  );
1735
- var calendarSchema = new MongooseSchema14(
1859
+ var calendarSchema = new MongooseSchema16(
1736
1860
  {
1737
1861
  dateTime: {
1738
1862
  dateStatus: {
1739
- enum: Object.values(import_cluemart_shared15.EnumEventDateStatus),
1863
+ enum: Object.values(import_cluemart_shared16.EnumEventDateStatus),
1740
1864
  required: false,
1741
1865
  type: String
1742
1866
  },
@@ -1753,14 +1877,14 @@ var calendarSchema = new MongooseSchema14(
1753
1877
  },
1754
1878
  { _id: false }
1755
1879
  );
1756
- var calendarWrapperSchema = new MongooseSchema14(
1880
+ var calendarWrapperSchema = new MongooseSchema16(
1757
1881
  {
1758
1882
  active: { default: false, required: true, type: Boolean },
1759
1883
  calendarData: { required: false, type: [calendarSchema] }
1760
1884
  },
1761
1885
  { _id: false }
1762
1886
  );
1763
- var vendorAvailabilitySchema = new MongooseSchema14(
1887
+ var vendorAvailabilitySchema = new MongooseSchema16(
1764
1888
  {
1765
1889
  corporate: { default: false, required: false, type: Boolean },
1766
1890
  private: { default: false, required: false, type: Boolean },
@@ -1768,7 +1892,7 @@ var vendorAvailabilitySchema = new MongooseSchema14(
1768
1892
  },
1769
1893
  { _id: false }
1770
1894
  );
1771
- var downgradeSnapshotSchema = new MongooseSchema14(
1895
+ var downgradeSnapshotSchema = new MongooseSchema16(
1772
1896
  {
1773
1897
  availability: { required: false, type: vendorAvailabilitySchema },
1774
1898
  calendarActive: { required: false, type: Boolean },
@@ -1776,7 +1900,7 @@ var downgradeSnapshotSchema = new MongooseSchema14(
1776
1900
  },
1777
1901
  { _id: false }
1778
1902
  );
1779
- var schema14 = new MongooseSchema14(
1903
+ var schema15 = new MongooseSchema16(
1780
1904
  {
1781
1905
  ...baseResourceFields,
1782
1906
  // Importing base resource fields from global.ts
@@ -1795,47 +1919,47 @@ var schema14 = new MongooseSchema14(
1795
1919
  unregisteredVendorId: {
1796
1920
  ref: "UnregisteredVendor",
1797
1921
  required: false,
1798
- type: import_mongoose18.default.Schema.Types.ObjectId
1922
+ type: import_mongoose20.default.Schema.Types.ObjectId
1799
1923
  },
1800
1924
  vendorInfoId: {
1801
1925
  ref: "VendorInfo",
1802
1926
  required: false,
1803
- type: import_mongoose18.default.Schema.Types.ObjectId
1927
+ type: import_mongoose20.default.Schema.Types.ObjectId
1804
1928
  },
1805
1929
  vendorType: {
1806
- enum: Object.values(import_cluemart_shared15.EnumVendorType),
1930
+ enum: Object.values(import_cluemart_shared16.EnumVendorType),
1807
1931
  required: true,
1808
1932
  type: String
1809
1933
  }
1810
1934
  },
1811
1935
  { timestamps: true }
1812
1936
  );
1813
- schema14.index({ name: 1 });
1814
- schema14.index({ description: 1 });
1815
- schema14.index({ region: 1 });
1816
- schema14.index({ "categories.name": 1 });
1817
- schema14.index({ slug: 1 });
1818
- schema14.index({
1937
+ schema15.index({ name: 1 });
1938
+ schema15.index({ description: 1 });
1939
+ schema15.index({ region: 1 });
1940
+ schema15.index({ "categories.name": 1 });
1941
+ schema15.index({ slug: 1 });
1942
+ schema15.index({
1819
1943
  categoriesNames: "text",
1820
1944
  description: "text",
1821
1945
  name: "text"
1822
1946
  });
1823
- schema14.index({ deletedAt: 1, "owner.userId": 1 });
1824
- schema14.plugin(searchNamePlugin);
1825
- var VendorModel = import_mongoose18.default.models.Vendor || import_mongoose18.default.model("Vendor", schema14);
1947
+ schema15.index({ deletedAt: 1, "owner.userId": 1 });
1948
+ schema15.plugin(searchNamePlugin);
1949
+ var VendorModel = import_mongoose20.default.models.Vendor || import_mongoose20.default.model("Vendor", schema15);
1826
1950
 
1827
1951
  // src/mongoose/vendor/VendorInfo.ts
1828
- var import_cluemart_shared16 = require("@timardex/cluemart-shared");
1829
- var import_mongoose19 = __toESM(require("mongoose"));
1830
- var MongooseSchema15 = import_mongoose19.default.Schema;
1831
- var AttributesSchema = new MongooseSchema15(
1952
+ var import_cluemart_shared17 = require("@timardex/cluemart-shared");
1953
+ var import_mongoose21 = __toESM(require("mongoose"));
1954
+ var MongooseSchema17 = import_mongoose21.default.Schema;
1955
+ var AttributesSchema = new MongooseSchema17(
1832
1956
  {
1833
1957
  details: { required: false, type: String },
1834
1958
  isRequired: { default: false, required: true, type: Boolean }
1835
1959
  },
1836
1960
  { _id: false }
1837
1961
  );
1838
- var schema15 = new MongooseSchema15(
1962
+ var schema16 = new MongooseSchema17(
1839
1963
  {
1840
1964
  active: { default: true, type: Boolean },
1841
1965
  compliance: {
@@ -1845,7 +1969,7 @@ var schema15 = new MongooseSchema15(
1845
1969
  documents: [ResourceImageTypeSchema],
1846
1970
  product: {
1847
1971
  foodFlavors: {
1848
- enum: Object.values(import_cluemart_shared16.EnumFoodFlavor),
1972
+ enum: Object.values(import_cluemart_shared17.EnumFoodFlavor),
1849
1973
  required: true,
1850
1974
  type: [String]
1851
1975
  },
@@ -1870,29 +1994,29 @@ var schema15 = new MongooseSchema15(
1870
1994
  vendorId: {
1871
1995
  ref: "Vendor",
1872
1996
  required: true,
1873
- type: import_mongoose19.default.Schema.Types.ObjectId
1997
+ type: import_mongoose21.default.Schema.Types.ObjectId
1874
1998
  }
1875
1999
  },
1876
2000
  { timestamps: true }
1877
2001
  );
1878
- schema15.index({ vendorId: 1 });
1879
- var VendorInfoModel = import_mongoose19.default.models.VendorInfo || import_mongoose19.default.model("VendorInfo", schema15);
2002
+ schema16.index({ vendorId: 1 });
2003
+ var VendorInfoModel = import_mongoose21.default.models.VendorInfo || import_mongoose21.default.model("VendorInfo", schema16);
1880
2004
 
1881
2005
  // src/mongoose/vendor/UnregisteredVendor.ts
1882
- var import_mongoose20 = __toESM(require("mongoose"));
1883
- var MongooseSchema16 = import_mongoose20.default.Schema;
1884
- var invitationSchema = new MongooseSchema16(
2006
+ var import_mongoose22 = __toESM(require("mongoose"));
2007
+ var MongooseSchema18 = import_mongoose22.default.Schema;
2008
+ var invitationSchema = new MongooseSchema18(
1885
2009
  {
1886
2010
  dateTime: { required: true, type: [dateTimeSchema] },
1887
2011
  inviterId: {
1888
2012
  ref: "Event",
1889
2013
  required: true,
1890
- type: import_mongoose20.default.Schema.Types.ObjectId
2014
+ type: import_mongoose22.default.Schema.Types.ObjectId
1891
2015
  }
1892
2016
  },
1893
2017
  { _id: false }
1894
2018
  );
1895
- var schema16 = new MongooseSchema16(
2019
+ var schema17 = new MongooseSchema18(
1896
2020
  {
1897
2021
  active: { default: true, required: true, type: Boolean },
1898
2022
  categoryIds: { required: true, type: [String] },
@@ -1901,7 +2025,7 @@ var schema16 = new MongooseSchema16(
1901
2025
  claimedByUserId: {
1902
2026
  ref: "User",
1903
2027
  required: false,
1904
- type: import_mongoose20.default.Schema.Types.ObjectId
2028
+ type: import_mongoose22.default.Schema.Types.ObjectId
1905
2029
  },
1906
2030
  claimInitiatedAt: { default: null, required: false, type: Date },
1907
2031
  claimToken: { default: null, required: false, type: String },
@@ -1914,15 +2038,15 @@ var schema16 = new MongooseSchema16(
1914
2038
  },
1915
2039
  { timestamps: true }
1916
2040
  );
1917
- schema16.index({ name: 1 });
1918
- schema16.index({ email: 1 });
1919
- var UnregisteredVendorModel = import_mongoose20.default.models.UnregisteredVendor || import_mongoose20.default.model("UnregisteredVendor", schema16);
2041
+ schema17.index({ name: 1 });
2042
+ schema17.index({ email: 1 });
2043
+ var UnregisteredVendorModel = import_mongoose22.default.models.UnregisteredVendor || import_mongoose22.default.model("UnregisteredVendor", schema17);
1920
2044
 
1921
2045
  // src/mongoose/event/Event.ts
1922
- var import_cluemart_shared17 = require("@timardex/cluemart-shared");
1923
- var import_mongoose21 = __toESM(require("mongoose"));
1924
- var MongooseSchema17 = import_mongoose21.default.Schema;
1925
- var schema17 = new MongooseSchema17(
2046
+ var import_cluemart_shared18 = require("@timardex/cluemart-shared");
2047
+ var import_mongoose23 = __toESM(require("mongoose"));
2048
+ var MongooseSchema19 = import_mongoose23.default.Schema;
2049
+ var schema18 = new MongooseSchema19(
1926
2050
  {
1927
2051
  ...baseResourceFields,
1928
2052
  // Importing base resource fields from global.ts
@@ -1931,10 +2055,10 @@ var schema17 = new MongooseSchema17(
1931
2055
  eventInfoId: {
1932
2056
  ref: "EventInfo",
1933
2057
  required: false,
1934
- type: import_mongoose21.default.Schema.Types.ObjectId
2058
+ type: import_mongoose23.default.Schema.Types.ObjectId
1935
2059
  },
1936
2060
  eventType: {
1937
- enum: Object.values(import_cluemart_shared17.EnumEventType),
2061
+ enum: Object.values(import_cluemart_shared18.EnumEventType),
1938
2062
  required: true,
1939
2063
  type: String
1940
2064
  },
@@ -1955,40 +2079,40 @@ var schema17 = new MongooseSchema17(
1955
2079
  },
1956
2080
  { timestamps: true }
1957
2081
  );
1958
- schema17.index({ name: 1 });
1959
- schema17.index({ description: 1 });
1960
- schema17.index({ region: 1 });
1961
- schema17.index({ "location.geo": "2dsphere" });
1962
- schema17.index({ tags: 1 });
1963
- schema17.index({ deletedAt: 1 });
1964
- schema17.index({ "dateTime.dateStatus": 1 });
1965
- schema17.index({ slug: 1 });
1966
- schema17.index({ description: "text", name: "text", tags: "text" });
1967
- schema17.index({ deletedAt: 1, "owner.userId": 1 });
1968
- schema17.plugin(searchNamePlugin);
1969
- var EventModel = import_mongoose21.default.models.Event || import_mongoose21.default.model("Event", schema17);
2082
+ schema18.index({ name: 1 });
2083
+ schema18.index({ description: 1 });
2084
+ schema18.index({ region: 1 });
2085
+ schema18.index({ "location.geo": "2dsphere" });
2086
+ schema18.index({ tags: 1 });
2087
+ schema18.index({ deletedAt: 1 });
2088
+ schema18.index({ "dateTime.dateStatus": 1 });
2089
+ schema18.index({ slug: 1 });
2090
+ schema18.index({ description: "text", name: "text", tags: "text" });
2091
+ schema18.index({ deletedAt: 1, "owner.userId": 1 });
2092
+ schema18.plugin(searchNamePlugin);
2093
+ var EventModel = import_mongoose23.default.models.Event || import_mongoose23.default.model("Event", schema18);
1970
2094
 
1971
2095
  // src/mongoose/event/EventDateArchive.ts
1972
- var import_mongoose22 = __toESM(require("mongoose"));
1973
- var schema18 = new import_mongoose22.default.Schema(
2096
+ var import_mongoose24 = __toESM(require("mongoose"));
2097
+ var schema19 = new import_mongoose24.default.Schema(
1974
2098
  {
1975
2099
  dateTime: { required: true, type: [dateTimeSchema] },
1976
2100
  eventId: {
1977
2101
  ref: "Event",
1978
2102
  required: true,
1979
- type: import_mongoose22.default.Schema.Types.ObjectId
2103
+ type: import_mongoose24.default.Schema.Types.ObjectId
1980
2104
  }
1981
2105
  },
1982
2106
  { timestamps: true }
1983
2107
  );
1984
- schema18.index({ eventId: 1 }, { unique: true });
1985
- var EventDateArchiveModel = import_mongoose22.default.models.EventDateArchive || import_mongoose22.default.model("EventDateArchive", schema18);
2108
+ schema19.index({ eventId: 1 }, { unique: true });
2109
+ var EventDateArchiveModel = import_mongoose24.default.models.EventDateArchive || import_mongoose24.default.model("EventDateArchive", schema19);
1986
2110
 
1987
2111
  // src/mongoose/Partner.ts
1988
- var import_cluemart_shared18 = require("@timardex/cluemart-shared");
1989
- var import_mongoose23 = __toESM(require("mongoose"));
1990
- var MongooseSchema18 = import_mongoose23.default.Schema;
1991
- var schema19 = new MongooseSchema18(
2112
+ var import_cluemart_shared19 = require("@timardex/cluemart-shared");
2113
+ var import_mongoose25 = __toESM(require("mongoose"));
2114
+ var MongooseSchema20 = import_mongoose25.default.Schema;
2115
+ var schema20 = new MongooseSchema20(
1992
2116
  {
1993
2117
  ...baseResourceFields,
1994
2118
  location: {
@@ -1997,53 +2121,53 @@ var schema19 = new MongooseSchema18(
1997
2121
  },
1998
2122
  nzbn: { required: true, type: String },
1999
2123
  partnerType: {
2000
- enum: Object.values(import_cluemart_shared18.EnumPartnerType),
2124
+ enum: Object.values(import_cluemart_shared19.EnumPartnerType),
2001
2125
  required: true,
2002
2126
  type: String
2003
2127
  }
2004
2128
  },
2005
2129
  { timestamps: true }
2006
2130
  );
2007
- schema19.index({ name: 1 });
2008
- schema19.index({ description: 1 });
2009
- schema19.index({ region: 1 });
2010
- schema19.index({ "location.geo": "2dsphere" });
2011
- schema19.index({ slug: 1 });
2012
- schema19.index({ name: "text", description: "text" });
2013
- schema19.index({ "owner.userId": 1, deletedAt: 1 });
2014
- schema19.plugin(searchNamePlugin);
2015
- var PartnerModel = import_mongoose23.default.models.Partner || import_mongoose23.default.model("Partner", schema19);
2131
+ schema20.index({ name: 1 });
2132
+ schema20.index({ description: 1 });
2133
+ schema20.index({ region: 1 });
2134
+ schema20.index({ "location.geo": "2dsphere" });
2135
+ schema20.index({ slug: 1 });
2136
+ schema20.index({ name: "text", description: "text" });
2137
+ schema20.index({ "owner.userId": 1, deletedAt: 1 });
2138
+ schema20.plugin(searchNamePlugin);
2139
+ var PartnerModel = import_mongoose25.default.models.Partner || import_mongoose25.default.model("Partner", schema20);
2016
2140
 
2017
2141
  // src/mongoose/Post.ts
2018
- var import_cluemart_shared19 = require("@timardex/cluemart-shared");
2019
- var import_mongoose24 = __toESM(require("mongoose"));
2020
- var MongooseSchema19 = import_mongoose24.default.Schema;
2021
- var contentSchema = new MongooseSchema19(
2142
+ var import_cluemart_shared20 = require("@timardex/cluemart-shared");
2143
+ var import_mongoose26 = __toESM(require("mongoose"));
2144
+ var MongooseSchema21 = import_mongoose26.default.Schema;
2145
+ var contentSchema = new MongooseSchema21(
2022
2146
  {
2023
- contentData: import_mongoose24.Schema.Types.Mixed,
2147
+ contentData: import_mongoose26.Schema.Types.Mixed,
2024
2148
  contentOrder: { required: true, type: Number },
2025
2149
  contentType: {
2026
- enum: Object.values(import_cluemart_shared19.EnumPostContentType),
2150
+ enum: Object.values(import_cluemart_shared20.EnumPostContentType),
2027
2151
  required: true,
2028
2152
  type: String
2029
2153
  }
2030
2154
  },
2031
2155
  { _id: false }
2032
2156
  );
2033
- var resourceSchema = new MongooseSchema19(
2157
+ var resourceSchema = new MongooseSchema21(
2034
2158
  {
2035
2159
  resourceId: { required: true, type: String },
2036
2160
  resourceRegion: { required: true, type: String },
2037
2161
  resourceSlug: { required: true, type: String },
2038
2162
  resourceType: {
2039
- enum: Object.values(import_cluemart_shared19.EnumResourceType),
2163
+ enum: Object.values(import_cluemart_shared20.EnumResourceType),
2040
2164
  required: true,
2041
2165
  type: String
2042
2166
  }
2043
2167
  },
2044
2168
  { _id: false }
2045
2169
  );
2046
- var schema20 = new MongooseSchema19(
2170
+ var schema21 = new MongooseSchema21(
2047
2171
  {
2048
2172
  active: { default: false, required: true, type: Boolean },
2049
2173
  approvedAt: { default: null, required: false, type: Date },
@@ -2059,7 +2183,7 @@ var schema20 = new MongooseSchema19(
2059
2183
  },
2060
2184
  deletedAt: { default: null, required: false, type: Date },
2061
2185
  postType: {
2062
- enum: Object.values(import_cluemart_shared19.EnumPostType),
2186
+ enum: Object.values(import_cluemart_shared20.EnumPostType),
2063
2187
  required: true,
2064
2188
  type: String
2065
2189
  },
@@ -2074,16 +2198,16 @@ var schema20 = new MongooseSchema19(
2074
2198
  },
2075
2199
  { timestamps: true }
2076
2200
  );
2077
- schema20.index({ title: 1 });
2078
- schema20.index({ tags: 1 });
2079
- schema20.index({ postType: 1, slug: 1 }, { unique: true });
2080
- var PostModel = import_mongoose24.default.models.Post || import_mongoose24.default.model("Post", schema20);
2201
+ schema21.index({ title: 1 });
2202
+ schema21.index({ tags: 1 });
2203
+ schema21.index({ postType: 1, slug: 1 }, { unique: true });
2204
+ var PostModel = import_mongoose26.default.models.Post || import_mongoose26.default.model("Post", schema21);
2081
2205
 
2082
2206
  // src/mongoose/AppSetting.ts
2083
- var import_mongoose25 = __toESM(require("mongoose"));
2084
- var MongooseSchema20 = import_mongoose25.default.Schema;
2207
+ var import_mongoose27 = __toESM(require("mongoose"));
2208
+ var MongooseSchema22 = import_mongoose27.default.Schema;
2085
2209
  var APP_SETTINGS_ID = "APP_SETTINGS_DOCUMENT_ID";
2086
- var AppSettingSchema = new MongooseSchema20(
2210
+ var AppSettingSchema = new MongooseSchema22(
2087
2211
  {
2088
2212
  activeSchoolsStudentCountTotal: {
2089
2213
  default: 0,
@@ -2105,8 +2229,8 @@ var AppSettingSchema = new MongooseSchema20(
2105
2229
  validate: Number.isInteger
2106
2230
  },
2107
2231
  mobileDisplayEnabled: { default: false, required: true, type: Boolean },
2108
- purchasePricing: { type: MongooseSchema20.Types.Mixed },
2109
- regionPricing: { type: MongooseSchema20.Types.Mixed },
2232
+ purchasePricing: { type: MongooseSchema22.Types.Mixed },
2233
+ regionPricing: { type: MongooseSchema22.Types.Mixed },
2110
2234
  paidSlotsPerPlacement: { enum: [30], type: Number },
2111
2235
  reservedSlotsPerPlacement: { enum: [7], type: Number },
2112
2236
  rotationSeconds: { enum: [8], type: Number },
@@ -2131,12 +2255,12 @@ var AppSettingSchema = new MongooseSchema20(
2131
2255
  },
2132
2256
  { timestamps: true }
2133
2257
  );
2134
- var AppSettingModel = import_mongoose25.default.models.AppSetting || import_mongoose25.default.model("AppSetting", AppSettingSchema);
2258
+ var AppSettingModel = import_mongoose27.default.models.AppSetting || import_mongoose27.default.model("AppSetting", AppSettingSchema);
2135
2259
 
2136
2260
  // src/mongoose/AuthHandoffToken.ts
2137
- var import_mongoose26 = __toESM(require("mongoose"));
2138
- var MongooseSchema21 = import_mongoose26.default.Schema;
2139
- var schema21 = new MongooseSchema21(
2261
+ var import_mongoose28 = __toESM(require("mongoose"));
2262
+ var MongooseSchema23 = import_mongoose28.default.Schema;
2263
+ var schema22 = new MongooseSchema23(
2140
2264
  {
2141
2265
  expiresAt: { required: true, type: Date },
2142
2266
  jti: { index: true, required: true, type: String, unique: true },
@@ -2145,25 +2269,25 @@ var schema21 = new MongooseSchema21(
2145
2269
  index: true,
2146
2270
  ref: "User",
2147
2271
  required: true,
2148
- type: import_mongoose26.default.Schema.Types.ObjectId
2272
+ type: import_mongoose28.default.Schema.Types.ObjectId
2149
2273
  }
2150
2274
  },
2151
2275
  { timestamps: true }
2152
2276
  );
2153
- schema21.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
2154
- var AuthHandoffTokenModel = import_mongoose26.default.models.AuthHandoffToken || import_mongoose26.default.model("AuthHandoffToken", schema21);
2277
+ schema22.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
2278
+ var AuthHandoffTokenModel = import_mongoose28.default.models.AuthHandoffToken || import_mongoose28.default.model("AuthHandoffToken", schema22);
2155
2279
 
2156
2280
  // src/mongoose/game/Game.ts
2157
- var import_cluemart_shared20 = require("@timardex/cluemart-shared");
2158
- var import_mongoose30 = __toESM(require("mongoose"));
2281
+ var import_cluemart_shared21 = require("@timardex/cluemart-shared");
2282
+ var import_mongoose32 = __toESM(require("mongoose"));
2159
2283
 
2160
2284
  // src/mongoose/game/DailyClue.ts
2161
- var import_mongoose28 = __toESM(require("mongoose"));
2285
+ var import_mongoose30 = __toESM(require("mongoose"));
2162
2286
 
2163
2287
  // src/mongoose/game/utils.ts
2164
- var import_mongoose27 = __toESM(require("mongoose"));
2165
- var MongooseSchema22 = import_mongoose27.default.Schema;
2166
- var schemaGameDate = new MongooseSchema22(
2288
+ var import_mongoose29 = __toESM(require("mongoose"));
2289
+ var MongooseSchema24 = import_mongoose29.default.Schema;
2290
+ var schemaGameDate = new MongooseSchema24(
2167
2291
  {
2168
2292
  endDate: { required: true, type: Date },
2169
2293
  startDate: { required: true, type: Date }
@@ -2172,8 +2296,8 @@ var schemaGameDate = new MongooseSchema22(
2172
2296
  );
2173
2297
 
2174
2298
  // src/mongoose/game/DailyClue.ts
2175
- var MongooseSchema23 = import_mongoose28.default.Schema;
2176
- var schemaLetters = new MongooseSchema23(
2299
+ var MongooseSchema25 = import_mongoose30.default.Schema;
2300
+ var schemaLetters = new MongooseSchema25(
2177
2301
  {
2178
2302
  collected: { required: false, type: [String] },
2179
2303
  solutionShuffled: { required: true, type: [String] }
@@ -2181,14 +2305,14 @@ var schemaLetters = new MongooseSchema23(
2181
2305
  },
2182
2306
  { _id: false }
2183
2307
  );
2184
- var schemaDailyClueBaseGame = new MongooseSchema23(
2308
+ var schemaDailyClueBaseGame = new MongooseSchema25(
2185
2309
  {
2186
2310
  gameDate: { required: true, type: schemaGameDate },
2187
2311
  gameSolution: { required: true, type: String }
2188
2312
  },
2189
2313
  { _id: false }
2190
2314
  );
2191
- var schemaDailyClueGameData = new MongooseSchema23(
2315
+ var schemaDailyClueGameData = new MongooseSchema25(
2192
2316
  {
2193
2317
  gameFields: { required: true, type: schemaDailyClueBaseGame },
2194
2318
  lastFoundDate: { default: null, required: false, type: Date },
@@ -2203,9 +2327,9 @@ var schemaDailyClueGameData = new MongooseSchema23(
2203
2327
  );
2204
2328
 
2205
2329
  // src/mongoose/game/PuzzleGame.ts
2206
- var import_mongoose29 = __toESM(require("mongoose"));
2207
- var MongooseSchema24 = import_mongoose29.default.Schema;
2208
- var schemaPuzzleAnswer = new MongooseSchema24(
2330
+ var import_mongoose31 = __toESM(require("mongoose"));
2331
+ var MongooseSchema26 = import_mongoose31.default.Schema;
2332
+ var schemaPuzzleAnswer = new MongooseSchema26(
2209
2333
  {
2210
2334
  answer: { required: true, type: String },
2211
2335
  answerId: { required: true, type: String },
@@ -2213,7 +2337,7 @@ var schemaPuzzleAnswer = new MongooseSchema24(
2213
2337
  },
2214
2338
  { _id: false }
2215
2339
  );
2216
- var schemaPuzzleQuestion = new MongooseSchema24(
2340
+ var schemaPuzzleQuestion = new MongooseSchema26(
2217
2341
  {
2218
2342
  answers: { required: true, type: [schemaPuzzleAnswer] },
2219
2343
  question: { required: true, type: String },
@@ -2221,20 +2345,20 @@ var schemaPuzzleQuestion = new MongooseSchema24(
2221
2345
  },
2222
2346
  { _id: false }
2223
2347
  );
2224
- var schemaPuzzleBaseGame = new MongooseSchema24(
2348
+ var schemaPuzzleBaseGame = new MongooseSchema26(
2225
2349
  {
2226
2350
  questions: { required: true, type: [schemaPuzzleQuestion] }
2227
2351
  },
2228
2352
  { _id: false }
2229
2353
  );
2230
- var schemaPuzzleAnsweredQuestion = new MongooseSchema24(
2354
+ var schemaPuzzleAnsweredQuestion = new MongooseSchema26(
2231
2355
  {
2232
2356
  questionId: { required: true, type: String },
2233
2357
  selectedAnswerId: { required: true, type: String }
2234
2358
  },
2235
2359
  { _id: false }
2236
2360
  );
2237
- var schemaPuzzleGameData = new MongooseSchema24(
2361
+ var schemaPuzzleGameData = new MongooseSchema26(
2238
2362
  {
2239
2363
  answeredQuestions: {
2240
2364
  default: null,
@@ -2249,30 +2373,30 @@ var schemaPuzzleGameData = new MongooseSchema24(
2249
2373
  );
2250
2374
 
2251
2375
  // src/mongoose/game/Game.ts
2252
- var MongooseSchema25 = import_mongoose30.default.Schema;
2376
+ var MongooseSchema27 = import_mongoose32.default.Schema;
2253
2377
  var gameDataSchemas = {
2254
- [import_cluemart_shared20.EnumGameType.DAILY_CLUE]: schemaDailyClueGameData,
2255
- [import_cluemart_shared20.EnumGameType.MINI_QUIZ]: schemaPuzzleGameData,
2256
- [import_cluemart_shared20.EnumGameType.ODD_ONE_OUT]: schemaPuzzleGameData
2378
+ [import_cluemart_shared21.EnumGameType.DAILY_CLUE]: schemaDailyClueGameData,
2379
+ [import_cluemart_shared21.EnumGameType.MINI_QUIZ]: schemaPuzzleGameData,
2380
+ [import_cluemart_shared21.EnumGameType.ODD_ONE_OUT]: schemaPuzzleGameData
2257
2381
  };
2258
2382
  var gameDataDefinition = Object.fromEntries(
2259
- Object.entries(gameDataSchemas).map(([key, schema26]) => [
2383
+ Object.entries(gameDataSchemas).map(([key, schema27]) => [
2260
2384
  key,
2261
- { default: null, required: false, type: schema26 }
2385
+ { default: null, required: false, type: schema27 }
2262
2386
  ])
2263
2387
  );
2264
- var gameHistorySchema = new MongooseSchema25(
2388
+ var gameHistorySchema = new MongooseSchema27(
2265
2389
  {
2266
2390
  createdAt: { required: true, type: Date },
2267
2391
  gameDate: { required: true, type: schemaGameDate },
2268
2392
  gameStatus: {
2269
- enum: Object.values(import_cluemart_shared20.EnumGameStatus),
2393
+ enum: Object.values(import_cluemart_shared21.EnumGameStatus),
2270
2394
  required: true,
2271
2395
  type: String
2272
2396
  },
2273
2397
  gameTitle: { required: true, type: String },
2274
2398
  gameType: {
2275
- enum: Object.values(import_cluemart_shared20.EnumGameType),
2399
+ enum: Object.values(import_cluemart_shared21.EnumGameType),
2276
2400
  required: true,
2277
2401
  type: String
2278
2402
  },
@@ -2281,14 +2405,14 @@ var gameHistorySchema = new MongooseSchema25(
2281
2405
  },
2282
2406
  { _id: false }
2283
2407
  );
2284
- var gameTypeSchema = new MongooseSchema25(
2408
+ var gameTypeSchema = new MongooseSchema27(
2285
2409
  {
2286
2410
  active: { default: true, required: true, type: Boolean },
2287
2411
  gameData: gameDataDefinition,
2288
2412
  gameHistory: { default: [], required: true, type: [gameHistorySchema] },
2289
2413
  gameTitle: { required: true, type: String },
2290
2414
  gameType: {
2291
- enum: Object.values(import_cluemart_shared20.EnumGameType),
2415
+ enum: Object.values(import_cluemart_shared21.EnumGameType),
2292
2416
  required: true,
2293
2417
  type: String
2294
2418
  },
@@ -2299,7 +2423,7 @@ var gameTypeSchema = new MongooseSchema25(
2299
2423
  },
2300
2424
  { timestamps: true }
2301
2425
  );
2302
- var schema22 = new MongooseSchema25(
2426
+ var schema23 = new MongooseSchema27(
2303
2427
  {
2304
2428
  active: { default: false, required: true, type: Boolean },
2305
2429
  deletedAt: { default: null, required: false, type: Date },
@@ -2312,12 +2436,12 @@ var schema22 = new MongooseSchema25(
2312
2436
  },
2313
2437
  { timestamps: true }
2314
2438
  );
2315
- var GameModel = import_mongoose30.default.models.Game || import_mongoose30.default.model("Game", schema22);
2439
+ var GameModel = import_mongoose32.default.models.Game || import_mongoose32.default.model("Game", schema23);
2316
2440
 
2317
2441
  // src/mongoose/School.ts
2318
- var import_mongoose31 = __toESM(require("mongoose"));
2319
- var MongooseSchema26 = import_mongoose31.default.Schema;
2320
- var campaignsSchema = new MongooseSchema26(
2442
+ var import_mongoose33 = __toESM(require("mongoose"));
2443
+ var MongooseSchema28 = import_mongoose33.default.Schema;
2444
+ var campaignsSchema = new MongooseSchema28(
2321
2445
  {
2322
2446
  endDate: { required: true, type: Date },
2323
2447
  name: { required: true, type: String },
@@ -2325,7 +2449,7 @@ var campaignsSchema = new MongooseSchema26(
2325
2449
  },
2326
2450
  { _id: false }
2327
2451
  );
2328
- var schema23 = new MongooseSchema26(
2452
+ var schema24 = new MongooseSchema28(
2329
2453
  {
2330
2454
  // New schools are active by default
2331
2455
  active: { default: false, required: true, type: Boolean },
@@ -2352,26 +2476,26 @@ var schema23 = new MongooseSchema26(
2352
2476
  },
2353
2477
  { timestamps: true }
2354
2478
  );
2355
- schema23.index(
2479
+ schema24.index(
2356
2480
  { schoolCode: 1 },
2357
2481
  {
2358
2482
  partialFilterExpression: { active: true, deletedAt: null },
2359
2483
  unique: true
2360
2484
  }
2361
2485
  );
2362
- var SchoolModel = import_mongoose31.default.models.School || import_mongoose31.default.model("School", schema23);
2486
+ var SchoolModel = import_mongoose33.default.models.School || import_mongoose33.default.model("School", schema24);
2363
2487
 
2364
2488
  // src/mongoose/Affiliate.ts
2365
- var import_cluemart_shared21 = require("@timardex/cluemart-shared");
2366
- var import_mongoose32 = __toESM(require("mongoose"));
2367
- var MongooseSchema27 = import_mongoose32.default.Schema;
2368
- var affiliateRewardSchema = new MongooseSchema27(
2489
+ var import_cluemart_shared22 = require("@timardex/cluemart-shared");
2490
+ var import_mongoose34 = __toESM(require("mongoose"));
2491
+ var MongooseSchema29 = import_mongoose34.default.Schema;
2492
+ var affiliateRewardSchema = new MongooseSchema29(
2369
2493
  {
2370
2494
  createdAt: { required: true, type: Date },
2371
2495
  redeemedAt: { default: null, required: false, type: Date },
2372
2496
  rewardDescription: { required: true, type: String },
2373
2497
  rewardType: {
2374
- enum: Object.values(import_cluemart_shared21.EnumAffiliateRewardType),
2498
+ enum: Object.values(import_cluemart_shared22.EnumAffiliateRewardType),
2375
2499
  required: true,
2376
2500
  type: String
2377
2501
  },
@@ -2379,13 +2503,13 @@ var affiliateRewardSchema = new MongooseSchema27(
2379
2503
  },
2380
2504
  { _id: false }
2381
2505
  );
2382
- var affiliateResourceSchema = new MongooseSchema27(
2506
+ var affiliateResourceSchema = new MongooseSchema29(
2383
2507
  {
2384
2508
  resourceActive: { default: true, required: true, type: Boolean },
2385
2509
  resourceDeletedAt: { default: null, required: false, type: Date },
2386
2510
  resourceId: {
2387
2511
  required: true,
2388
- type: import_mongoose32.default.Schema.Types.ObjectId
2512
+ type: import_mongoose34.default.Schema.Types.ObjectId
2389
2513
  },
2390
2514
  resourceName: { required: true, type: String },
2391
2515
  resourceOwner: {
@@ -2393,7 +2517,7 @@ var affiliateResourceSchema = new MongooseSchema27(
2393
2517
  type: OwnerTypeSchema
2394
2518
  },
2395
2519
  resourceType: {
2396
- enum: Object.values(import_cluemart_shared21.EnumResourceType),
2520
+ enum: Object.values(import_cluemart_shared22.EnumResourceType),
2397
2521
  required: true,
2398
2522
  type: String
2399
2523
  },
@@ -2405,20 +2529,20 @@ var affiliateResourceSchema = new MongooseSchema27(
2405
2529
  },
2406
2530
  { _id: false }
2407
2531
  );
2408
- var affiliateContactDetailsSchema = new MongooseSchema27(
2532
+ var affiliateContactDetailsSchema = new MongooseSchema29(
2409
2533
  {
2410
2534
  mobilePhone: { required: true, type: String }
2411
2535
  },
2412
2536
  { _id: false }
2413
2537
  );
2414
- var affiliateBankAccountDetailsSchema = new MongooseSchema27(
2538
+ var affiliateBankAccountDetailsSchema = new MongooseSchema29(
2415
2539
  {
2416
2540
  accountHolderName: { required: true, type: String },
2417
2541
  accountNumber: { required: true, type: String }
2418
2542
  },
2419
2543
  { _id: false }
2420
2544
  );
2421
- var affiliateDetailsSchema = new MongooseSchema27(
2545
+ var affiliateDetailsSchema = new MongooseSchema29(
2422
2546
  {
2423
2547
  bankAccountDetails: {
2424
2548
  required: true,
@@ -2431,7 +2555,7 @@ var affiliateDetailsSchema = new MongooseSchema27(
2431
2555
  lastName: { required: true, type: String },
2432
2556
  location: { required: true, type: locationsSchema },
2433
2557
  participantType: {
2434
- enum: Object.values(import_cluemart_shared21.EnumAffiliateParticipantType),
2558
+ enum: Object.values(import_cluemart_shared22.EnumAffiliateParticipantType),
2435
2559
  required: true,
2436
2560
  type: String
2437
2561
  },
@@ -2440,7 +2564,7 @@ var affiliateDetailsSchema = new MongooseSchema27(
2440
2564
  },
2441
2565
  { _id: false }
2442
2566
  );
2443
- var redeemHistorySchema = new MongooseSchema27(
2567
+ var redeemHistorySchema = new MongooseSchema29(
2444
2568
  {
2445
2569
  paidAt: { default: null, required: false, type: Date },
2446
2570
  redeemedAt: { required: true, type: Date },
@@ -2448,7 +2572,7 @@ var redeemHistorySchema = new MongooseSchema27(
2448
2572
  },
2449
2573
  { _id: false }
2450
2574
  );
2451
- var schema24 = new MongooseSchema27(
2575
+ var schema25 = new MongooseSchema29(
2452
2576
  {
2453
2577
  active: { default: false, required: true, type: Boolean },
2454
2578
  affiliateBonusRewards: {
@@ -2478,26 +2602,26 @@ var schema24 = new MongooseSchema27(
2478
2602
  },
2479
2603
  { timestamps: true }
2480
2604
  );
2481
- schema24.index(
2605
+ schema25.index(
2482
2606
  { affiliateCode: 1 },
2483
2607
  {
2484
2608
  partialFilterExpression: { active: true, deletedAt: null },
2485
2609
  unique: true
2486
2610
  }
2487
2611
  );
2488
- var AffiliateModel = import_mongoose32.default.models.Affiliate || import_mongoose32.default.model("Affiliate", schema24);
2612
+ var AffiliateModel = import_mongoose34.default.models.Affiliate || import_mongoose34.default.model("Affiliate", schema25);
2489
2613
 
2490
2614
  // src/mongoose/Coupon.ts
2491
- var import_cluemart_shared22 = require("@timardex/cluemart-shared");
2492
- var import_mongoose33 = __toESM(require("mongoose"));
2493
- var MongooseSchema28 = import_mongoose33.default.Schema;
2494
- var couponOptionSchema = new MongooseSchema28(
2615
+ var import_cluemart_shared23 = require("@timardex/cluemart-shared");
2616
+ var import_mongoose35 = __toESM(require("mongoose"));
2617
+ var MongooseSchema30 = import_mongoose35.default.Schema;
2618
+ var couponOptionSchema = new MongooseSchema30(
2495
2619
  {
2496
2620
  buy: { required: false, type: Number },
2497
2621
  get: { required: false, type: Number },
2498
2622
  maxRewardCount: { required: false, type: Number },
2499
2623
  type: {
2500
- enum: Object.values(import_cluemart_shared22.EnumCouponQualificationType),
2624
+ enum: Object.values(import_cluemart_shared23.EnumCouponQualificationType),
2501
2625
  required: true,
2502
2626
  type: String
2503
2627
  },
@@ -2506,29 +2630,29 @@ var couponOptionSchema = new MongooseSchema28(
2506
2630
  },
2507
2631
  { _id: false }
2508
2632
  );
2509
- var couponVendorProductSchema = new MongooseSchema28(
2633
+ var couponVendorProductSchema = new MongooseSchema30(
2510
2634
  {
2511
2635
  couponId: {
2512
2636
  required: true,
2513
- type: import_mongoose33.default.Schema.Types.ObjectId
2637
+ type: import_mongoose35.default.Schema.Types.ObjectId
2514
2638
  },
2515
2639
  productId: {
2516
2640
  required: true,
2517
- type: import_mongoose33.default.Schema.Types.ObjectId
2641
+ type: import_mongoose35.default.Schema.Types.ObjectId
2518
2642
  },
2519
2643
  vendorCouponId: {
2520
2644
  required: false,
2521
- type: import_mongoose33.default.Schema.Types.ObjectId
2645
+ type: import_mongoose35.default.Schema.Types.ObjectId
2522
2646
  },
2523
2647
  vendorId: {
2524
2648
  ref: "Vendor",
2525
2649
  required: true,
2526
- type: import_mongoose33.default.Schema.Types.ObjectId
2650
+ type: import_mongoose35.default.Schema.Types.ObjectId
2527
2651
  }
2528
2652
  },
2529
2653
  { _id: false }
2530
2654
  );
2531
- var couponCodeSchema = new MongooseSchema28(
2655
+ var couponCodeSchema = new MongooseSchema30(
2532
2656
  {
2533
2657
  code: { required: true, type: String },
2534
2658
  qrCode: { required: true, type: ResourceImageTypeSchema },
@@ -2536,7 +2660,7 @@ var couponCodeSchema = new MongooseSchema28(
2536
2660
  },
2537
2661
  { _id: false }
2538
2662
  );
2539
- var couponParticipantUserSchema = new MongooseSchema28(
2663
+ var couponParticipantUserSchema = new MongooseSchema30(
2540
2664
  {
2541
2665
  couponCollectedCount: { default: 0, required: true, type: Number },
2542
2666
  couponCycleRedeemed: { default: false, required: true, type: Boolean },
@@ -2545,12 +2669,12 @@ var couponParticipantUserSchema = new MongooseSchema28(
2545
2669
  userId: {
2546
2670
  ref: "User",
2547
2671
  required: true,
2548
- type: import_mongoose33.default.Schema.Types.ObjectId
2672
+ type: import_mongoose35.default.Schema.Types.ObjectId
2549
2673
  }
2550
2674
  },
2551
2675
  { timestamps: true }
2552
2676
  );
2553
- var couponDataSchema = new MongooseSchema28(
2677
+ var couponDataSchema = new MongooseSchema30(
2554
2678
  {
2555
2679
  active: { default: true, required: true, type: Boolean },
2556
2680
  couponCode: { required: false, type: couponCodeSchema },
@@ -2569,7 +2693,7 @@ var couponDataSchema = new MongooseSchema28(
2569
2693
  },
2570
2694
  resourceId: { required: true, type: String },
2571
2695
  resourceType: {
2572
- enum: Object.values(import_cluemart_shared22.EnumResourceType),
2696
+ enum: Object.values(import_cluemart_shared23.EnumResourceType),
2573
2697
  required: true,
2574
2698
  type: String
2575
2699
  },
@@ -2577,7 +2701,7 @@ var couponDataSchema = new MongooseSchema28(
2577
2701
  },
2578
2702
  { timestamps: true }
2579
2703
  );
2580
- var schema25 = new MongooseSchema28(
2704
+ var schema26 = new MongooseSchema30(
2581
2705
  {
2582
2706
  active: { default: true, required: true, type: Boolean },
2583
2707
  couponData: { default: [], required: false, type: [couponDataSchema] },
@@ -2589,62 +2713,62 @@ var schema25 = new MongooseSchema28(
2589
2713
  },
2590
2714
  { timestamps: true }
2591
2715
  );
2592
- schema25.index({ active: 1, deletedAt: 1, "owner.userId": 1 });
2593
- schema25.index({ "couponData.participantUsers.userId": 1 });
2594
- var CouponModel = import_mongoose33.default.models.Coupon || import_mongoose33.default.model("Coupon", schema25);
2716
+ schema26.index({ active: 1, deletedAt: 1, "owner.userId": 1 });
2717
+ schema26.index({ "couponData.participantUsers.userId": 1 });
2718
+ var CouponModel = import_mongoose35.default.models.Coupon || import_mongoose35.default.model("Coupon", schema26);
2595
2719
 
2596
2720
  // src/mongoose/Impersonation.ts
2597
- var import_cluemart_shared23 = require("@timardex/cluemart-shared");
2598
- var import_mongoose34 = __toESM(require("mongoose"));
2599
- var MongooseSchema29 = import_mongoose34.default.Schema;
2600
- var impersonationSessionSchema = new MongooseSchema29(
2721
+ var import_cluemart_shared24 = require("@timardex/cluemart-shared");
2722
+ var import_mongoose36 = __toESM(require("mongoose"));
2723
+ var MongooseSchema31 = import_mongoose36.default.Schema;
2724
+ var impersonationSessionSchema = new MongooseSchema31(
2601
2725
  {
2602
2726
  expiresAt: { expires: 0, required: true, type: Date },
2603
2727
  impersonatedUserId: {
2604
2728
  index: true,
2605
2729
  ref: "User",
2606
2730
  required: true,
2607
- type: import_mongoose34.default.Schema.Types.ObjectId
2731
+ type: import_mongoose36.default.Schema.Types.ObjectId
2608
2732
  },
2609
2733
  impersonatorUserId: {
2610
2734
  index: true,
2611
2735
  ref: "User",
2612
2736
  required: true,
2613
- type: import_mongoose34.default.Schema.Types.ObjectId
2737
+ type: import_mongoose36.default.Schema.Types.ObjectId
2614
2738
  },
2615
2739
  refreshToken: { required: true, type: String }
2616
2740
  },
2617
2741
  { timestamps: true }
2618
2742
  );
2619
- var ImpersonationSessionModel = import_mongoose34.default.models.ImpersonationSession || import_mongoose34.default.model(
2743
+ var ImpersonationSessionModel = import_mongoose36.default.models.ImpersonationSession || import_mongoose36.default.model(
2620
2744
  "ImpersonationSession",
2621
2745
  impersonationSessionSchema
2622
2746
  );
2623
- var impersonationAuditSchema = new MongooseSchema29(
2747
+ var impersonationAuditSchema = new MongooseSchema31(
2624
2748
  {
2625
2749
  action: { enum: ["start", "end"], required: true, type: String },
2626
2750
  endReason: { type: String },
2627
2751
  impersonatedUserId: {
2628
2752
  ref: "User",
2629
2753
  required: true,
2630
- type: import_mongoose34.default.Schema.Types.ObjectId
2754
+ type: import_mongoose36.default.Schema.Types.ObjectId
2631
2755
  },
2632
2756
  impersonatorUserId: {
2633
2757
  ref: "User",
2634
2758
  required: true,
2635
- type: import_mongoose34.default.Schema.Types.ObjectId
2759
+ type: import_mongoose36.default.Schema.Types.ObjectId
2636
2760
  },
2637
- resourceId: { type: import_mongoose34.default.Schema.Types.ObjectId },
2638
- resourceType: { enum: Object.values(import_cluemart_shared23.EnumResourceType), type: String },
2761
+ resourceId: { type: import_mongoose36.default.Schema.Types.ObjectId },
2762
+ resourceType: { enum: Object.values(import_cluemart_shared24.EnumResourceType), type: String },
2639
2763
  sessionId: {
2640
2764
  ref: "ImpersonationSession",
2641
2765
  required: true,
2642
- type: import_mongoose34.default.Schema.Types.ObjectId
2766
+ type: import_mongoose36.default.Schema.Types.ObjectId
2643
2767
  }
2644
2768
  },
2645
2769
  { timestamps: true }
2646
2770
  );
2647
- var ImpersonationAuditModel = import_mongoose34.default.models.ImpersonationAudit || import_mongoose34.default.model(
2771
+ var ImpersonationAuditModel = import_mongoose36.default.models.ImpersonationAudit || import_mongoose36.default.model(
2648
2772
  "ImpersonationAudit",
2649
2773
  impersonationAuditSchema
2650
2774
  );
@@ -2665,7 +2789,7 @@ async function activeAffiliateCodeExists(affiliateCode) {
2665
2789
  }
2666
2790
 
2667
2791
  // src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
2668
- var import_cluemart_shared25 = require("@timardex/cluemart-shared");
2792
+ var import_cluemart_shared26 = require("@timardex/cluemart-shared");
2669
2793
  var import_utils3 = require("@timardex/cluemart-shared/utils");
2670
2794
 
2671
2795
  // src/service/saveNotificationsInDb.ts
@@ -2800,7 +2924,7 @@ async function sendPushNotifications({
2800
2924
  }
2801
2925
 
2802
2926
  // src/service/affiliate/vendorSubscriptionRewards.ts
2803
- var import_cluemart_shared24 = require("@timardex/cluemart-shared");
2927
+ var import_cluemart_shared25 = require("@timardex/cluemart-shared");
2804
2928
  var import_dayjs = __toESM(require("dayjs"));
2805
2929
  var import_timezone = __toESM(require("dayjs/plugin/timezone"));
2806
2930
  var import_utc = __toESM(require("dayjs/plugin/utc"));
@@ -2858,17 +2982,17 @@ async function getPayingEventStripeSubscriptionPlan(userId, now = /* @__PURE__ *
2858
2982
  // src/service/affiliate/vendorSubscriptionRewards.ts
2859
2983
  import_dayjs.default.extend(import_utc.default);
2860
2984
  import_dayjs.default.extend(import_timezone.default);
2861
- var SUBSCRIPTION_REWARD_TIMEZONE = import_cluemart_shared24.NZ_TZ;
2985
+ var SUBSCRIPTION_REWARD_TIMEZONE = import_cluemart_shared25.NZ_TZ;
2862
2986
  async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
2863
2987
  const { hasSubscription, validTypes } = await getVendorStripeSubscriptionPlanForRewards(userId, now);
2864
- if (validTypes.has(import_cluemart_shared24.EnumUserLicence.PRO_VENDOR) || validTypes.has(import_cluemart_shared24.EnumUserLicence.PRO_PLUS_VENDOR)) {
2988
+ if (validTypes.has(import_cluemart_shared25.EnumUserLicence.PRO_VENDOR) || validTypes.has(import_cluemart_shared25.EnumUserLicence.PRO_PLUS_VENDOR)) {
2865
2989
  if (hasSubscription) {
2866
- return import_cluemart_shared24.EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
2990
+ return import_cluemart_shared25.EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
2867
2991
  }
2868
- return import_cluemart_shared24.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2992
+ return import_cluemart_shared25.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2869
2993
  }
2870
- if (validTypes.has(import_cluemart_shared24.EnumUserLicence.STANDARD_VENDOR)) {
2871
- return import_cluemart_shared24.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2994
+ if (validTypes.has(import_cluemart_shared25.EnumUserLicence.STANDARD_VENDOR)) {
2995
+ return import_cluemart_shared25.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2872
2996
  }
2873
2997
  return null;
2874
2998
  }
@@ -2880,7 +3004,7 @@ function getSubscriptionRewardPeriodBounds(now = /* @__PURE__ */ new Date()) {
2880
3004
 
2881
3005
  // src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
2882
3006
  function isEligibleVendorResource(resource) {
2883
- return resource.resourceType === import_cluemart_shared25.EnumResourceType.VENDOR && resource.resourceActive === true && resource.resourceDeletedAt == null;
3007
+ return resource.resourceType === import_cluemart_shared26.EnumResourceType.VENDOR && resource.resourceActive === true && resource.resourceDeletedAt == null;
2884
3008
  }
2885
3009
  async function findAffiliatesWithActiveVendorReferrals() {
2886
3010
  return await AffiliateModel.find({
@@ -2889,7 +3013,7 @@ async function findAffiliatesWithActiveVendorReferrals() {
2889
3013
  $elemMatch: {
2890
3014
  resourceActive: true,
2891
3015
  resourceDeletedAt: null,
2892
- resourceType: import_cluemart_shared25.EnumResourceType.VENDOR
3016
+ resourceType: import_cluemart_shared26.EnumResourceType.VENDOR
2893
3017
  }
2894
3018
  },
2895
3019
  deletedAt: null
@@ -2923,11 +3047,11 @@ async function notifyAffiliateOwnerOfSubscriptionReward({
2923
3047
  data: {
2924
3048
  resourceId: String(affiliateId),
2925
3049
  resourceName: resourceNames.join(", "),
2926
- resourceType: import_cluemart_shared25.EnumNotificationResourceType.AFFILIATE_REWARD_RECEIVED
3050
+ resourceType: import_cluemart_shared26.EnumNotificationResourceType.AFFILIATE_REWARD_RECEIVED
2927
3051
  },
2928
3052
  message,
2929
3053
  title: "Affiliate points earned",
2930
- type: import_cluemart_shared25.EnumNotificationType.SYSTEM,
3054
+ type: import_cluemart_shared26.EnumNotificationType.SYSTEM,
2931
3055
  userIds: [affiliateOwnerUserId]
2932
3056
  };
2933
3057
  try {
@@ -2956,7 +3080,7 @@ async function tryAwardSubscriptionReward({
2956
3080
  resourceActive: true,
2957
3081
  resourceDeletedAt: null,
2958
3082
  resourceId: resource.resourceId,
2959
- resourceType: import_cluemart_shared25.EnumResourceType.VENDOR,
3083
+ resourceType: import_cluemart_shared26.EnumResourceType.VENDOR,
2960
3084
  rewards: {
2961
3085
  $not: {
2962
3086
  $elemMatch: {
@@ -3077,7 +3201,7 @@ function normalizeAffiliatePromoCodes(promoCodes) {
3077
3201
  }
3078
3202
 
3079
3203
  // src/service/database.ts
3080
- var import_mongoose38 = __toESM(require("mongoose"));
3204
+ var import_mongoose40 = __toESM(require("mongoose"));
3081
3205
  var connectToDatabase = async ({
3082
3206
  appName,
3083
3207
  dbName,
@@ -3090,7 +3214,7 @@ var connectToDatabase = async ({
3090
3214
  // Fallback to MongoDB Atlas connection string
3091
3215
  `mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
3092
3216
  );
3093
- await import_mongoose38.default.connect(mongoUri);
3217
+ await import_mongoose40.default.connect(mongoUri);
3094
3218
  const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
3095
3219
  console.log(
3096
3220
  `${connectionType} connected from server/src/service/database.ts`
@@ -3103,7 +3227,7 @@ var connectToDatabase = async ({
3103
3227
 
3104
3228
  // src/types/index.ts
3105
3229
  var import_express = __toESM(require("express"));
3106
- var import_mongoose39 = __toESM(require("mongoose"));
3230
+ var import_mongoose41 = __toESM(require("mongoose"));
3107
3231
 
3108
3232
  // src/service/notifyUsers.ts
3109
3233
  async function publishNotificationEvents(userId, pubsub) {
@@ -3151,9 +3275,9 @@ async function notifyUsers({
3151
3275
  }
3152
3276
 
3153
3277
  // src/service/updateAdStatus.ts
3154
- var import_cluemart_shared26 = require("@timardex/cluemart-shared");
3278
+ var import_cluemart_shared27 = require("@timardex/cluemart-shared");
3155
3279
  async function updateAdStatuses() {
3156
- const now = (0, import_cluemart_shared26.nzDayKey)();
3280
+ const now = (0, import_cluemart_shared27.nzDayKey)();
3157
3281
  const invalidResult = await AdModel.updateMany(
3158
3282
  {
3159
3283
  $or: [
@@ -3161,50 +3285,50 @@ async function updateAdStatuses() {
3161
3285
  { end: { $exists: false } },
3162
3286
  { $expr: { $gt: ["$start", "$end"] } }
3163
3287
  ],
3164
- status: { $ne: import_cluemart_shared26.EnumAdStatus.PAUSED }
3288
+ status: { $ne: import_cluemart_shared27.EnumAdStatus.PAUSED }
3165
3289
  },
3166
- { $set: { status: import_cluemart_shared26.EnumAdStatus.PAUSED } }
3290
+ { $set: { status: import_cluemart_shared27.EnumAdStatus.PAUSED } }
3167
3291
  );
3168
3292
  const expiredResult = await AdModel.updateMany(
3169
- { end: { $lte: now }, status: { $ne: import_cluemart_shared26.EnumAdStatus.EXPIRED } },
3170
- { $set: { status: import_cluemart_shared26.EnumAdStatus.EXPIRED } }
3293
+ { end: { $lte: now }, status: { $ne: import_cluemart_shared27.EnumAdStatus.EXPIRED } },
3294
+ { $set: { status: import_cluemart_shared27.EnumAdStatus.EXPIRED } }
3171
3295
  );
3172
3296
  const eligibleBooking = {
3173
3297
  $or: [
3174
3298
  { bookingKind: { $exists: false } },
3175
3299
  { bookingKind: null },
3176
3300
  {
3177
- approvalStatus: import_cluemart_shared26.EnumAdApprovalStatus.APPROVED,
3178
- bookingKind: import_cluemart_shared26.EnumAdBookingSlotKind.RESERVED
3301
+ approvalStatus: import_cluemart_shared27.EnumAdApprovalStatus.APPROVED,
3302
+ bookingKind: import_cluemart_shared27.EnumAdBookingSlotKind.RESERVED
3179
3303
  },
3180
3304
  {
3181
- approvalStatus: import_cluemart_shared26.EnumAdApprovalStatus.APPROVED,
3182
- bookingKind: import_cluemart_shared26.EnumAdBookingSlotKind.PAID,
3183
- paymentStatus: import_cluemart_shared26.EnumAdPaymentStatus.PAID
3305
+ approvalStatus: import_cluemart_shared27.EnumAdApprovalStatus.APPROVED,
3306
+ bookingKind: import_cluemart_shared27.EnumAdBookingSlotKind.PAID,
3307
+ paymentStatus: import_cluemart_shared27.EnumAdPaymentStatus.PAID
3184
3308
  }
3185
3309
  ]
3186
3310
  };
3187
3311
  const awaitingApprovalResult = await AdModel.updateMany(
3188
3312
  {
3189
3313
  $nor: eligibleBooking.$or,
3190
- bookingKind: { $in: Object.values(import_cluemart_shared26.EnumAdBookingSlotKind) },
3314
+ bookingKind: { $in: Object.values(import_cluemart_shared27.EnumAdBookingSlotKind) },
3191
3315
  end: { $gt: now },
3192
- status: import_cluemart_shared26.EnumAdStatus.ACTIVE
3316
+ status: import_cluemart_shared27.EnumAdStatus.ACTIVE
3193
3317
  },
3194
- { $set: { status: import_cluemart_shared26.EnumAdStatus.PAUSED } }
3318
+ { $set: { status: import_cluemart_shared27.EnumAdStatus.PAUSED } }
3195
3319
  );
3196
3320
  const activeResult = await AdModel.updateMany(
3197
3321
  {
3198
3322
  end: { $gt: now },
3199
3323
  start: { $lte: now },
3200
- status: { $ne: import_cluemart_shared26.EnumAdStatus.ACTIVE },
3324
+ status: { $ne: import_cluemart_shared27.EnumAdStatus.ACTIVE },
3201
3325
  ...eligibleBooking
3202
3326
  },
3203
- { $set: { status: import_cluemart_shared26.EnumAdStatus.ACTIVE } }
3327
+ { $set: { status: import_cluemart_shared27.EnumAdStatus.ACTIVE } }
3204
3328
  );
3205
3329
  const pausedResult = await AdModel.updateMany(
3206
- { start: { $gt: now }, status: { $ne: import_cluemart_shared26.EnumAdStatus.PAUSED } },
3207
- { $set: { status: import_cluemart_shared26.EnumAdStatus.PAUSED } }
3330
+ { start: { $gt: now }, status: { $ne: import_cluemart_shared27.EnumAdStatus.PAUSED } },
3331
+ { $set: { status: import_cluemart_shared27.EnumAdStatus.PAUSED } }
3208
3332
  );
3209
3333
  console.log(
3210
3334
  `\u2705 Ad statuses updated: invalid=${invalidResult.modifiedCount}, expired=${expiredResult.modifiedCount}, awaitingApproval=${awaitingApprovalResult.modifiedCount}, active=${activeResult.modifiedCount}, paused=${pausedResult.modifiedCount}`
@@ -3212,15 +3336,15 @@ async function updateAdStatuses() {
3212
3336
  }
3213
3337
 
3214
3338
  // src/service/objectIdToString.ts
3215
- var import_mongoose41 = __toESM(require("mongoose"));
3339
+ var import_mongoose43 = __toESM(require("mongoose"));
3216
3340
  function isValidObjectId(value) {
3217
- return import_mongoose41.default.Types.ObjectId.isValid(value);
3341
+ return import_mongoose43.default.Types.ObjectId.isValid(value);
3218
3342
  }
3219
3343
  function convertObjectIdsToStrings(obj) {
3220
3344
  if (obj === null || obj === void 0) {
3221
3345
  return obj;
3222
3346
  }
3223
- if (obj instanceof import_mongoose41.default.Types.ObjectId) {
3347
+ if (obj instanceof import_mongoose43.default.Types.ObjectId) {
3224
3348
  return obj.toString();
3225
3349
  }
3226
3350
  if (obj instanceof Date) {
@@ -3414,19 +3538,19 @@ function buildUserPointEntryRemovalPipeline(pointType, sourceId) {
3414
3538
  }
3415
3539
 
3416
3540
  // src/service/event/updateAllEventDateTimeStatuses.ts
3417
- var import_cluemart_shared28 = require("@timardex/cluemart-shared");
3541
+ var import_cluemart_shared29 = require("@timardex/cluemart-shared");
3418
3542
  var import_dayjs4 = __toESM(require("dayjs"));
3419
3543
 
3420
3544
  // src/service/event/archiveEndedEventDates.ts
3421
- var import_cluemart_shared27 = require("@timardex/cluemart-shared");
3545
+ var import_cluemart_shared28 = require("@timardex/cluemart-shared");
3422
3546
  var import_dayjs3 = __toESM(require("dayjs"));
3423
3547
  var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
3424
3548
  import_dayjs3.default.extend(import_customParseFormat.default);
3425
3549
  var ARCHIVED_STATUSES = /* @__PURE__ */ new Set([
3426
- import_cluemart_shared27.EnumEventDateStatus.ENDED
3550
+ import_cluemart_shared28.EnumEventDateStatus.ENDED
3427
3551
  ]);
3428
3552
  var DISCARDED_STATUSES = /* @__PURE__ */ new Set([
3429
- import_cluemart_shared27.EnumEventDateStatus.INVALID
3553
+ import_cluemart_shared28.EnumEventDateStatus.INVALID
3430
3554
  ]);
3431
3555
  function splitEventDatesForArchive(dateTime) {
3432
3556
  return {
@@ -3449,12 +3573,12 @@ function dedupeArchivedSlotsByStartDateTime(slots) {
3449
3573
  });
3450
3574
  }
3451
3575
  function isPastCanceledEventDate(slot, now) {
3452
- if (slot.dateStatus !== import_cluemart_shared27.EnumEventDateStatus.CANCELED) {
3576
+ if (slot.dateStatus !== import_cluemart_shared28.EnumEventDateStatus.CANCELED) {
3453
3577
  return false;
3454
3578
  }
3455
3579
  const endDateTime = (0, import_dayjs3.default)(
3456
3580
  `${slot.endDate} ${slot.endTime}`,
3457
- `${import_cluemart_shared27.dateFormat} ${import_cluemart_shared27.timeFormat}`,
3581
+ `${import_cluemart_shared28.dateFormat} ${import_cluemart_shared28.timeFormat}`,
3458
3582
  true
3459
3583
  );
3460
3584
  return endDateTime.isValid() && endDateTime.isBefore(now);
@@ -3500,7 +3624,7 @@ async function updateModelDateTimeStatuses(model, now) {
3500
3624
  try {
3501
3625
  for await (const doc of cursor) {
3502
3626
  const dateTime = doc.dateTime.map(
3503
- (slot) => (0, import_cluemart_shared28.updateSingleDateTimeStatus)(slot, now)
3627
+ (slot) => (0, import_cluemart_shared29.updateSingleDateTimeStatus)(slot, now)
3504
3628
  );
3505
3629
  if (!hasDateTimeStatusChanges(doc.dateTime, dateTime)) {
3506
3630
  continue;
@@ -3524,9 +3648,9 @@ async function updateModelDateTimeStatuses(model, now) {
3524
3648
  var ARCHIVABLE_EVENT_FILTER = {
3525
3649
  "dateTime.dateStatus": {
3526
3650
  $in: [
3527
- import_cluemart_shared28.EnumEventDateStatus.ENDED,
3528
- import_cluemart_shared28.EnumEventDateStatus.INVALID,
3529
- import_cluemart_shared28.EnumEventDateStatus.CANCELED
3651
+ import_cluemart_shared29.EnumEventDateStatus.ENDED,
3652
+ import_cluemart_shared29.EnumEventDateStatus.INVALID,
3653
+ import_cluemart_shared29.EnumEventDateStatus.CANCELED
3530
3654
  ]
3531
3655
  },
3532
3656
  deletedAt: null
@@ -3551,7 +3675,7 @@ async function archiveEndedAndDiscardInvalidEventDates(now) {
3551
3675
  try {
3552
3676
  for await (const doc of cursor) {
3553
3677
  const updated = doc.dateTime.map(
3554
- (slot) => (0, import_cluemart_shared28.updateSingleDateTimeStatus)(slot, now)
3678
+ (slot) => (0, import_cluemart_shared29.updateSingleDateTimeStatus)(slot, now)
3555
3679
  );
3556
3680
  const { archive, discard } = splitEventDatesForArchive(updated);
3557
3681
  const pastCanceled = updated.filter(
@@ -3575,13 +3699,13 @@ async function archiveEndedAndDiscardInvalidEventDates(now) {
3575
3699
  if (archive.length > 0 || discard.length > 0) {
3576
3700
  pullConditions.push({
3577
3701
  dateStatus: {
3578
- $in: [import_cluemart_shared28.EnumEventDateStatus.ENDED, import_cluemart_shared28.EnumEventDateStatus.INVALID]
3702
+ $in: [import_cluemart_shared29.EnumEventDateStatus.ENDED, import_cluemart_shared29.EnumEventDateStatus.INVALID]
3579
3703
  }
3580
3704
  });
3581
3705
  }
3582
3706
  for (const slot of pastCanceled) {
3583
3707
  pullConditions.push({
3584
- dateStatus: import_cluemart_shared28.EnumEventDateStatus.CANCELED,
3708
+ dateStatus: import_cluemart_shared29.EnumEventDateStatus.CANCELED,
3585
3709
  startDate: slot.startDate,
3586
3710
  startTime: slot.startTime
3587
3711
  });
@@ -3623,9 +3747,9 @@ async function cleanEventInfoDates(now) {
3623
3747
  try {
3624
3748
  for await (const doc of cursor) {
3625
3749
  const updated = doc.dateTime.map(
3626
- (slot) => (0, import_cluemart_shared28.updateSingleDateTimeStatus)(slot, now)
3750
+ (slot) => (0, import_cluemart_shared29.updateSingleDateTimeStatus)(slot, now)
3627
3751
  );
3628
- const kept = (0, import_cluemart_shared28.filterDatesByFutureStatus)(updated);
3752
+ const kept = (0, import_cluemart_shared29.filterDatesByFutureStatus)(updated);
3629
3753
  if (kept.length === updated.length) {
3630
3754
  continue;
3631
3755
  }
@@ -3648,15 +3772,19 @@ async function cleanEventInfoDates(now) {
3648
3772
  }
3649
3773
  async function updateAllEventDateTimeStatuses() {
3650
3774
  const now = (0, import_dayjs4.default)();
3651
- const [eventCount, marketCount] = await Promise.all([
3775
+ const [eventCount, marketCount, aiMarketCount] = await Promise.all([
3652
3776
  updateModelDateTimeStatuses(EventModel, now),
3653
3777
  updateModelDateTimeStatuses(
3654
3778
  GoogleImportedMarketModel,
3655
3779
  now
3780
+ ),
3781
+ updateModelDateTimeStatuses(
3782
+ AiImportedMarketModel,
3783
+ now
3656
3784
  )
3657
3785
  ]);
3658
3786
  console.log(
3659
- `\u2705 Event dateTime statuses updated: events=${eventCount} changed, google imported markets=${marketCount} changed`
3787
+ `\u2705 Event dateTime statuses updated: events=${eventCount} changed, google imported markets=${marketCount} changed, ai imported markets=${aiMarketCount} changed`
3660
3788
  );
3661
3789
  const archivedCount = await archiveEndedAndDiscardInvalidEventDates(now);
3662
3790
  if (archivedCount > 0) {
@@ -3671,7 +3799,7 @@ async function updateAllEventDateTimeStatuses() {
3671
3799
  }
3672
3800
 
3673
3801
  // src/service/index.ts
3674
- var import_cluemart_shared36 = require("@timardex/cluemart-shared");
3802
+ var import_cluemart_shared37 = require("@timardex/cluemart-shared");
3675
3803
 
3676
3804
  // src/service/event/findEventOrImportedMarketById.ts
3677
3805
  async function findEventOrImportedMarketById(resourceId) {
@@ -3679,15 +3807,16 @@ async function findEventOrImportedMarketById(resourceId) {
3679
3807
  return null;
3680
3808
  }
3681
3809
  const normalizedId = convertObjectIdsToStrings(resourceId);
3682
- const [eventDoc, googleImportedDoc] = await Promise.all([
3810
+ const [eventDoc, googleImportedDoc, aiImportedDoc] = await Promise.all([
3683
3811
  EventModel.findById(normalizedId).select("_id name dateTime owner").lean().exec(),
3684
- GoogleImportedMarketModel.findById(normalizedId).select("_id name dateTime").lean().exec()
3812
+ GoogleImportedMarketModel.findById(normalizedId).select("_id name dateTime").lean().exec(),
3813
+ AiImportedMarketModel.findById(normalizedId).select("_id name dateTime").lean().exec()
3685
3814
  ]);
3686
- return eventDoc ?? googleImportedDoc;
3815
+ return eventDoc ?? googleImportedDoc ?? aiImportedDoc;
3687
3816
  }
3688
3817
 
3689
3818
  // src/service/relations.ts
3690
- var import_cluemart_shared29 = require("@timardex/cluemart-shared");
3819
+ var import_cluemart_shared30 = require("@timardex/cluemart-shared");
3691
3820
  function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
3692
3821
  if (!previousDateTime?.length) {
3693
3822
  return false;
@@ -3703,8 +3832,8 @@ function didRemoveAnyStartedDates(previousDateTime, nextDateTime) {
3703
3832
  return false;
3704
3833
  }
3705
3834
  return previousDateTime.some(
3706
- (prev) => prev.dateStatus === import_cluemart_shared29.EnumEventDateStatus.STARTED && !nextDateTime?.some(
3707
- (next) => next.startDate === prev.startDate && next.startTime === prev.startTime && next.dateStatus === import_cluemart_shared29.EnumEventDateStatus.STARTED
3835
+ (prev) => prev.dateStatus === import_cluemart_shared30.EnumEventDateStatus.STARTED && !nextDateTime?.some(
3836
+ (next) => next.startDate === prev.startDate && next.startTime === prev.startTime && next.dateStatus === import_cluemart_shared30.EnumEventDateStatus.STARTED
3708
3837
  )
3709
3838
  );
3710
3839
  }
@@ -3715,7 +3844,7 @@ function updateRelationDatesToCanceled(relationDates, eventDateTime) {
3715
3844
  ) ?? false;
3716
3845
  return {
3717
3846
  ...relationDate,
3718
- status: existsInEvent ? relationDate.status : import_cluemart_shared29.EnumInviteStatus.CANCELED
3847
+ status: existsInEvent ? relationDate.status : import_cluemart_shared30.EnumInviteStatus.CANCELED
3719
3848
  };
3720
3849
  });
3721
3850
  }
@@ -3724,15 +3853,15 @@ function updateRelationDatesToCanceled(relationDates, eventDateTime) {
3724
3853
  var import_dayjs8 = __toESM(require("dayjs"));
3725
3854
 
3726
3855
  // src/service/license/compliance/utils.ts
3727
- var import_cluemart_shared34 = require("@timardex/cluemart-shared");
3856
+ var import_cluemart_shared35 = require("@timardex/cluemart-shared");
3728
3857
  var import_dayjs7 = __toESM(require("dayjs"));
3729
3858
 
3730
3859
  // src/service/license/compliance/event.ts
3731
- var import_cluemart_shared30 = require("@timardex/cluemart-shared");
3860
+ var import_cluemart_shared31 = require("@timardex/cluemart-shared");
3732
3861
  var eventLicences = [
3733
- import_cluemart_shared30.EnumUserLicence.STANDARD_EVENT,
3734
- import_cluemart_shared30.EnumUserLicence.PRO_EVENT,
3735
- import_cluemart_shared30.EnumUserLicence.PRO_PLUS_EVENT
3862
+ import_cluemart_shared31.EnumUserLicence.STANDARD_EVENT,
3863
+ import_cluemart_shared31.EnumUserLicence.PRO_EVENT,
3864
+ import_cluemart_shared31.EnumUserLicence.PRO_PLUS_EVENT
3736
3865
  ];
3737
3866
  async function handleEventLicenceCompliance(user, now) {
3738
3867
  if (!user.licences || !user.events?.length) {
@@ -3944,9 +4073,9 @@ function buildLicenceExpiryPipeline(params) {
3944
4073
  }
3945
4074
 
3946
4075
  // src/service/license/compliance/partner.ts
3947
- var import_cluemart_shared31 = require("@timardex/cluemart-shared");
4076
+ var import_cluemart_shared32 = require("@timardex/cluemart-shared");
3948
4077
  var partnerLicences = [
3949
- import_cluemart_shared31.EnumUserLicence.STANDARD_PARTNER
4078
+ import_cluemart_shared32.EnumUserLicence.STANDARD_PARTNER
3950
4079
  ];
3951
4080
  async function handlePartnerLicenceCompliance(user, now) {
3952
4081
  if (!user.licences || !user.partner) {
@@ -3956,11 +4085,11 @@ async function handlePartnerLicenceCompliance(user, now) {
3956
4085
  }
3957
4086
 
3958
4087
  // src/service/license/compliance/vendor.ts
3959
- var import_cluemart_shared33 = require("@timardex/cluemart-shared");
4088
+ var import_cluemart_shared34 = require("@timardex/cluemart-shared");
3960
4089
  var import_dayjs6 = __toESM(require("dayjs"));
3961
4090
 
3962
4091
  // src/service/license/models.ts
3963
- var import_cluemart_shared32 = require("@timardex/cluemart-shared");
4092
+ var import_cluemart_shared33 = require("@timardex/cluemart-shared");
3964
4093
  var import_dayjs5 = __toESM(require("dayjs"));
3965
4094
  var import_graphql = require("graphql");
3966
4095
  var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
@@ -3972,31 +4101,31 @@ var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
3972
4101
  return LicenceCategory2;
3973
4102
  })(LicenceCategory || {});
3974
4103
  var licenceCategoryMapping = {
3975
- [import_cluemart_shared32.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
3976
- [import_cluemart_shared32.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
3977
- [import_cluemart_shared32.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
3978
- [import_cluemart_shared32.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
3979
- [import_cluemart_shared32.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
3980
- [import_cluemart_shared32.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
3981
- [import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
3982
- [import_cluemart_shared32.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
3983
- [import_cluemart_shared32.EnumUserLicence.STANDARD_SCHOOL]: "school" /* SCHOOL */
4104
+ [import_cluemart_shared33.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
4105
+ [import_cluemart_shared33.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
4106
+ [import_cluemart_shared33.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
4107
+ [import_cluemart_shared33.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
4108
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
4109
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
4110
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
4111
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
4112
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_SCHOOL]: "school" /* SCHOOL */
3984
4113
  };
3985
4114
  var licencePriority = {
3986
- [import_cluemart_shared32.EnumUserLicence.PRO_PLUS_EVENT]: 3,
3987
- [import_cluemart_shared32.EnumUserLicence.PRO_EVENT]: 2,
3988
- [import_cluemart_shared32.EnumUserLicence.STANDARD_EVENT]: 1,
3989
- [import_cluemart_shared32.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
3990
- [import_cluemart_shared32.EnumUserLicence.PRO_VENDOR]: 2,
3991
- [import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR]: 1,
3992
- [import_cluemart_shared32.EnumUserLicence.STANDARD_PARTNER]: 1,
3993
- [import_cluemart_shared32.EnumUserLicence.STANDARD_AFFILIATE]: 1,
3994
- [import_cluemart_shared32.EnumUserLicence.STANDARD_SCHOOL]: 1
4115
+ [import_cluemart_shared33.EnumUserLicence.PRO_PLUS_EVENT]: 3,
4116
+ [import_cluemart_shared33.EnumUserLicence.PRO_EVENT]: 2,
4117
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_EVENT]: 1,
4118
+ [import_cluemart_shared33.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
4119
+ [import_cluemart_shared33.EnumUserLicence.PRO_VENDOR]: 2,
4120
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR]: 1,
4121
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_PARTNER]: 1,
4122
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_AFFILIATE]: 1,
4123
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_SCHOOL]: 1
3995
4124
  };
3996
4125
  var standardLicences = [
3997
- import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR,
3998
- import_cluemart_shared32.EnumUserLicence.STANDARD_EVENT,
3999
- import_cluemart_shared32.EnumUserLicence.STANDARD_PARTNER
4126
+ import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR,
4127
+ import_cluemart_shared33.EnumUserLicence.STANDARD_EVENT,
4128
+ import_cluemart_shared33.EnumUserLicence.STANDARD_PARTNER
4000
4129
  ];
4001
4130
  var standardLicenceSet = new Set(standardLicences);
4002
4131
  function isStandardLicence(licence) {
@@ -4010,11 +4139,11 @@ var categoryRegexMapping = {
4010
4139
  ["school" /* SCHOOL */]: /_school$/
4011
4140
  };
4012
4141
  var categoryFallbackLicence = {
4013
- ["event" /* EVENT */]: import_cluemart_shared32.EnumUserLicence.STANDARD_EVENT,
4014
- ["partner" /* PARTNER */]: import_cluemart_shared32.EnumUserLicence.STANDARD_PARTNER,
4015
- ["vendor" /* VENDOR */]: import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR,
4016
- ["affiliate" /* AFFILIATE */]: import_cluemart_shared32.EnumUserLicence.STANDARD_AFFILIATE,
4017
- ["school" /* SCHOOL */]: import_cluemart_shared32.EnumUserLicence.STANDARD_SCHOOL
4142
+ ["event" /* EVENT */]: import_cluemart_shared33.EnumUserLicence.STANDARD_EVENT,
4143
+ ["partner" /* PARTNER */]: import_cluemart_shared33.EnumUserLicence.STANDARD_PARTNER,
4144
+ ["vendor" /* VENDOR */]: import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR,
4145
+ ["affiliate" /* AFFILIATE */]: import_cluemart_shared33.EnumUserLicence.STANDARD_AFFILIATE,
4146
+ ["school" /* SCHOOL */]: import_cluemart_shared33.EnumUserLicence.STANDARD_SCHOOL
4018
4147
  };
4019
4148
  var LicenceFilterInput = {
4020
4149
  INPUT_USER_LICENCES: "$licences"
@@ -4044,11 +4173,11 @@ function getHighestLicenceForCategory(licences, category) {
4044
4173
  function createLicenceObject(expiryDate, licenceType) {
4045
4174
  const today = (0, import_dayjs5.default)();
4046
4175
  const expiryDateMapping = {
4047
- [import_cluemart_shared32.LicenceExpiryDate.ONE_YEAR]: today.add(1, "year").endOf("day").toDate(),
4048
- [import_cluemart_shared32.LicenceExpiryDate.ONE_MONTH]: today.add(1, "month").endOf("day").toDate(),
4049
- [import_cluemart_shared32.LicenceExpiryDate.TWO_MONTHS]: today.add(2, "month").endOf("day").toDate(),
4050
- [import_cluemart_shared32.LicenceExpiryDate.THREE_MONTHS]: today.add(3, "month").endOf("day").toDate(),
4051
- [import_cluemart_shared32.LicenceExpiryDate.SIX_MONTHS]: today.add(6, "month").endOf("day").toDate()
4176
+ [import_cluemart_shared33.LicenceExpiryDate.ONE_YEAR]: today.add(1, "year").endOf("day").toDate(),
4177
+ [import_cluemart_shared33.LicenceExpiryDate.ONE_MONTH]: today.add(1, "month").endOf("day").toDate(),
4178
+ [import_cluemart_shared33.LicenceExpiryDate.TWO_MONTHS]: today.add(2, "month").endOf("day").toDate(),
4179
+ [import_cluemart_shared33.LicenceExpiryDate.THREE_MONTHS]: today.add(3, "month").endOf("day").toDate(),
4180
+ [import_cluemart_shared33.LicenceExpiryDate.SIX_MONTHS]: today.add(6, "month").endOf("day").toDate()
4052
4181
  };
4053
4182
  const licenceObject = {
4054
4183
  expiryDate: expiryDateMapping[expiryDate],
@@ -4152,13 +4281,13 @@ async function checkOwnerHasLicence({
4152
4281
  const owner = await UserModel.findById(userId);
4153
4282
  if (!owner) throw new import_graphql.GraphQLError("Owner not found");
4154
4283
  const categoryByResource = {
4155
- [import_cluemart_shared32.EnumResourceType.EVENT]: "event" /* EVENT */,
4156
- [import_cluemart_shared32.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
4157
- [import_cluemart_shared32.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
4158
- [import_cluemart_shared32.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
4159
- [import_cluemart_shared32.EnumResourceType.SCHOOL]: "school" /* SCHOOL */
4284
+ [import_cluemart_shared33.EnumResourceType.EVENT]: "event" /* EVENT */,
4285
+ [import_cluemart_shared33.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
4286
+ [import_cluemart_shared33.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
4287
+ [import_cluemart_shared33.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
4288
+ [import_cluemart_shared33.EnumResourceType.SCHOOL]: "school" /* SCHOOL */
4160
4289
  };
4161
- if (!(0, import_cluemart_shared32.isNonVisitorResourceType)(resourceType)) {
4290
+ if (!(0, import_cluemart_shared33.isNonVisitorResourceType)(resourceType)) {
4162
4291
  throw new import_graphql.GraphQLError(`Invalid resource type: ${resourceType}.`);
4163
4292
  }
4164
4293
  const requiredCategory = categoryByResource[resourceType];
@@ -4238,7 +4367,7 @@ async function applyVendorDowngrade(vendor, ownerUserId) {
4238
4367
  return (result?.matchedCount ?? 0) > 0;
4239
4368
  }
4240
4369
  async function downgradeVendorProFeatures(userId, licenceType) {
4241
- const isStandardVendor = licenceType === import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR;
4370
+ const isStandardVendor = licenceType === import_cluemart_shared34.EnumUserLicence.STANDARD_VENDOR;
4242
4371
  if (!isStandardVendor) {
4243
4372
  return;
4244
4373
  }
@@ -4285,7 +4414,7 @@ async function applyVendorRestore(vendor, ownerUserId) {
4285
4414
  return (result?.matchedCount ?? 0) > 0;
4286
4415
  }
4287
4416
  async function restoreVendorProFeatures(userId, licenceType) {
4288
- const isProVendor = licenceType === import_cluemart_shared33.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared33.EnumUserLicence.PRO_PLUS_VENDOR;
4417
+ const isProVendor = licenceType === import_cluemart_shared34.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared34.EnumUserLicence.PRO_PLUS_VENDOR;
4289
4418
  if (!isProVendor) {
4290
4419
  return;
4291
4420
  }
@@ -4306,14 +4435,14 @@ function isProtectedByCurrentStripeSubscription(user, licenceType, now) {
4306
4435
  return false;
4307
4436
  }
4308
4437
  const gracePeriodEndsAt = stripe.paymentGracePeriodEndsAt ? (0, import_dayjs6.default)(stripe.paymentGracePeriodEndsAt) : null;
4309
- const hasActivePaymentGracePeriod = (stripe.status === import_cluemart_shared33.EnumSubscriptionStatus.PAST_DUE || stripe.status === import_cluemart_shared33.EnumSubscriptionStatus.INACTIVE) && Boolean(stripe.paymentGraceSubscriptionId) && (!stripe.subscriptionId || stripe.subscriptionId === stripe.paymentGraceSubscriptionId) && gracePeriodEndsAt !== null && gracePeriodEndsAt.isValid() && gracePeriodEndsAt.isAfter(now);
4438
+ const hasActivePaymentGracePeriod = (stripe.status === import_cluemart_shared34.EnumSubscriptionStatus.PAST_DUE || stripe.status === import_cluemart_shared34.EnumSubscriptionStatus.INACTIVE) && Boolean(stripe.paymentGraceSubscriptionId) && (!stripe.subscriptionId || stripe.subscriptionId === stripe.paymentGraceSubscriptionId) && gracePeriodEndsAt !== null && gracePeriodEndsAt.isValid() && gracePeriodEndsAt.isAfter(now);
4310
4439
  if (hasActivePaymentGracePeriod) {
4311
4440
  return true;
4312
4441
  }
4313
4442
  if (!stripe.subscriptionId) {
4314
4443
  return false;
4315
4444
  }
4316
- if (stripe.status !== import_cluemart_shared33.EnumSubscriptionStatus.ACTIVE) {
4445
+ if (stripe.status !== import_cluemart_shared34.EnumSubscriptionStatus.ACTIVE) {
4317
4446
  return false;
4318
4447
  }
4319
4448
  if (!stripe.endDate) {
@@ -4333,7 +4462,7 @@ async function handleVendorLicenceCompliance(user, now) {
4333
4462
  return;
4334
4463
  }
4335
4464
  const proLicences = vendorLicencesOfUser.filter(
4336
- (licence) => licence.licenceType !== import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR
4465
+ (licence) => licence.licenceType !== import_cluemart_shared34.EnumUserLicence.STANDARD_VENDOR
4337
4466
  );
4338
4467
  const expiredProLicences = proLicences.filter(
4339
4468
  (licence) => !(0, import_dayjs6.default)(licence.expiryDate).isAfter(now)
@@ -4346,7 +4475,7 @@ async function handleVendorLicenceCompliance(user, now) {
4346
4475
  const expiredProLicence = expiredProLicences.some(
4347
4476
  (licence) => !stripeProtectedLicenceTypes.has(licence.licenceType)
4348
4477
  );
4349
- const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences, import_cluemart_shared33.vendorLicences, now);
4478
+ const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences, import_cluemart_shared34.vendorLicences, now);
4350
4479
  const hasExpiredVendorLicence = vendorLicencesOfUser.some(
4351
4480
  (licence) => !(0, import_dayjs6.default)(licence.expiryDate).isAfter(now) && !stripeProtectedLicenceTypes.has(licence.licenceType)
4352
4481
  );
@@ -4362,7 +4491,7 @@ async function handleVendorLicenceCompliance(user, now) {
4362
4491
  "owner.userId": user._id
4363
4492
  }).lean().exec();
4364
4493
  }
4365
- const licencesToSync = import_cluemart_shared33.vendorLicences.filter(
4494
+ const licencesToSync = import_cluemart_shared34.vendorLicences.filter(
4366
4495
  (licenceType) => !stripeProtectedLicenceTypes.has(licenceType)
4367
4496
  );
4368
4497
  await syncUserLicencesAfterExpiry(user._id, licencesToSync, now, "downgrade");
@@ -4377,11 +4506,11 @@ async function handleVendorLicenceCompliance(user, now) {
4377
4506
  data: {
4378
4507
  resourceId: String(vendor._id),
4379
4508
  resourceName: vendor.name,
4380
- resourceType: import_cluemart_shared33.EnumNotificationResourceType.DOWNGRADED_VENDOR
4509
+ resourceType: import_cluemart_shared34.EnumNotificationResourceType.DOWNGRADED_VENDOR
4381
4510
  },
4382
4511
  message: `Your Vendor licence has been downgraded due to licence expiration.`,
4383
4512
  title: `Vendor Licence Downgraded`,
4384
- type: import_cluemart_shared33.EnumNotificationType.SYSTEM,
4513
+ type: import_cluemart_shared34.EnumNotificationType.SYSTEM,
4385
4514
  userIds: [user._id]
4386
4515
  };
4387
4516
  await sendDeactivationNotification(payload, user._id, vendor.name, "vendor");
@@ -4414,7 +4543,7 @@ async function vendorOwnerHasProLicence(vendorId) {
4414
4543
  effectiveVendorLicences,
4415
4544
  "vendor" /* VENDOR */
4416
4545
  );
4417
- return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[import_cluemart_shared33.EnumUserLicence.PRO_VENDOR];
4546
+ return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[import_cluemart_shared34.EnumUserLicence.PRO_VENDOR];
4418
4547
  }
4419
4548
 
4420
4549
  // src/service/license/compliance/utils.ts
@@ -4424,12 +4553,12 @@ async function syncUserLicencesAfterExpiry(userId, licenceTypes, now, mode = "do
4424
4553
  const pipeline = buildLicenceExpiryPipeline({
4425
4554
  downgradeBranches: [
4426
4555
  {
4427
- case: import_cluemart_shared34.EnumUserLicence.PRO_PLUS_VENDOR,
4428
- then: import_cluemart_shared34.EnumUserLicence.STANDARD_VENDOR
4556
+ case: import_cluemart_shared35.EnumUserLicence.PRO_PLUS_VENDOR,
4557
+ then: import_cluemart_shared35.EnumUserLicence.STANDARD_VENDOR
4429
4558
  },
4430
4559
  {
4431
- case: import_cluemart_shared34.EnumUserLicence.PRO_VENDOR,
4432
- then: import_cluemart_shared34.EnumUserLicence.STANDARD_VENDOR
4560
+ case: import_cluemart_shared35.EnumUserLicence.PRO_VENDOR,
4561
+ then: import_cluemart_shared35.EnumUserLicence.STANDARD_VENDOR
4433
4562
  }
4434
4563
  ],
4435
4564
  licenceTypes,
@@ -4558,7 +4687,7 @@ var REMINDER_WINDOW_MIN_HOURS = 6.5 * 24;
4558
4687
  var REMINDER_WINDOW_MAX_HOURS = 7.5 * 24;
4559
4688
 
4560
4689
  // src/service/license/reminder/utils.ts
4561
- var import_cluemart_shared35 = require("@timardex/cluemart-shared");
4690
+ var import_cluemart_shared36 = require("@timardex/cluemart-shared");
4562
4691
  var import_utils8 = require("@timardex/cluemart-shared/utils");
4563
4692
  var import_dayjs9 = __toESM(require("dayjs"));
4564
4693
 
@@ -4624,28 +4753,28 @@ function isLicenseExpiringIn7Days(expiryDate, now) {
4624
4753
  return hoursUntilExpiry >= REMINDER_WINDOW_MIN_HOURS && hoursUntilExpiry <= REMINDER_WINDOW_MAX_HOURS;
4625
4754
  }
4626
4755
  function getLicenseName(licenceType) {
4627
- return import_cluemart_shared35.licenseNiceNames[licenceType] || licenceType;
4756
+ return import_cluemart_shared36.licenseNiceNames[licenceType] || licenceType;
4628
4757
  }
4629
4758
  function getNotificationTypes(isVendorLicense, isPartnerLicense) {
4630
4759
  if (isVendorLicense) {
4631
4760
  return {
4632
- notificationType: import_cluemart_shared35.EnumNotificationType.SYSTEM,
4633
- resourceType: import_cluemart_shared35.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
4761
+ notificationType: import_cluemart_shared36.EnumNotificationType.SYSTEM,
4762
+ resourceType: import_cluemart_shared36.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
4634
4763
  };
4635
4764
  }
4636
4765
  if (isPartnerLicense) {
4637
4766
  return {
4638
- notificationType: import_cluemart_shared35.EnumNotificationType.SYSTEM,
4639
- resourceType: import_cluemart_shared35.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
4767
+ notificationType: import_cluemart_shared36.EnumNotificationType.SYSTEM,
4768
+ resourceType: import_cluemart_shared36.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
4640
4769
  };
4641
4770
  }
4642
4771
  return {
4643
- notificationType: import_cluemart_shared35.EnumNotificationType.SYSTEM,
4644
- resourceType: import_cluemart_shared35.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
4772
+ notificationType: import_cluemart_shared36.EnumNotificationType.SYSTEM,
4773
+ resourceType: import_cluemart_shared36.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
4645
4774
  };
4646
4775
  }
4647
4776
  async function getLicenseResourceInfo(user, licence) {
4648
- const isVendorLicense = import_cluemart_shared35.vendorLicences.includes(licence.licenceType);
4777
+ const isVendorLicense = import_cluemart_shared36.vendorLicences.includes(licence.licenceType);
4649
4778
  const isPartnerLicense = partnerLicences.includes(licence.licenceType);
4650
4779
  const licenceName = getLicenseName(licence.licenceType);
4651
4780
  const { notificationType, resourceType } = getNotificationTypes(
@@ -4693,11 +4822,11 @@ async function getLicenseResourceInfo(user, licence) {
4693
4822
  };
4694
4823
  }
4695
4824
  function getLicenceExpiryMode(licenceType) {
4696
- return licenceType === import_cluemart_shared35.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared35.EnumUserLicence.PRO_PLUS_VENDOR ? "downgrade" : "extend";
4825
+ return licenceType === import_cluemart_shared36.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared36.EnumUserLicence.PRO_PLUS_VENDOR ? "downgrade" : "extend";
4697
4826
  }
4698
4827
  async function sendLicenseReminder(user, licence) {
4699
4828
  const licenceName = getLicenseName(licence.licenceType);
4700
- const expiryDate = (0, import_dayjs9.default)(licence.expiryDate).format(import_cluemart_shared35.dateFormat);
4829
+ const expiryDate = (0, import_dayjs9.default)(licence.expiryDate).format(import_cluemart_shared36.dateFormat);
4701
4830
  const userId = String(user._id);
4702
4831
  const resourceInfo = await getLicenseResourceInfo(user, licence);
4703
4832
  if (!resourceInfo) {