@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.
package/dist/index.cjs CHANGED
@@ -39,6 +39,7 @@ __export(index_exports, {
39
39
  AdModel: () => AdModel,
40
40
  AdPurchaseModel: () => AdPurchaseModel,
41
41
  AffiliateModel: () => AffiliateModel,
42
+ AiImportedMarketModel: () => AiImportedMarketModel,
42
43
  AppSettingModel: () => AppSettingModel,
43
44
  AuthHandoffTokenModel: () => AuthHandoffTokenModel,
44
45
  BILLING_CATALOG_COLLECTION_NAME: () => BILLING_CATALOG_COLLECTION_NAME,
@@ -68,8 +69,10 @@ __export(index_exports, {
68
69
  RelationTypeSchema: () => RelationTypeSchema,
69
70
  ResourceActivityModel: () => ResourceActivityModel,
70
71
  ResourceImageTypeSchema: () => ResourceImageTypeSchema,
72
+ SCRAPE_SITES_CONFIG_KEY: () => SCRAPE_SITES_CONFIG_KEY,
71
73
  SUBSCRIPTION_REWARD_TIMEZONE: () => SUBSCRIPTION_REWARD_TIMEZONE,
72
74
  SchoolModel: () => SchoolModel,
75
+ ScrapeSiteConfigModel: () => ScrapeSiteConfigModel,
73
76
  SocialMediaTypeSchema: () => SocialMediaTypeSchema,
74
77
  StallTypeSchema: () => StallTypeSchema,
75
78
  UnregisteredVendorModel: () => UnregisteredVendorModel,
@@ -124,7 +127,7 @@ __export(index_exports, {
124
127
  locationGeoSchema: () => locationGeoSchema,
125
128
  locationsSchema: () => locationsSchema,
126
129
  mapVendorLicenceToSubscriptionRewardType: () => mapVendorLicenceToSubscriptionRewardType,
127
- mongoose: () => import_mongoose39.default,
130
+ mongoose: () => import_mongoose41.default,
128
131
  normalizeAffiliatePromoCodes: () => normalizeAffiliatePromoCodes,
129
132
  normalizePromoCode: () => normalizePromoCode,
130
133
  notifyUsers: () => notifyUsers,
@@ -153,7 +156,7 @@ __export(index_exports, {
153
156
  updateAdStatuses: () => updateAdStatuses,
154
157
  updateAllEventDateTimeStatuses: () => updateAllEventDateTimeStatuses,
155
158
  updateRelationDatesToCanceled: () => updateRelationDatesToCanceled,
156
- updateSingleDateTimeStatus: () => import_cluemart_shared36.updateSingleDateTimeStatus,
159
+ updateSingleDateTimeStatus: () => import_cluemart_shared37.updateSingleDateTimeStatus,
157
160
  upgradeUserToLicence: () => upgradeUserToLicence,
158
161
  userLicenseSchema: () => userLicenseSchema,
159
162
  vendorOwnerHasProLicence: () => vendorOwnerHasProLicence,
@@ -1082,15 +1085,15 @@ function syncSearchNameInUpdate(update) {
1082
1085
  }
1083
1086
  return null;
1084
1087
  }
1085
- function searchNamePlugin(schema26) {
1086
- schema26.add({ searchName: { default: "", required: false, type: String } });
1087
- schema26.index({ searchName: 1 });
1088
- schema26.pre("save", function syncSearchNameOnSave(next) {
1088
+ function searchNamePlugin(schema27) {
1089
+ schema27.add({ searchName: { default: "", required: false, type: String } });
1090
+ schema27.index({ searchName: 1 });
1091
+ schema27.pre("save", function syncSearchNameOnSave(next) {
1089
1092
  const doc = this;
1090
1093
  doc.searchName = deriveSearchName(doc.name);
1091
1094
  next();
1092
1095
  });
1093
- schema26.pre("insertMany", function syncSearchNameOnInsertMany(next, docs) {
1096
+ schema27.pre("insertMany", function syncSearchNameOnInsertMany(next, docs) {
1094
1097
  const list = Array.isArray(docs) ? docs : [docs];
1095
1098
  for (const doc of list) {
1096
1099
  if (doc && typeof doc.name === "string") {
@@ -1099,7 +1102,7 @@ function searchNamePlugin(schema26) {
1099
1102
  }
1100
1103
  next();
1101
1104
  });
1102
- schema26.pre("bulkWrite", function syncSearchNameOnBulkWrite(next, ops) {
1105
+ schema27.pre("bulkWrite", function syncSearchNameOnBulkWrite(next, ops) {
1103
1106
  for (const op of ops) {
1104
1107
  const doc = op.insertOne?.document ?? op.replaceOne?.replacement;
1105
1108
  if (doc && typeof doc.name === "string") {
@@ -1125,7 +1128,7 @@ function searchNamePlugin(schema26) {
1125
1128
  }
1126
1129
  next();
1127
1130
  };
1128
- schema26.pre(
1131
+ schema27.pre(
1129
1132
  ["findOneAndUpdate", "updateOne", "updateMany"],
1130
1133
  syncSearchNameOnUpdate
1131
1134
  );
@@ -1162,6 +1165,7 @@ var schema7 = new MongooseSchema6(
1162
1165
  dateTime: [dateTimeSchema],
1163
1166
  deletedAt: { default: null, required: false, type: Date },
1164
1167
  description: { required: true, type: String },
1168
+ earliestStartDate: { default: null, required: false, type: Date },
1165
1169
  eventId: {
1166
1170
  ref: "Event",
1167
1171
  required: false,
@@ -1204,28 +1208,152 @@ schema7.index({ name: 1 });
1204
1208
  schema7.index({ region: 1 });
1205
1209
  schema7.index({ deletedAt: 1 });
1206
1210
  schema7.index({ "dateTime.dateStatus": 1 });
1211
+ schema7.index({ earliestStartDate: 1, _id: 1 });
1207
1212
  schema7.index({ slug: 1 });
1208
1213
  schema7.index({ description: "text", name: "text" });
1209
1214
  schema7.plugin(searchNamePlugin);
1210
1215
  var GoogleImportedMarketModel = import_mongoose10.default.models.GoogleImportedMarket || import_mongoose10.default.model("GoogleImportedMarket", schema7);
1211
1216
 
1212
- // src/mongoose/Notification.ts
1217
+ // src/mongoose/AiImportedMarket.ts
1213
1218
  var import_cluemart_shared10 = require("@timardex/cluemart-shared");
1214
1219
  var import_mongoose11 = __toESM(require("mongoose"));
1215
1220
  var MongooseSchema7 = import_mongoose11.default.Schema;
1216
- var notificationDataSchema = new MongooseSchema7(
1221
+ var addressComponentSchema2 = new MongooseSchema7(
1222
+ {
1223
+ longName: { required: false, type: String },
1224
+ shortName: { required: false, type: String },
1225
+ types: { required: false, type: [String] }
1226
+ },
1227
+ { _id: false }
1228
+ );
1229
+ var schema8 = new MongooseSchema7(
1230
+ {
1231
+ active: { default: false, required: true, type: Boolean },
1232
+ address: { required: true, type: String },
1233
+ addressComponents: { required: false, type: [addressComponentSchema2] },
1234
+ approvedAt: { default: null, required: false, type: Date },
1235
+ claimed: { default: false, required: true, type: Boolean },
1236
+ claimedAt: { default: null, required: false, type: Date },
1237
+ claimedByUserId: {
1238
+ ref: "User",
1239
+ required: false,
1240
+ type: import_mongoose11.default.Schema.Types.ObjectId
1241
+ },
1242
+ cover: {
1243
+ required: false,
1244
+ type: ResourceImageTypeSchema
1245
+ },
1246
+ dateTime: [dateTimeSchema],
1247
+ deletedAt: { default: null, required: false, type: Date },
1248
+ description: { required: true, type: String },
1249
+ earliestStartDate: { default: null, required: false, type: Date },
1250
+ eventId: {
1251
+ ref: "Event",
1252
+ required: false,
1253
+ type: import_mongoose11.default.Schema.Types.ObjectId
1254
+ },
1255
+ eventType: {
1256
+ enum: Object.values(import_cluemart_shared10.EnumEventType),
1257
+ required: true,
1258
+ type: String
1259
+ },
1260
+ images: { required: false, type: [ResourceImageTypeSchema] },
1261
+ location: {
1262
+ required: true,
1263
+ type: locationsSchema
1264
+ },
1265
+ logo: { required: false, type: ResourceImageTypeSchema },
1266
+ name: { required: true, type: String },
1267
+ openingHours: { required: false, type: [String] },
1268
+ rainOrShine: { required: true, type: Boolean },
1269
+ rating: { required: false, type: Number },
1270
+ region: { required: false, type: String },
1271
+ rejectReason: { required: false, type: String },
1272
+ reviewCount: { required: false, type: Number },
1273
+ reviewedAt: { default: null, required: false, type: Date },
1274
+ reviewedByUserId: {
1275
+ ref: "User",
1276
+ required: false,
1277
+ type: import_mongoose11.default.Schema.Types.ObjectId
1278
+ },
1279
+ reviewStatus: {
1280
+ default: import_cluemart_shared10.EnumImportedMarketReviewStatus.PENDING,
1281
+ enum: Object.values(import_cluemart_shared10.EnumImportedMarketReviewStatus),
1282
+ required: true,
1283
+ type: String
1284
+ },
1285
+ scrapedAt: { default: () => /* @__PURE__ */ new Date(), required: true, type: Date },
1286
+ slug: { required: true, type: String },
1287
+ sourceKey: {
1288
+ required: true,
1289
+ type: String,
1290
+ unique: true
1291
+ // unique, indexed
1292
+ },
1293
+ sourceName: { required: true, type: String },
1294
+ sourceUrl: { required: true, type: String },
1295
+ website: { required: false, type: String }
1296
+ },
1297
+ { timestamps: true }
1298
+ );
1299
+ schema8.index({ "location.geo": "2dsphere" });
1300
+ schema8.index({ name: 1 });
1301
+ schema8.index({ region: 1 });
1302
+ schema8.index({ deletedAt: 1 });
1303
+ schema8.index({ "dateTime.dateStatus": 1 });
1304
+ schema8.index({ earliestStartDate: 1, _id: 1 });
1305
+ schema8.index({ slug: 1 });
1306
+ schema8.index({ reviewStatus: 1 });
1307
+ schema8.index({ description: "text", name: "text" });
1308
+ schema8.plugin(searchNamePlugin);
1309
+ var AiImportedMarketModel = import_mongoose11.default.models.AiImportedMarket || import_mongoose11.default.model("AiImportedMarket", schema8);
1310
+
1311
+ // src/mongoose/ScrapeSite.ts
1312
+ var import_mongoose12 = __toESM(require("mongoose"));
1313
+ var SCRAPE_SITES_CONFIG_KEY = "scrapeSites";
1314
+ var MongooseSchema8 = import_mongoose12.default.Schema;
1315
+ var scrapeSiteItemSchema = new MongooseSchema8(
1316
+ {
1317
+ enabled: { default: true, required: true, type: Boolean },
1318
+ lastError: { required: false, type: String },
1319
+ lastScrapedAt: { required: false, type: Date },
1320
+ lastScrapeStatus: { required: false, type: String },
1321
+ name: { required: true, type: String },
1322
+ regionHint: { required: false, type: String },
1323
+ url: { required: true, type: String }
1324
+ },
1325
+ { timestamps: true }
1326
+ );
1327
+ var configSchema = new MongooseSchema8(
1328
+ {
1329
+ key: { required: true, type: String, unique: true },
1330
+ sites: {
1331
+ default: [],
1332
+ required: true,
1333
+ type: [scrapeSiteItemSchema]
1334
+ }
1335
+ },
1336
+ { timestamps: true }
1337
+ );
1338
+ var ScrapeSiteConfigModel = import_mongoose12.default.models.ScrapeSiteConfig || import_mongoose12.default.model("ScrapeSiteConfig", configSchema);
1339
+
1340
+ // src/mongoose/Notification.ts
1341
+ var import_cluemart_shared11 = require("@timardex/cluemart-shared");
1342
+ var import_mongoose13 = __toESM(require("mongoose"));
1343
+ var MongooseSchema9 = import_mongoose13.default.Schema;
1344
+ var notificationDataSchema = new MongooseSchema9(
1217
1345
  {
1218
1346
  resourceId: { required: true, type: String },
1219
1347
  resourceName: { required: true, type: String },
1220
1348
  resourceType: {
1221
- enum: Object.values(import_cluemart_shared10.EnumNotificationResourceType),
1349
+ enum: Object.values(import_cluemart_shared11.EnumNotificationResourceType),
1222
1350
  required: true,
1223
1351
  type: String
1224
1352
  }
1225
1353
  },
1226
1354
  { _id: false }
1227
1355
  );
1228
- var schema8 = new MongooseSchema7(
1356
+ var schema9 = new MongooseSchema9(
1229
1357
  {
1230
1358
  data: {
1231
1359
  default: null,
@@ -1236,28 +1364,28 @@ var schema8 = new MongooseSchema7(
1236
1364
  message: { required: true, type: String },
1237
1365
  title: { required: true, type: String },
1238
1366
  type: {
1239
- default: import_cluemart_shared10.EnumNotificationType.SYSTEM,
1240
- enum: Object.values(import_cluemart_shared10.EnumNotificationType),
1367
+ default: import_cluemart_shared11.EnumNotificationType.SYSTEM,
1368
+ enum: Object.values(import_cluemart_shared11.EnumNotificationType),
1241
1369
  required: true,
1242
1370
  type: String
1243
1371
  },
1244
1372
  userId: {
1245
1373
  ref: "User",
1246
1374
  required: true,
1247
- type: import_mongoose11.default.Schema.Types.ObjectId
1375
+ type: import_mongoose13.default.Schema.Types.ObjectId
1248
1376
  }
1249
1377
  },
1250
1378
  { timestamps: true }
1251
1379
  );
1252
- schema8.index({ isRead: 1, userId: 1 });
1253
- schema8.index({ createdAt: -1, userId: 1 });
1254
- var NotificationModel = import_mongoose11.default.models.Notification || import_mongoose11.default.model("Notification", schema8);
1380
+ schema9.index({ isRead: 1, userId: 1 });
1381
+ schema9.index({ createdAt: -1, userId: 1 });
1382
+ var NotificationModel = import_mongoose13.default.models.Notification || import_mongoose13.default.model("Notification", schema9);
1255
1383
 
1256
1384
  // src/mongoose/PushToken.ts
1257
1385
  var import_enums = require("@timardex/cluemart-shared/enums");
1258
- var import_mongoose12 = __toESM(require("mongoose"));
1259
- var MongooseSchema8 = import_mongoose12.default.Schema;
1260
- var schema9 = new MongooseSchema8(
1386
+ var import_mongoose14 = __toESM(require("mongoose"));
1387
+ var MongooseSchema10 = import_mongoose14.default.Schema;
1388
+ var schema10 = new MongooseSchema10(
1261
1389
  {
1262
1390
  platform: {
1263
1391
  enum: Object.values(import_enums.EnumOSPlatform),
@@ -1268,22 +1396,22 @@ var schema9 = new MongooseSchema8(
1268
1396
  userId: {
1269
1397
  ref: "User",
1270
1398
  required: true,
1271
- type: import_mongoose12.default.Schema.Types.ObjectId
1399
+ type: import_mongoose14.default.Schema.Types.ObjectId
1272
1400
  }
1273
1401
  },
1274
1402
  { timestamps: true }
1275
1403
  );
1276
- var PushTokenModel = import_mongoose12.default.models.PushToken || import_mongoose12.default.model("PushToken", schema9);
1404
+ var PushTokenModel = import_mongoose14.default.models.PushToken || import_mongoose14.default.model("PushToken", schema10);
1277
1405
 
1278
1406
  // src/mongoose/Relation.ts
1279
- var import_cluemart_shared12 = require("@timardex/cluemart-shared");
1280
- var import_mongoose14 = __toESM(require("mongoose"));
1407
+ var import_cluemart_shared13 = require("@timardex/cluemart-shared");
1408
+ var import_mongoose16 = __toESM(require("mongoose"));
1281
1409
 
1282
1410
  // src/mongoose/event/EventInfo.ts
1283
- var import_cluemart_shared11 = require("@timardex/cluemart-shared");
1284
- var import_mongoose13 = __toESM(require("mongoose"));
1285
- var MongooseSchema9 = import_mongoose13.default.Schema;
1286
- var StallTypeSchema = new MongooseSchema9(
1411
+ var import_cluemart_shared12 = require("@timardex/cluemart-shared");
1412
+ var import_mongoose15 = __toESM(require("mongoose"));
1413
+ var MongooseSchema11 = import_mongoose15.default.Schema;
1414
+ var StallTypeSchema = new MongooseSchema11(
1287
1415
  {
1288
1416
  label: { required: false, type: String },
1289
1417
  price: { required: false, type: Number },
@@ -1294,10 +1422,10 @@ var StallTypeSchema = new MongooseSchema9(
1294
1422
  // Prevents Mongoose from creating an additional _id field for subdocuments
1295
1423
  }
1296
1424
  );
1297
- var dateTimeSchema2 = new MongooseSchema9(
1425
+ var dateTimeSchema2 = new MongooseSchema11(
1298
1426
  {
1299
1427
  dateStatus: {
1300
- enum: Object.values(import_cluemart_shared11.EnumEventDateStatus),
1428
+ enum: Object.values(import_cluemart_shared12.EnumEventDateStatus),
1301
1429
  required: false,
1302
1430
  type: String
1303
1431
  },
@@ -1310,13 +1438,13 @@ var dateTimeSchema2 = new MongooseSchema9(
1310
1438
  { _id: false }
1311
1439
  // Prevents Mongoose from creating an additional _id field for subdocuments
1312
1440
  );
1313
- var paymentInfoSchema = new MongooseSchema9(
1441
+ var paymentInfoSchema = new MongooseSchema11(
1314
1442
  {
1315
1443
  accountHolderName: { required: false, type: String },
1316
1444
  accountNumber: { required: false, type: String },
1317
1445
  link: { required: false, type: String },
1318
1446
  paymentMethod: {
1319
- enum: Object.values(import_cluemart_shared11.EnumPaymentMethod),
1447
+ enum: Object.values(import_cluemart_shared12.EnumPaymentMethod),
1320
1448
  required: true,
1321
1449
  type: String
1322
1450
  }
@@ -1324,7 +1452,7 @@ var paymentInfoSchema = new MongooseSchema9(
1324
1452
  { _id: false }
1325
1453
  // Prevents Mongoose from creating an additional _id field
1326
1454
  );
1327
- var requirementsSchema = new MongooseSchema9(
1455
+ var requirementsSchema = new MongooseSchema11(
1328
1456
  {
1329
1457
  category: { required: true, type: String },
1330
1458
  label: { required: true, type: String },
@@ -1335,7 +1463,7 @@ var requirementsSchema = new MongooseSchema9(
1335
1463
  // Prevents Mongoose from creating an additional _id field for
1336
1464
  }
1337
1465
  );
1338
- var refundPolicySchema = new MongooseSchema9(
1466
+ var refundPolicySchema = new MongooseSchema11(
1339
1467
  {
1340
1468
  category: { required: true, type: String },
1341
1469
  label: { required: true, type: String },
@@ -1343,7 +1471,7 @@ var refundPolicySchema = new MongooseSchema9(
1343
1471
  },
1344
1472
  { _id: false }
1345
1473
  );
1346
- var schema10 = new MongooseSchema9(
1474
+ var schema11 = new MongooseSchema11(
1347
1475
  {
1348
1476
  active: { default: true, type: Boolean },
1349
1477
  applicationDeadlineHours: { required: true, type: Number },
@@ -1351,7 +1479,7 @@ var schema10 = new MongooseSchema9(
1351
1479
  eventId: {
1352
1480
  ref: "Event",
1353
1481
  required: true,
1354
- type: import_mongoose13.default.Schema.Types.ObjectId
1482
+ type: import_mongoose15.default.Schema.Types.ObjectId
1355
1483
  },
1356
1484
  packInTime: { required: true, type: Number },
1357
1485
  paymentDueHours: { required: true, type: Number },
@@ -1361,15 +1489,15 @@ var schema10 = new MongooseSchema9(
1361
1489
  },
1362
1490
  { timestamps: true }
1363
1491
  );
1364
- schema10.index({ eventId: 1 });
1365
- var EventInfoModel = import_mongoose13.default.models.EventInfo || import_mongoose13.default.model("EventInfo", schema10);
1492
+ schema11.index({ eventId: 1 });
1493
+ var EventInfoModel = import_mongoose15.default.models.EventInfo || import_mongoose15.default.model("EventInfo", schema11);
1366
1494
 
1367
1495
  // src/mongoose/Relation.ts
1368
- var MongooseSchema10 = import_mongoose14.default.Schema;
1369
- var relationDateTimeSchema = new MongooseSchema10(
1496
+ var MongooseSchema12 = import_mongoose16.default.Schema;
1497
+ var relationDateTimeSchema = new MongooseSchema12(
1370
1498
  {
1371
1499
  dateStatus: {
1372
- enum: Object.values(import_cluemart_shared12.EnumEventDateStatus),
1500
+ enum: Object.values(import_cluemart_shared13.EnumEventDateStatus),
1373
1501
  required: true,
1374
1502
  type: String
1375
1503
  },
@@ -1381,7 +1509,7 @@ var relationDateTimeSchema = new MongooseSchema10(
1381
1509
  },
1382
1510
  { _id: false }
1383
1511
  );
1384
- var relationDatesSchema = new MongooseSchema10(
1512
+ var relationDatesSchema = new MongooseSchema12(
1385
1513
  {
1386
1514
  dateTime: {
1387
1515
  required: true,
@@ -1393,42 +1521,42 @@ var relationDatesSchema = new MongooseSchema10(
1393
1521
  },
1394
1522
  paymentReference: { required: false, type: String },
1395
1523
  status: {
1396
- enum: Object.values(import_cluemart_shared12.EnumInviteStatus),
1524
+ enum: Object.values(import_cluemart_shared13.EnumInviteStatus),
1397
1525
  required: false,
1398
1526
  type: String
1399
1527
  }
1400
1528
  },
1401
1529
  { _id: false }
1402
1530
  );
1403
- var RelationTypeSchema = new MongooseSchema10(
1531
+ var RelationTypeSchema = new MongooseSchema12(
1404
1532
  {
1405
1533
  active: { default: true, required: true, type: Boolean },
1406
1534
  chatId: {
1407
1535
  ref: "Chat",
1408
1536
  required: true,
1409
- type: import_mongoose14.default.Schema.Types.ObjectId
1537
+ type: import_mongoose16.default.Schema.Types.ObjectId
1410
1538
  },
1411
1539
  deletedAt: { default: null, required: false, type: Date },
1412
1540
  eventId: {
1413
1541
  ref: "Event",
1414
1542
  required: true,
1415
- type: import_mongoose14.default.Schema.Types.ObjectId
1543
+ type: import_mongoose16.default.Schema.Types.ObjectId
1416
1544
  },
1417
1545
  lastUpdateBy: {
1418
- enum: Object.values(import_cluemart_shared12.EnumResourceType),
1546
+ enum: Object.values(import_cluemart_shared13.EnumResourceType),
1419
1547
  required: true,
1420
1548
  type: String
1421
1549
  },
1422
1550
  relationDates: [relationDatesSchema],
1423
1551
  relationType: {
1424
- enum: Object.values(import_cluemart_shared12.EnumRelationResource),
1552
+ enum: Object.values(import_cluemart_shared13.EnumRelationResource),
1425
1553
  required: true,
1426
1554
  type: String
1427
1555
  },
1428
1556
  vendorId: {
1429
1557
  ref: "Vendor",
1430
1558
  required: true,
1431
- type: import_mongoose14.default.Schema.Types.ObjectId
1559
+ type: import_mongoose16.default.Schema.Types.ObjectId
1432
1560
  }
1433
1561
  },
1434
1562
  { timestamps: true }
@@ -1440,21 +1568,21 @@ RelationTypeSchema.index({
1440
1568
  "relationDates.status": 1,
1441
1569
  vendorId: 1
1442
1570
  });
1443
- var RelationModel = import_mongoose14.default.models.Relation || import_mongoose14.default.model("Relation", RelationTypeSchema);
1571
+ var RelationModel = import_mongoose16.default.models.Relation || import_mongoose16.default.model("Relation", RelationTypeSchema);
1444
1572
 
1445
1573
  // src/mongoose/ResourceActivity.ts
1446
- var import_cluemart_shared13 = require("@timardex/cluemart-shared");
1447
- var import_mongoose15 = __toESM(require("mongoose"));
1448
- var MongooseSchema11 = import_mongoose15.default.Schema;
1449
- var ActivitySchema = new MongooseSchema11(
1574
+ var import_cluemart_shared14 = require("@timardex/cluemart-shared");
1575
+ var import_mongoose17 = __toESM(require("mongoose"));
1576
+ var MongooseSchema13 = import_mongoose17.default.Schema;
1577
+ var ActivitySchema = new MongooseSchema13(
1450
1578
  {
1451
1579
  activityType: {
1452
- enum: Object.values(import_cluemart_shared13.EnumActivity),
1580
+ enum: Object.values(import_cluemart_shared14.EnumActivity),
1453
1581
  required: true,
1454
1582
  type: String
1455
1583
  },
1456
1584
  dateStatus: {
1457
- enum: Object.values(import_cluemart_shared13.EnumEventDateStatus),
1585
+ enum: Object.values(import_cluemart_shared14.EnumEventDateStatus),
1458
1586
  required: false,
1459
1587
  type: String
1460
1588
  },
@@ -1466,7 +1594,7 @@ var ActivitySchema = new MongooseSchema11(
1466
1594
  startTime: { required: false, type: String },
1467
1595
  timestamp: { default: Date.now, type: Date },
1468
1596
  userAgent: {
1469
- enum: Object.values(import_cluemart_shared13.EnumOSPlatform),
1597
+ enum: Object.values(import_cluemart_shared14.EnumOSPlatform),
1470
1598
  required: true,
1471
1599
  type: String
1472
1600
  },
@@ -1474,61 +1602,61 @@ var ActivitySchema = new MongooseSchema11(
1474
1602
  },
1475
1603
  { _id: false }
1476
1604
  );
1477
- var schema11 = new MongooseSchema11(
1605
+ var schema12 = new MongooseSchema13(
1478
1606
  {
1479
1607
  activity: { default: [], type: [ActivitySchema] },
1480
1608
  resourceId: { required: true, type: String },
1481
1609
  resourceType: {
1482
- enum: Object.values(import_cluemart_shared13.EnumResourceType),
1610
+ enum: Object.values(import_cluemart_shared14.EnumResourceType),
1483
1611
  required: true,
1484
1612
  type: String
1485
1613
  }
1486
1614
  },
1487
1615
  { timestamps: true }
1488
1616
  );
1489
- schema11.index({ resourceId: 1, resourceType: 1 }, { unique: true });
1490
- schema11.index({ "views.location": "2dsphere" });
1491
- var ResourceActivityModel = import_mongoose15.default.models.ResourceActivity || import_mongoose15.default.model("ResourceActivity", schema11);
1617
+ schema12.index({ resourceId: 1, resourceType: 1 }, { unique: true });
1618
+ schema12.index({ "views.location": "2dsphere" });
1619
+ var ResourceActivityModel = import_mongoose17.default.models.ResourceActivity || import_mongoose17.default.model("ResourceActivity", schema12);
1492
1620
 
1493
1621
  // src/mongoose/User.ts
1494
- var import_cluemart_shared14 = require("@timardex/cluemart-shared");
1495
- var import_mongoose16 = __toESM(require("mongoose"));
1496
- var MongooseSchema12 = import_mongoose16.default.Schema;
1497
- var userActivityEventSchema = new MongooseSchema12(
1622
+ var import_cluemart_shared15 = require("@timardex/cluemart-shared");
1623
+ var import_mongoose18 = __toESM(require("mongoose"));
1624
+ var MongooseSchema14 = import_mongoose18.default.Schema;
1625
+ var userActivityEventSchema = new MongooseSchema14(
1498
1626
  {
1499
1627
  dateTime: dateTimeSchema,
1500
1628
  resourceId: {
1501
1629
  ref: "Event",
1502
1630
  required: false,
1503
- type: import_mongoose16.default.Schema.Types.ObjectId
1631
+ type: import_mongoose18.default.Schema.Types.ObjectId
1504
1632
  }
1505
1633
  },
1506
1634
  { _id: false }
1507
1635
  );
1508
- var userActivityFavouritesSchema = new MongooseSchema12(
1636
+ var userActivityFavouritesSchema = new MongooseSchema14(
1509
1637
  {
1510
1638
  events: {
1511
1639
  ref: "Event",
1512
1640
  required: false,
1513
- type: [import_mongoose16.default.Schema.Types.ObjectId]
1641
+ type: [import_mongoose18.default.Schema.Types.ObjectId]
1514
1642
  },
1515
1643
  partners: {
1516
1644
  ref: "Partner",
1517
1645
  required: false,
1518
- type: [import_mongoose16.default.Schema.Types.ObjectId]
1646
+ type: [import_mongoose18.default.Schema.Types.ObjectId]
1519
1647
  },
1520
1648
  vendors: {
1521
1649
  ref: "Vendor",
1522
1650
  required: false,
1523
- type: [import_mongoose16.default.Schema.Types.ObjectId]
1651
+ type: [import_mongoose18.default.Schema.Types.ObjectId]
1524
1652
  }
1525
1653
  },
1526
1654
  { _id: false }
1527
1655
  );
1528
- var stripeSchema = new MongooseSchema12(
1656
+ var stripeSchema = new MongooseSchema14(
1529
1657
  {
1530
1658
  billingPeriod: {
1531
- enum: Object.values(import_cluemart_shared14.EnumBillingPeriod),
1659
+ enum: Object.values(import_cluemart_shared15.EnumBillingPeriod),
1532
1660
  required: false,
1533
1661
  type: String
1534
1662
  },
@@ -1537,7 +1665,7 @@ var stripeSchema = new MongooseSchema12(
1537
1665
  type: Boolean
1538
1666
  },
1539
1667
  currentPlan: {
1540
- enum: Object.values(import_cluemart_shared14.EnumUserLicence),
1668
+ enum: Object.values(import_cluemart_shared15.EnumUserLicence),
1541
1669
  required: false,
1542
1670
  type: String
1543
1671
  },
@@ -1562,7 +1690,7 @@ var stripeSchema = new MongooseSchema12(
1562
1690
  type: String
1563
1691
  },
1564
1692
  pendingBillingPeriod: {
1565
- enum: Object.values(import_cluemart_shared14.EnumBillingPeriod),
1693
+ enum: Object.values(import_cluemart_shared15.EnumBillingPeriod),
1566
1694
  required: false,
1567
1695
  type: String
1568
1696
  },
@@ -1571,7 +1699,7 @@ var stripeSchema = new MongooseSchema12(
1571
1699
  type: Date
1572
1700
  },
1573
1701
  pendingPlan: {
1574
- enum: Object.values(import_cluemart_shared14.EnumUserLicence),
1702
+ enum: Object.values(import_cluemart_shared15.EnumUserLicence),
1575
1703
  required: false,
1576
1704
  type: String
1577
1705
  },
@@ -1588,7 +1716,7 @@ var stripeSchema = new MongooseSchema12(
1588
1716
  type: Date
1589
1717
  },
1590
1718
  status: {
1591
- enum: Object.values(import_cluemart_shared14.EnumSubscriptionStatus),
1719
+ enum: Object.values(import_cluemart_shared15.EnumSubscriptionStatus),
1592
1720
  required: false,
1593
1721
  type: String
1594
1722
  },
@@ -1607,10 +1735,10 @@ var stripeSchema = new MongooseSchema12(
1607
1735
  },
1608
1736
  { _id: false }
1609
1737
  );
1610
- var redeemedRewardSchema = new MongooseSchema12(
1738
+ var redeemedRewardSchema = new MongooseSchema14(
1611
1739
  {
1612
1740
  name: {
1613
- enum: Object.values(import_cluemart_shared14.EnumReward),
1741
+ enum: Object.values(import_cluemart_shared15.EnumReward),
1614
1742
  required: true,
1615
1743
  type: String
1616
1744
  },
@@ -1619,12 +1747,12 @@ var redeemedRewardSchema = new MongooseSchema12(
1619
1747
  },
1620
1748
  { _id: false }
1621
1749
  );
1622
- var userOverallPointsSchema = new MongooseSchema12(
1750
+ var userOverallPointsSchema = new MongooseSchema14(
1623
1751
  {
1624
1752
  createdAt: { required: true, type: Date },
1625
1753
  points: { default: 0, required: true, type: Number },
1626
1754
  pointType: {
1627
- enum: Object.values(import_cluemart_shared14.EnumPointType),
1755
+ enum: Object.values(import_cluemart_shared15.EnumPointType),
1628
1756
  required: true,
1629
1757
  type: String
1630
1758
  },
@@ -1632,13 +1760,13 @@ var userOverallPointsSchema = new MongooseSchema12(
1632
1760
  },
1633
1761
  { _id: false }
1634
1762
  );
1635
- var schema12 = new MongooseSchema12(
1763
+ var schema13 = new MongooseSchema14(
1636
1764
  {
1637
1765
  active: { default: false, required: true, type: Boolean },
1638
1766
  affiliate: {
1639
1767
  ref: "Affiliate",
1640
1768
  required: false,
1641
- type: import_mongoose16.default.Schema.Types.ObjectId
1769
+ type: import_mongoose18.default.Schema.Types.ObjectId
1642
1770
  },
1643
1771
  avatar: {
1644
1772
  required: false,
@@ -1647,28 +1775,28 @@ var schema12 = new MongooseSchema12(
1647
1775
  coupon: {
1648
1776
  ref: "Coupon",
1649
1777
  required: false,
1650
- type: import_mongoose16.default.Schema.Types.ObjectId
1778
+ type: import_mongoose18.default.Schema.Types.ObjectId
1651
1779
  },
1652
1780
  deletedAt: { default: null, required: false, type: Date },
1653
1781
  email: { required: true, type: String },
1654
1782
  emailSentFor: {
1655
- enum: Object.values(import_cluemart_shared14.EnumNotificationResourceType),
1783
+ enum: Object.values(import_cluemart_shared15.EnumNotificationResourceType),
1656
1784
  required: false,
1657
1785
  type: [String]
1658
1786
  },
1659
1787
  events: {
1660
1788
  ref: "Event",
1661
1789
  required: false,
1662
- type: [import_mongoose16.default.Schema.Types.ObjectId]
1790
+ type: [import_mongoose18.default.Schema.Types.ObjectId]
1663
1791
  },
1664
1792
  firstName: { required: true, type: String },
1665
1793
  game: {
1666
1794
  ref: "Game",
1667
1795
  required: false,
1668
- type: import_mongoose16.default.Schema.Types.ObjectId
1796
+ type: import_mongoose18.default.Schema.Types.ObjectId
1669
1797
  },
1670
1798
  interests: {
1671
- enum: Object.values(import_cluemart_shared14.EnumResourceType),
1799
+ enum: Object.values(import_cluemart_shared15.EnumResourceType),
1672
1800
  required: false,
1673
1801
  type: [String]
1674
1802
  },
@@ -1691,11 +1819,11 @@ var schema12 = new MongooseSchema12(
1691
1819
  partner: {
1692
1820
  ref: "Partner",
1693
1821
  required: false,
1694
- type: import_mongoose16.default.Schema.Types.ObjectId
1822
+ type: import_mongoose18.default.Schema.Types.ObjectId
1695
1823
  },
1696
1824
  password: { required: true, type: String },
1697
1825
  platform: {
1698
- enum: Object.values(import_cluemart_shared14.EnumOSPlatform),
1826
+ enum: Object.values(import_cluemart_shared15.EnumOSPlatform),
1699
1827
  required: false,
1700
1828
  type: String
1701
1829
  },
@@ -1724,15 +1852,15 @@ var schema12 = new MongooseSchema12(
1724
1852
  type: String
1725
1853
  },
1726
1854
  roles: {
1727
- default: [import_cluemart_shared14.EnumUserRole.CUSTOMER],
1728
- enum: Object.values(import_cluemart_shared14.EnumUserRole),
1855
+ default: [import_cluemart_shared15.EnumUserRole.CUSTOMER],
1856
+ enum: Object.values(import_cluemart_shared15.EnumUserRole),
1729
1857
  required: true,
1730
1858
  type: [String]
1731
1859
  },
1732
1860
  school: {
1733
1861
  ref: "School",
1734
1862
  required: false,
1735
- type: import_mongoose16.default.Schema.Types.ObjectId
1863
+ type: import_mongoose18.default.Schema.Types.ObjectId
1736
1864
  },
1737
1865
  stripe: {
1738
1866
  required: false,
@@ -1757,21 +1885,21 @@ var schema12 = new MongooseSchema12(
1757
1885
  vendor: {
1758
1886
  ref: "Vendor",
1759
1887
  required: false,
1760
- type: import_mongoose16.default.Schema.Types.ObjectId
1888
+ type: import_mongoose18.default.Schema.Types.ObjectId
1761
1889
  }
1762
1890
  },
1763
1891
  { strict: false, timestamps: true }
1764
1892
  );
1765
- schema12.index({ "licences.expiryDate": 1 });
1766
- schema12.index({ "licences.licenceType": 1 });
1767
- schema12.index({ promoCodes: 1, active: 1, deletedAt: 1 });
1768
- schema12.index({ email: "text", firstName: "text", lastName: "text" });
1769
- var UserModel = import_mongoose16.default.models.User || import_mongoose16.default.model("User", schema12);
1893
+ schema13.index({ "licences.expiryDate": 1 });
1894
+ schema13.index({ "licences.licenceType": 1 });
1895
+ schema13.index({ promoCodes: 1, active: 1, deletedAt: 1 });
1896
+ schema13.index({ email: "text", firstName: "text", lastName: "text" });
1897
+ var UserModel = import_mongoose18.default.models.User || import_mongoose18.default.model("User", schema13);
1770
1898
 
1771
1899
  // src/mongoose/VerificationToken.ts
1772
- var import_mongoose17 = __toESM(require("mongoose"));
1773
- var MongooseSchema13 = import_mongoose17.default.Schema;
1774
- var schema13 = new MongooseSchema13(
1900
+ var import_mongoose19 = __toESM(require("mongoose"));
1901
+ var MongooseSchema15 = import_mongoose19.default.Schema;
1902
+ var schema14 = new MongooseSchema15(
1775
1903
  {
1776
1904
  createdAt: {
1777
1905
  default: Date.now,
@@ -1786,13 +1914,13 @@ var schema13 = new MongooseSchema13(
1786
1914
  },
1787
1915
  { timestamps: true }
1788
1916
  );
1789
- var VerificationTokenModel = import_mongoose17.default.models.VerificationToken || import_mongoose17.default.model("VerificationToken", schema13);
1917
+ var VerificationTokenModel = import_mongoose19.default.models.VerificationToken || import_mongoose19.default.model("VerificationToken", schema14);
1790
1918
 
1791
1919
  // src/mongoose/vendor/Vendor.ts
1792
- var import_cluemart_shared15 = require("@timardex/cluemart-shared");
1793
- var import_mongoose18 = __toESM(require("mongoose"));
1794
- var MongooseSchema14 = import_mongoose18.default.Schema;
1795
- var vendorProductTypeSchema = new MongooseSchema14(
1920
+ var import_cluemart_shared16 = require("@timardex/cluemart-shared");
1921
+ var import_mongoose20 = __toESM(require("mongoose"));
1922
+ var MongooseSchema16 = import_mongoose20.default.Schema;
1923
+ var vendorProductTypeSchema = new MongooseSchema16(
1796
1924
  {
1797
1925
  description: { required: false, type: String },
1798
1926
  name: { required: true, type: String },
@@ -1803,18 +1931,18 @@ var vendorProductTypeSchema = new MongooseSchema14(
1803
1931
  },
1804
1932
  { timestamps: true }
1805
1933
  );
1806
- var productWrapperSchema = new MongooseSchema14(
1934
+ var productWrapperSchema = new MongooseSchema16(
1807
1935
  {
1808
1936
  active: { default: false, required: false, type: Boolean },
1809
1937
  productsList: { required: false, type: [vendorProductTypeSchema] }
1810
1938
  },
1811
1939
  { _id: false }
1812
1940
  );
1813
- var calendarSchema = new MongooseSchema14(
1941
+ var calendarSchema = new MongooseSchema16(
1814
1942
  {
1815
1943
  dateTime: {
1816
1944
  dateStatus: {
1817
- enum: Object.values(import_cluemart_shared15.EnumEventDateStatus),
1945
+ enum: Object.values(import_cluemart_shared16.EnumEventDateStatus),
1818
1946
  required: false,
1819
1947
  type: String
1820
1948
  },
@@ -1831,14 +1959,14 @@ var calendarSchema = new MongooseSchema14(
1831
1959
  },
1832
1960
  { _id: false }
1833
1961
  );
1834
- var calendarWrapperSchema = new MongooseSchema14(
1962
+ var calendarWrapperSchema = new MongooseSchema16(
1835
1963
  {
1836
1964
  active: { default: false, required: true, type: Boolean },
1837
1965
  calendarData: { required: false, type: [calendarSchema] }
1838
1966
  },
1839
1967
  { _id: false }
1840
1968
  );
1841
- var vendorAvailabilitySchema = new MongooseSchema14(
1969
+ var vendorAvailabilitySchema = new MongooseSchema16(
1842
1970
  {
1843
1971
  corporate: { default: false, required: false, type: Boolean },
1844
1972
  private: { default: false, required: false, type: Boolean },
@@ -1846,7 +1974,7 @@ var vendorAvailabilitySchema = new MongooseSchema14(
1846
1974
  },
1847
1975
  { _id: false }
1848
1976
  );
1849
- var downgradeSnapshotSchema = new MongooseSchema14(
1977
+ var downgradeSnapshotSchema = new MongooseSchema16(
1850
1978
  {
1851
1979
  availability: { required: false, type: vendorAvailabilitySchema },
1852
1980
  calendarActive: { required: false, type: Boolean },
@@ -1854,7 +1982,7 @@ var downgradeSnapshotSchema = new MongooseSchema14(
1854
1982
  },
1855
1983
  { _id: false }
1856
1984
  );
1857
- var schema14 = new MongooseSchema14(
1985
+ var schema15 = new MongooseSchema16(
1858
1986
  {
1859
1987
  ...baseResourceFields,
1860
1988
  // Importing base resource fields from global.ts
@@ -1873,47 +2001,47 @@ var schema14 = new MongooseSchema14(
1873
2001
  unregisteredVendorId: {
1874
2002
  ref: "UnregisteredVendor",
1875
2003
  required: false,
1876
- type: import_mongoose18.default.Schema.Types.ObjectId
2004
+ type: import_mongoose20.default.Schema.Types.ObjectId
1877
2005
  },
1878
2006
  vendorInfoId: {
1879
2007
  ref: "VendorInfo",
1880
2008
  required: false,
1881
- type: import_mongoose18.default.Schema.Types.ObjectId
2009
+ type: import_mongoose20.default.Schema.Types.ObjectId
1882
2010
  },
1883
2011
  vendorType: {
1884
- enum: Object.values(import_cluemart_shared15.EnumVendorType),
2012
+ enum: Object.values(import_cluemart_shared16.EnumVendorType),
1885
2013
  required: true,
1886
2014
  type: String
1887
2015
  }
1888
2016
  },
1889
2017
  { timestamps: true }
1890
2018
  );
1891
- schema14.index({ name: 1 });
1892
- schema14.index({ description: 1 });
1893
- schema14.index({ region: 1 });
1894
- schema14.index({ "categories.name": 1 });
1895
- schema14.index({ slug: 1 });
1896
- schema14.index({
2019
+ schema15.index({ name: 1 });
2020
+ schema15.index({ description: 1 });
2021
+ schema15.index({ region: 1 });
2022
+ schema15.index({ "categories.name": 1 });
2023
+ schema15.index({ slug: 1 });
2024
+ schema15.index({
1897
2025
  categoriesNames: "text",
1898
2026
  description: "text",
1899
2027
  name: "text"
1900
2028
  });
1901
- schema14.index({ deletedAt: 1, "owner.userId": 1 });
1902
- schema14.plugin(searchNamePlugin);
1903
- var VendorModel = import_mongoose18.default.models.Vendor || import_mongoose18.default.model("Vendor", schema14);
2029
+ schema15.index({ deletedAt: 1, "owner.userId": 1 });
2030
+ schema15.plugin(searchNamePlugin);
2031
+ var VendorModel = import_mongoose20.default.models.Vendor || import_mongoose20.default.model("Vendor", schema15);
1904
2032
 
1905
2033
  // src/mongoose/vendor/VendorInfo.ts
1906
- var import_cluemart_shared16 = require("@timardex/cluemart-shared");
1907
- var import_mongoose19 = __toESM(require("mongoose"));
1908
- var MongooseSchema15 = import_mongoose19.default.Schema;
1909
- var AttributesSchema = new MongooseSchema15(
2034
+ var import_cluemart_shared17 = require("@timardex/cluemart-shared");
2035
+ var import_mongoose21 = __toESM(require("mongoose"));
2036
+ var MongooseSchema17 = import_mongoose21.default.Schema;
2037
+ var AttributesSchema = new MongooseSchema17(
1910
2038
  {
1911
2039
  details: { required: false, type: String },
1912
2040
  isRequired: { default: false, required: true, type: Boolean }
1913
2041
  },
1914
2042
  { _id: false }
1915
2043
  );
1916
- var schema15 = new MongooseSchema15(
2044
+ var schema16 = new MongooseSchema17(
1917
2045
  {
1918
2046
  active: { default: true, type: Boolean },
1919
2047
  compliance: {
@@ -1923,7 +2051,7 @@ var schema15 = new MongooseSchema15(
1923
2051
  documents: [ResourceImageTypeSchema],
1924
2052
  product: {
1925
2053
  foodFlavors: {
1926
- enum: Object.values(import_cluemart_shared16.EnumFoodFlavor),
2054
+ enum: Object.values(import_cluemart_shared17.EnumFoodFlavor),
1927
2055
  required: true,
1928
2056
  type: [String]
1929
2057
  },
@@ -1948,29 +2076,29 @@ var schema15 = new MongooseSchema15(
1948
2076
  vendorId: {
1949
2077
  ref: "Vendor",
1950
2078
  required: true,
1951
- type: import_mongoose19.default.Schema.Types.ObjectId
2079
+ type: import_mongoose21.default.Schema.Types.ObjectId
1952
2080
  }
1953
2081
  },
1954
2082
  { timestamps: true }
1955
2083
  );
1956
- schema15.index({ vendorId: 1 });
1957
- var VendorInfoModel = import_mongoose19.default.models.VendorInfo || import_mongoose19.default.model("VendorInfo", schema15);
2084
+ schema16.index({ vendorId: 1 });
2085
+ var VendorInfoModel = import_mongoose21.default.models.VendorInfo || import_mongoose21.default.model("VendorInfo", schema16);
1958
2086
 
1959
2087
  // src/mongoose/vendor/UnregisteredVendor.ts
1960
- var import_mongoose20 = __toESM(require("mongoose"));
1961
- var MongooseSchema16 = import_mongoose20.default.Schema;
1962
- var invitationSchema = new MongooseSchema16(
2088
+ var import_mongoose22 = __toESM(require("mongoose"));
2089
+ var MongooseSchema18 = import_mongoose22.default.Schema;
2090
+ var invitationSchema = new MongooseSchema18(
1963
2091
  {
1964
2092
  dateTime: { required: true, type: [dateTimeSchema] },
1965
2093
  inviterId: {
1966
2094
  ref: "Event",
1967
2095
  required: true,
1968
- type: import_mongoose20.default.Schema.Types.ObjectId
2096
+ type: import_mongoose22.default.Schema.Types.ObjectId
1969
2097
  }
1970
2098
  },
1971
2099
  { _id: false }
1972
2100
  );
1973
- var schema16 = new MongooseSchema16(
2101
+ var schema17 = new MongooseSchema18(
1974
2102
  {
1975
2103
  active: { default: true, required: true, type: Boolean },
1976
2104
  categoryIds: { required: true, type: [String] },
@@ -1979,7 +2107,7 @@ var schema16 = new MongooseSchema16(
1979
2107
  claimedByUserId: {
1980
2108
  ref: "User",
1981
2109
  required: false,
1982
- type: import_mongoose20.default.Schema.Types.ObjectId
2110
+ type: import_mongoose22.default.Schema.Types.ObjectId
1983
2111
  },
1984
2112
  claimInitiatedAt: { default: null, required: false, type: Date },
1985
2113
  claimToken: { default: null, required: false, type: String },
@@ -1992,15 +2120,15 @@ var schema16 = new MongooseSchema16(
1992
2120
  },
1993
2121
  { timestamps: true }
1994
2122
  );
1995
- schema16.index({ name: 1 });
1996
- schema16.index({ email: 1 });
1997
- var UnregisteredVendorModel = import_mongoose20.default.models.UnregisteredVendor || import_mongoose20.default.model("UnregisteredVendor", schema16);
2123
+ schema17.index({ name: 1 });
2124
+ schema17.index({ email: 1 });
2125
+ var UnregisteredVendorModel = import_mongoose22.default.models.UnregisteredVendor || import_mongoose22.default.model("UnregisteredVendor", schema17);
1998
2126
 
1999
2127
  // src/mongoose/event/Event.ts
2000
- var import_cluemart_shared17 = require("@timardex/cluemart-shared");
2001
- var import_mongoose21 = __toESM(require("mongoose"));
2002
- var MongooseSchema17 = import_mongoose21.default.Schema;
2003
- var schema17 = new MongooseSchema17(
2128
+ var import_cluemart_shared18 = require("@timardex/cluemart-shared");
2129
+ var import_mongoose23 = __toESM(require("mongoose"));
2130
+ var MongooseSchema19 = import_mongoose23.default.Schema;
2131
+ var schema18 = new MongooseSchema19(
2004
2132
  {
2005
2133
  ...baseResourceFields,
2006
2134
  // Importing base resource fields from global.ts
@@ -2009,10 +2137,10 @@ var schema17 = new MongooseSchema17(
2009
2137
  eventInfoId: {
2010
2138
  ref: "EventInfo",
2011
2139
  required: false,
2012
- type: import_mongoose21.default.Schema.Types.ObjectId
2140
+ type: import_mongoose23.default.Schema.Types.ObjectId
2013
2141
  },
2014
2142
  eventType: {
2015
- enum: Object.values(import_cluemart_shared17.EnumEventType),
2143
+ enum: Object.values(import_cluemart_shared18.EnumEventType),
2016
2144
  required: true,
2017
2145
  type: String
2018
2146
  },
@@ -2033,40 +2161,40 @@ var schema17 = new MongooseSchema17(
2033
2161
  },
2034
2162
  { timestamps: true }
2035
2163
  );
2036
- schema17.index({ name: 1 });
2037
- schema17.index({ description: 1 });
2038
- schema17.index({ region: 1 });
2039
- schema17.index({ "location.geo": "2dsphere" });
2040
- schema17.index({ tags: 1 });
2041
- schema17.index({ deletedAt: 1 });
2042
- schema17.index({ "dateTime.dateStatus": 1 });
2043
- schema17.index({ slug: 1 });
2044
- schema17.index({ description: "text", name: "text", tags: "text" });
2045
- schema17.index({ deletedAt: 1, "owner.userId": 1 });
2046
- schema17.plugin(searchNamePlugin);
2047
- var EventModel = import_mongoose21.default.models.Event || import_mongoose21.default.model("Event", schema17);
2164
+ schema18.index({ name: 1 });
2165
+ schema18.index({ description: 1 });
2166
+ schema18.index({ region: 1 });
2167
+ schema18.index({ "location.geo": "2dsphere" });
2168
+ schema18.index({ tags: 1 });
2169
+ schema18.index({ deletedAt: 1 });
2170
+ schema18.index({ "dateTime.dateStatus": 1 });
2171
+ schema18.index({ slug: 1 });
2172
+ schema18.index({ description: "text", name: "text", tags: "text" });
2173
+ schema18.index({ deletedAt: 1, "owner.userId": 1 });
2174
+ schema18.plugin(searchNamePlugin);
2175
+ var EventModel = import_mongoose23.default.models.Event || import_mongoose23.default.model("Event", schema18);
2048
2176
 
2049
2177
  // src/mongoose/event/EventDateArchive.ts
2050
- var import_mongoose22 = __toESM(require("mongoose"));
2051
- var schema18 = new import_mongoose22.default.Schema(
2178
+ var import_mongoose24 = __toESM(require("mongoose"));
2179
+ var schema19 = new import_mongoose24.default.Schema(
2052
2180
  {
2053
2181
  dateTime: { required: true, type: [dateTimeSchema] },
2054
2182
  eventId: {
2055
2183
  ref: "Event",
2056
2184
  required: true,
2057
- type: import_mongoose22.default.Schema.Types.ObjectId
2185
+ type: import_mongoose24.default.Schema.Types.ObjectId
2058
2186
  }
2059
2187
  },
2060
2188
  { timestamps: true }
2061
2189
  );
2062
- schema18.index({ eventId: 1 }, { unique: true });
2063
- var EventDateArchiveModel = import_mongoose22.default.models.EventDateArchive || import_mongoose22.default.model("EventDateArchive", schema18);
2190
+ schema19.index({ eventId: 1 }, { unique: true });
2191
+ var EventDateArchiveModel = import_mongoose24.default.models.EventDateArchive || import_mongoose24.default.model("EventDateArchive", schema19);
2064
2192
 
2065
2193
  // src/mongoose/Partner.ts
2066
- var import_cluemart_shared18 = require("@timardex/cluemart-shared");
2067
- var import_mongoose23 = __toESM(require("mongoose"));
2068
- var MongooseSchema18 = import_mongoose23.default.Schema;
2069
- var schema19 = new MongooseSchema18(
2194
+ var import_cluemart_shared19 = require("@timardex/cluemart-shared");
2195
+ var import_mongoose25 = __toESM(require("mongoose"));
2196
+ var MongooseSchema20 = import_mongoose25.default.Schema;
2197
+ var schema20 = new MongooseSchema20(
2070
2198
  {
2071
2199
  ...baseResourceFields,
2072
2200
  location: {
@@ -2075,53 +2203,53 @@ var schema19 = new MongooseSchema18(
2075
2203
  },
2076
2204
  nzbn: { required: true, type: String },
2077
2205
  partnerType: {
2078
- enum: Object.values(import_cluemart_shared18.EnumPartnerType),
2206
+ enum: Object.values(import_cluemart_shared19.EnumPartnerType),
2079
2207
  required: true,
2080
2208
  type: String
2081
2209
  }
2082
2210
  },
2083
2211
  { timestamps: true }
2084
2212
  );
2085
- schema19.index({ name: 1 });
2086
- schema19.index({ description: 1 });
2087
- schema19.index({ region: 1 });
2088
- schema19.index({ "location.geo": "2dsphere" });
2089
- schema19.index({ slug: 1 });
2090
- schema19.index({ name: "text", description: "text" });
2091
- schema19.index({ "owner.userId": 1, deletedAt: 1 });
2092
- schema19.plugin(searchNamePlugin);
2093
- var PartnerModel = import_mongoose23.default.models.Partner || import_mongoose23.default.model("Partner", schema19);
2213
+ schema20.index({ name: 1 });
2214
+ schema20.index({ description: 1 });
2215
+ schema20.index({ region: 1 });
2216
+ schema20.index({ "location.geo": "2dsphere" });
2217
+ schema20.index({ slug: 1 });
2218
+ schema20.index({ name: "text", description: "text" });
2219
+ schema20.index({ "owner.userId": 1, deletedAt: 1 });
2220
+ schema20.plugin(searchNamePlugin);
2221
+ var PartnerModel = import_mongoose25.default.models.Partner || import_mongoose25.default.model("Partner", schema20);
2094
2222
 
2095
2223
  // src/mongoose/Post.ts
2096
- var import_cluemart_shared19 = require("@timardex/cluemart-shared");
2097
- var import_mongoose24 = __toESM(require("mongoose"));
2098
- var MongooseSchema19 = import_mongoose24.default.Schema;
2099
- var contentSchema = new MongooseSchema19(
2224
+ var import_cluemart_shared20 = require("@timardex/cluemart-shared");
2225
+ var import_mongoose26 = __toESM(require("mongoose"));
2226
+ var MongooseSchema21 = import_mongoose26.default.Schema;
2227
+ var contentSchema = new MongooseSchema21(
2100
2228
  {
2101
- contentData: import_mongoose24.Schema.Types.Mixed,
2229
+ contentData: import_mongoose26.Schema.Types.Mixed,
2102
2230
  contentOrder: { required: true, type: Number },
2103
2231
  contentType: {
2104
- enum: Object.values(import_cluemart_shared19.EnumPostContentType),
2232
+ enum: Object.values(import_cluemart_shared20.EnumPostContentType),
2105
2233
  required: true,
2106
2234
  type: String
2107
2235
  }
2108
2236
  },
2109
2237
  { _id: false }
2110
2238
  );
2111
- var resourceSchema = new MongooseSchema19(
2239
+ var resourceSchema = new MongooseSchema21(
2112
2240
  {
2113
2241
  resourceId: { required: true, type: String },
2114
2242
  resourceRegion: { required: true, type: String },
2115
2243
  resourceSlug: { required: true, type: String },
2116
2244
  resourceType: {
2117
- enum: Object.values(import_cluemart_shared19.EnumResourceType),
2245
+ enum: Object.values(import_cluemart_shared20.EnumResourceType),
2118
2246
  required: true,
2119
2247
  type: String
2120
2248
  }
2121
2249
  },
2122
2250
  { _id: false }
2123
2251
  );
2124
- var schema20 = new MongooseSchema19(
2252
+ var schema21 = new MongooseSchema21(
2125
2253
  {
2126
2254
  active: { default: false, required: true, type: Boolean },
2127
2255
  approvedAt: { default: null, required: false, type: Date },
@@ -2137,7 +2265,7 @@ var schema20 = new MongooseSchema19(
2137
2265
  },
2138
2266
  deletedAt: { default: null, required: false, type: Date },
2139
2267
  postType: {
2140
- enum: Object.values(import_cluemart_shared19.EnumPostType),
2268
+ enum: Object.values(import_cluemart_shared20.EnumPostType),
2141
2269
  required: true,
2142
2270
  type: String
2143
2271
  },
@@ -2152,16 +2280,16 @@ var schema20 = new MongooseSchema19(
2152
2280
  },
2153
2281
  { timestamps: true }
2154
2282
  );
2155
- schema20.index({ title: 1 });
2156
- schema20.index({ tags: 1 });
2157
- schema20.index({ postType: 1, slug: 1 }, { unique: true });
2158
- var PostModel = import_mongoose24.default.models.Post || import_mongoose24.default.model("Post", schema20);
2283
+ schema21.index({ title: 1 });
2284
+ schema21.index({ tags: 1 });
2285
+ schema21.index({ postType: 1, slug: 1 }, { unique: true });
2286
+ var PostModel = import_mongoose26.default.models.Post || import_mongoose26.default.model("Post", schema21);
2159
2287
 
2160
2288
  // src/mongoose/AppSetting.ts
2161
- var import_mongoose25 = __toESM(require("mongoose"));
2162
- var MongooseSchema20 = import_mongoose25.default.Schema;
2289
+ var import_mongoose27 = __toESM(require("mongoose"));
2290
+ var MongooseSchema22 = import_mongoose27.default.Schema;
2163
2291
  var APP_SETTINGS_ID = "APP_SETTINGS_DOCUMENT_ID";
2164
- var AppSettingSchema = new MongooseSchema20(
2292
+ var AppSettingSchema = new MongooseSchema22(
2165
2293
  {
2166
2294
  activeSchoolsStudentCountTotal: {
2167
2295
  default: 0,
@@ -2183,8 +2311,8 @@ var AppSettingSchema = new MongooseSchema20(
2183
2311
  validate: Number.isInteger
2184
2312
  },
2185
2313
  mobileDisplayEnabled: { default: false, required: true, type: Boolean },
2186
- purchasePricing: { type: MongooseSchema20.Types.Mixed },
2187
- regionPricing: { type: MongooseSchema20.Types.Mixed },
2314
+ purchasePricing: { type: MongooseSchema22.Types.Mixed },
2315
+ regionPricing: { type: MongooseSchema22.Types.Mixed },
2188
2316
  paidSlotsPerPlacement: { enum: [30], type: Number },
2189
2317
  reservedSlotsPerPlacement: { enum: [7], type: Number },
2190
2318
  rotationSeconds: { enum: [8], type: Number },
@@ -2209,12 +2337,12 @@ var AppSettingSchema = new MongooseSchema20(
2209
2337
  },
2210
2338
  { timestamps: true }
2211
2339
  );
2212
- var AppSettingModel = import_mongoose25.default.models.AppSetting || import_mongoose25.default.model("AppSetting", AppSettingSchema);
2340
+ var AppSettingModel = import_mongoose27.default.models.AppSetting || import_mongoose27.default.model("AppSetting", AppSettingSchema);
2213
2341
 
2214
2342
  // src/mongoose/AuthHandoffToken.ts
2215
- var import_mongoose26 = __toESM(require("mongoose"));
2216
- var MongooseSchema21 = import_mongoose26.default.Schema;
2217
- var schema21 = new MongooseSchema21(
2343
+ var import_mongoose28 = __toESM(require("mongoose"));
2344
+ var MongooseSchema23 = import_mongoose28.default.Schema;
2345
+ var schema22 = new MongooseSchema23(
2218
2346
  {
2219
2347
  expiresAt: { required: true, type: Date },
2220
2348
  jti: { index: true, required: true, type: String, unique: true },
@@ -2223,25 +2351,25 @@ var schema21 = new MongooseSchema21(
2223
2351
  index: true,
2224
2352
  ref: "User",
2225
2353
  required: true,
2226
- type: import_mongoose26.default.Schema.Types.ObjectId
2354
+ type: import_mongoose28.default.Schema.Types.ObjectId
2227
2355
  }
2228
2356
  },
2229
2357
  { timestamps: true }
2230
2358
  );
2231
- schema21.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
2232
- var AuthHandoffTokenModel = import_mongoose26.default.models.AuthHandoffToken || import_mongoose26.default.model("AuthHandoffToken", schema21);
2359
+ schema22.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
2360
+ var AuthHandoffTokenModel = import_mongoose28.default.models.AuthHandoffToken || import_mongoose28.default.model("AuthHandoffToken", schema22);
2233
2361
 
2234
2362
  // src/mongoose/game/Game.ts
2235
- var import_cluemart_shared20 = require("@timardex/cluemart-shared");
2236
- var import_mongoose30 = __toESM(require("mongoose"));
2363
+ var import_cluemart_shared21 = require("@timardex/cluemart-shared");
2364
+ var import_mongoose32 = __toESM(require("mongoose"));
2237
2365
 
2238
2366
  // src/mongoose/game/DailyClue.ts
2239
- var import_mongoose28 = __toESM(require("mongoose"));
2367
+ var import_mongoose30 = __toESM(require("mongoose"));
2240
2368
 
2241
2369
  // src/mongoose/game/utils.ts
2242
- var import_mongoose27 = __toESM(require("mongoose"));
2243
- var MongooseSchema22 = import_mongoose27.default.Schema;
2244
- var schemaGameDate = new MongooseSchema22(
2370
+ var import_mongoose29 = __toESM(require("mongoose"));
2371
+ var MongooseSchema24 = import_mongoose29.default.Schema;
2372
+ var schemaGameDate = new MongooseSchema24(
2245
2373
  {
2246
2374
  endDate: { required: true, type: Date },
2247
2375
  startDate: { required: true, type: Date }
@@ -2250,8 +2378,8 @@ var schemaGameDate = new MongooseSchema22(
2250
2378
  );
2251
2379
 
2252
2380
  // src/mongoose/game/DailyClue.ts
2253
- var MongooseSchema23 = import_mongoose28.default.Schema;
2254
- var schemaLetters = new MongooseSchema23(
2381
+ var MongooseSchema25 = import_mongoose30.default.Schema;
2382
+ var schemaLetters = new MongooseSchema25(
2255
2383
  {
2256
2384
  collected: { required: false, type: [String] },
2257
2385
  solutionShuffled: { required: true, type: [String] }
@@ -2259,14 +2387,14 @@ var schemaLetters = new MongooseSchema23(
2259
2387
  },
2260
2388
  { _id: false }
2261
2389
  );
2262
- var schemaDailyClueBaseGame = new MongooseSchema23(
2390
+ var schemaDailyClueBaseGame = new MongooseSchema25(
2263
2391
  {
2264
2392
  gameDate: { required: true, type: schemaGameDate },
2265
2393
  gameSolution: { required: true, type: String }
2266
2394
  },
2267
2395
  { _id: false }
2268
2396
  );
2269
- var schemaDailyClueGameData = new MongooseSchema23(
2397
+ var schemaDailyClueGameData = new MongooseSchema25(
2270
2398
  {
2271
2399
  gameFields: { required: true, type: schemaDailyClueBaseGame },
2272
2400
  lastFoundDate: { default: null, required: false, type: Date },
@@ -2281,9 +2409,9 @@ var schemaDailyClueGameData = new MongooseSchema23(
2281
2409
  );
2282
2410
 
2283
2411
  // src/mongoose/game/PuzzleGame.ts
2284
- var import_mongoose29 = __toESM(require("mongoose"));
2285
- var MongooseSchema24 = import_mongoose29.default.Schema;
2286
- var schemaPuzzleAnswer = new MongooseSchema24(
2412
+ var import_mongoose31 = __toESM(require("mongoose"));
2413
+ var MongooseSchema26 = import_mongoose31.default.Schema;
2414
+ var schemaPuzzleAnswer = new MongooseSchema26(
2287
2415
  {
2288
2416
  answer: { required: true, type: String },
2289
2417
  answerId: { required: true, type: String },
@@ -2291,7 +2419,7 @@ var schemaPuzzleAnswer = new MongooseSchema24(
2291
2419
  },
2292
2420
  { _id: false }
2293
2421
  );
2294
- var schemaPuzzleQuestion = new MongooseSchema24(
2422
+ var schemaPuzzleQuestion = new MongooseSchema26(
2295
2423
  {
2296
2424
  answers: { required: true, type: [schemaPuzzleAnswer] },
2297
2425
  question: { required: true, type: String },
@@ -2299,20 +2427,20 @@ var schemaPuzzleQuestion = new MongooseSchema24(
2299
2427
  },
2300
2428
  { _id: false }
2301
2429
  );
2302
- var schemaPuzzleBaseGame = new MongooseSchema24(
2430
+ var schemaPuzzleBaseGame = new MongooseSchema26(
2303
2431
  {
2304
2432
  questions: { required: true, type: [schemaPuzzleQuestion] }
2305
2433
  },
2306
2434
  { _id: false }
2307
2435
  );
2308
- var schemaPuzzleAnsweredQuestion = new MongooseSchema24(
2436
+ var schemaPuzzleAnsweredQuestion = new MongooseSchema26(
2309
2437
  {
2310
2438
  questionId: { required: true, type: String },
2311
2439
  selectedAnswerId: { required: true, type: String }
2312
2440
  },
2313
2441
  { _id: false }
2314
2442
  );
2315
- var schemaPuzzleGameData = new MongooseSchema24(
2443
+ var schemaPuzzleGameData = new MongooseSchema26(
2316
2444
  {
2317
2445
  answeredQuestions: {
2318
2446
  default: null,
@@ -2327,30 +2455,30 @@ var schemaPuzzleGameData = new MongooseSchema24(
2327
2455
  );
2328
2456
 
2329
2457
  // src/mongoose/game/Game.ts
2330
- var MongooseSchema25 = import_mongoose30.default.Schema;
2458
+ var MongooseSchema27 = import_mongoose32.default.Schema;
2331
2459
  var gameDataSchemas = {
2332
- [import_cluemart_shared20.EnumGameType.DAILY_CLUE]: schemaDailyClueGameData,
2333
- [import_cluemart_shared20.EnumGameType.MINI_QUIZ]: schemaPuzzleGameData,
2334
- [import_cluemart_shared20.EnumGameType.ODD_ONE_OUT]: schemaPuzzleGameData
2460
+ [import_cluemart_shared21.EnumGameType.DAILY_CLUE]: schemaDailyClueGameData,
2461
+ [import_cluemart_shared21.EnumGameType.MINI_QUIZ]: schemaPuzzleGameData,
2462
+ [import_cluemart_shared21.EnumGameType.ODD_ONE_OUT]: schemaPuzzleGameData
2335
2463
  };
2336
2464
  var gameDataDefinition = Object.fromEntries(
2337
- Object.entries(gameDataSchemas).map(([key, schema26]) => [
2465
+ Object.entries(gameDataSchemas).map(([key, schema27]) => [
2338
2466
  key,
2339
- { default: null, required: false, type: schema26 }
2467
+ { default: null, required: false, type: schema27 }
2340
2468
  ])
2341
2469
  );
2342
- var gameHistorySchema = new MongooseSchema25(
2470
+ var gameHistorySchema = new MongooseSchema27(
2343
2471
  {
2344
2472
  createdAt: { required: true, type: Date },
2345
2473
  gameDate: { required: true, type: schemaGameDate },
2346
2474
  gameStatus: {
2347
- enum: Object.values(import_cluemart_shared20.EnumGameStatus),
2475
+ enum: Object.values(import_cluemart_shared21.EnumGameStatus),
2348
2476
  required: true,
2349
2477
  type: String
2350
2478
  },
2351
2479
  gameTitle: { required: true, type: String },
2352
2480
  gameType: {
2353
- enum: Object.values(import_cluemart_shared20.EnumGameType),
2481
+ enum: Object.values(import_cluemart_shared21.EnumGameType),
2354
2482
  required: true,
2355
2483
  type: String
2356
2484
  },
@@ -2359,14 +2487,14 @@ var gameHistorySchema = new MongooseSchema25(
2359
2487
  },
2360
2488
  { _id: false }
2361
2489
  );
2362
- var gameTypeSchema = new MongooseSchema25(
2490
+ var gameTypeSchema = new MongooseSchema27(
2363
2491
  {
2364
2492
  active: { default: true, required: true, type: Boolean },
2365
2493
  gameData: gameDataDefinition,
2366
2494
  gameHistory: { default: [], required: true, type: [gameHistorySchema] },
2367
2495
  gameTitle: { required: true, type: String },
2368
2496
  gameType: {
2369
- enum: Object.values(import_cluemart_shared20.EnumGameType),
2497
+ enum: Object.values(import_cluemart_shared21.EnumGameType),
2370
2498
  required: true,
2371
2499
  type: String
2372
2500
  },
@@ -2377,7 +2505,7 @@ var gameTypeSchema = new MongooseSchema25(
2377
2505
  },
2378
2506
  { timestamps: true }
2379
2507
  );
2380
- var schema22 = new MongooseSchema25(
2508
+ var schema23 = new MongooseSchema27(
2381
2509
  {
2382
2510
  active: { default: false, required: true, type: Boolean },
2383
2511
  deletedAt: { default: null, required: false, type: Date },
@@ -2390,12 +2518,12 @@ var schema22 = new MongooseSchema25(
2390
2518
  },
2391
2519
  { timestamps: true }
2392
2520
  );
2393
- var GameModel = import_mongoose30.default.models.Game || import_mongoose30.default.model("Game", schema22);
2521
+ var GameModel = import_mongoose32.default.models.Game || import_mongoose32.default.model("Game", schema23);
2394
2522
 
2395
2523
  // src/mongoose/School.ts
2396
- var import_mongoose31 = __toESM(require("mongoose"));
2397
- var MongooseSchema26 = import_mongoose31.default.Schema;
2398
- var campaignsSchema = new MongooseSchema26(
2524
+ var import_mongoose33 = __toESM(require("mongoose"));
2525
+ var MongooseSchema28 = import_mongoose33.default.Schema;
2526
+ var campaignsSchema = new MongooseSchema28(
2399
2527
  {
2400
2528
  endDate: { required: true, type: Date },
2401
2529
  name: { required: true, type: String },
@@ -2403,7 +2531,7 @@ var campaignsSchema = new MongooseSchema26(
2403
2531
  },
2404
2532
  { _id: false }
2405
2533
  );
2406
- var schema23 = new MongooseSchema26(
2534
+ var schema24 = new MongooseSchema28(
2407
2535
  {
2408
2536
  // New schools are active by default
2409
2537
  active: { default: false, required: true, type: Boolean },
@@ -2430,26 +2558,26 @@ var schema23 = new MongooseSchema26(
2430
2558
  },
2431
2559
  { timestamps: true }
2432
2560
  );
2433
- schema23.index(
2561
+ schema24.index(
2434
2562
  { schoolCode: 1 },
2435
2563
  {
2436
2564
  partialFilterExpression: { active: true, deletedAt: null },
2437
2565
  unique: true
2438
2566
  }
2439
2567
  );
2440
- var SchoolModel = import_mongoose31.default.models.School || import_mongoose31.default.model("School", schema23);
2568
+ var SchoolModel = import_mongoose33.default.models.School || import_mongoose33.default.model("School", schema24);
2441
2569
 
2442
2570
  // src/mongoose/Affiliate.ts
2443
- var import_cluemart_shared21 = require("@timardex/cluemart-shared");
2444
- var import_mongoose32 = __toESM(require("mongoose"));
2445
- var MongooseSchema27 = import_mongoose32.default.Schema;
2446
- var affiliateRewardSchema = new MongooseSchema27(
2571
+ var import_cluemart_shared22 = require("@timardex/cluemart-shared");
2572
+ var import_mongoose34 = __toESM(require("mongoose"));
2573
+ var MongooseSchema29 = import_mongoose34.default.Schema;
2574
+ var affiliateRewardSchema = new MongooseSchema29(
2447
2575
  {
2448
2576
  createdAt: { required: true, type: Date },
2449
2577
  redeemedAt: { default: null, required: false, type: Date },
2450
2578
  rewardDescription: { required: true, type: String },
2451
2579
  rewardType: {
2452
- enum: Object.values(import_cluemart_shared21.EnumAffiliateRewardType),
2580
+ enum: Object.values(import_cluemart_shared22.EnumAffiliateRewardType),
2453
2581
  required: true,
2454
2582
  type: String
2455
2583
  },
@@ -2457,13 +2585,13 @@ var affiliateRewardSchema = new MongooseSchema27(
2457
2585
  },
2458
2586
  { _id: false }
2459
2587
  );
2460
- var affiliateResourceSchema = new MongooseSchema27(
2588
+ var affiliateResourceSchema = new MongooseSchema29(
2461
2589
  {
2462
2590
  resourceActive: { default: true, required: true, type: Boolean },
2463
2591
  resourceDeletedAt: { default: null, required: false, type: Date },
2464
2592
  resourceId: {
2465
2593
  required: true,
2466
- type: import_mongoose32.default.Schema.Types.ObjectId
2594
+ type: import_mongoose34.default.Schema.Types.ObjectId
2467
2595
  },
2468
2596
  resourceName: { required: true, type: String },
2469
2597
  resourceOwner: {
@@ -2471,7 +2599,7 @@ var affiliateResourceSchema = new MongooseSchema27(
2471
2599
  type: OwnerTypeSchema
2472
2600
  },
2473
2601
  resourceType: {
2474
- enum: Object.values(import_cluemart_shared21.EnumResourceType),
2602
+ enum: Object.values(import_cluemart_shared22.EnumResourceType),
2475
2603
  required: true,
2476
2604
  type: String
2477
2605
  },
@@ -2483,20 +2611,20 @@ var affiliateResourceSchema = new MongooseSchema27(
2483
2611
  },
2484
2612
  { _id: false }
2485
2613
  );
2486
- var affiliateContactDetailsSchema = new MongooseSchema27(
2614
+ var affiliateContactDetailsSchema = new MongooseSchema29(
2487
2615
  {
2488
2616
  mobilePhone: { required: true, type: String }
2489
2617
  },
2490
2618
  { _id: false }
2491
2619
  );
2492
- var affiliateBankAccountDetailsSchema = new MongooseSchema27(
2620
+ var affiliateBankAccountDetailsSchema = new MongooseSchema29(
2493
2621
  {
2494
2622
  accountHolderName: { required: true, type: String },
2495
2623
  accountNumber: { required: true, type: String }
2496
2624
  },
2497
2625
  { _id: false }
2498
2626
  );
2499
- var affiliateDetailsSchema = new MongooseSchema27(
2627
+ var affiliateDetailsSchema = new MongooseSchema29(
2500
2628
  {
2501
2629
  bankAccountDetails: {
2502
2630
  required: true,
@@ -2509,7 +2637,7 @@ var affiliateDetailsSchema = new MongooseSchema27(
2509
2637
  lastName: { required: true, type: String },
2510
2638
  location: { required: true, type: locationsSchema },
2511
2639
  participantType: {
2512
- enum: Object.values(import_cluemart_shared21.EnumAffiliateParticipantType),
2640
+ enum: Object.values(import_cluemart_shared22.EnumAffiliateParticipantType),
2513
2641
  required: true,
2514
2642
  type: String
2515
2643
  },
@@ -2518,7 +2646,7 @@ var affiliateDetailsSchema = new MongooseSchema27(
2518
2646
  },
2519
2647
  { _id: false }
2520
2648
  );
2521
- var redeemHistorySchema = new MongooseSchema27(
2649
+ var redeemHistorySchema = new MongooseSchema29(
2522
2650
  {
2523
2651
  paidAt: { default: null, required: false, type: Date },
2524
2652
  redeemedAt: { required: true, type: Date },
@@ -2526,7 +2654,7 @@ var redeemHistorySchema = new MongooseSchema27(
2526
2654
  },
2527
2655
  { _id: false }
2528
2656
  );
2529
- var schema24 = new MongooseSchema27(
2657
+ var schema25 = new MongooseSchema29(
2530
2658
  {
2531
2659
  active: { default: false, required: true, type: Boolean },
2532
2660
  affiliateBonusRewards: {
@@ -2556,26 +2684,26 @@ var schema24 = new MongooseSchema27(
2556
2684
  },
2557
2685
  { timestamps: true }
2558
2686
  );
2559
- schema24.index(
2687
+ schema25.index(
2560
2688
  { affiliateCode: 1 },
2561
2689
  {
2562
2690
  partialFilterExpression: { active: true, deletedAt: null },
2563
2691
  unique: true
2564
2692
  }
2565
2693
  );
2566
- var AffiliateModel = import_mongoose32.default.models.Affiliate || import_mongoose32.default.model("Affiliate", schema24);
2694
+ var AffiliateModel = import_mongoose34.default.models.Affiliate || import_mongoose34.default.model("Affiliate", schema25);
2567
2695
 
2568
2696
  // src/mongoose/Coupon.ts
2569
- var import_cluemart_shared22 = require("@timardex/cluemart-shared");
2570
- var import_mongoose33 = __toESM(require("mongoose"));
2571
- var MongooseSchema28 = import_mongoose33.default.Schema;
2572
- var couponOptionSchema = new MongooseSchema28(
2697
+ var import_cluemart_shared23 = require("@timardex/cluemart-shared");
2698
+ var import_mongoose35 = __toESM(require("mongoose"));
2699
+ var MongooseSchema30 = import_mongoose35.default.Schema;
2700
+ var couponOptionSchema = new MongooseSchema30(
2573
2701
  {
2574
2702
  buy: { required: false, type: Number },
2575
2703
  get: { required: false, type: Number },
2576
2704
  maxRewardCount: { required: false, type: Number },
2577
2705
  type: {
2578
- enum: Object.values(import_cluemart_shared22.EnumCouponQualificationType),
2706
+ enum: Object.values(import_cluemart_shared23.EnumCouponQualificationType),
2579
2707
  required: true,
2580
2708
  type: String
2581
2709
  },
@@ -2584,29 +2712,29 @@ var couponOptionSchema = new MongooseSchema28(
2584
2712
  },
2585
2713
  { _id: false }
2586
2714
  );
2587
- var couponVendorProductSchema = new MongooseSchema28(
2715
+ var couponVendorProductSchema = new MongooseSchema30(
2588
2716
  {
2589
2717
  couponId: {
2590
2718
  required: true,
2591
- type: import_mongoose33.default.Schema.Types.ObjectId
2719
+ type: import_mongoose35.default.Schema.Types.ObjectId
2592
2720
  },
2593
2721
  productId: {
2594
2722
  required: true,
2595
- type: import_mongoose33.default.Schema.Types.ObjectId
2723
+ type: import_mongoose35.default.Schema.Types.ObjectId
2596
2724
  },
2597
2725
  vendorCouponId: {
2598
2726
  required: false,
2599
- type: import_mongoose33.default.Schema.Types.ObjectId
2727
+ type: import_mongoose35.default.Schema.Types.ObjectId
2600
2728
  },
2601
2729
  vendorId: {
2602
2730
  ref: "Vendor",
2603
2731
  required: true,
2604
- type: import_mongoose33.default.Schema.Types.ObjectId
2732
+ type: import_mongoose35.default.Schema.Types.ObjectId
2605
2733
  }
2606
2734
  },
2607
2735
  { _id: false }
2608
2736
  );
2609
- var couponCodeSchema = new MongooseSchema28(
2737
+ var couponCodeSchema = new MongooseSchema30(
2610
2738
  {
2611
2739
  code: { required: true, type: String },
2612
2740
  qrCode: { required: true, type: ResourceImageTypeSchema },
@@ -2614,7 +2742,7 @@ var couponCodeSchema = new MongooseSchema28(
2614
2742
  },
2615
2743
  { _id: false }
2616
2744
  );
2617
- var couponParticipantUserSchema = new MongooseSchema28(
2745
+ var couponParticipantUserSchema = new MongooseSchema30(
2618
2746
  {
2619
2747
  couponCollectedCount: { default: 0, required: true, type: Number },
2620
2748
  couponCycleRedeemed: { default: false, required: true, type: Boolean },
@@ -2623,12 +2751,12 @@ var couponParticipantUserSchema = new MongooseSchema28(
2623
2751
  userId: {
2624
2752
  ref: "User",
2625
2753
  required: true,
2626
- type: import_mongoose33.default.Schema.Types.ObjectId
2754
+ type: import_mongoose35.default.Schema.Types.ObjectId
2627
2755
  }
2628
2756
  },
2629
2757
  { timestamps: true }
2630
2758
  );
2631
- var couponDataSchema = new MongooseSchema28(
2759
+ var couponDataSchema = new MongooseSchema30(
2632
2760
  {
2633
2761
  active: { default: true, required: true, type: Boolean },
2634
2762
  couponCode: { required: false, type: couponCodeSchema },
@@ -2647,7 +2775,7 @@ var couponDataSchema = new MongooseSchema28(
2647
2775
  },
2648
2776
  resourceId: { required: true, type: String },
2649
2777
  resourceType: {
2650
- enum: Object.values(import_cluemart_shared22.EnumResourceType),
2778
+ enum: Object.values(import_cluemart_shared23.EnumResourceType),
2651
2779
  required: true,
2652
2780
  type: String
2653
2781
  },
@@ -2655,7 +2783,7 @@ var couponDataSchema = new MongooseSchema28(
2655
2783
  },
2656
2784
  { timestamps: true }
2657
2785
  );
2658
- var schema25 = new MongooseSchema28(
2786
+ var schema26 = new MongooseSchema30(
2659
2787
  {
2660
2788
  active: { default: true, required: true, type: Boolean },
2661
2789
  couponData: { default: [], required: false, type: [couponDataSchema] },
@@ -2667,62 +2795,62 @@ var schema25 = new MongooseSchema28(
2667
2795
  },
2668
2796
  { timestamps: true }
2669
2797
  );
2670
- schema25.index({ active: 1, deletedAt: 1, "owner.userId": 1 });
2671
- schema25.index({ "couponData.participantUsers.userId": 1 });
2672
- var CouponModel = import_mongoose33.default.models.Coupon || import_mongoose33.default.model("Coupon", schema25);
2798
+ schema26.index({ active: 1, deletedAt: 1, "owner.userId": 1 });
2799
+ schema26.index({ "couponData.participantUsers.userId": 1 });
2800
+ var CouponModel = import_mongoose35.default.models.Coupon || import_mongoose35.default.model("Coupon", schema26);
2673
2801
 
2674
2802
  // src/mongoose/Impersonation.ts
2675
- var import_cluemart_shared23 = require("@timardex/cluemart-shared");
2676
- var import_mongoose34 = __toESM(require("mongoose"));
2677
- var MongooseSchema29 = import_mongoose34.default.Schema;
2678
- var impersonationSessionSchema = new MongooseSchema29(
2803
+ var import_cluemart_shared24 = require("@timardex/cluemart-shared");
2804
+ var import_mongoose36 = __toESM(require("mongoose"));
2805
+ var MongooseSchema31 = import_mongoose36.default.Schema;
2806
+ var impersonationSessionSchema = new MongooseSchema31(
2679
2807
  {
2680
2808
  expiresAt: { expires: 0, required: true, type: Date },
2681
2809
  impersonatedUserId: {
2682
2810
  index: true,
2683
2811
  ref: "User",
2684
2812
  required: true,
2685
- type: import_mongoose34.default.Schema.Types.ObjectId
2813
+ type: import_mongoose36.default.Schema.Types.ObjectId
2686
2814
  },
2687
2815
  impersonatorUserId: {
2688
2816
  index: true,
2689
2817
  ref: "User",
2690
2818
  required: true,
2691
- type: import_mongoose34.default.Schema.Types.ObjectId
2819
+ type: import_mongoose36.default.Schema.Types.ObjectId
2692
2820
  },
2693
2821
  refreshToken: { required: true, type: String }
2694
2822
  },
2695
2823
  { timestamps: true }
2696
2824
  );
2697
- var ImpersonationSessionModel = import_mongoose34.default.models.ImpersonationSession || import_mongoose34.default.model(
2825
+ var ImpersonationSessionModel = import_mongoose36.default.models.ImpersonationSession || import_mongoose36.default.model(
2698
2826
  "ImpersonationSession",
2699
2827
  impersonationSessionSchema
2700
2828
  );
2701
- var impersonationAuditSchema = new MongooseSchema29(
2829
+ var impersonationAuditSchema = new MongooseSchema31(
2702
2830
  {
2703
2831
  action: { enum: ["start", "end"], required: true, type: String },
2704
2832
  endReason: { type: String },
2705
2833
  impersonatedUserId: {
2706
2834
  ref: "User",
2707
2835
  required: true,
2708
- type: import_mongoose34.default.Schema.Types.ObjectId
2836
+ type: import_mongoose36.default.Schema.Types.ObjectId
2709
2837
  },
2710
2838
  impersonatorUserId: {
2711
2839
  ref: "User",
2712
2840
  required: true,
2713
- type: import_mongoose34.default.Schema.Types.ObjectId
2841
+ type: import_mongoose36.default.Schema.Types.ObjectId
2714
2842
  },
2715
- resourceId: { type: import_mongoose34.default.Schema.Types.ObjectId },
2716
- resourceType: { enum: Object.values(import_cluemart_shared23.EnumResourceType), type: String },
2843
+ resourceId: { type: import_mongoose36.default.Schema.Types.ObjectId },
2844
+ resourceType: { enum: Object.values(import_cluemart_shared24.EnumResourceType), type: String },
2717
2845
  sessionId: {
2718
2846
  ref: "ImpersonationSession",
2719
2847
  required: true,
2720
- type: import_mongoose34.default.Schema.Types.ObjectId
2848
+ type: import_mongoose36.default.Schema.Types.ObjectId
2721
2849
  }
2722
2850
  },
2723
2851
  { timestamps: true }
2724
2852
  );
2725
- var ImpersonationAuditModel = import_mongoose34.default.models.ImpersonationAudit || import_mongoose34.default.model(
2853
+ var ImpersonationAuditModel = import_mongoose36.default.models.ImpersonationAudit || import_mongoose36.default.model(
2726
2854
  "ImpersonationAudit",
2727
2855
  impersonationAuditSchema
2728
2856
  );
@@ -2743,7 +2871,7 @@ async function activeAffiliateCodeExists(affiliateCode) {
2743
2871
  }
2744
2872
 
2745
2873
  // src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
2746
- var import_cluemart_shared25 = require("@timardex/cluemart-shared");
2874
+ var import_cluemart_shared26 = require("@timardex/cluemart-shared");
2747
2875
  var import_utils3 = require("@timardex/cluemart-shared/utils");
2748
2876
 
2749
2877
  // src/service/saveNotificationsInDb.ts
@@ -2878,7 +3006,7 @@ async function sendPushNotifications({
2878
3006
  }
2879
3007
 
2880
3008
  // src/service/affiliate/vendorSubscriptionRewards.ts
2881
- var import_cluemart_shared24 = require("@timardex/cluemart-shared");
3009
+ var import_cluemart_shared25 = require("@timardex/cluemart-shared");
2882
3010
  var import_dayjs = __toESM(require("dayjs"));
2883
3011
  var import_timezone = __toESM(require("dayjs/plugin/timezone"));
2884
3012
  var import_utc = __toESM(require("dayjs/plugin/utc"));
@@ -2936,17 +3064,17 @@ async function getPayingEventStripeSubscriptionPlan(userId, now = /* @__PURE__ *
2936
3064
  // src/service/affiliate/vendorSubscriptionRewards.ts
2937
3065
  import_dayjs.default.extend(import_utc.default);
2938
3066
  import_dayjs.default.extend(import_timezone.default);
2939
- var SUBSCRIPTION_REWARD_TIMEZONE = import_cluemart_shared24.NZ_TZ;
3067
+ var SUBSCRIPTION_REWARD_TIMEZONE = import_cluemart_shared25.NZ_TZ;
2940
3068
  async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
2941
3069
  const { hasSubscription, validTypes } = await getVendorStripeSubscriptionPlanForRewards(userId, now);
2942
- if (validTypes.has(import_cluemart_shared24.EnumUserLicence.PRO_VENDOR) || validTypes.has(import_cluemart_shared24.EnumUserLicence.PRO_PLUS_VENDOR)) {
3070
+ if (validTypes.has(import_cluemart_shared25.EnumUserLicence.PRO_VENDOR) || validTypes.has(import_cluemart_shared25.EnumUserLicence.PRO_PLUS_VENDOR)) {
2943
3071
  if (hasSubscription) {
2944
- return import_cluemart_shared24.EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
3072
+ return import_cluemart_shared25.EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
2945
3073
  }
2946
- return import_cluemart_shared24.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
3074
+ return import_cluemart_shared25.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2947
3075
  }
2948
- if (validTypes.has(import_cluemart_shared24.EnumUserLicence.STANDARD_VENDOR)) {
2949
- return import_cluemart_shared24.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
3076
+ if (validTypes.has(import_cluemart_shared25.EnumUserLicence.STANDARD_VENDOR)) {
3077
+ return import_cluemart_shared25.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2950
3078
  }
2951
3079
  return null;
2952
3080
  }
@@ -2958,7 +3086,7 @@ function getSubscriptionRewardPeriodBounds(now = /* @__PURE__ */ new Date()) {
2958
3086
 
2959
3087
  // src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
2960
3088
  function isEligibleVendorResource(resource) {
2961
- return resource.resourceType === import_cluemart_shared25.EnumResourceType.VENDOR && resource.resourceActive === true && resource.resourceDeletedAt == null;
3089
+ return resource.resourceType === import_cluemart_shared26.EnumResourceType.VENDOR && resource.resourceActive === true && resource.resourceDeletedAt == null;
2962
3090
  }
2963
3091
  async function findAffiliatesWithActiveVendorReferrals() {
2964
3092
  return await AffiliateModel.find({
@@ -2967,7 +3095,7 @@ async function findAffiliatesWithActiveVendorReferrals() {
2967
3095
  $elemMatch: {
2968
3096
  resourceActive: true,
2969
3097
  resourceDeletedAt: null,
2970
- resourceType: import_cluemart_shared25.EnumResourceType.VENDOR
3098
+ resourceType: import_cluemart_shared26.EnumResourceType.VENDOR
2971
3099
  }
2972
3100
  },
2973
3101
  deletedAt: null
@@ -3001,11 +3129,11 @@ async function notifyAffiliateOwnerOfSubscriptionReward({
3001
3129
  data: {
3002
3130
  resourceId: String(affiliateId),
3003
3131
  resourceName: resourceNames.join(", "),
3004
- resourceType: import_cluemart_shared25.EnumNotificationResourceType.AFFILIATE_REWARD_RECEIVED
3132
+ resourceType: import_cluemart_shared26.EnumNotificationResourceType.AFFILIATE_REWARD_RECEIVED
3005
3133
  },
3006
3134
  message,
3007
3135
  title: "Affiliate points earned",
3008
- type: import_cluemart_shared25.EnumNotificationType.SYSTEM,
3136
+ type: import_cluemart_shared26.EnumNotificationType.SYSTEM,
3009
3137
  userIds: [affiliateOwnerUserId]
3010
3138
  };
3011
3139
  try {
@@ -3034,7 +3162,7 @@ async function tryAwardSubscriptionReward({
3034
3162
  resourceActive: true,
3035
3163
  resourceDeletedAt: null,
3036
3164
  resourceId: resource.resourceId,
3037
- resourceType: import_cluemart_shared25.EnumResourceType.VENDOR,
3165
+ resourceType: import_cluemart_shared26.EnumResourceType.VENDOR,
3038
3166
  rewards: {
3039
3167
  $not: {
3040
3168
  $elemMatch: {
@@ -3155,7 +3283,7 @@ function normalizeAffiliatePromoCodes(promoCodes) {
3155
3283
  }
3156
3284
 
3157
3285
  // src/service/database.ts
3158
- var import_mongoose38 = __toESM(require("mongoose"));
3286
+ var import_mongoose40 = __toESM(require("mongoose"));
3159
3287
  var connectToDatabase = async ({
3160
3288
  appName,
3161
3289
  dbName,
@@ -3168,7 +3296,7 @@ var connectToDatabase = async ({
3168
3296
  // Fallback to MongoDB Atlas connection string
3169
3297
  `mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
3170
3298
  );
3171
- await import_mongoose38.default.connect(mongoUri);
3299
+ await import_mongoose40.default.connect(mongoUri);
3172
3300
  const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
3173
3301
  console.log(
3174
3302
  `${connectionType} connected from server/src/service/database.ts`
@@ -3181,7 +3309,7 @@ var connectToDatabase = async ({
3181
3309
 
3182
3310
  // src/types/index.ts
3183
3311
  var import_express = __toESM(require("express"));
3184
- var import_mongoose39 = __toESM(require("mongoose"));
3312
+ var import_mongoose41 = __toESM(require("mongoose"));
3185
3313
  var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
3186
3314
  EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
3187
3315
  EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
@@ -3236,9 +3364,9 @@ async function notifyUsers({
3236
3364
  }
3237
3365
 
3238
3366
  // src/service/updateAdStatus.ts
3239
- var import_cluemart_shared26 = require("@timardex/cluemart-shared");
3367
+ var import_cluemart_shared27 = require("@timardex/cluemart-shared");
3240
3368
  async function updateAdStatuses() {
3241
- const now = (0, import_cluemart_shared26.nzDayKey)();
3369
+ const now = (0, import_cluemart_shared27.nzDayKey)();
3242
3370
  const invalidResult = await AdModel.updateMany(
3243
3371
  {
3244
3372
  $or: [
@@ -3246,50 +3374,50 @@ async function updateAdStatuses() {
3246
3374
  { end: { $exists: false } },
3247
3375
  { $expr: { $gt: ["$start", "$end"] } }
3248
3376
  ],
3249
- status: { $ne: import_cluemart_shared26.EnumAdStatus.PAUSED }
3377
+ status: { $ne: import_cluemart_shared27.EnumAdStatus.PAUSED }
3250
3378
  },
3251
- { $set: { status: import_cluemart_shared26.EnumAdStatus.PAUSED } }
3379
+ { $set: { status: import_cluemart_shared27.EnumAdStatus.PAUSED } }
3252
3380
  );
3253
3381
  const expiredResult = await AdModel.updateMany(
3254
- { end: { $lte: now }, status: { $ne: import_cluemart_shared26.EnumAdStatus.EXPIRED } },
3255
- { $set: { status: import_cluemart_shared26.EnumAdStatus.EXPIRED } }
3382
+ { end: { $lte: now }, status: { $ne: import_cluemart_shared27.EnumAdStatus.EXPIRED } },
3383
+ { $set: { status: import_cluemart_shared27.EnumAdStatus.EXPIRED } }
3256
3384
  );
3257
3385
  const eligibleBooking = {
3258
3386
  $or: [
3259
3387
  { bookingKind: { $exists: false } },
3260
3388
  { bookingKind: null },
3261
3389
  {
3262
- approvalStatus: import_cluemart_shared26.EnumAdApprovalStatus.APPROVED,
3263
- bookingKind: import_cluemart_shared26.EnumAdBookingSlotKind.RESERVED
3390
+ approvalStatus: import_cluemart_shared27.EnumAdApprovalStatus.APPROVED,
3391
+ bookingKind: import_cluemart_shared27.EnumAdBookingSlotKind.RESERVED
3264
3392
  },
3265
3393
  {
3266
- approvalStatus: import_cluemart_shared26.EnumAdApprovalStatus.APPROVED,
3267
- bookingKind: import_cluemart_shared26.EnumAdBookingSlotKind.PAID,
3268
- paymentStatus: import_cluemart_shared26.EnumAdPaymentStatus.PAID
3394
+ approvalStatus: import_cluemart_shared27.EnumAdApprovalStatus.APPROVED,
3395
+ bookingKind: import_cluemart_shared27.EnumAdBookingSlotKind.PAID,
3396
+ paymentStatus: import_cluemart_shared27.EnumAdPaymentStatus.PAID
3269
3397
  }
3270
3398
  ]
3271
3399
  };
3272
3400
  const awaitingApprovalResult = await AdModel.updateMany(
3273
3401
  {
3274
3402
  $nor: eligibleBooking.$or,
3275
- bookingKind: { $in: Object.values(import_cluemart_shared26.EnumAdBookingSlotKind) },
3403
+ bookingKind: { $in: Object.values(import_cluemart_shared27.EnumAdBookingSlotKind) },
3276
3404
  end: { $gt: now },
3277
- status: import_cluemart_shared26.EnumAdStatus.ACTIVE
3405
+ status: import_cluemart_shared27.EnumAdStatus.ACTIVE
3278
3406
  },
3279
- { $set: { status: import_cluemart_shared26.EnumAdStatus.PAUSED } }
3407
+ { $set: { status: import_cluemart_shared27.EnumAdStatus.PAUSED } }
3280
3408
  );
3281
3409
  const activeResult = await AdModel.updateMany(
3282
3410
  {
3283
3411
  end: { $gt: now },
3284
3412
  start: { $lte: now },
3285
- status: { $ne: import_cluemart_shared26.EnumAdStatus.ACTIVE },
3413
+ status: { $ne: import_cluemart_shared27.EnumAdStatus.ACTIVE },
3286
3414
  ...eligibleBooking
3287
3415
  },
3288
- { $set: { status: import_cluemart_shared26.EnumAdStatus.ACTIVE } }
3416
+ { $set: { status: import_cluemart_shared27.EnumAdStatus.ACTIVE } }
3289
3417
  );
3290
3418
  const pausedResult = await AdModel.updateMany(
3291
- { start: { $gt: now }, status: { $ne: import_cluemart_shared26.EnumAdStatus.PAUSED } },
3292
- { $set: { status: import_cluemart_shared26.EnumAdStatus.PAUSED } }
3419
+ { start: { $gt: now }, status: { $ne: import_cluemart_shared27.EnumAdStatus.PAUSED } },
3420
+ { $set: { status: import_cluemart_shared27.EnumAdStatus.PAUSED } }
3293
3421
  );
3294
3422
  console.log(
3295
3423
  `\u2705 Ad statuses updated: invalid=${invalidResult.modifiedCount}, expired=${expiredResult.modifiedCount}, awaitingApproval=${awaitingApprovalResult.modifiedCount}, active=${activeResult.modifiedCount}, paused=${pausedResult.modifiedCount}`
@@ -3297,15 +3425,15 @@ async function updateAdStatuses() {
3297
3425
  }
3298
3426
 
3299
3427
  // src/service/objectIdToString.ts
3300
- var import_mongoose41 = __toESM(require("mongoose"));
3428
+ var import_mongoose43 = __toESM(require("mongoose"));
3301
3429
  function isValidObjectId(value) {
3302
- return import_mongoose41.default.Types.ObjectId.isValid(value);
3430
+ return import_mongoose43.default.Types.ObjectId.isValid(value);
3303
3431
  }
3304
3432
  function convertObjectIdsToStrings(obj) {
3305
3433
  if (obj === null || obj === void 0) {
3306
3434
  return obj;
3307
3435
  }
3308
- if (obj instanceof import_mongoose41.default.Types.ObjectId) {
3436
+ if (obj instanceof import_mongoose43.default.Types.ObjectId) {
3309
3437
  return obj.toString();
3310
3438
  }
3311
3439
  if (obj instanceof Date) {
@@ -3499,19 +3627,19 @@ function buildUserPointEntryRemovalPipeline(pointType, sourceId) {
3499
3627
  }
3500
3628
 
3501
3629
  // src/service/event/updateAllEventDateTimeStatuses.ts
3502
- var import_cluemart_shared28 = require("@timardex/cluemart-shared");
3630
+ var import_cluemart_shared29 = require("@timardex/cluemart-shared");
3503
3631
  var import_dayjs4 = __toESM(require("dayjs"));
3504
3632
 
3505
3633
  // src/service/event/archiveEndedEventDates.ts
3506
- var import_cluemart_shared27 = require("@timardex/cluemart-shared");
3634
+ var import_cluemart_shared28 = require("@timardex/cluemart-shared");
3507
3635
  var import_dayjs3 = __toESM(require("dayjs"));
3508
3636
  var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
3509
3637
  import_dayjs3.default.extend(import_customParseFormat.default);
3510
3638
  var ARCHIVED_STATUSES = /* @__PURE__ */ new Set([
3511
- import_cluemart_shared27.EnumEventDateStatus.ENDED
3639
+ import_cluemart_shared28.EnumEventDateStatus.ENDED
3512
3640
  ]);
3513
3641
  var DISCARDED_STATUSES = /* @__PURE__ */ new Set([
3514
- import_cluemart_shared27.EnumEventDateStatus.INVALID
3642
+ import_cluemart_shared28.EnumEventDateStatus.INVALID
3515
3643
  ]);
3516
3644
  function splitEventDatesForArchive(dateTime) {
3517
3645
  return {
@@ -3534,12 +3662,12 @@ function dedupeArchivedSlotsByStartDateTime(slots) {
3534
3662
  });
3535
3663
  }
3536
3664
  function isPastCanceledEventDate(slot, now) {
3537
- if (slot.dateStatus !== import_cluemart_shared27.EnumEventDateStatus.CANCELED) {
3665
+ if (slot.dateStatus !== import_cluemart_shared28.EnumEventDateStatus.CANCELED) {
3538
3666
  return false;
3539
3667
  }
3540
3668
  const endDateTime = (0, import_dayjs3.default)(
3541
3669
  `${slot.endDate} ${slot.endTime}`,
3542
- `${import_cluemart_shared27.dateFormat} ${import_cluemart_shared27.timeFormat}`,
3670
+ `${import_cluemart_shared28.dateFormat} ${import_cluemart_shared28.timeFormat}`,
3543
3671
  true
3544
3672
  );
3545
3673
  return endDateTime.isValid() && endDateTime.isBefore(now);
@@ -3585,7 +3713,7 @@ async function updateModelDateTimeStatuses(model, now) {
3585
3713
  try {
3586
3714
  for await (const doc of cursor) {
3587
3715
  const dateTime = doc.dateTime.map(
3588
- (slot) => (0, import_cluemart_shared28.updateSingleDateTimeStatus)(slot, now)
3716
+ (slot) => (0, import_cluemart_shared29.updateSingleDateTimeStatus)(slot, now)
3589
3717
  );
3590
3718
  if (!hasDateTimeStatusChanges(doc.dateTime, dateTime)) {
3591
3719
  continue;
@@ -3609,9 +3737,9 @@ async function updateModelDateTimeStatuses(model, now) {
3609
3737
  var ARCHIVABLE_EVENT_FILTER = {
3610
3738
  "dateTime.dateStatus": {
3611
3739
  $in: [
3612
- import_cluemart_shared28.EnumEventDateStatus.ENDED,
3613
- import_cluemart_shared28.EnumEventDateStatus.INVALID,
3614
- import_cluemart_shared28.EnumEventDateStatus.CANCELED
3740
+ import_cluemart_shared29.EnumEventDateStatus.ENDED,
3741
+ import_cluemart_shared29.EnumEventDateStatus.INVALID,
3742
+ import_cluemart_shared29.EnumEventDateStatus.CANCELED
3615
3743
  ]
3616
3744
  },
3617
3745
  deletedAt: null
@@ -3636,7 +3764,7 @@ async function archiveEndedAndDiscardInvalidEventDates(now) {
3636
3764
  try {
3637
3765
  for await (const doc of cursor) {
3638
3766
  const updated = doc.dateTime.map(
3639
- (slot) => (0, import_cluemart_shared28.updateSingleDateTimeStatus)(slot, now)
3767
+ (slot) => (0, import_cluemart_shared29.updateSingleDateTimeStatus)(slot, now)
3640
3768
  );
3641
3769
  const { archive, discard } = splitEventDatesForArchive(updated);
3642
3770
  const pastCanceled = updated.filter(
@@ -3660,13 +3788,13 @@ async function archiveEndedAndDiscardInvalidEventDates(now) {
3660
3788
  if (archive.length > 0 || discard.length > 0) {
3661
3789
  pullConditions.push({
3662
3790
  dateStatus: {
3663
- $in: [import_cluemart_shared28.EnumEventDateStatus.ENDED, import_cluemart_shared28.EnumEventDateStatus.INVALID]
3791
+ $in: [import_cluemart_shared29.EnumEventDateStatus.ENDED, import_cluemart_shared29.EnumEventDateStatus.INVALID]
3664
3792
  }
3665
3793
  });
3666
3794
  }
3667
3795
  for (const slot of pastCanceled) {
3668
3796
  pullConditions.push({
3669
- dateStatus: import_cluemart_shared28.EnumEventDateStatus.CANCELED,
3797
+ dateStatus: import_cluemart_shared29.EnumEventDateStatus.CANCELED,
3670
3798
  startDate: slot.startDate,
3671
3799
  startTime: slot.startTime
3672
3800
  });
@@ -3708,9 +3836,9 @@ async function cleanEventInfoDates(now) {
3708
3836
  try {
3709
3837
  for await (const doc of cursor) {
3710
3838
  const updated = doc.dateTime.map(
3711
- (slot) => (0, import_cluemart_shared28.updateSingleDateTimeStatus)(slot, now)
3839
+ (slot) => (0, import_cluemart_shared29.updateSingleDateTimeStatus)(slot, now)
3712
3840
  );
3713
- const kept = (0, import_cluemart_shared28.filterDatesByFutureStatus)(updated);
3841
+ const kept = (0, import_cluemart_shared29.filterDatesByFutureStatus)(updated);
3714
3842
  if (kept.length === updated.length) {
3715
3843
  continue;
3716
3844
  }
@@ -3733,15 +3861,19 @@ async function cleanEventInfoDates(now) {
3733
3861
  }
3734
3862
  async function updateAllEventDateTimeStatuses() {
3735
3863
  const now = (0, import_dayjs4.default)();
3736
- const [eventCount, marketCount] = await Promise.all([
3864
+ const [eventCount, marketCount, aiMarketCount] = await Promise.all([
3737
3865
  updateModelDateTimeStatuses(EventModel, now),
3738
3866
  updateModelDateTimeStatuses(
3739
3867
  GoogleImportedMarketModel,
3740
3868
  now
3869
+ ),
3870
+ updateModelDateTimeStatuses(
3871
+ AiImportedMarketModel,
3872
+ now
3741
3873
  )
3742
3874
  ]);
3743
3875
  console.log(
3744
- `\u2705 Event dateTime statuses updated: events=${eventCount} changed, google imported markets=${marketCount} changed`
3876
+ `\u2705 Event dateTime statuses updated: events=${eventCount} changed, google imported markets=${marketCount} changed, ai imported markets=${aiMarketCount} changed`
3745
3877
  );
3746
3878
  const archivedCount = await archiveEndedAndDiscardInvalidEventDates(now);
3747
3879
  if (archivedCount > 0) {
@@ -3756,7 +3888,7 @@ async function updateAllEventDateTimeStatuses() {
3756
3888
  }
3757
3889
 
3758
3890
  // src/service/index.ts
3759
- var import_cluemart_shared36 = require("@timardex/cluemart-shared");
3891
+ var import_cluemart_shared37 = require("@timardex/cluemart-shared");
3760
3892
 
3761
3893
  // src/service/event/findEventOrImportedMarketById.ts
3762
3894
  async function findEventOrImportedMarketById(resourceId) {
@@ -3764,15 +3896,16 @@ async function findEventOrImportedMarketById(resourceId) {
3764
3896
  return null;
3765
3897
  }
3766
3898
  const normalizedId = convertObjectIdsToStrings(resourceId);
3767
- const [eventDoc, googleImportedDoc] = await Promise.all([
3899
+ const [eventDoc, googleImportedDoc, aiImportedDoc] = await Promise.all([
3768
3900
  EventModel.findById(normalizedId).select("_id name dateTime owner").lean().exec(),
3769
- GoogleImportedMarketModel.findById(normalizedId).select("_id name dateTime").lean().exec()
3901
+ GoogleImportedMarketModel.findById(normalizedId).select("_id name dateTime").lean().exec(),
3902
+ AiImportedMarketModel.findById(normalizedId).select("_id name dateTime").lean().exec()
3770
3903
  ]);
3771
- return eventDoc ?? googleImportedDoc;
3904
+ return eventDoc ?? googleImportedDoc ?? aiImportedDoc;
3772
3905
  }
3773
3906
 
3774
3907
  // src/service/relations.ts
3775
- var import_cluemart_shared29 = require("@timardex/cluemart-shared");
3908
+ var import_cluemart_shared30 = require("@timardex/cluemart-shared");
3776
3909
  function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
3777
3910
  if (!previousDateTime?.length) {
3778
3911
  return false;
@@ -3788,8 +3921,8 @@ function didRemoveAnyStartedDates(previousDateTime, nextDateTime) {
3788
3921
  return false;
3789
3922
  }
3790
3923
  return previousDateTime.some(
3791
- (prev) => prev.dateStatus === import_cluemart_shared29.EnumEventDateStatus.STARTED && !nextDateTime?.some(
3792
- (next) => next.startDate === prev.startDate && next.startTime === prev.startTime && next.dateStatus === import_cluemart_shared29.EnumEventDateStatus.STARTED
3924
+ (prev) => prev.dateStatus === import_cluemart_shared30.EnumEventDateStatus.STARTED && !nextDateTime?.some(
3925
+ (next) => next.startDate === prev.startDate && next.startTime === prev.startTime && next.dateStatus === import_cluemart_shared30.EnumEventDateStatus.STARTED
3793
3926
  )
3794
3927
  );
3795
3928
  }
@@ -3800,7 +3933,7 @@ function updateRelationDatesToCanceled(relationDates, eventDateTime) {
3800
3933
  ) ?? false;
3801
3934
  return {
3802
3935
  ...relationDate,
3803
- status: existsInEvent ? relationDate.status : import_cluemart_shared29.EnumInviteStatus.CANCELED
3936
+ status: existsInEvent ? relationDate.status : import_cluemart_shared30.EnumInviteStatus.CANCELED
3804
3937
  };
3805
3938
  });
3806
3939
  }
@@ -3809,15 +3942,15 @@ function updateRelationDatesToCanceled(relationDates, eventDateTime) {
3809
3942
  var import_dayjs8 = __toESM(require("dayjs"));
3810
3943
 
3811
3944
  // src/service/license/compliance/utils.ts
3812
- var import_cluemart_shared34 = require("@timardex/cluemart-shared");
3945
+ var import_cluemart_shared35 = require("@timardex/cluemart-shared");
3813
3946
  var import_dayjs7 = __toESM(require("dayjs"));
3814
3947
 
3815
3948
  // src/service/license/compliance/event.ts
3816
- var import_cluemart_shared30 = require("@timardex/cluemart-shared");
3949
+ var import_cluemart_shared31 = require("@timardex/cluemart-shared");
3817
3950
  var eventLicences = [
3818
- import_cluemart_shared30.EnumUserLicence.STANDARD_EVENT,
3819
- import_cluemart_shared30.EnumUserLicence.PRO_EVENT,
3820
- import_cluemart_shared30.EnumUserLicence.PRO_PLUS_EVENT
3951
+ import_cluemart_shared31.EnumUserLicence.STANDARD_EVENT,
3952
+ import_cluemart_shared31.EnumUserLicence.PRO_EVENT,
3953
+ import_cluemart_shared31.EnumUserLicence.PRO_PLUS_EVENT
3821
3954
  ];
3822
3955
  async function handleEventLicenceCompliance(user, now) {
3823
3956
  if (!user.licences || !user.events?.length) {
@@ -4029,9 +4162,9 @@ function buildLicenceExpiryPipeline(params) {
4029
4162
  }
4030
4163
 
4031
4164
  // src/service/license/compliance/partner.ts
4032
- var import_cluemart_shared31 = require("@timardex/cluemart-shared");
4165
+ var import_cluemart_shared32 = require("@timardex/cluemart-shared");
4033
4166
  var partnerLicences = [
4034
- import_cluemart_shared31.EnumUserLicence.STANDARD_PARTNER
4167
+ import_cluemart_shared32.EnumUserLicence.STANDARD_PARTNER
4035
4168
  ];
4036
4169
  async function handlePartnerLicenceCompliance(user, now) {
4037
4170
  if (!user.licences || !user.partner) {
@@ -4041,11 +4174,11 @@ async function handlePartnerLicenceCompliance(user, now) {
4041
4174
  }
4042
4175
 
4043
4176
  // src/service/license/compliance/vendor.ts
4044
- var import_cluemart_shared33 = require("@timardex/cluemart-shared");
4177
+ var import_cluemart_shared34 = require("@timardex/cluemart-shared");
4045
4178
  var import_dayjs6 = __toESM(require("dayjs"));
4046
4179
 
4047
4180
  // src/service/license/models.ts
4048
- var import_cluemart_shared32 = require("@timardex/cluemart-shared");
4181
+ var import_cluemart_shared33 = require("@timardex/cluemart-shared");
4049
4182
  var import_dayjs5 = __toESM(require("dayjs"));
4050
4183
  var import_graphql = require("graphql");
4051
4184
  var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
@@ -4057,31 +4190,31 @@ var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
4057
4190
  return LicenceCategory2;
4058
4191
  })(LicenceCategory || {});
4059
4192
  var licenceCategoryMapping = {
4060
- [import_cluemart_shared32.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
4061
- [import_cluemart_shared32.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
4062
- [import_cluemart_shared32.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
4063
- [import_cluemart_shared32.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
4064
- [import_cluemart_shared32.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
4065
- [import_cluemart_shared32.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
4066
- [import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
4067
- [import_cluemart_shared32.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
4068
- [import_cluemart_shared32.EnumUserLicence.STANDARD_SCHOOL]: "school" /* SCHOOL */
4193
+ [import_cluemart_shared33.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
4194
+ [import_cluemart_shared33.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
4195
+ [import_cluemart_shared33.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
4196
+ [import_cluemart_shared33.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
4197
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
4198
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
4199
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
4200
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
4201
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_SCHOOL]: "school" /* SCHOOL */
4069
4202
  };
4070
4203
  var licencePriority = {
4071
- [import_cluemart_shared32.EnumUserLicence.PRO_PLUS_EVENT]: 3,
4072
- [import_cluemart_shared32.EnumUserLicence.PRO_EVENT]: 2,
4073
- [import_cluemart_shared32.EnumUserLicence.STANDARD_EVENT]: 1,
4074
- [import_cluemart_shared32.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
4075
- [import_cluemart_shared32.EnumUserLicence.PRO_VENDOR]: 2,
4076
- [import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR]: 1,
4077
- [import_cluemart_shared32.EnumUserLicence.STANDARD_PARTNER]: 1,
4078
- [import_cluemart_shared32.EnumUserLicence.STANDARD_AFFILIATE]: 1,
4079
- [import_cluemart_shared32.EnumUserLicence.STANDARD_SCHOOL]: 1
4204
+ [import_cluemart_shared33.EnumUserLicence.PRO_PLUS_EVENT]: 3,
4205
+ [import_cluemart_shared33.EnumUserLicence.PRO_EVENT]: 2,
4206
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_EVENT]: 1,
4207
+ [import_cluemart_shared33.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
4208
+ [import_cluemart_shared33.EnumUserLicence.PRO_VENDOR]: 2,
4209
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR]: 1,
4210
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_PARTNER]: 1,
4211
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_AFFILIATE]: 1,
4212
+ [import_cluemart_shared33.EnumUserLicence.STANDARD_SCHOOL]: 1
4080
4213
  };
4081
4214
  var standardLicences = [
4082
- import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR,
4083
- import_cluemart_shared32.EnumUserLicence.STANDARD_EVENT,
4084
- import_cluemart_shared32.EnumUserLicence.STANDARD_PARTNER
4215
+ import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR,
4216
+ import_cluemart_shared33.EnumUserLicence.STANDARD_EVENT,
4217
+ import_cluemart_shared33.EnumUserLicence.STANDARD_PARTNER
4085
4218
  ];
4086
4219
  var standardLicenceSet = new Set(standardLicences);
4087
4220
  function isStandardLicence(licence) {
@@ -4095,11 +4228,11 @@ var categoryRegexMapping = {
4095
4228
  ["school" /* SCHOOL */]: /_school$/
4096
4229
  };
4097
4230
  var categoryFallbackLicence = {
4098
- ["event" /* EVENT */]: import_cluemart_shared32.EnumUserLicence.STANDARD_EVENT,
4099
- ["partner" /* PARTNER */]: import_cluemart_shared32.EnumUserLicence.STANDARD_PARTNER,
4100
- ["vendor" /* VENDOR */]: import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR,
4101
- ["affiliate" /* AFFILIATE */]: import_cluemart_shared32.EnumUserLicence.STANDARD_AFFILIATE,
4102
- ["school" /* SCHOOL */]: import_cluemart_shared32.EnumUserLicence.STANDARD_SCHOOL
4231
+ ["event" /* EVENT */]: import_cluemart_shared33.EnumUserLicence.STANDARD_EVENT,
4232
+ ["partner" /* PARTNER */]: import_cluemart_shared33.EnumUserLicence.STANDARD_PARTNER,
4233
+ ["vendor" /* VENDOR */]: import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR,
4234
+ ["affiliate" /* AFFILIATE */]: import_cluemart_shared33.EnumUserLicence.STANDARD_AFFILIATE,
4235
+ ["school" /* SCHOOL */]: import_cluemart_shared33.EnumUserLicence.STANDARD_SCHOOL
4103
4236
  };
4104
4237
  var LicenceFilterInput = {
4105
4238
  INPUT_USER_LICENCES: "$licences"
@@ -4129,11 +4262,11 @@ function getHighestLicenceForCategory(licences, category) {
4129
4262
  function createLicenceObject(expiryDate, licenceType) {
4130
4263
  const today = (0, import_dayjs5.default)();
4131
4264
  const expiryDateMapping = {
4132
- [import_cluemart_shared32.LicenceExpiryDate.ONE_YEAR]: today.add(1, "year").endOf("day").toDate(),
4133
- [import_cluemart_shared32.LicenceExpiryDate.ONE_MONTH]: today.add(1, "month").endOf("day").toDate(),
4134
- [import_cluemart_shared32.LicenceExpiryDate.TWO_MONTHS]: today.add(2, "month").endOf("day").toDate(),
4135
- [import_cluemart_shared32.LicenceExpiryDate.THREE_MONTHS]: today.add(3, "month").endOf("day").toDate(),
4136
- [import_cluemart_shared32.LicenceExpiryDate.SIX_MONTHS]: today.add(6, "month").endOf("day").toDate()
4265
+ [import_cluemart_shared33.LicenceExpiryDate.ONE_YEAR]: today.add(1, "year").endOf("day").toDate(),
4266
+ [import_cluemart_shared33.LicenceExpiryDate.ONE_MONTH]: today.add(1, "month").endOf("day").toDate(),
4267
+ [import_cluemart_shared33.LicenceExpiryDate.TWO_MONTHS]: today.add(2, "month").endOf("day").toDate(),
4268
+ [import_cluemart_shared33.LicenceExpiryDate.THREE_MONTHS]: today.add(3, "month").endOf("day").toDate(),
4269
+ [import_cluemart_shared33.LicenceExpiryDate.SIX_MONTHS]: today.add(6, "month").endOf("day").toDate()
4137
4270
  };
4138
4271
  const licenceObject = {
4139
4272
  expiryDate: expiryDateMapping[expiryDate],
@@ -4237,13 +4370,13 @@ async function checkOwnerHasLicence({
4237
4370
  const owner = await UserModel.findById(userId);
4238
4371
  if (!owner) throw new import_graphql.GraphQLError("Owner not found");
4239
4372
  const categoryByResource = {
4240
- [import_cluemart_shared32.EnumResourceType.EVENT]: "event" /* EVENT */,
4241
- [import_cluemart_shared32.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
4242
- [import_cluemart_shared32.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
4243
- [import_cluemart_shared32.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
4244
- [import_cluemart_shared32.EnumResourceType.SCHOOL]: "school" /* SCHOOL */
4373
+ [import_cluemart_shared33.EnumResourceType.EVENT]: "event" /* EVENT */,
4374
+ [import_cluemart_shared33.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
4375
+ [import_cluemart_shared33.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
4376
+ [import_cluemart_shared33.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
4377
+ [import_cluemart_shared33.EnumResourceType.SCHOOL]: "school" /* SCHOOL */
4245
4378
  };
4246
- if (!(0, import_cluemart_shared32.isNonVisitorResourceType)(resourceType)) {
4379
+ if (!(0, import_cluemart_shared33.isNonVisitorResourceType)(resourceType)) {
4247
4380
  throw new import_graphql.GraphQLError(`Invalid resource type: ${resourceType}.`);
4248
4381
  }
4249
4382
  const requiredCategory = categoryByResource[resourceType];
@@ -4323,7 +4456,7 @@ async function applyVendorDowngrade(vendor, ownerUserId) {
4323
4456
  return (result?.matchedCount ?? 0) > 0;
4324
4457
  }
4325
4458
  async function downgradeVendorProFeatures(userId, licenceType) {
4326
- const isStandardVendor = licenceType === import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR;
4459
+ const isStandardVendor = licenceType === import_cluemart_shared34.EnumUserLicence.STANDARD_VENDOR;
4327
4460
  if (!isStandardVendor) {
4328
4461
  return;
4329
4462
  }
@@ -4370,7 +4503,7 @@ async function applyVendorRestore(vendor, ownerUserId) {
4370
4503
  return (result?.matchedCount ?? 0) > 0;
4371
4504
  }
4372
4505
  async function restoreVendorProFeatures(userId, licenceType) {
4373
- const isProVendor = licenceType === import_cluemart_shared33.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared33.EnumUserLicence.PRO_PLUS_VENDOR;
4506
+ const isProVendor = licenceType === import_cluemart_shared34.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared34.EnumUserLicence.PRO_PLUS_VENDOR;
4374
4507
  if (!isProVendor) {
4375
4508
  return;
4376
4509
  }
@@ -4391,14 +4524,14 @@ function isProtectedByCurrentStripeSubscription(user, licenceType, now) {
4391
4524
  return false;
4392
4525
  }
4393
4526
  const gracePeriodEndsAt = stripe.paymentGracePeriodEndsAt ? (0, import_dayjs6.default)(stripe.paymentGracePeriodEndsAt) : null;
4394
- 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);
4527
+ 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);
4395
4528
  if (hasActivePaymentGracePeriod) {
4396
4529
  return true;
4397
4530
  }
4398
4531
  if (!stripe.subscriptionId) {
4399
4532
  return false;
4400
4533
  }
4401
- if (stripe.status !== import_cluemart_shared33.EnumSubscriptionStatus.ACTIVE) {
4534
+ if (stripe.status !== import_cluemart_shared34.EnumSubscriptionStatus.ACTIVE) {
4402
4535
  return false;
4403
4536
  }
4404
4537
  if (!stripe.endDate) {
@@ -4418,7 +4551,7 @@ async function handleVendorLicenceCompliance(user, now) {
4418
4551
  return;
4419
4552
  }
4420
4553
  const proLicences = vendorLicencesOfUser.filter(
4421
- (licence) => licence.licenceType !== import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR
4554
+ (licence) => licence.licenceType !== import_cluemart_shared34.EnumUserLicence.STANDARD_VENDOR
4422
4555
  );
4423
4556
  const expiredProLicences = proLicences.filter(
4424
4557
  (licence) => !(0, import_dayjs6.default)(licence.expiryDate).isAfter(now)
@@ -4431,7 +4564,7 @@ async function handleVendorLicenceCompliance(user, now) {
4431
4564
  const expiredProLicence = expiredProLicences.some(
4432
4565
  (licence) => !stripeProtectedLicenceTypes.has(licence.licenceType)
4433
4566
  );
4434
- const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences, import_cluemart_shared33.vendorLicences, now);
4567
+ const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences, import_cluemart_shared34.vendorLicences, now);
4435
4568
  const hasExpiredVendorLicence = vendorLicencesOfUser.some(
4436
4569
  (licence) => !(0, import_dayjs6.default)(licence.expiryDate).isAfter(now) && !stripeProtectedLicenceTypes.has(licence.licenceType)
4437
4570
  );
@@ -4447,7 +4580,7 @@ async function handleVendorLicenceCompliance(user, now) {
4447
4580
  "owner.userId": user._id
4448
4581
  }).lean().exec();
4449
4582
  }
4450
- const licencesToSync = import_cluemart_shared33.vendorLicences.filter(
4583
+ const licencesToSync = import_cluemart_shared34.vendorLicences.filter(
4451
4584
  (licenceType) => !stripeProtectedLicenceTypes.has(licenceType)
4452
4585
  );
4453
4586
  await syncUserLicencesAfterExpiry(user._id, licencesToSync, now, "downgrade");
@@ -4462,11 +4595,11 @@ async function handleVendorLicenceCompliance(user, now) {
4462
4595
  data: {
4463
4596
  resourceId: String(vendor._id),
4464
4597
  resourceName: vendor.name,
4465
- resourceType: import_cluemart_shared33.EnumNotificationResourceType.DOWNGRADED_VENDOR
4598
+ resourceType: import_cluemart_shared34.EnumNotificationResourceType.DOWNGRADED_VENDOR
4466
4599
  },
4467
4600
  message: `Your Vendor licence has been downgraded due to licence expiration.`,
4468
4601
  title: `Vendor Licence Downgraded`,
4469
- type: import_cluemart_shared33.EnumNotificationType.SYSTEM,
4602
+ type: import_cluemart_shared34.EnumNotificationType.SYSTEM,
4470
4603
  userIds: [user._id]
4471
4604
  };
4472
4605
  await sendDeactivationNotification(payload, user._id, vendor.name, "vendor");
@@ -4499,7 +4632,7 @@ async function vendorOwnerHasProLicence(vendorId) {
4499
4632
  effectiveVendorLicences,
4500
4633
  "vendor" /* VENDOR */
4501
4634
  );
4502
- return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[import_cluemart_shared33.EnumUserLicence.PRO_VENDOR];
4635
+ return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[import_cluemart_shared34.EnumUserLicence.PRO_VENDOR];
4503
4636
  }
4504
4637
 
4505
4638
  // src/service/license/compliance/utils.ts
@@ -4509,12 +4642,12 @@ async function syncUserLicencesAfterExpiry(userId, licenceTypes, now, mode = "do
4509
4642
  const pipeline = buildLicenceExpiryPipeline({
4510
4643
  downgradeBranches: [
4511
4644
  {
4512
- case: import_cluemart_shared34.EnumUserLicence.PRO_PLUS_VENDOR,
4513
- then: import_cluemart_shared34.EnumUserLicence.STANDARD_VENDOR
4645
+ case: import_cluemart_shared35.EnumUserLicence.PRO_PLUS_VENDOR,
4646
+ then: import_cluemart_shared35.EnumUserLicence.STANDARD_VENDOR
4514
4647
  },
4515
4648
  {
4516
- case: import_cluemart_shared34.EnumUserLicence.PRO_VENDOR,
4517
- then: import_cluemart_shared34.EnumUserLicence.STANDARD_VENDOR
4649
+ case: import_cluemart_shared35.EnumUserLicence.PRO_VENDOR,
4650
+ then: import_cluemart_shared35.EnumUserLicence.STANDARD_VENDOR
4518
4651
  }
4519
4652
  ],
4520
4653
  licenceTypes,
@@ -4643,7 +4776,7 @@ var REMINDER_WINDOW_MIN_HOURS = 6.5 * 24;
4643
4776
  var REMINDER_WINDOW_MAX_HOURS = 7.5 * 24;
4644
4777
 
4645
4778
  // src/service/license/reminder/utils.ts
4646
- var import_cluemart_shared35 = require("@timardex/cluemart-shared");
4779
+ var import_cluemart_shared36 = require("@timardex/cluemart-shared");
4647
4780
  var import_utils8 = require("@timardex/cluemart-shared/utils");
4648
4781
  var import_dayjs9 = __toESM(require("dayjs"));
4649
4782
 
@@ -4709,28 +4842,28 @@ function isLicenseExpiringIn7Days(expiryDate, now) {
4709
4842
  return hoursUntilExpiry >= REMINDER_WINDOW_MIN_HOURS && hoursUntilExpiry <= REMINDER_WINDOW_MAX_HOURS;
4710
4843
  }
4711
4844
  function getLicenseName(licenceType) {
4712
- return import_cluemart_shared35.licenseNiceNames[licenceType] || licenceType;
4845
+ return import_cluemart_shared36.licenseNiceNames[licenceType] || licenceType;
4713
4846
  }
4714
4847
  function getNotificationTypes(isVendorLicense, isPartnerLicense) {
4715
4848
  if (isVendorLicense) {
4716
4849
  return {
4717
- notificationType: import_cluemart_shared35.EnumNotificationType.SYSTEM,
4718
- resourceType: import_cluemart_shared35.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
4850
+ notificationType: import_cluemart_shared36.EnumNotificationType.SYSTEM,
4851
+ resourceType: import_cluemart_shared36.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
4719
4852
  };
4720
4853
  }
4721
4854
  if (isPartnerLicense) {
4722
4855
  return {
4723
- notificationType: import_cluemart_shared35.EnumNotificationType.SYSTEM,
4724
- resourceType: import_cluemart_shared35.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
4856
+ notificationType: import_cluemart_shared36.EnumNotificationType.SYSTEM,
4857
+ resourceType: import_cluemart_shared36.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
4725
4858
  };
4726
4859
  }
4727
4860
  return {
4728
- notificationType: import_cluemart_shared35.EnumNotificationType.SYSTEM,
4729
- resourceType: import_cluemart_shared35.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
4861
+ notificationType: import_cluemart_shared36.EnumNotificationType.SYSTEM,
4862
+ resourceType: import_cluemart_shared36.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
4730
4863
  };
4731
4864
  }
4732
4865
  async function getLicenseResourceInfo(user, licence) {
4733
- const isVendorLicense = import_cluemart_shared35.vendorLicences.includes(licence.licenceType);
4866
+ const isVendorLicense = import_cluemart_shared36.vendorLicences.includes(licence.licenceType);
4734
4867
  const isPartnerLicense = partnerLicences.includes(licence.licenceType);
4735
4868
  const licenceName = getLicenseName(licence.licenceType);
4736
4869
  const { notificationType, resourceType } = getNotificationTypes(
@@ -4778,11 +4911,11 @@ async function getLicenseResourceInfo(user, licence) {
4778
4911
  };
4779
4912
  }
4780
4913
  function getLicenceExpiryMode(licenceType) {
4781
- return licenceType === import_cluemart_shared35.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared35.EnumUserLicence.PRO_PLUS_VENDOR ? "downgrade" : "extend";
4914
+ return licenceType === import_cluemart_shared36.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared36.EnumUserLicence.PRO_PLUS_VENDOR ? "downgrade" : "extend";
4782
4915
  }
4783
4916
  async function sendLicenseReminder(user, licence) {
4784
4917
  const licenceName = getLicenseName(licence.licenceType);
4785
- const expiryDate = (0, import_dayjs9.default)(licence.expiryDate).format(import_cluemart_shared35.dateFormat);
4918
+ const expiryDate = (0, import_dayjs9.default)(licence.expiryDate).format(import_cluemart_shared36.dateFormat);
4786
4919
  const userId = String(user._id);
4787
4920
  const resourceInfo = await getLicenseResourceInfo(user, licence);
4788
4921
  if (!resourceInfo) {
@@ -4916,6 +5049,7 @@ async function remindUsersAboutLicenseExpiration() {
4916
5049
  AdModel,
4917
5050
  AdPurchaseModel,
4918
5051
  AffiliateModel,
5052
+ AiImportedMarketModel,
4919
5053
  AppSettingModel,
4920
5054
  AuthHandoffTokenModel,
4921
5055
  BILLING_CATALOG_COLLECTION_NAME,
@@ -4945,8 +5079,10 @@ async function remindUsersAboutLicenseExpiration() {
4945
5079
  RelationTypeSchema,
4946
5080
  ResourceActivityModel,
4947
5081
  ResourceImageTypeSchema,
5082
+ SCRAPE_SITES_CONFIG_KEY,
4948
5083
  SUBSCRIPTION_REWARD_TIMEZONE,
4949
5084
  SchoolModel,
5085
+ ScrapeSiteConfigModel,
4950
5086
  SocialMediaTypeSchema,
4951
5087
  StallTypeSchema,
4952
5088
  UnregisteredVendorModel,