@timardex/cluemart-server-shared 2.1.8 → 2.1.11

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.mjs CHANGED
@@ -690,202 +690,25 @@ var ChatReportModel = mongoose8.models.ChatReport || mongoose8.model("ChatReport
690
690
 
691
691
  // src/mongoose/global.ts
692
692
  import {
693
- EnumEventDateStatus as EnumEventDateStatus3,
693
+ EnumEventDateStatus,
694
694
  EnumPostType,
695
695
  EnumUserLicence as EnumUserLicence2
696
696
  } from "@timardex/cluemart-shared";
697
- import mongoose11 from "mongoose";
698
-
699
- // src/mongoose/Relation.ts
700
- import {
701
- EnumEventDateStatus as EnumEventDateStatus2,
702
- EnumInviteStatus,
703
- EnumRelationResource,
704
- EnumResourceType as EnumResourceType2
705
- } from "@timardex/cluemart-shared";
706
- import mongoose10 from "mongoose";
707
-
708
- // src/mongoose/event/EventInfo.ts
709
- import {
710
- EnumEventDateStatus,
711
- EnumPaymentMethod
712
- } from "@timardex/cluemart-shared";
713
697
  import mongoose9 from "mongoose";
714
698
  var MongooseSchema5 = mongoose9.Schema;
715
- var StallTypeSchema = new MongooseSchema5(
716
- {
717
- label: { required: false, type: String },
718
- price: { required: false, type: Number },
719
- stallCapacity: { required: false, type: Number }
720
- },
721
- {
722
- _id: false
723
- // Prevents Mongoose from creating an additional _id field for subdocuments
724
- }
725
- );
726
- var dateTimeSchema = new MongooseSchema5(
727
- {
728
- dateStatus: {
729
- enum: Object.values(EnumEventDateStatus),
730
- required: false,
731
- type: String
732
- },
733
- endDate: { required: true, type: String },
734
- endTime: { required: true, type: String },
735
- stallTypes: [StallTypeSchema],
736
- startDate: { required: true, type: String },
737
- startTime: { required: true, type: String }
738
- },
739
- { _id: false }
740
- // Prevents Mongoose from creating an additional _id field for subdocuments
741
- );
742
- var paymentInfoSchema = new MongooseSchema5(
743
- {
744
- accountHolderName: { required: false, type: String },
745
- accountNumber: { required: false, type: String },
746
- link: { required: false, type: String },
747
- paymentMethod: {
748
- enum: Object.values(EnumPaymentMethod),
749
- required: true,
750
- type: String
751
- }
752
- },
753
- { _id: false }
754
- // Prevents Mongoose from creating an additional _id field
755
- );
756
- var requirementsSchema = new MongooseSchema5(
757
- {
758
- category: { required: true, type: String },
759
- label: { required: true, type: String },
760
- value: { required: true, type: Boolean }
761
- },
762
- {
763
- _id: false
764
- // Prevents Mongoose from creating an additional _id field for
765
- }
766
- );
767
- var refundPolicySchema = new MongooseSchema5(
768
- {
769
- category: { required: true, type: String },
770
- label: { required: true, type: String },
771
- value: { required: true, type: Boolean }
772
- },
773
- { _id: false }
774
- );
775
- var schema7 = new MongooseSchema5(
776
- {
777
- active: { default: true, type: Boolean },
778
- applicationDeadlineHours: { required: true, type: Number },
779
- dateTime: { required: true, type: [dateTimeSchema] },
780
- eventId: {
781
- ref: "Event",
782
- required: true,
783
- type: mongoose9.Schema.Types.ObjectId
784
- },
785
- packInTime: { required: true, type: Number },
786
- paymentDueHours: { required: true, type: Number },
787
- paymentInfo: { required: true, type: [paymentInfoSchema] },
788
- refundPolicy: { required: true, type: [refundPolicySchema] },
789
- requirements: { required: false, type: [requirementsSchema] }
790
- },
791
- { timestamps: true }
792
- );
793
- schema7.index({ eventId: 1 });
794
- var EventInfoModel = mongoose9.models.EventInfo || mongoose9.model("EventInfo", schema7);
795
-
796
- // src/mongoose/Relation.ts
797
- var MongooseSchema6 = mongoose10.Schema;
798
- var relationDateTimeSchema = new MongooseSchema6(
799
- {
800
- dateStatus: {
801
- enum: Object.values(EnumEventDateStatus2),
802
- required: true,
803
- type: String
804
- },
805
- endDate: { required: true, type: String },
806
- endTime: { required: true, type: String },
807
- stallType: StallTypeSchema,
808
- startDate: { required: true, type: String },
809
- startTime: { required: true, type: String }
810
- },
811
- { _id: false }
812
- );
813
- var relationDatesSchema = new MongooseSchema6(
814
- {
815
- dateTime: {
816
- required: true,
817
- type: relationDateTimeSchema
818
- },
819
- lastUpdateBy: {
820
- resourceId: { required: false, type: String },
821
- userEmail: { required: false, type: String }
822
- },
823
- paymentReference: { required: false, type: String },
824
- status: {
825
- enum: Object.values(EnumInviteStatus),
826
- required: false,
827
- type: String
828
- }
829
- },
830
- { _id: false }
831
- );
832
- var RelationTypeSchema = new MongooseSchema6(
833
- {
834
- active: { default: true, required: true, type: Boolean },
835
- chatId: {
836
- ref: "Chat",
837
- required: true,
838
- type: mongoose10.Schema.Types.ObjectId
839
- },
840
- deletedAt: { default: null, required: false, type: Date },
841
- eventId: {
842
- ref: "Event",
843
- required: true,
844
- type: mongoose10.Schema.Types.ObjectId
845
- },
846
- lastUpdateBy: {
847
- enum: Object.values(EnumResourceType2),
848
- required: true,
849
- type: String
850
- },
851
- relationDates: [relationDatesSchema],
852
- relationType: {
853
- enum: Object.values(EnumRelationResource),
854
- required: true,
855
- type: String
856
- },
857
- vendorId: {
858
- ref: "Vendor",
859
- required: true,
860
- type: mongoose10.Schema.Types.ObjectId
861
- }
862
- },
863
- { timestamps: true }
864
- );
865
- RelationTypeSchema.index({
866
- eventId: 1,
867
- "relationDates.startDate": 1,
868
- "relationDates.startTime": 1,
869
- "relationDates.status": 1,
870
- vendorId: 1
871
- });
872
- var RelationModel = mongoose10.models.Relation || mongoose10.model("Relation", RelationTypeSchema);
873
-
874
- // src/mongoose/global.ts
875
- var MongooseSchema7 = mongoose11.Schema;
876
- var OwnerTypeSchema = new MongooseSchema7(
699
+ var OwnerTypeSchema = new MongooseSchema5(
877
700
  {
878
701
  email: { required: true, type: String },
879
702
  userId: {
880
703
  ref: "User",
881
704
  required: true,
882
- type: mongoose11.Schema.Types.ObjectId
705
+ type: mongoose9.Schema.Types.ObjectId
883
706
  }
884
707
  },
885
708
  { _id: false }
886
709
  // Prevents Mongoose from creating an additional _id field for subdocuments
887
710
  );
888
- var SocialMediaTypeSchema = new MongooseSchema7(
711
+ var SocialMediaTypeSchema = new MongooseSchema5(
889
712
  {
890
713
  link: { required: true, type: String },
891
714
  name: { required: true, type: String }
@@ -893,7 +716,7 @@ var SocialMediaTypeSchema = new MongooseSchema7(
893
716
  { _id: false }
894
717
  // Prevents Mongoose from creating an additional _id field
895
718
  );
896
- var ResourceImageTypeSchema = new MongooseSchema7(
719
+ var ResourceImageTypeSchema = new MongooseSchema5(
897
720
  {
898
721
  active: { default: true, required: true, type: Boolean },
899
722
  source: { required: false, type: String },
@@ -902,7 +725,7 @@ var ResourceImageTypeSchema = new MongooseSchema7(
902
725
  { _id: false }
903
726
  // Prevents Mongoose from creating an additional _id field for subdocuments
904
727
  );
905
- var SubCategorySchema = new MongooseSchema7(
728
+ var SubCategorySchema = new MongooseSchema5(
906
729
  {
907
730
  id: { required: false, type: String },
908
731
  items: [
@@ -916,7 +739,7 @@ var SubCategorySchema = new MongooseSchema7(
916
739
  { _id: false }
917
740
  // Prevents Mongoose from creating an additional _id field for subdocuments
918
741
  );
919
- var CategorySchema = new MongooseSchema7(
742
+ var CategorySchema = new MongooseSchema5(
920
743
  {
921
744
  id: { required: true, type: String },
922
745
  name: { required: true, type: String },
@@ -925,7 +748,7 @@ var CategorySchema = new MongooseSchema7(
925
748
  { _id: false }
926
749
  // Prevents Mongoose from creating an additional _id field for subdocuments
927
750
  );
928
- var PosterUsageTypeSchema = new MongooseSchema7(
751
+ var PosterUsageTypeSchema = new MongooseSchema5(
929
752
  {
930
753
  count: { default: 0, required: false, type: Number },
931
754
  month: { required: false, type: String }
@@ -933,7 +756,7 @@ var PosterUsageTypeSchema = new MongooseSchema7(
933
756
  { _id: false }
934
757
  // Prevents Mongoose from creating an additional _id field for subdocuments
935
758
  );
936
- var userLicenseSchema = new MongooseSchema7(
759
+ var userLicenseSchema = new MongooseSchema5(
937
760
  {
938
761
  expiryDate: { required: true, type: Date },
939
762
  issuedDate: { required: true, type: Date },
@@ -950,7 +773,7 @@ var userLicenseSchema = new MongooseSchema7(
950
773
  },
951
774
  { _id: false, timestamps: false }
952
775
  );
953
- var ContactDetailsSchema = new MongooseSchema7(
776
+ var ContactDetailsSchema = new MongooseSchema5(
954
777
  {
955
778
  email: { required: false, type: String },
956
779
  landlinePhone: { required: false, type: String },
@@ -959,7 +782,7 @@ var ContactDetailsSchema = new MongooseSchema7(
959
782
  { _id: false }
960
783
  // Prevents Mongoose from creating an additional _id field for subdocuments
961
784
  );
962
- var termsAgreementSchema = new MongooseSchema7(
785
+ var termsAgreementSchema = new MongooseSchema5(
963
786
  {
964
787
  appBuildNumber: { required: true, type: String },
965
788
  appId: { required: true, type: String },
@@ -976,25 +799,10 @@ var termsAgreementSchema = new MongooseSchema7(
976
799
  },
977
800
  { _id: false }
978
801
  );
979
- var resourceRelationsSchema = new MongooseSchema7(
980
- {
981
- relationDates: {
982
- default: [],
983
- required: false,
984
- type: [relationDatesSchema]
985
- },
986
- relationId: {
987
- ref: "Relation",
988
- required: false,
989
- type: mongoose11.Schema.Types.ObjectId
990
- }
991
- },
992
- { _id: false }
993
- );
994
- var dateTimeSchema2 = new MongooseSchema7(
802
+ var dateTimeSchema = new MongooseSchema5(
995
803
  {
996
804
  dateStatus: {
997
- enum: Object.values(EnumEventDateStatus3),
805
+ enum: Object.values(EnumEventDateStatus),
998
806
  required: false,
999
807
  type: String
1000
808
  },
@@ -1006,7 +814,7 @@ var dateTimeSchema2 = new MongooseSchema7(
1006
814
  { _id: false }
1007
815
  // Prevents Mongoose from creating an additional _id field for subdocuments
1008
816
  );
1009
- var locationGeoSchema = new MongooseSchema7(
817
+ var locationGeoSchema = new MongooseSchema5(
1010
818
  {
1011
819
  coordinates: { required: true, type: [Number] },
1012
820
  // [longitude, latitude]
@@ -1015,7 +823,7 @@ var locationGeoSchema = new MongooseSchema7(
1015
823
  { _id: false }
1016
824
  // Prevents Mongoose from creating an additional _id field for subdocuments
1017
825
  );
1018
- var locationsSchema = new MongooseSchema7(
826
+ var locationsSchema = new MongooseSchema5(
1019
827
  {
1020
828
  city: { required: true, type: String },
1021
829
  country: { required: true, type: String },
@@ -1031,13 +839,13 @@ var locationsSchema = new MongooseSchema7(
1031
839
  { _id: false }
1032
840
  // Prevents Mongoose from creating an additional _id field for subdocuments
1033
841
  );
1034
- var relatedPostSchema = new MongooseSchema7(
842
+ var relatedPostSchema = new MongooseSchema5(
1035
843
  {
1036
844
  postActive: { default: true, required: true, type: Boolean },
1037
845
  postId: {
1038
846
  ref: "Post",
1039
847
  required: true,
1040
- type: mongoose11.Schema.Types.ObjectId
848
+ type: mongoose9.Schema.Types.ObjectId
1041
849
  },
1042
850
  postSlug: { required: true, type: String },
1043
851
  postType: {
@@ -1049,7 +857,7 @@ var relatedPostSchema = new MongooseSchema7(
1049
857
  { _id: false }
1050
858
  // Prevents Mongoose from creating an additional _id field for subdocuments
1051
859
  );
1052
- var socialShareResourceSchema = new MongooseSchema7(
860
+ var socialShareResourceSchema = new MongooseSchema5(
1053
861
  {
1054
862
  qrCode: { required: true, type: ResourceImageTypeSchema },
1055
863
  socialImage: { required: true, type: ResourceImageTypeSchema }
@@ -1062,7 +870,7 @@ var baseResourceFields = {
1062
870
  adIds: {
1063
871
  ref: "Ad",
1064
872
  required: false,
1065
- type: [mongoose11.Schema.Types.ObjectId]
873
+ type: [mongoose9.Schema.Types.ObjectId]
1066
874
  },
1067
875
  approvedAt: { default: null, required: false, type: Date },
1068
876
  contactDetails: { required: false, type: ContactDetailsSchema },
@@ -1095,7 +903,7 @@ var baseResourceFields = {
1095
903
  import {
1096
904
  EnumEventType
1097
905
  } from "@timardex/cluemart-shared";
1098
- import mongoose12 from "mongoose";
906
+ import mongoose10 from "mongoose";
1099
907
 
1100
908
  // src/mongoose/searchNamePlugin.ts
1101
909
  function deriveSearchName(name) {
@@ -1141,15 +949,15 @@ function syncSearchNameInUpdate(update) {
1141
949
  }
1142
950
  return null;
1143
951
  }
1144
- function searchNamePlugin(schema24) {
1145
- schema24.add({ searchName: { default: "", required: false, type: String } });
1146
- schema24.index({ searchName: 1 });
1147
- schema24.pre("save", function syncSearchNameOnSave(next) {
952
+ function searchNamePlugin(schema25) {
953
+ schema25.add({ searchName: { default: "", required: false, type: String } });
954
+ schema25.index({ searchName: 1 });
955
+ schema25.pre("save", function syncSearchNameOnSave(next) {
1148
956
  const doc = this;
1149
957
  doc.searchName = deriveSearchName(doc.name);
1150
958
  next();
1151
959
  });
1152
- schema24.pre("insertMany", function syncSearchNameOnInsertMany(next, docs) {
960
+ schema25.pre("insertMany", function syncSearchNameOnInsertMany(next, docs) {
1153
961
  const list = Array.isArray(docs) ? docs : [docs];
1154
962
  for (const doc of list) {
1155
963
  if (doc && typeof doc.name === "string") {
@@ -1158,7 +966,7 @@ function searchNamePlugin(schema24) {
1158
966
  }
1159
967
  next();
1160
968
  });
1161
- schema24.pre("bulkWrite", function syncSearchNameOnBulkWrite(next, ops) {
969
+ schema25.pre("bulkWrite", function syncSearchNameOnBulkWrite(next, ops) {
1162
970
  for (const op of ops) {
1163
971
  const doc = op.insertOne?.document ?? op.replaceOne?.replacement;
1164
972
  if (doc && typeof doc.name === "string") {
@@ -1184,15 +992,15 @@ function searchNamePlugin(schema24) {
1184
992
  }
1185
993
  next();
1186
994
  };
1187
- schema24.pre(
995
+ schema25.pre(
1188
996
  ["findOneAndUpdate", "updateOne", "updateMany"],
1189
997
  syncSearchNameOnUpdate
1190
998
  );
1191
999
  }
1192
1000
 
1193
1001
  // src/mongoose/GoogleImportedMarket.ts
1194
- var MongooseSchema8 = mongoose12.Schema;
1195
- var addressComponentSchema = new MongooseSchema8(
1002
+ var MongooseSchema6 = mongoose10.Schema;
1003
+ var addressComponentSchema = new MongooseSchema6(
1196
1004
  {
1197
1005
  longName: { required: false, type: String },
1198
1006
  shortName: { required: false, type: String },
@@ -1200,7 +1008,7 @@ var addressComponentSchema = new MongooseSchema8(
1200
1008
  },
1201
1009
  { _id: false }
1202
1010
  );
1203
- var schema8 = new MongooseSchema8(
1011
+ var schema7 = new MongooseSchema6(
1204
1012
  {
1205
1013
  active: { default: false, required: true, type: Boolean },
1206
1014
  address: { required: true, type: String },
@@ -1212,19 +1020,19 @@ var schema8 = new MongooseSchema8(
1212
1020
  claimedByUserId: {
1213
1021
  ref: "User",
1214
1022
  required: false,
1215
- type: mongoose12.Schema.Types.ObjectId
1023
+ type: mongoose10.Schema.Types.ObjectId
1216
1024
  },
1217
1025
  cover: {
1218
1026
  required: false,
1219
1027
  type: ResourceImageTypeSchema
1220
1028
  },
1221
- dateTime: [dateTimeSchema2],
1029
+ dateTime: [dateTimeSchema],
1222
1030
  deletedAt: { default: null, required: false, type: Date },
1223
1031
  description: { required: true, type: String },
1224
1032
  eventId: {
1225
1033
  ref: "Event",
1226
1034
  required: false,
1227
- type: mongoose12.Schema.Types.ObjectId
1035
+ type: mongoose10.Schema.Types.ObjectId
1228
1036
  },
1229
1037
  eventType: {
1230
1038
  enum: Object.values(EnumEventType),
@@ -1252,35 +1060,30 @@ var schema8 = new MongooseSchema8(
1252
1060
  rainOrShine: { required: true, type: Boolean },
1253
1061
  rating: { required: false, type: Number },
1254
1062
  region: { required: false, type: String },
1255
- relations: {
1256
- default: [],
1257
- required: false,
1258
- type: [resourceRelationsSchema]
1259
- },
1260
1063
  reviewCount: { required: false, type: Number },
1261
1064
  slug: { required: true, type: String },
1262
1065
  website: { required: false, type: String }
1263
1066
  },
1264
1067
  { timestamps: true }
1265
1068
  );
1266
- schema8.index({ "location.geo": "2dsphere" });
1267
- schema8.index({ name: 1 });
1268
- schema8.index({ region: 1 });
1269
- schema8.index({ deletedAt: 1 });
1270
- schema8.index({ "dateTime.dateStatus": 1 });
1271
- schema8.index({ slug: 1 });
1272
- schema8.index({ name: "text", description: "text" });
1273
- schema8.plugin(searchNamePlugin);
1274
- var GoogleImportedMarketModel = mongoose12.models.GoogleImportedMarket || mongoose12.model("GoogleImportedMarket", schema8);
1069
+ schema7.index({ "location.geo": "2dsphere" });
1070
+ schema7.index({ name: 1 });
1071
+ schema7.index({ region: 1 });
1072
+ schema7.index({ deletedAt: 1 });
1073
+ schema7.index({ "dateTime.dateStatus": 1 });
1074
+ schema7.index({ slug: 1 });
1075
+ schema7.index({ description: "text", name: "text" });
1076
+ schema7.plugin(searchNamePlugin);
1077
+ var GoogleImportedMarketModel = mongoose10.models.GoogleImportedMarket || mongoose10.model("GoogleImportedMarket", schema7);
1275
1078
 
1276
1079
  // src/mongoose/Notification.ts
1277
1080
  import {
1278
1081
  EnumNotificationResourceType,
1279
1082
  EnumNotificationType
1280
1083
  } from "@timardex/cluemart-shared";
1281
- import mongoose13 from "mongoose";
1282
- var MongooseSchema9 = mongoose13.Schema;
1283
- var schema9 = new MongooseSchema9(
1084
+ import mongoose11 from "mongoose";
1085
+ var MongooseSchema7 = mongoose11.Schema;
1086
+ var schema8 = new MongooseSchema7(
1284
1087
  {
1285
1088
  data: {
1286
1089
  resourceId: { required: true, type: String },
@@ -1303,20 +1106,20 @@ var schema9 = new MongooseSchema9(
1303
1106
  userId: {
1304
1107
  ref: "User",
1305
1108
  required: true,
1306
- type: mongoose13.Schema.Types.ObjectId
1109
+ type: mongoose11.Schema.Types.ObjectId
1307
1110
  }
1308
1111
  },
1309
1112
  { timestamps: true }
1310
1113
  );
1311
- schema9.index({ isRead: 1, userId: 1 });
1312
- schema9.index({ createdAt: -1, userId: 1 });
1313
- var NotificationModel = mongoose13.models.Notification || mongoose13.model("Notification", schema9);
1114
+ schema8.index({ isRead: 1, userId: 1 });
1115
+ schema8.index({ createdAt: -1, userId: 1 });
1116
+ var NotificationModel = mongoose11.models.Notification || mongoose11.model("Notification", schema8);
1314
1117
 
1315
1118
  // src/mongoose/PushToken.ts
1316
1119
  import { EnumOSPlatform } from "@timardex/cluemart-shared/enums";
1317
- import mongoose14 from "mongoose";
1318
- var MongooseSchema10 = mongoose14.Schema;
1319
- var schema10 = new MongooseSchema10(
1120
+ import mongoose12 from "mongoose";
1121
+ var MongooseSchema8 = mongoose12.Schema;
1122
+ var schema9 = new MongooseSchema8(
1320
1123
  {
1321
1124
  platform: {
1322
1125
  enum: Object.values(EnumOSPlatform),
@@ -1327,12 +1130,187 @@ var schema10 = new MongooseSchema10(
1327
1130
  userId: {
1328
1131
  ref: "User",
1329
1132
  required: true,
1133
+ type: mongoose12.Schema.Types.ObjectId
1134
+ }
1135
+ },
1136
+ { timestamps: true }
1137
+ );
1138
+ var PushTokenModel = mongoose12.models.PushToken || mongoose12.model("PushToken", schema9);
1139
+
1140
+ // src/mongoose/Relation.ts
1141
+ import {
1142
+ EnumEventDateStatus as EnumEventDateStatus3,
1143
+ EnumInviteStatus,
1144
+ EnumRelationResource,
1145
+ EnumResourceType as EnumResourceType2
1146
+ } from "@timardex/cluemart-shared";
1147
+ import mongoose14 from "mongoose";
1148
+
1149
+ // src/mongoose/event/EventInfo.ts
1150
+ import {
1151
+ EnumEventDateStatus as EnumEventDateStatus2,
1152
+ EnumPaymentMethod
1153
+ } from "@timardex/cluemart-shared";
1154
+ import mongoose13 from "mongoose";
1155
+ var MongooseSchema9 = mongoose13.Schema;
1156
+ var StallTypeSchema = new MongooseSchema9(
1157
+ {
1158
+ label: { required: false, type: String },
1159
+ price: { required: false, type: Number },
1160
+ stallCapacity: { required: false, type: Number }
1161
+ },
1162
+ {
1163
+ _id: false
1164
+ // Prevents Mongoose from creating an additional _id field for subdocuments
1165
+ }
1166
+ );
1167
+ var dateTimeSchema2 = new MongooseSchema9(
1168
+ {
1169
+ dateStatus: {
1170
+ enum: Object.values(EnumEventDateStatus2),
1171
+ required: false,
1172
+ type: String
1173
+ },
1174
+ endDate: { required: true, type: String },
1175
+ endTime: { required: true, type: String },
1176
+ stallTypes: [StallTypeSchema],
1177
+ startDate: { required: true, type: String },
1178
+ startTime: { required: true, type: String }
1179
+ },
1180
+ { _id: false }
1181
+ // Prevents Mongoose from creating an additional _id field for subdocuments
1182
+ );
1183
+ var paymentInfoSchema = new MongooseSchema9(
1184
+ {
1185
+ accountHolderName: { required: false, type: String },
1186
+ accountNumber: { required: false, type: String },
1187
+ link: { required: false, type: String },
1188
+ paymentMethod: {
1189
+ enum: Object.values(EnumPaymentMethod),
1190
+ required: true,
1191
+ type: String
1192
+ }
1193
+ },
1194
+ { _id: false }
1195
+ // Prevents Mongoose from creating an additional _id field
1196
+ );
1197
+ var requirementsSchema = new MongooseSchema9(
1198
+ {
1199
+ category: { required: true, type: String },
1200
+ label: { required: true, type: String },
1201
+ value: { required: true, type: Boolean }
1202
+ },
1203
+ {
1204
+ _id: false
1205
+ // Prevents Mongoose from creating an additional _id field for
1206
+ }
1207
+ );
1208
+ var refundPolicySchema = new MongooseSchema9(
1209
+ {
1210
+ category: { required: true, type: String },
1211
+ label: { required: true, type: String },
1212
+ value: { required: true, type: Boolean }
1213
+ },
1214
+ { _id: false }
1215
+ );
1216
+ var schema10 = new MongooseSchema9(
1217
+ {
1218
+ active: { default: true, type: Boolean },
1219
+ applicationDeadlineHours: { required: true, type: Number },
1220
+ dateTime: { required: true, type: [dateTimeSchema2] },
1221
+ eventId: {
1222
+ ref: "Event",
1223
+ required: true,
1224
+ type: mongoose13.Schema.Types.ObjectId
1225
+ },
1226
+ packInTime: { required: true, type: Number },
1227
+ paymentDueHours: { required: true, type: Number },
1228
+ paymentInfo: { required: true, type: [paymentInfoSchema] },
1229
+ refundPolicy: { required: true, type: [refundPolicySchema] },
1230
+ requirements: { required: false, type: [requirementsSchema] }
1231
+ },
1232
+ { timestamps: true }
1233
+ );
1234
+ schema10.index({ eventId: 1 });
1235
+ var EventInfoModel = mongoose13.models.EventInfo || mongoose13.model("EventInfo", schema10);
1236
+
1237
+ // src/mongoose/Relation.ts
1238
+ var MongooseSchema10 = mongoose14.Schema;
1239
+ var relationDateTimeSchema = new MongooseSchema10(
1240
+ {
1241
+ dateStatus: {
1242
+ enum: Object.values(EnumEventDateStatus3),
1243
+ required: true,
1244
+ type: String
1245
+ },
1246
+ endDate: { required: true, type: String },
1247
+ endTime: { required: true, type: String },
1248
+ stallType: StallTypeSchema,
1249
+ startDate: { required: true, type: String },
1250
+ startTime: { required: true, type: String }
1251
+ },
1252
+ { _id: false }
1253
+ );
1254
+ var relationDatesSchema = new MongooseSchema10(
1255
+ {
1256
+ dateTime: {
1257
+ required: true,
1258
+ type: relationDateTimeSchema
1259
+ },
1260
+ lastUpdateBy: {
1261
+ resourceId: { required: false, type: String },
1262
+ userEmail: { required: false, type: String }
1263
+ },
1264
+ paymentReference: { required: false, type: String },
1265
+ status: {
1266
+ enum: Object.values(EnumInviteStatus),
1267
+ required: false,
1268
+ type: String
1269
+ }
1270
+ },
1271
+ { _id: false }
1272
+ );
1273
+ var RelationTypeSchema = new MongooseSchema10(
1274
+ {
1275
+ active: { default: true, required: true, type: Boolean },
1276
+ chatId: {
1277
+ ref: "Chat",
1278
+ required: true,
1279
+ type: mongoose14.Schema.Types.ObjectId
1280
+ },
1281
+ deletedAt: { default: null, required: false, type: Date },
1282
+ eventId: {
1283
+ ref: "Event",
1284
+ required: true,
1285
+ type: mongoose14.Schema.Types.ObjectId
1286
+ },
1287
+ lastUpdateBy: {
1288
+ enum: Object.values(EnumResourceType2),
1289
+ required: true,
1290
+ type: String
1291
+ },
1292
+ relationDates: [relationDatesSchema],
1293
+ relationType: {
1294
+ enum: Object.values(EnumRelationResource),
1295
+ required: true,
1296
+ type: String
1297
+ },
1298
+ vendorId: {
1299
+ ref: "Vendor",
1300
+ required: true,
1330
1301
  type: mongoose14.Schema.Types.ObjectId
1331
1302
  }
1332
1303
  },
1333
1304
  { timestamps: true }
1334
1305
  );
1335
- var PushTokenModel = mongoose14.models.PushToken || mongoose14.model("PushToken", schema10);
1306
+ RelationTypeSchema.index({
1307
+ eventId: 1,
1308
+ "relationDates.startDate": 1,
1309
+ "relationDates.startTime": 1,
1310
+ "relationDates.status": 1,
1311
+ vendorId: 1
1312
+ });
1313
+ var RelationModel = mongoose14.models.Relation || mongoose14.model("Relation", RelationTypeSchema);
1336
1314
 
1337
1315
  // src/mongoose/ResourceActivity.ts
1338
1316
  import {
@@ -1402,7 +1380,7 @@ import mongoose16 from "mongoose";
1402
1380
  var MongooseSchema12 = mongoose16.Schema;
1403
1381
  var userActivityEventSchema = new MongooseSchema12(
1404
1382
  {
1405
- dateTime: dateTimeSchema2,
1383
+ dateTime: dateTimeSchema,
1406
1384
  resourceId: {
1407
1385
  ref: "Event",
1408
1386
  required: false,
@@ -1753,11 +1731,6 @@ var schema14 = new MongooseSchema14(
1753
1731
  downgradeSnapshot: { required: false, type: downgradeSnapshotSchema },
1754
1732
  foodTruck: { required: true, type: Boolean },
1755
1733
  products: { required: false, type: productWrapperSchema },
1756
- relations: {
1757
- default: [],
1758
- required: false,
1759
- type: [resourceRelationsSchema]
1760
- },
1761
1734
  shareRelation: { required: false, type: socialShareResourceSchema },
1762
1735
  unregisteredVendorId: {
1763
1736
  ref: "UnregisteredVendor",
@@ -1852,7 +1825,7 @@ import mongoose20 from "mongoose";
1852
1825
  var MongooseSchema16 = mongoose20.Schema;
1853
1826
  var invitationSchema = new MongooseSchema16(
1854
1827
  {
1855
- dateTime: { required: true, type: [dateTimeSchema2] },
1828
+ dateTime: { required: true, type: [dateTimeSchema] },
1856
1829
  inviterId: {
1857
1830
  ref: "Event",
1858
1831
  required: true,
@@ -1896,7 +1869,7 @@ var schema17 = new MongooseSchema17(
1896
1869
  ...baseResourceFields,
1897
1870
  // Importing base resource fields from global.ts
1898
1871
  claimed: { default: true, required: false, type: Boolean },
1899
- dateTime: { required: true, type: [dateTimeSchema2] },
1872
+ dateTime: { required: true, type: [dateTimeSchema] },
1900
1873
  eventInfoId: {
1901
1874
  ref: "EventInfo",
1902
1875
  required: false,
@@ -1919,11 +1892,6 @@ var schema17 = new MongooseSchema17(
1919
1892
  nzbn: { required: true, type: String },
1920
1893
  provider: { required: false, type: String },
1921
1894
  rainOrShine: { required: true, type: Boolean },
1922
- relations: {
1923
- default: [],
1924
- required: false,
1925
- type: [resourceRelationsSchema]
1926
- },
1927
1895
  shareRelation: { required: false, type: socialShareResourceSchema },
1928
1896
  tags: { required: true, type: [String] }
1929
1897
  },
@@ -1937,16 +1905,32 @@ schema17.index({ tags: 1 });
1937
1905
  schema17.index({ deletedAt: 1 });
1938
1906
  schema17.index({ "dateTime.dateStatus": 1 });
1939
1907
  schema17.index({ slug: 1 });
1940
- schema17.index({ name: "text", description: "text", tags: "text" });
1941
- schema17.index({ "owner.userId": 1, deletedAt: 1 });
1908
+ schema17.index({ description: "text", name: "text", tags: "text" });
1909
+ schema17.index({ deletedAt: 1, "owner.userId": 1 });
1942
1910
  schema17.plugin(searchNamePlugin);
1943
1911
  var EventModel = mongoose21.models.Event || mongoose21.model("Event", schema17);
1944
1912
 
1913
+ // src/mongoose/event/EventDateArchive.ts
1914
+ import mongoose22 from "mongoose";
1915
+ var schema18 = new mongoose22.Schema(
1916
+ {
1917
+ dateTime: { required: true, type: [dateTimeSchema] },
1918
+ eventId: {
1919
+ ref: "Event",
1920
+ required: true,
1921
+ type: mongoose22.Schema.Types.ObjectId
1922
+ }
1923
+ },
1924
+ { timestamps: true }
1925
+ );
1926
+ schema18.index({ eventId: 1 }, { unique: true });
1927
+ var EventDateArchiveModel = mongoose22.models.EventDateArchive || mongoose22.model("EventDateArchive", schema18);
1928
+
1945
1929
  // src/mongoose/Partner.ts
1946
1930
  import { EnumPartnerType } from "@timardex/cluemart-shared";
1947
- import mongoose22 from "mongoose";
1948
- var MongooseSchema18 = mongoose22.Schema;
1949
- var schema18 = new MongooseSchema18(
1931
+ import mongoose23 from "mongoose";
1932
+ var MongooseSchema18 = mongoose23.Schema;
1933
+ var schema19 = new MongooseSchema18(
1950
1934
  {
1951
1935
  ...baseResourceFields,
1952
1936
  location: {
@@ -1962,15 +1946,15 @@ var schema18 = new MongooseSchema18(
1962
1946
  },
1963
1947
  { timestamps: true }
1964
1948
  );
1965
- schema18.index({ name: 1 });
1966
- schema18.index({ description: 1 });
1967
- schema18.index({ region: 1 });
1968
- schema18.index({ "location.geo": "2dsphere" });
1969
- schema18.index({ slug: 1 });
1970
- schema18.index({ name: "text", description: "text" });
1971
- schema18.index({ "owner.userId": 1, deletedAt: 1 });
1972
- schema18.plugin(searchNamePlugin);
1973
- var PartnerModel = mongoose22.models.Partner || mongoose22.model("Partner", schema18);
1949
+ schema19.index({ name: 1 });
1950
+ schema19.index({ description: 1 });
1951
+ schema19.index({ region: 1 });
1952
+ schema19.index({ "location.geo": "2dsphere" });
1953
+ schema19.index({ slug: 1 });
1954
+ schema19.index({ name: "text", description: "text" });
1955
+ schema19.index({ "owner.userId": 1, deletedAt: 1 });
1956
+ schema19.plugin(searchNamePlugin);
1957
+ var PartnerModel = mongoose23.models.Partner || mongoose23.model("Partner", schema19);
1974
1958
 
1975
1959
  // src/mongoose/Post.ts
1976
1960
  import {
@@ -1978,8 +1962,8 @@ import {
1978
1962
  EnumPostType as EnumPostType2,
1979
1963
  EnumResourceType as EnumResourceType5
1980
1964
  } from "@timardex/cluemart-shared";
1981
- import mongoose23, { Schema } from "mongoose";
1982
- var MongooseSchema19 = mongoose23.Schema;
1965
+ import mongoose24, { Schema } from "mongoose";
1966
+ var MongooseSchema19 = mongoose24.Schema;
1983
1967
  var contentSchema = new MongooseSchema19(
1984
1968
  {
1985
1969
  contentData: Schema.Types.Mixed,
@@ -2005,7 +1989,7 @@ var resourceSchema = new MongooseSchema19(
2005
1989
  },
2006
1990
  { _id: false }
2007
1991
  );
2008
- var schema19 = new MongooseSchema19(
1992
+ var schema20 = new MongooseSchema19(
2009
1993
  {
2010
1994
  active: { default: false, required: true, type: Boolean },
2011
1995
  approvedAt: { default: null, required: false, type: Date },
@@ -2036,14 +2020,14 @@ var schema19 = new MongooseSchema19(
2036
2020
  },
2037
2021
  { timestamps: true }
2038
2022
  );
2039
- schema19.index({ title: 1 });
2040
- schema19.index({ tags: 1 });
2041
- schema19.index({ postType: 1, slug: 1 }, { unique: true });
2042
- var PostModel = mongoose23.models.Post || mongoose23.model("Post", schema19);
2023
+ schema20.index({ title: 1 });
2024
+ schema20.index({ tags: 1 });
2025
+ schema20.index({ postType: 1, slug: 1 }, { unique: true });
2026
+ var PostModel = mongoose24.models.Post || mongoose24.model("Post", schema20);
2043
2027
 
2044
2028
  // src/mongoose/AppSetting.ts
2045
- import mongoose24 from "mongoose";
2046
- var MongooseSchema20 = mongoose24.Schema;
2029
+ import mongoose25 from "mongoose";
2030
+ var MongooseSchema20 = mongoose25.Schema;
2047
2031
  var APP_SETTINGS_ID = "APP_SETTINGS_DOCUMENT_ID";
2048
2032
  var AppSettingSchema = new MongooseSchema20(
2049
2033
  {
@@ -2080,21 +2064,21 @@ var AppSettingSchema = new MongooseSchema20(
2080
2064
  },
2081
2065
  { timestamps: true }
2082
2066
  );
2083
- var AppSettingModel = mongoose24.models.AppSetting || mongoose24.model("AppSetting", AppSettingSchema);
2067
+ var AppSettingModel = mongoose25.models.AppSetting || mongoose25.model("AppSetting", AppSettingSchema);
2084
2068
 
2085
2069
  // src/mongoose/game/Game.ts
2086
2070
  import {
2087
2071
  EnumGameStatus,
2088
2072
  EnumGameType
2089
2073
  } from "@timardex/cluemart-shared";
2090
- import mongoose28 from "mongoose";
2074
+ import mongoose29 from "mongoose";
2091
2075
 
2092
2076
  // src/mongoose/game/DailyClue.ts
2093
- import mongoose26 from "mongoose";
2077
+ import mongoose27 from "mongoose";
2094
2078
 
2095
2079
  // src/mongoose/game/utils.ts
2096
- import mongoose25 from "mongoose";
2097
- var MongooseSchema21 = mongoose25.Schema;
2080
+ import mongoose26 from "mongoose";
2081
+ var MongooseSchema21 = mongoose26.Schema;
2098
2082
  var schemaGameDate = new MongooseSchema21(
2099
2083
  {
2100
2084
  endDate: { required: true, type: Date },
@@ -2104,7 +2088,7 @@ var schemaGameDate = new MongooseSchema21(
2104
2088
  );
2105
2089
 
2106
2090
  // src/mongoose/game/DailyClue.ts
2107
- var MongooseSchema22 = mongoose26.Schema;
2091
+ var MongooseSchema22 = mongoose27.Schema;
2108
2092
  var schemaLetters = new MongooseSchema22(
2109
2093
  {
2110
2094
  collected: { required: false, type: [String] },
@@ -2135,8 +2119,8 @@ var schemaDailyClueGameData = new MongooseSchema22(
2135
2119
  );
2136
2120
 
2137
2121
  // src/mongoose/game/PuzzleGame.ts
2138
- import mongoose27 from "mongoose";
2139
- var MongooseSchema23 = mongoose27.Schema;
2122
+ import mongoose28 from "mongoose";
2123
+ var MongooseSchema23 = mongoose28.Schema;
2140
2124
  var schemaPuzzleAnswer = new MongooseSchema23(
2141
2125
  {
2142
2126
  answer: { required: true, type: String },
@@ -2181,16 +2165,16 @@ var schemaPuzzleGameData = new MongooseSchema23(
2181
2165
  );
2182
2166
 
2183
2167
  // src/mongoose/game/Game.ts
2184
- var MongooseSchema24 = mongoose28.Schema;
2168
+ var MongooseSchema24 = mongoose29.Schema;
2185
2169
  var gameDataSchemas = {
2186
2170
  [EnumGameType.DAILY_CLUE]: schemaDailyClueGameData,
2187
2171
  [EnumGameType.MINI_QUIZ]: schemaPuzzleGameData,
2188
2172
  [EnumGameType.ODD_ONE_OUT]: schemaPuzzleGameData
2189
2173
  };
2190
2174
  var gameDataDefinition = Object.fromEntries(
2191
- Object.entries(gameDataSchemas).map(([key, schema24]) => [
2175
+ Object.entries(gameDataSchemas).map(([key, schema25]) => [
2192
2176
  key,
2193
- { default: null, required: false, type: schema24 }
2177
+ { default: null, required: false, type: schema25 }
2194
2178
  ])
2195
2179
  );
2196
2180
  var gameHistorySchema = new MongooseSchema24(
@@ -2228,7 +2212,7 @@ var gameTypeSchema = new MongooseSchema24(
2228
2212
  },
2229
2213
  { timestamps: true }
2230
2214
  );
2231
- var schema20 = new MongooseSchema24(
2215
+ var schema21 = new MongooseSchema24(
2232
2216
  {
2233
2217
  active: { default: false, required: true, type: Boolean },
2234
2218
  deletedAt: { default: null, required: false, type: Date },
@@ -2241,11 +2225,11 @@ var schema20 = new MongooseSchema24(
2241
2225
  },
2242
2226
  { timestamps: true }
2243
2227
  );
2244
- var GameModel = mongoose28.models.Game || mongoose28.model("Game", schema20);
2228
+ var GameModel = mongoose29.models.Game || mongoose29.model("Game", schema21);
2245
2229
 
2246
2230
  // src/mongoose/School.ts
2247
- import mongoose29 from "mongoose";
2248
- var MongooseSchema25 = mongoose29.Schema;
2231
+ import mongoose30 from "mongoose";
2232
+ var MongooseSchema25 = mongoose30.Schema;
2249
2233
  var campaignsSchema = new MongooseSchema25(
2250
2234
  {
2251
2235
  endDate: { required: true, type: Date },
@@ -2254,7 +2238,7 @@ var campaignsSchema = new MongooseSchema25(
2254
2238
  },
2255
2239
  { _id: false }
2256
2240
  );
2257
- var schema21 = new MongooseSchema25(
2241
+ var schema22 = new MongooseSchema25(
2258
2242
  {
2259
2243
  // New schools are active by default
2260
2244
  active: { default: false, required: true, type: Boolean },
@@ -2281,14 +2265,14 @@ var schema21 = new MongooseSchema25(
2281
2265
  },
2282
2266
  { timestamps: true }
2283
2267
  );
2284
- schema21.index(
2268
+ schema22.index(
2285
2269
  { schoolCode: 1 },
2286
2270
  {
2287
2271
  partialFilterExpression: { active: true, deletedAt: null },
2288
2272
  unique: true
2289
2273
  }
2290
2274
  );
2291
- var SchoolModel = mongoose29.models.School || mongoose29.model("School", schema21);
2275
+ var SchoolModel = mongoose30.models.School || mongoose30.model("School", schema22);
2292
2276
 
2293
2277
  // src/mongoose/Affiliate.ts
2294
2278
  import {
@@ -2296,8 +2280,8 @@ import {
2296
2280
  EnumAffiliateRewardType,
2297
2281
  EnumResourceType as EnumResourceType6
2298
2282
  } from "@timardex/cluemart-shared";
2299
- import mongoose30 from "mongoose";
2300
- var MongooseSchema26 = mongoose30.Schema;
2283
+ import mongoose31 from "mongoose";
2284
+ var MongooseSchema26 = mongoose31.Schema;
2301
2285
  var affiliateRewardSchema = new MongooseSchema26(
2302
2286
  {
2303
2287
  createdAt: { required: true, type: Date },
@@ -2318,7 +2302,7 @@ var affiliateResourceSchema = new MongooseSchema26(
2318
2302
  resourceDeletedAt: { default: null, required: false, type: Date },
2319
2303
  resourceId: {
2320
2304
  required: true,
2321
- type: mongoose30.Schema.Types.ObjectId
2305
+ type: mongoose31.Schema.Types.ObjectId
2322
2306
  },
2323
2307
  resourceName: { required: true, type: String },
2324
2308
  resourceOwner: {
@@ -2381,7 +2365,7 @@ var redeemHistorySchema = new MongooseSchema26(
2381
2365
  },
2382
2366
  { _id: false }
2383
2367
  );
2384
- var schema22 = new MongooseSchema26(
2368
+ var schema23 = new MongooseSchema26(
2385
2369
  {
2386
2370
  active: { default: false, required: true, type: Boolean },
2387
2371
  affiliateBonusRewards: {
@@ -2411,22 +2395,22 @@ var schema22 = new MongooseSchema26(
2411
2395
  },
2412
2396
  { timestamps: true }
2413
2397
  );
2414
- schema22.index(
2398
+ schema23.index(
2415
2399
  { affiliateCode: 1 },
2416
2400
  {
2417
2401
  partialFilterExpression: { active: true, deletedAt: null },
2418
2402
  unique: true
2419
2403
  }
2420
2404
  );
2421
- var AffiliateModel = mongoose30.models.Affiliate || mongoose30.model("Affiliate", schema22);
2405
+ var AffiliateModel = mongoose31.models.Affiliate || mongoose31.model("Affiliate", schema23);
2422
2406
 
2423
2407
  // src/mongoose/Coupon.ts
2424
2408
  import {
2425
2409
  EnumCouponQualificationType,
2426
2410
  EnumResourceType as EnumResourceType7
2427
2411
  } from "@timardex/cluemart-shared";
2428
- import mongoose31 from "mongoose";
2429
- var MongooseSchema27 = mongoose31.Schema;
2412
+ import mongoose32 from "mongoose";
2413
+ var MongooseSchema27 = mongoose32.Schema;
2430
2414
  var couponOptionSchema = new MongooseSchema27(
2431
2415
  {
2432
2416
  buy: { required: false, type: Number },
@@ -2446,20 +2430,20 @@ var couponVendorProductSchema = new MongooseSchema27(
2446
2430
  {
2447
2431
  couponId: {
2448
2432
  required: true,
2449
- type: mongoose31.Schema.Types.ObjectId
2433
+ type: mongoose32.Schema.Types.ObjectId
2450
2434
  },
2451
2435
  productId: {
2452
2436
  required: true,
2453
- type: mongoose31.Schema.Types.ObjectId
2437
+ type: mongoose32.Schema.Types.ObjectId
2454
2438
  },
2455
2439
  vendorCouponId: {
2456
2440
  required: false,
2457
- type: mongoose31.Schema.Types.ObjectId
2441
+ type: mongoose32.Schema.Types.ObjectId
2458
2442
  },
2459
2443
  vendorId: {
2460
2444
  ref: "Vendor",
2461
2445
  required: true,
2462
- type: mongoose31.Schema.Types.ObjectId
2446
+ type: mongoose32.Schema.Types.ObjectId
2463
2447
  }
2464
2448
  },
2465
2449
  { _id: false }
@@ -2481,7 +2465,7 @@ var couponParticipantUserSchema = new MongooseSchema27(
2481
2465
  userId: {
2482
2466
  ref: "User",
2483
2467
  required: true,
2484
- type: mongoose31.Schema.Types.ObjectId
2468
+ type: mongoose32.Schema.Types.ObjectId
2485
2469
  }
2486
2470
  },
2487
2471
  { timestamps: true }
@@ -2513,7 +2497,7 @@ var couponDataSchema = new MongooseSchema27(
2513
2497
  },
2514
2498
  { timestamps: true }
2515
2499
  );
2516
- var schema23 = new MongooseSchema27(
2500
+ var schema24 = new MongooseSchema27(
2517
2501
  {
2518
2502
  active: { default: true, required: true, type: Boolean },
2519
2503
  couponData: { default: [], required: false, type: [couponDataSchema] },
@@ -2525,9 +2509,9 @@ var schema23 = new MongooseSchema27(
2525
2509
  },
2526
2510
  { timestamps: true }
2527
2511
  );
2528
- schema23.index({ active: 1, deletedAt: 1, "owner.userId": 1 });
2529
- schema23.index({ "couponData.participantUsers.userId": 1 });
2530
- var CouponModel = mongoose31.models.Coupon || mongoose31.model("Coupon", schema23);
2512
+ schema24.index({ active: 1, deletedAt: 1, "owner.userId": 1 });
2513
+ schema24.index({ "couponData.participantUsers.userId": 1 });
2514
+ var CouponModel = mongoose32.models.Coupon || mongoose32.model("Coupon", schema24);
2531
2515
 
2532
2516
  // src/service/promoCode/constants.ts
2533
2517
  var ACTIVE_NOT_DELETED_FILTER = {
@@ -2966,7 +2950,7 @@ function normalizeAffiliatePromoCodes(promoCodes) {
2966
2950
  }
2967
2951
 
2968
2952
  // src/service/database.ts
2969
- import mongoose32 from "mongoose";
2953
+ import mongoose33 from "mongoose";
2970
2954
  var connectToDatabase = async ({
2971
2955
  appName,
2972
2956
  dbName,
@@ -2979,7 +2963,7 @@ var connectToDatabase = async ({
2979
2963
  // Fallback to MongoDB Atlas connection string
2980
2964
  `mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
2981
2965
  );
2982
- await mongoose32.connect(mongoUri);
2966
+ await mongoose33.connect(mongoUri);
2983
2967
  const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
2984
2968
  console.log(
2985
2969
  `${connectionType} connected from server/src/service/database.ts`
@@ -2992,7 +2976,7 @@ var connectToDatabase = async ({
2992
2976
 
2993
2977
  // src/types/index.ts
2994
2978
  import express from "express";
2995
- import mongoose33 from "mongoose";
2979
+ import mongoose34 from "mongoose";
2996
2980
  var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
2997
2981
  EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
2998
2982
  EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
@@ -3113,15 +3097,15 @@ async function updateAdStatuses() {
3113
3097
  }
3114
3098
 
3115
3099
  // src/service/objectIdToString.ts
3116
- import mongoose34 from "mongoose";
3100
+ import mongoose35 from "mongoose";
3117
3101
  function isValidObjectId(value) {
3118
- return mongoose34.Types.ObjectId.isValid(value);
3102
+ return mongoose35.Types.ObjectId.isValid(value);
3119
3103
  }
3120
3104
  function convertObjectIdsToStrings(obj) {
3121
3105
  if (obj === null || obj === void 0) {
3122
3106
  return obj;
3123
3107
  }
3124
- if (obj instanceof mongoose34.Types.ObjectId) {
3108
+ if (obj instanceof mongoose35.Types.ObjectId) {
3125
3109
  return obj.toString();
3126
3110
  }
3127
3111
  if (obj instanceof Date) {
@@ -3143,32 +3127,75 @@ function convertObjectIdsToStrings(obj) {
3143
3127
  // src/service/event/updateAllEventDateTimeStatuses.ts
3144
3128
  import {
3145
3129
  dateFormat,
3146
- EnumEventDateStatus as EnumEventDateStatus6,
3130
+ EnumEventDateStatus as EnumEventDateStatus7,
3131
+ filterDatesByFutureStatus,
3147
3132
  timeFormat
3148
3133
  } from "@timardex/cluemart-shared";
3149
3134
  import dayjs2 from "dayjs";
3150
3135
  import customParseFormat from "dayjs/plugin/customParseFormat";
3151
3136
  import isoWeek from "dayjs/plugin/isoWeek";
3137
+
3138
+ // src/service/event/archiveEndedEventDates.ts
3139
+ import { EnumEventDateStatus as EnumEventDateStatus6 } from "@timardex/cluemart-shared";
3140
+ var ARCHIVED_STATUSES = /* @__PURE__ */ new Set([
3141
+ EnumEventDateStatus6.ENDED
3142
+ ]);
3143
+ var DISCARDED_STATUSES = /* @__PURE__ */ new Set([
3144
+ EnumEventDateStatus6.INVALID
3145
+ ]);
3146
+ function splitEventDatesForArchive(dateTime) {
3147
+ return {
3148
+ archive: dateTime.filter((slot) => ARCHIVED_STATUSES.has(slot.dateStatus)),
3149
+ discard: dateTime.filter((slot) => DISCARDED_STATUSES.has(slot.dateStatus)),
3150
+ keep: dateTime.filter(
3151
+ (slot) => !ARCHIVED_STATUSES.has(slot.dateStatus) && !DISCARDED_STATUSES.has(slot.dateStatus)
3152
+ )
3153
+ };
3154
+ }
3155
+ function dedupeArchivedSlotsByStartDateTime(slots) {
3156
+ const seen = /* @__PURE__ */ new Set();
3157
+ return slots.filter((slot) => {
3158
+ const key = `${slot.startDate}_${slot.startTime}`;
3159
+ if (seen.has(key)) {
3160
+ return false;
3161
+ }
3162
+ seen.add(key);
3163
+ return true;
3164
+ });
3165
+ }
3166
+ async function persistArchivedEventDates(eventId, slots) {
3167
+ if (slots.length === 0) {
3168
+ return;
3169
+ }
3170
+ const uniqueSlots = dedupeArchivedSlotsByStartDateTime(slots);
3171
+ await EventDateArchiveModel.updateOne(
3172
+ { eventId },
3173
+ { $addToSet: { dateTime: { $each: uniqueSlots } } },
3174
+ { upsert: true }
3175
+ );
3176
+ }
3177
+
3178
+ // src/service/event/updateAllEventDateTimeStatuses.ts
3152
3179
  dayjs2.extend(customParseFormat);
3153
3180
  dayjs2.extend(isoWeek);
3154
3181
  function getFutureEventStatus(startDateTime, now) {
3155
3182
  const hoursUntilStart = startDateTime.diff(now, "hour", true);
3156
3183
  if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
3157
- return EnumEventDateStatus6.STARTING_SOON;
3184
+ return EnumEventDateStatus7.STARTING_SOON;
3158
3185
  }
3159
3186
  if (startDateTime.isSame(now, "day")) {
3160
- return EnumEventDateStatus6.TODAY;
3187
+ return EnumEventDateStatus7.TODAY;
3161
3188
  }
3162
3189
  if (startDateTime.isSame(now.add(1, "day"), "day")) {
3163
- return EnumEventDateStatus6.TOMORROW;
3190
+ return EnumEventDateStatus7.TOMORROW;
3164
3191
  }
3165
3192
  if (startDateTime.isSame(now, "isoWeek")) {
3166
- return EnumEventDateStatus6.THIS_WEEK;
3193
+ return EnumEventDateStatus7.THIS_WEEK;
3167
3194
  }
3168
3195
  if (startDateTime.isSame(now.add(1, "week"), "isoWeek")) {
3169
- return EnumEventDateStatus6.NEXT_WEEK;
3196
+ return EnumEventDateStatus7.NEXT_WEEK;
3170
3197
  }
3171
- return EnumEventDateStatus6.UPCOMING;
3198
+ return EnumEventDateStatus7.UPCOMING;
3172
3199
  }
3173
3200
  function updateSingleDateTimeStatus(dateTime, now = dayjs2()) {
3174
3201
  const dateTimeFormat = `${dateFormat} ${timeFormat}`;
@@ -3185,13 +3212,13 @@ function updateSingleDateTimeStatus(dateTime, now = dayjs2()) {
3185
3212
  if (!startDateTime.isValid() || !endDateTime.isValid()) {
3186
3213
  return {
3187
3214
  ...dateTime,
3188
- dateStatus: EnumEventDateStatus6.INVALID
3215
+ dateStatus: EnumEventDateStatus7.INVALID
3189
3216
  };
3190
3217
  }
3191
3218
  if (endDateTime.isBefore(startDateTime)) {
3192
3219
  return {
3193
3220
  ...dateTime,
3194
- dateStatus: EnumEventDateStatus6.INVALID
3221
+ dateStatus: EnumEventDateStatus7.INVALID
3195
3222
  };
3196
3223
  }
3197
3224
  let dateStatus;
@@ -3199,10 +3226,10 @@ function updateSingleDateTimeStatus(dateTime, now = dayjs2()) {
3199
3226
  if (startDateTime.isAfter(now)) {
3200
3227
  dateStatus = getFutureEventStatus(startDateTime, now);
3201
3228
  } else {
3202
- dateStatus = EnumEventDateStatus6.STARTED;
3229
+ dateStatus = EnumEventDateStatus7.STARTED;
3203
3230
  }
3204
3231
  } else {
3205
- dateStatus = EnumEventDateStatus6.ENDED;
3232
+ dateStatus = EnumEventDateStatus7.ENDED;
3206
3233
  }
3207
3234
  return {
3208
3235
  ...dateTime,
@@ -3258,6 +3285,111 @@ async function updateModelDateTimeStatuses(model, now) {
3258
3285
  }
3259
3286
  return updated;
3260
3287
  }
3288
+ var ARCHIVABLE_EVENT_FILTER = {
3289
+ "dateTime.dateStatus": {
3290
+ $in: [EnumEventDateStatus7.ENDED, EnumEventDateStatus7.INVALID]
3291
+ },
3292
+ deletedAt: null
3293
+ };
3294
+ async function archiveEndedAndDiscardInvalidEventDates(now) {
3295
+ const cursor = EventModel.find(ARCHIVABLE_EVENT_FILTER).select({ _id: 1, dateTime: 1 }).lean().cursor({ batchSize: CURSOR_BATCH_SIZE });
3296
+ let archivedCount = 0;
3297
+ let archiveOps = [];
3298
+ let eventOps = [];
3299
+ const flushBulkWrites = async () => {
3300
+ if (archiveOps.length) {
3301
+ await EventDateArchiveModel.bulkWrite(archiveOps);
3302
+ archiveOps = [];
3303
+ }
3304
+ if (eventOps.length) {
3305
+ await EventModel.bulkWrite(eventOps);
3306
+ eventOps = [];
3307
+ }
3308
+ };
3309
+ try {
3310
+ for await (const doc of cursor) {
3311
+ const updated = doc.dateTime.map(
3312
+ (slot) => updateSingleDateTimeStatus(slot, now)
3313
+ );
3314
+ const { archive, discard } = splitEventDatesForArchive(updated);
3315
+ if (archive.length === 0 && discard.length === 0) {
3316
+ continue;
3317
+ }
3318
+ if (archive.length > 0) {
3319
+ const uniqueArchive = dedupeArchivedSlotsByStartDateTime(archive);
3320
+ archiveOps.push({
3321
+ updateOne: {
3322
+ filter: { eventId: doc._id },
3323
+ update: { $addToSet: { dateTime: { $each: uniqueArchive } } },
3324
+ upsert: true
3325
+ }
3326
+ });
3327
+ archivedCount += uniqueArchive.length;
3328
+ }
3329
+ eventOps.push({
3330
+ updateOne: {
3331
+ filter: { _id: doc._id },
3332
+ update: {
3333
+ $pull: {
3334
+ dateTime: {
3335
+ dateStatus: {
3336
+ $in: [EnumEventDateStatus7.ENDED, EnumEventDateStatus7.INVALID]
3337
+ }
3338
+ }
3339
+ }
3340
+ }
3341
+ }
3342
+ });
3343
+ if (archiveOps.length >= CURSOR_BATCH_SIZE || eventOps.length >= CURSOR_BATCH_SIZE) {
3344
+ await flushBulkWrites();
3345
+ }
3346
+ }
3347
+ await flushBulkWrites();
3348
+ } finally {
3349
+ await cursor.close().catch(() => void 0);
3350
+ }
3351
+ return archivedCount;
3352
+ }
3353
+ var EVENT_INFO_DATE_FILTER = {
3354
+ dateTime: { $ne: [], $type: "array" }
3355
+ };
3356
+ async function cleanEventInfoDates(now) {
3357
+ const cursor = EventInfoModel.find(EVENT_INFO_DATE_FILTER).select({ _id: 1, dateTime: 1 }).lean().cursor({ batchSize: CURSOR_BATCH_SIZE });
3358
+ let removedCount = 0;
3359
+ let bulkOps = [];
3360
+ const flushBulkWrites = async () => {
3361
+ if (!bulkOps.length) {
3362
+ return;
3363
+ }
3364
+ await EventInfoModel.bulkWrite(bulkOps);
3365
+ bulkOps = [];
3366
+ };
3367
+ try {
3368
+ for await (const doc of cursor) {
3369
+ const updated = doc.dateTime.map(
3370
+ (slot) => updateSingleDateTimeStatus(slot, now)
3371
+ );
3372
+ const kept = filterDatesByFutureStatus(updated);
3373
+ if (kept.length === updated.length) {
3374
+ continue;
3375
+ }
3376
+ bulkOps.push({
3377
+ updateOne: {
3378
+ filter: { _id: doc._id },
3379
+ update: { $set: { dateTime: kept } }
3380
+ }
3381
+ });
3382
+ removedCount += updated.length - kept.length;
3383
+ if (bulkOps.length >= CURSOR_BATCH_SIZE) {
3384
+ await flushBulkWrites();
3385
+ }
3386
+ }
3387
+ await flushBulkWrites();
3388
+ } finally {
3389
+ await cursor.close().catch(() => void 0);
3390
+ }
3391
+ return removedCount;
3392
+ }
3261
3393
  async function updateAllEventDateTimeStatuses() {
3262
3394
  const now = dayjs2();
3263
3395
  const [eventCount, marketCount] = await Promise.all([
@@ -3270,6 +3402,16 @@ async function updateAllEventDateTimeStatuses() {
3270
3402
  console.log(
3271
3403
  `\u2705 Event dateTime statuses updated: events=${eventCount} changed, google imported markets=${marketCount} changed`
3272
3404
  );
3405
+ const archivedCount = await archiveEndedAndDiscardInvalidEventDates(now);
3406
+ if (archivedCount > 0) {
3407
+ console.log(`\u2705 Archived ${archivedCount} ended event date slot(s)`);
3408
+ }
3409
+ const removedEventInfoCount = await cleanEventInfoDates(now);
3410
+ if (removedEventInfoCount > 0) {
3411
+ console.log(
3412
+ `\u2705 Removed ${removedEventInfoCount} non-future event info date slot(s)`
3413
+ );
3414
+ }
3273
3415
  }
3274
3416
 
3275
3417
  // src/service/event/findEventOrImportedMarketById.ts
@@ -4451,6 +4593,7 @@ export {
4451
4593
  CouponModel,
4452
4594
  DEFAULT_AD_SETTINGS,
4453
4595
  EnumPubSubEvents,
4596
+ EventDateArchiveModel,
4454
4597
  EventInfoModel,
4455
4598
  EventModel,
4456
4599
  GameModel,
@@ -4485,7 +4628,8 @@ export {
4485
4628
  connectToDatabase,
4486
4629
  convertObjectIdsToStrings,
4487
4630
  createLicenceObject,
4488
- dateTimeSchema2 as dateTimeSchema,
4631
+ dateTimeSchema,
4632
+ dedupeArchivedSlotsByStartDateTime,
4489
4633
  didRemoveAnyEventDates,
4490
4634
  downgradeVendorProFeatures,
4491
4635
  ensureUserLicenseCompliance,
@@ -4516,11 +4660,12 @@ export {
4516
4660
  locationGeoSchema,
4517
4661
  locationsSchema,
4518
4662
  mapVendorLicenceToSubscriptionRewardType,
4519
- mongoose33 as mongoose,
4663
+ mongoose34 as mongoose,
4520
4664
  normalizeAffiliatePromoCodes,
4521
4665
  normalizePromoCode,
4522
4666
  notifyUsers,
4523
4667
  partnerLicences,
4668
+ persistArchivedEventDates,
4524
4669
  processLicenseReminder,
4525
4670
  processUserCompliance,
4526
4671
  processUserLicenseReminders,
@@ -4530,7 +4675,6 @@ export {
4530
4675
  relationDatesSchema,
4531
4676
  remindUsersAboutLicenseExpiration,
4532
4677
  replaceUserLicenceWithObject,
4533
- resourceRelationsSchema,
4534
4678
  restoreVendorProFeatures,
4535
4679
  saveNotificationsInDb,
4536
4680
  schemaAdresource,
@@ -4539,6 +4683,7 @@ export {
4539
4683
  sendPushNotifications,
4540
4684
  sendReminderSafely,
4541
4685
  socialShareResourceSchema,
4686
+ splitEventDatesForArchive,
4542
4687
  syncUserLicencesAfterExpiry,
4543
4688
  termsAgreementSchema,
4544
4689
  updateAdStatuses,