@timardex/cluemart-server-shared 2.1.8 → 2.2.0
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/{Affiliate-Dlf_OLIh.d.ts → Affiliate-BSF7Wm6O.d.ts} +2 -32
- package/dist/{Affiliate-B1mxoMeD.d.mts → Affiliate-i11rkfv5.d.mts} +2 -32
- package/dist/{chunk-OVAGFPTP.mjs → chunk-HLRUWJLN.mjs} +314 -330
- package/dist/chunk-HLRUWJLN.mjs.map +1 -0
- package/dist/index.cjs +571 -417
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +45 -35
- package/dist/index.d.ts +45 -35
- package/dist/index.mjs +493 -341
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +309 -325
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.d.mts +14 -4
- package/dist/mongoose/index.d.ts +14 -4
- package/dist/mongoose/index.mjs +3 -3
- package/dist/service/index.cjs +567 -413
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +35 -5
- package/dist/service/index.d.ts +35 -5
- package/dist/service/index.mjs +182 -12
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-OVAGFPTP.mjs.map +0 -1
package/dist/service/index.cjs
CHANGED
|
@@ -42,6 +42,7 @@ __export(service_exports, {
|
|
|
42
42
|
connectToDatabase: () => connectToDatabase,
|
|
43
43
|
convertObjectIdsToStrings: () => convertObjectIdsToStrings,
|
|
44
44
|
createLicenceObject: () => createLicenceObject,
|
|
45
|
+
dedupeArchivedSlotsByStartDateTime: () => dedupeArchivedSlotsByStartDateTime,
|
|
45
46
|
didRemoveAnyEventDates: () => didRemoveAnyEventDates,
|
|
46
47
|
downgradeVendorProFeatures: () => downgradeVendorProFeatures,
|
|
47
48
|
ensureUserLicenseCompliance: () => ensureUserLicenseCompliance,
|
|
@@ -72,6 +73,7 @@ __export(service_exports, {
|
|
|
72
73
|
normalizePromoCode: () => normalizePromoCode,
|
|
73
74
|
notifyUsers: () => notifyUsers,
|
|
74
75
|
partnerLicences: () => partnerLicences,
|
|
76
|
+
persistArchivedEventDates: () => persistArchivedEventDates,
|
|
75
77
|
processLicenseReminder: () => processLicenseReminder,
|
|
76
78
|
processUserCompliance: () => processUserCompliance,
|
|
77
79
|
processUserLicenseReminders: () => processUserLicenseReminders,
|
|
@@ -84,6 +86,7 @@ __export(service_exports, {
|
|
|
84
86
|
sendLicenseReminder: () => sendLicenseReminder,
|
|
85
87
|
sendPushNotifications: () => sendPushNotifications,
|
|
86
88
|
sendReminderSafely: () => sendReminderSafely,
|
|
89
|
+
splitEventDatesForArchive: () => splitEventDatesForArchive,
|
|
87
90
|
syncUserLicencesAfterExpiry: () => syncUserLicencesAfterExpiry,
|
|
88
91
|
updateAdStatuses: () => updateAdStatuses,
|
|
89
92
|
updateAllEventDateTimeStatuses: () => updateAllEventDateTimeStatuses,
|
|
@@ -730,191 +733,22 @@ ChatReportSchema.index({ createdAt: -1, reporterUserId: 1 });
|
|
|
730
733
|
var ChatReportModel = import_mongoose8.default.models.ChatReport || import_mongoose8.default.model("ChatReport", ChatReportSchema);
|
|
731
734
|
|
|
732
735
|
// src/mongoose/global.ts
|
|
733
|
-
var import_cluemart_shared9 = require("@timardex/cluemart-shared");
|
|
734
|
-
var import_mongoose11 = __toESM(require("mongoose"));
|
|
735
|
-
|
|
736
|
-
// src/mongoose/Relation.ts
|
|
737
|
-
var import_cluemart_shared8 = require("@timardex/cluemart-shared");
|
|
738
|
-
var import_mongoose10 = __toESM(require("mongoose"));
|
|
739
|
-
|
|
740
|
-
// src/mongoose/event/EventInfo.ts
|
|
741
736
|
var import_cluemart_shared7 = require("@timardex/cluemart-shared");
|
|
742
737
|
var import_mongoose9 = __toESM(require("mongoose"));
|
|
743
738
|
var MongooseSchema5 = import_mongoose9.default.Schema;
|
|
744
|
-
var
|
|
745
|
-
{
|
|
746
|
-
label: { required: false, type: String },
|
|
747
|
-
price: { required: false, type: Number },
|
|
748
|
-
stallCapacity: { required: false, type: Number }
|
|
749
|
-
},
|
|
750
|
-
{
|
|
751
|
-
_id: false
|
|
752
|
-
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
753
|
-
}
|
|
754
|
-
);
|
|
755
|
-
var dateTimeSchema = new MongooseSchema5(
|
|
756
|
-
{
|
|
757
|
-
dateStatus: {
|
|
758
|
-
enum: Object.values(import_cluemart_shared7.EnumEventDateStatus),
|
|
759
|
-
required: false,
|
|
760
|
-
type: String
|
|
761
|
-
},
|
|
762
|
-
endDate: { required: true, type: String },
|
|
763
|
-
endTime: { required: true, type: String },
|
|
764
|
-
stallTypes: [StallTypeSchema],
|
|
765
|
-
startDate: { required: true, type: String },
|
|
766
|
-
startTime: { required: true, type: String }
|
|
767
|
-
},
|
|
768
|
-
{ _id: false }
|
|
769
|
-
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
770
|
-
);
|
|
771
|
-
var paymentInfoSchema = new MongooseSchema5(
|
|
772
|
-
{
|
|
773
|
-
accountHolderName: { required: false, type: String },
|
|
774
|
-
accountNumber: { required: false, type: String },
|
|
775
|
-
link: { required: false, type: String },
|
|
776
|
-
paymentMethod: {
|
|
777
|
-
enum: Object.values(import_cluemart_shared7.EnumPaymentMethod),
|
|
778
|
-
required: true,
|
|
779
|
-
type: String
|
|
780
|
-
}
|
|
781
|
-
},
|
|
782
|
-
{ _id: false }
|
|
783
|
-
// Prevents Mongoose from creating an additional _id field
|
|
784
|
-
);
|
|
785
|
-
var requirementsSchema = new MongooseSchema5(
|
|
786
|
-
{
|
|
787
|
-
category: { required: true, type: String },
|
|
788
|
-
label: { required: true, type: String },
|
|
789
|
-
value: { required: true, type: Boolean }
|
|
790
|
-
},
|
|
791
|
-
{
|
|
792
|
-
_id: false
|
|
793
|
-
// Prevents Mongoose from creating an additional _id field for
|
|
794
|
-
}
|
|
795
|
-
);
|
|
796
|
-
var refundPolicySchema = new MongooseSchema5(
|
|
797
|
-
{
|
|
798
|
-
category: { required: true, type: String },
|
|
799
|
-
label: { required: true, type: String },
|
|
800
|
-
value: { required: true, type: Boolean }
|
|
801
|
-
},
|
|
802
|
-
{ _id: false }
|
|
803
|
-
);
|
|
804
|
-
var schema7 = new MongooseSchema5(
|
|
805
|
-
{
|
|
806
|
-
active: { default: true, type: Boolean },
|
|
807
|
-
applicationDeadlineHours: { required: true, type: Number },
|
|
808
|
-
dateTime: { required: true, type: [dateTimeSchema] },
|
|
809
|
-
eventId: {
|
|
810
|
-
ref: "Event",
|
|
811
|
-
required: true,
|
|
812
|
-
type: import_mongoose9.default.Schema.Types.ObjectId
|
|
813
|
-
},
|
|
814
|
-
packInTime: { required: true, type: Number },
|
|
815
|
-
paymentDueHours: { required: true, type: Number },
|
|
816
|
-
paymentInfo: { required: true, type: [paymentInfoSchema] },
|
|
817
|
-
refundPolicy: { required: true, type: [refundPolicySchema] },
|
|
818
|
-
requirements: { required: false, type: [requirementsSchema] }
|
|
819
|
-
},
|
|
820
|
-
{ timestamps: true }
|
|
821
|
-
);
|
|
822
|
-
schema7.index({ eventId: 1 });
|
|
823
|
-
var EventInfoModel = import_mongoose9.default.models.EventInfo || import_mongoose9.default.model("EventInfo", schema7);
|
|
824
|
-
|
|
825
|
-
// src/mongoose/Relation.ts
|
|
826
|
-
var MongooseSchema6 = import_mongoose10.default.Schema;
|
|
827
|
-
var relationDateTimeSchema = new MongooseSchema6(
|
|
828
|
-
{
|
|
829
|
-
dateStatus: {
|
|
830
|
-
enum: Object.values(import_cluemart_shared8.EnumEventDateStatus),
|
|
831
|
-
required: true,
|
|
832
|
-
type: String
|
|
833
|
-
},
|
|
834
|
-
endDate: { required: true, type: String },
|
|
835
|
-
endTime: { required: true, type: String },
|
|
836
|
-
stallType: StallTypeSchema,
|
|
837
|
-
startDate: { required: true, type: String },
|
|
838
|
-
startTime: { required: true, type: String }
|
|
839
|
-
},
|
|
840
|
-
{ _id: false }
|
|
841
|
-
);
|
|
842
|
-
var relationDatesSchema = new MongooseSchema6(
|
|
843
|
-
{
|
|
844
|
-
dateTime: {
|
|
845
|
-
required: true,
|
|
846
|
-
type: relationDateTimeSchema
|
|
847
|
-
},
|
|
848
|
-
lastUpdateBy: {
|
|
849
|
-
resourceId: { required: false, type: String },
|
|
850
|
-
userEmail: { required: false, type: String }
|
|
851
|
-
},
|
|
852
|
-
paymentReference: { required: false, type: String },
|
|
853
|
-
status: {
|
|
854
|
-
enum: Object.values(import_cluemart_shared8.EnumInviteStatus),
|
|
855
|
-
required: false,
|
|
856
|
-
type: String
|
|
857
|
-
}
|
|
858
|
-
},
|
|
859
|
-
{ _id: false }
|
|
860
|
-
);
|
|
861
|
-
var RelationTypeSchema = new MongooseSchema6(
|
|
862
|
-
{
|
|
863
|
-
active: { default: true, required: true, type: Boolean },
|
|
864
|
-
chatId: {
|
|
865
|
-
ref: "Chat",
|
|
866
|
-
required: true,
|
|
867
|
-
type: import_mongoose10.default.Schema.Types.ObjectId
|
|
868
|
-
},
|
|
869
|
-
deletedAt: { default: null, required: false, type: Date },
|
|
870
|
-
eventId: {
|
|
871
|
-
ref: "Event",
|
|
872
|
-
required: true,
|
|
873
|
-
type: import_mongoose10.default.Schema.Types.ObjectId
|
|
874
|
-
},
|
|
875
|
-
lastUpdateBy: {
|
|
876
|
-
enum: Object.values(import_cluemart_shared8.EnumResourceType),
|
|
877
|
-
required: true,
|
|
878
|
-
type: String
|
|
879
|
-
},
|
|
880
|
-
relationDates: [relationDatesSchema],
|
|
881
|
-
relationType: {
|
|
882
|
-
enum: Object.values(import_cluemart_shared8.EnumRelationResource),
|
|
883
|
-
required: true,
|
|
884
|
-
type: String
|
|
885
|
-
},
|
|
886
|
-
vendorId: {
|
|
887
|
-
ref: "Vendor",
|
|
888
|
-
required: true,
|
|
889
|
-
type: import_mongoose10.default.Schema.Types.ObjectId
|
|
890
|
-
}
|
|
891
|
-
},
|
|
892
|
-
{ timestamps: true }
|
|
893
|
-
);
|
|
894
|
-
RelationTypeSchema.index({
|
|
895
|
-
eventId: 1,
|
|
896
|
-
"relationDates.startDate": 1,
|
|
897
|
-
"relationDates.startTime": 1,
|
|
898
|
-
"relationDates.status": 1,
|
|
899
|
-
vendorId: 1
|
|
900
|
-
});
|
|
901
|
-
var RelationModel = import_mongoose10.default.models.Relation || import_mongoose10.default.model("Relation", RelationTypeSchema);
|
|
902
|
-
|
|
903
|
-
// src/mongoose/global.ts
|
|
904
|
-
var MongooseSchema7 = import_mongoose11.default.Schema;
|
|
905
|
-
var OwnerTypeSchema = new MongooseSchema7(
|
|
739
|
+
var OwnerTypeSchema = new MongooseSchema5(
|
|
906
740
|
{
|
|
907
741
|
email: { required: true, type: String },
|
|
908
742
|
userId: {
|
|
909
743
|
ref: "User",
|
|
910
744
|
required: true,
|
|
911
|
-
type:
|
|
745
|
+
type: import_mongoose9.default.Schema.Types.ObjectId
|
|
912
746
|
}
|
|
913
747
|
},
|
|
914
748
|
{ _id: false }
|
|
915
749
|
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
916
750
|
);
|
|
917
|
-
var SocialMediaTypeSchema = new
|
|
751
|
+
var SocialMediaTypeSchema = new MongooseSchema5(
|
|
918
752
|
{
|
|
919
753
|
link: { required: true, type: String },
|
|
920
754
|
name: { required: true, type: String }
|
|
@@ -922,7 +756,7 @@ var SocialMediaTypeSchema = new MongooseSchema7(
|
|
|
922
756
|
{ _id: false }
|
|
923
757
|
// Prevents Mongoose from creating an additional _id field
|
|
924
758
|
);
|
|
925
|
-
var ResourceImageTypeSchema = new
|
|
759
|
+
var ResourceImageTypeSchema = new MongooseSchema5(
|
|
926
760
|
{
|
|
927
761
|
active: { default: true, required: true, type: Boolean },
|
|
928
762
|
source: { required: false, type: String },
|
|
@@ -931,7 +765,7 @@ var ResourceImageTypeSchema = new MongooseSchema7(
|
|
|
931
765
|
{ _id: false }
|
|
932
766
|
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
933
767
|
);
|
|
934
|
-
var SubCategorySchema = new
|
|
768
|
+
var SubCategorySchema = new MongooseSchema5(
|
|
935
769
|
{
|
|
936
770
|
id: { required: false, type: String },
|
|
937
771
|
items: [
|
|
@@ -945,7 +779,7 @@ var SubCategorySchema = new MongooseSchema7(
|
|
|
945
779
|
{ _id: false }
|
|
946
780
|
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
947
781
|
);
|
|
948
|
-
var CategorySchema = new
|
|
782
|
+
var CategorySchema = new MongooseSchema5(
|
|
949
783
|
{
|
|
950
784
|
id: { required: true, type: String },
|
|
951
785
|
name: { required: true, type: String },
|
|
@@ -954,7 +788,7 @@ var CategorySchema = new MongooseSchema7(
|
|
|
954
788
|
{ _id: false }
|
|
955
789
|
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
956
790
|
);
|
|
957
|
-
var PosterUsageTypeSchema = new
|
|
791
|
+
var PosterUsageTypeSchema = new MongooseSchema5(
|
|
958
792
|
{
|
|
959
793
|
count: { default: 0, required: false, type: Number },
|
|
960
794
|
month: { required: false, type: String }
|
|
@@ -962,24 +796,24 @@ var PosterUsageTypeSchema = new MongooseSchema7(
|
|
|
962
796
|
{ _id: false }
|
|
963
797
|
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
964
798
|
);
|
|
965
|
-
var userLicenseSchema = new
|
|
799
|
+
var userLicenseSchema = new MongooseSchema5(
|
|
966
800
|
{
|
|
967
801
|
expiryDate: { required: true, type: Date },
|
|
968
802
|
issuedDate: { required: true, type: Date },
|
|
969
803
|
licenceType: {
|
|
970
|
-
enum: Object.values(
|
|
804
|
+
enum: Object.values(import_cluemart_shared7.EnumUserLicence),
|
|
971
805
|
required: true,
|
|
972
806
|
type: String
|
|
973
807
|
},
|
|
974
808
|
prevLicenceType: {
|
|
975
|
-
enum: Object.values(
|
|
809
|
+
enum: Object.values(import_cluemart_shared7.EnumUserLicence),
|
|
976
810
|
required: false,
|
|
977
811
|
type: String
|
|
978
812
|
}
|
|
979
813
|
},
|
|
980
814
|
{ _id: false, timestamps: false }
|
|
981
815
|
);
|
|
982
|
-
var ContactDetailsSchema = new
|
|
816
|
+
var ContactDetailsSchema = new MongooseSchema5(
|
|
983
817
|
{
|
|
984
818
|
email: { required: false, type: String },
|
|
985
819
|
landlinePhone: { required: false, type: String },
|
|
@@ -988,7 +822,7 @@ var ContactDetailsSchema = new MongooseSchema7(
|
|
|
988
822
|
{ _id: false }
|
|
989
823
|
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
990
824
|
);
|
|
991
|
-
var termsAgreementSchema = new
|
|
825
|
+
var termsAgreementSchema = new MongooseSchema5(
|
|
992
826
|
{
|
|
993
827
|
appBuildNumber: { required: true, type: String },
|
|
994
828
|
appId: { required: true, type: String },
|
|
@@ -1005,25 +839,10 @@ var termsAgreementSchema = new MongooseSchema7(
|
|
|
1005
839
|
},
|
|
1006
840
|
{ _id: false }
|
|
1007
841
|
);
|
|
1008
|
-
var
|
|
1009
|
-
{
|
|
1010
|
-
relationDates: {
|
|
1011
|
-
default: [],
|
|
1012
|
-
required: false,
|
|
1013
|
-
type: [relationDatesSchema]
|
|
1014
|
-
},
|
|
1015
|
-
relationId: {
|
|
1016
|
-
ref: "Relation",
|
|
1017
|
-
required: false,
|
|
1018
|
-
type: import_mongoose11.default.Schema.Types.ObjectId
|
|
1019
|
-
}
|
|
1020
|
-
},
|
|
1021
|
-
{ _id: false }
|
|
1022
|
-
);
|
|
1023
|
-
var dateTimeSchema2 = new MongooseSchema7(
|
|
842
|
+
var dateTimeSchema = new MongooseSchema5(
|
|
1024
843
|
{
|
|
1025
844
|
dateStatus: {
|
|
1026
|
-
enum: Object.values(
|
|
845
|
+
enum: Object.values(import_cluemart_shared7.EnumEventDateStatus),
|
|
1027
846
|
required: false,
|
|
1028
847
|
type: String
|
|
1029
848
|
},
|
|
@@ -1035,7 +854,7 @@ var dateTimeSchema2 = new MongooseSchema7(
|
|
|
1035
854
|
{ _id: false }
|
|
1036
855
|
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
1037
856
|
);
|
|
1038
|
-
var locationGeoSchema = new
|
|
857
|
+
var locationGeoSchema = new MongooseSchema5(
|
|
1039
858
|
{
|
|
1040
859
|
coordinates: { required: true, type: [Number] },
|
|
1041
860
|
// [longitude, latitude]
|
|
@@ -1044,7 +863,7 @@ var locationGeoSchema = new MongooseSchema7(
|
|
|
1044
863
|
{ _id: false }
|
|
1045
864
|
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
1046
865
|
);
|
|
1047
|
-
var locationsSchema = new
|
|
866
|
+
var locationsSchema = new MongooseSchema5(
|
|
1048
867
|
{
|
|
1049
868
|
city: { required: true, type: String },
|
|
1050
869
|
country: { required: true, type: String },
|
|
@@ -1060,17 +879,17 @@ var locationsSchema = new MongooseSchema7(
|
|
|
1060
879
|
{ _id: false }
|
|
1061
880
|
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
1062
881
|
);
|
|
1063
|
-
var relatedPostSchema = new
|
|
882
|
+
var relatedPostSchema = new MongooseSchema5(
|
|
1064
883
|
{
|
|
1065
884
|
postActive: { default: true, required: true, type: Boolean },
|
|
1066
885
|
postId: {
|
|
1067
886
|
ref: "Post",
|
|
1068
887
|
required: true,
|
|
1069
|
-
type:
|
|
888
|
+
type: import_mongoose9.default.Schema.Types.ObjectId
|
|
1070
889
|
},
|
|
1071
890
|
postSlug: { required: true, type: String },
|
|
1072
891
|
postType: {
|
|
1073
|
-
enum: Object.values(
|
|
892
|
+
enum: Object.values(import_cluemart_shared7.EnumPostType),
|
|
1074
893
|
required: true,
|
|
1075
894
|
type: String
|
|
1076
895
|
}
|
|
@@ -1078,7 +897,7 @@ var relatedPostSchema = new MongooseSchema7(
|
|
|
1078
897
|
{ _id: false }
|
|
1079
898
|
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
1080
899
|
);
|
|
1081
|
-
var socialShareResourceSchema = new
|
|
900
|
+
var socialShareResourceSchema = new MongooseSchema5(
|
|
1082
901
|
{
|
|
1083
902
|
qrCode: { required: true, type: ResourceImageTypeSchema },
|
|
1084
903
|
socialImage: { required: true, type: ResourceImageTypeSchema }
|
|
@@ -1091,7 +910,7 @@ var baseResourceFields = {
|
|
|
1091
910
|
adIds: {
|
|
1092
911
|
ref: "Ad",
|
|
1093
912
|
required: false,
|
|
1094
|
-
type: [
|
|
913
|
+
type: [import_mongoose9.default.Schema.Types.ObjectId]
|
|
1095
914
|
},
|
|
1096
915
|
approvedAt: { default: null, required: false, type: Date },
|
|
1097
916
|
contactDetails: { required: false, type: ContactDetailsSchema },
|
|
@@ -1121,8 +940,8 @@ var baseResourceFields = {
|
|
|
1121
940
|
};
|
|
1122
941
|
|
|
1123
942
|
// src/mongoose/GoogleImportedMarket.ts
|
|
1124
|
-
var
|
|
1125
|
-
var
|
|
943
|
+
var import_cluemart_shared8 = require("@timardex/cluemart-shared");
|
|
944
|
+
var import_mongoose10 = __toESM(require("mongoose"));
|
|
1126
945
|
|
|
1127
946
|
// src/mongoose/searchNamePlugin.ts
|
|
1128
947
|
function deriveSearchName(name) {
|
|
@@ -1168,15 +987,15 @@ function syncSearchNameInUpdate(update) {
|
|
|
1168
987
|
}
|
|
1169
988
|
return null;
|
|
1170
989
|
}
|
|
1171
|
-
function searchNamePlugin(
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
990
|
+
function searchNamePlugin(schema25) {
|
|
991
|
+
schema25.add({ searchName: { default: "", required: false, type: String } });
|
|
992
|
+
schema25.index({ searchName: 1 });
|
|
993
|
+
schema25.pre("save", function syncSearchNameOnSave(next) {
|
|
1175
994
|
const doc = this;
|
|
1176
995
|
doc.searchName = deriveSearchName(doc.name);
|
|
1177
996
|
next();
|
|
1178
997
|
});
|
|
1179
|
-
|
|
998
|
+
schema25.pre("insertMany", function syncSearchNameOnInsertMany(next, docs) {
|
|
1180
999
|
const list = Array.isArray(docs) ? docs : [docs];
|
|
1181
1000
|
for (const doc of list) {
|
|
1182
1001
|
if (doc && typeof doc.name === "string") {
|
|
@@ -1185,7 +1004,7 @@ function searchNamePlugin(schema24) {
|
|
|
1185
1004
|
}
|
|
1186
1005
|
next();
|
|
1187
1006
|
});
|
|
1188
|
-
|
|
1007
|
+
schema25.pre("bulkWrite", function syncSearchNameOnBulkWrite(next, ops) {
|
|
1189
1008
|
for (const op of ops) {
|
|
1190
1009
|
const doc = op.insertOne?.document ?? op.replaceOne?.replacement;
|
|
1191
1010
|
if (doc && typeof doc.name === "string") {
|
|
@@ -1211,15 +1030,15 @@ function searchNamePlugin(schema24) {
|
|
|
1211
1030
|
}
|
|
1212
1031
|
next();
|
|
1213
1032
|
};
|
|
1214
|
-
|
|
1033
|
+
schema25.pre(
|
|
1215
1034
|
["findOneAndUpdate", "updateOne", "updateMany"],
|
|
1216
1035
|
syncSearchNameOnUpdate
|
|
1217
1036
|
);
|
|
1218
1037
|
}
|
|
1219
1038
|
|
|
1220
1039
|
// src/mongoose/GoogleImportedMarket.ts
|
|
1221
|
-
var
|
|
1222
|
-
var addressComponentSchema = new
|
|
1040
|
+
var MongooseSchema6 = import_mongoose10.default.Schema;
|
|
1041
|
+
var addressComponentSchema = new MongooseSchema6(
|
|
1223
1042
|
{
|
|
1224
1043
|
longName: { required: false, type: String },
|
|
1225
1044
|
shortName: { required: false, type: String },
|
|
@@ -1227,7 +1046,7 @@ var addressComponentSchema = new MongooseSchema8(
|
|
|
1227
1046
|
},
|
|
1228
1047
|
{ _id: false }
|
|
1229
1048
|
);
|
|
1230
|
-
var
|
|
1049
|
+
var schema7 = new MongooseSchema6(
|
|
1231
1050
|
{
|
|
1232
1051
|
active: { default: false, required: true, type: Boolean },
|
|
1233
1052
|
address: { required: true, type: String },
|
|
@@ -1239,22 +1058,22 @@ var schema8 = new MongooseSchema8(
|
|
|
1239
1058
|
claimedByUserId: {
|
|
1240
1059
|
ref: "User",
|
|
1241
1060
|
required: false,
|
|
1242
|
-
type:
|
|
1061
|
+
type: import_mongoose10.default.Schema.Types.ObjectId
|
|
1243
1062
|
},
|
|
1244
1063
|
cover: {
|
|
1245
1064
|
required: false,
|
|
1246
1065
|
type: ResourceImageTypeSchema
|
|
1247
1066
|
},
|
|
1248
|
-
dateTime: [
|
|
1067
|
+
dateTime: [dateTimeSchema],
|
|
1249
1068
|
deletedAt: { default: null, required: false, type: Date },
|
|
1250
1069
|
description: { required: true, type: String },
|
|
1251
1070
|
eventId: {
|
|
1252
1071
|
ref: "Event",
|
|
1253
1072
|
required: false,
|
|
1254
|
-
type:
|
|
1073
|
+
type: import_mongoose10.default.Schema.Types.ObjectId
|
|
1255
1074
|
},
|
|
1256
1075
|
eventType: {
|
|
1257
|
-
enum: Object.values(
|
|
1076
|
+
enum: Object.values(import_cluemart_shared8.EnumEventType),
|
|
1258
1077
|
required: true,
|
|
1259
1078
|
type: String
|
|
1260
1079
|
},
|
|
@@ -1279,38 +1098,33 @@ var schema8 = new MongooseSchema8(
|
|
|
1279
1098
|
rainOrShine: { required: true, type: Boolean },
|
|
1280
1099
|
rating: { required: false, type: Number },
|
|
1281
1100
|
region: { required: false, type: String },
|
|
1282
|
-
relations: {
|
|
1283
|
-
default: [],
|
|
1284
|
-
required: false,
|
|
1285
|
-
type: [resourceRelationsSchema]
|
|
1286
|
-
},
|
|
1287
1101
|
reviewCount: { required: false, type: Number },
|
|
1288
1102
|
slug: { required: true, type: String },
|
|
1289
1103
|
website: { required: false, type: String }
|
|
1290
1104
|
},
|
|
1291
1105
|
{ timestamps: true }
|
|
1292
1106
|
);
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
var GoogleImportedMarketModel =
|
|
1107
|
+
schema7.index({ "location.geo": "2dsphere" });
|
|
1108
|
+
schema7.index({ name: 1 });
|
|
1109
|
+
schema7.index({ region: 1 });
|
|
1110
|
+
schema7.index({ deletedAt: 1 });
|
|
1111
|
+
schema7.index({ "dateTime.dateStatus": 1 });
|
|
1112
|
+
schema7.index({ slug: 1 });
|
|
1113
|
+
schema7.index({ description: "text", name: "text" });
|
|
1114
|
+
schema7.plugin(searchNamePlugin);
|
|
1115
|
+
var GoogleImportedMarketModel = import_mongoose10.default.models.GoogleImportedMarket || import_mongoose10.default.model("GoogleImportedMarket", schema7);
|
|
1302
1116
|
|
|
1303
1117
|
// src/mongoose/Notification.ts
|
|
1304
|
-
var
|
|
1305
|
-
var
|
|
1306
|
-
var
|
|
1307
|
-
var
|
|
1118
|
+
var import_cluemart_shared9 = require("@timardex/cluemart-shared");
|
|
1119
|
+
var import_mongoose11 = __toESM(require("mongoose"));
|
|
1120
|
+
var MongooseSchema7 = import_mongoose11.default.Schema;
|
|
1121
|
+
var schema8 = new MongooseSchema7(
|
|
1308
1122
|
{
|
|
1309
1123
|
data: {
|
|
1310
1124
|
resourceId: { required: true, type: String },
|
|
1311
1125
|
resourceName: { required: true, type: String },
|
|
1312
1126
|
resourceType: {
|
|
1313
|
-
enum: Object.values(
|
|
1127
|
+
enum: Object.values(import_cluemart_shared9.EnumNotificationResourceType),
|
|
1314
1128
|
required: true,
|
|
1315
1129
|
type: String
|
|
1316
1130
|
}
|
|
@@ -1319,28 +1133,28 @@ var schema9 = new MongooseSchema9(
|
|
|
1319
1133
|
message: { required: true, type: String },
|
|
1320
1134
|
title: { required: true, type: String },
|
|
1321
1135
|
type: {
|
|
1322
|
-
default:
|
|
1323
|
-
enum: Object.values(
|
|
1136
|
+
default: import_cluemart_shared9.EnumNotificationType.SYSTEM,
|
|
1137
|
+
enum: Object.values(import_cluemart_shared9.EnumNotificationType),
|
|
1324
1138
|
required: true,
|
|
1325
1139
|
type: String
|
|
1326
1140
|
},
|
|
1327
1141
|
userId: {
|
|
1328
1142
|
ref: "User",
|
|
1329
1143
|
required: true,
|
|
1330
|
-
type:
|
|
1144
|
+
type: import_mongoose11.default.Schema.Types.ObjectId
|
|
1331
1145
|
}
|
|
1332
1146
|
},
|
|
1333
1147
|
{ timestamps: true }
|
|
1334
1148
|
);
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
var NotificationModel =
|
|
1149
|
+
schema8.index({ isRead: 1, userId: 1 });
|
|
1150
|
+
schema8.index({ createdAt: -1, userId: 1 });
|
|
1151
|
+
var NotificationModel = import_mongoose11.default.models.Notification || import_mongoose11.default.model("Notification", schema8);
|
|
1338
1152
|
|
|
1339
1153
|
// src/mongoose/PushToken.ts
|
|
1340
1154
|
var import_enums = require("@timardex/cluemart-shared/enums");
|
|
1341
|
-
var
|
|
1342
|
-
var
|
|
1343
|
-
var
|
|
1155
|
+
var import_mongoose12 = __toESM(require("mongoose"));
|
|
1156
|
+
var MongooseSchema8 = import_mongoose12.default.Schema;
|
|
1157
|
+
var schema9 = new MongooseSchema8(
|
|
1344
1158
|
{
|
|
1345
1159
|
platform: {
|
|
1346
1160
|
enum: Object.values(import_enums.EnumOSPlatform),
|
|
@@ -1351,12 +1165,179 @@ var schema10 = new MongooseSchema10(
|
|
|
1351
1165
|
userId: {
|
|
1352
1166
|
ref: "User",
|
|
1353
1167
|
required: true,
|
|
1168
|
+
type: import_mongoose12.default.Schema.Types.ObjectId
|
|
1169
|
+
}
|
|
1170
|
+
},
|
|
1171
|
+
{ timestamps: true }
|
|
1172
|
+
);
|
|
1173
|
+
var PushTokenModel = import_mongoose12.default.models.PushToken || import_mongoose12.default.model("PushToken", schema9);
|
|
1174
|
+
|
|
1175
|
+
// src/mongoose/Relation.ts
|
|
1176
|
+
var import_cluemart_shared11 = require("@timardex/cluemart-shared");
|
|
1177
|
+
var import_mongoose14 = __toESM(require("mongoose"));
|
|
1178
|
+
|
|
1179
|
+
// src/mongoose/event/EventInfo.ts
|
|
1180
|
+
var import_cluemart_shared10 = require("@timardex/cluemart-shared");
|
|
1181
|
+
var import_mongoose13 = __toESM(require("mongoose"));
|
|
1182
|
+
var MongooseSchema9 = import_mongoose13.default.Schema;
|
|
1183
|
+
var StallTypeSchema = new MongooseSchema9(
|
|
1184
|
+
{
|
|
1185
|
+
label: { required: false, type: String },
|
|
1186
|
+
price: { required: false, type: Number },
|
|
1187
|
+
stallCapacity: { required: false, type: Number }
|
|
1188
|
+
},
|
|
1189
|
+
{
|
|
1190
|
+
_id: false
|
|
1191
|
+
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
1192
|
+
}
|
|
1193
|
+
);
|
|
1194
|
+
var dateTimeSchema2 = new MongooseSchema9(
|
|
1195
|
+
{
|
|
1196
|
+
dateStatus: {
|
|
1197
|
+
enum: Object.values(import_cluemart_shared10.EnumEventDateStatus),
|
|
1198
|
+
required: false,
|
|
1199
|
+
type: String
|
|
1200
|
+
},
|
|
1201
|
+
endDate: { required: true, type: String },
|
|
1202
|
+
endTime: { required: true, type: String },
|
|
1203
|
+
stallTypes: [StallTypeSchema],
|
|
1204
|
+
startDate: { required: true, type: String },
|
|
1205
|
+
startTime: { required: true, type: String }
|
|
1206
|
+
},
|
|
1207
|
+
{ _id: false }
|
|
1208
|
+
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
1209
|
+
);
|
|
1210
|
+
var paymentInfoSchema = new MongooseSchema9(
|
|
1211
|
+
{
|
|
1212
|
+
accountHolderName: { required: false, type: String },
|
|
1213
|
+
accountNumber: { required: false, type: String },
|
|
1214
|
+
link: { required: false, type: String },
|
|
1215
|
+
paymentMethod: {
|
|
1216
|
+
enum: Object.values(import_cluemart_shared10.EnumPaymentMethod),
|
|
1217
|
+
required: true,
|
|
1218
|
+
type: String
|
|
1219
|
+
}
|
|
1220
|
+
},
|
|
1221
|
+
{ _id: false }
|
|
1222
|
+
// Prevents Mongoose from creating an additional _id field
|
|
1223
|
+
);
|
|
1224
|
+
var requirementsSchema = new MongooseSchema9(
|
|
1225
|
+
{
|
|
1226
|
+
category: { required: true, type: String },
|
|
1227
|
+
label: { required: true, type: String },
|
|
1228
|
+
value: { required: true, type: Boolean }
|
|
1229
|
+
},
|
|
1230
|
+
{
|
|
1231
|
+
_id: false
|
|
1232
|
+
// Prevents Mongoose from creating an additional _id field for
|
|
1233
|
+
}
|
|
1234
|
+
);
|
|
1235
|
+
var refundPolicySchema = new MongooseSchema9(
|
|
1236
|
+
{
|
|
1237
|
+
category: { required: true, type: String },
|
|
1238
|
+
label: { required: true, type: String },
|
|
1239
|
+
value: { required: true, type: Boolean }
|
|
1240
|
+
},
|
|
1241
|
+
{ _id: false }
|
|
1242
|
+
);
|
|
1243
|
+
var schema10 = new MongooseSchema9(
|
|
1244
|
+
{
|
|
1245
|
+
active: { default: true, type: Boolean },
|
|
1246
|
+
applicationDeadlineHours: { required: true, type: Number },
|
|
1247
|
+
dateTime: { required: true, type: [dateTimeSchema2] },
|
|
1248
|
+
eventId: {
|
|
1249
|
+
ref: "Event",
|
|
1250
|
+
required: true,
|
|
1251
|
+
type: import_mongoose13.default.Schema.Types.ObjectId
|
|
1252
|
+
},
|
|
1253
|
+
packInTime: { required: true, type: Number },
|
|
1254
|
+
paymentDueHours: { required: true, type: Number },
|
|
1255
|
+
paymentInfo: { required: true, type: [paymentInfoSchema] },
|
|
1256
|
+
refundPolicy: { required: true, type: [refundPolicySchema] },
|
|
1257
|
+
requirements: { required: false, type: [requirementsSchema] }
|
|
1258
|
+
},
|
|
1259
|
+
{ timestamps: true }
|
|
1260
|
+
);
|
|
1261
|
+
schema10.index({ eventId: 1 });
|
|
1262
|
+
var EventInfoModel = import_mongoose13.default.models.EventInfo || import_mongoose13.default.model("EventInfo", schema10);
|
|
1263
|
+
|
|
1264
|
+
// src/mongoose/Relation.ts
|
|
1265
|
+
var MongooseSchema10 = import_mongoose14.default.Schema;
|
|
1266
|
+
var relationDateTimeSchema = new MongooseSchema10(
|
|
1267
|
+
{
|
|
1268
|
+
dateStatus: {
|
|
1269
|
+
enum: Object.values(import_cluemart_shared11.EnumEventDateStatus),
|
|
1270
|
+
required: true,
|
|
1271
|
+
type: String
|
|
1272
|
+
},
|
|
1273
|
+
endDate: { required: true, type: String },
|
|
1274
|
+
endTime: { required: true, type: String },
|
|
1275
|
+
stallType: StallTypeSchema,
|
|
1276
|
+
startDate: { required: true, type: String },
|
|
1277
|
+
startTime: { required: true, type: String }
|
|
1278
|
+
},
|
|
1279
|
+
{ _id: false }
|
|
1280
|
+
);
|
|
1281
|
+
var relationDatesSchema = new MongooseSchema10(
|
|
1282
|
+
{
|
|
1283
|
+
dateTime: {
|
|
1284
|
+
required: true,
|
|
1285
|
+
type: relationDateTimeSchema
|
|
1286
|
+
},
|
|
1287
|
+
lastUpdateBy: {
|
|
1288
|
+
resourceId: { required: false, type: String },
|
|
1289
|
+
userEmail: { required: false, type: String }
|
|
1290
|
+
},
|
|
1291
|
+
paymentReference: { required: false, type: String },
|
|
1292
|
+
status: {
|
|
1293
|
+
enum: Object.values(import_cluemart_shared11.EnumInviteStatus),
|
|
1294
|
+
required: false,
|
|
1295
|
+
type: String
|
|
1296
|
+
}
|
|
1297
|
+
},
|
|
1298
|
+
{ _id: false }
|
|
1299
|
+
);
|
|
1300
|
+
var RelationTypeSchema = new MongooseSchema10(
|
|
1301
|
+
{
|
|
1302
|
+
active: { default: true, required: true, type: Boolean },
|
|
1303
|
+
chatId: {
|
|
1304
|
+
ref: "Chat",
|
|
1305
|
+
required: true,
|
|
1306
|
+
type: import_mongoose14.default.Schema.Types.ObjectId
|
|
1307
|
+
},
|
|
1308
|
+
deletedAt: { default: null, required: false, type: Date },
|
|
1309
|
+
eventId: {
|
|
1310
|
+
ref: "Event",
|
|
1311
|
+
required: true,
|
|
1312
|
+
type: import_mongoose14.default.Schema.Types.ObjectId
|
|
1313
|
+
},
|
|
1314
|
+
lastUpdateBy: {
|
|
1315
|
+
enum: Object.values(import_cluemart_shared11.EnumResourceType),
|
|
1316
|
+
required: true,
|
|
1317
|
+
type: String
|
|
1318
|
+
},
|
|
1319
|
+
relationDates: [relationDatesSchema],
|
|
1320
|
+
relationType: {
|
|
1321
|
+
enum: Object.values(import_cluemart_shared11.EnumRelationResource),
|
|
1322
|
+
required: true,
|
|
1323
|
+
type: String
|
|
1324
|
+
},
|
|
1325
|
+
vendorId: {
|
|
1326
|
+
ref: "Vendor",
|
|
1327
|
+
required: true,
|
|
1354
1328
|
type: import_mongoose14.default.Schema.Types.ObjectId
|
|
1355
1329
|
}
|
|
1356
1330
|
},
|
|
1357
1331
|
{ timestamps: true }
|
|
1358
1332
|
);
|
|
1359
|
-
|
|
1333
|
+
RelationTypeSchema.index({
|
|
1334
|
+
eventId: 1,
|
|
1335
|
+
"relationDates.startDate": 1,
|
|
1336
|
+
"relationDates.startTime": 1,
|
|
1337
|
+
"relationDates.status": 1,
|
|
1338
|
+
vendorId: 1
|
|
1339
|
+
});
|
|
1340
|
+
var RelationModel = import_mongoose14.default.models.Relation || import_mongoose14.default.model("Relation", RelationTypeSchema);
|
|
1360
1341
|
|
|
1361
1342
|
// src/mongoose/ResourceActivity.ts
|
|
1362
1343
|
var import_cluemart_shared12 = require("@timardex/cluemart-shared");
|
|
@@ -1412,7 +1393,7 @@ var import_mongoose16 = __toESM(require("mongoose"));
|
|
|
1412
1393
|
var MongooseSchema12 = import_mongoose16.default.Schema;
|
|
1413
1394
|
var userActivityEventSchema = new MongooseSchema12(
|
|
1414
1395
|
{
|
|
1415
|
-
dateTime:
|
|
1396
|
+
dateTime: dateTimeSchema,
|
|
1416
1397
|
resourceId: {
|
|
1417
1398
|
ref: "Event",
|
|
1418
1399
|
required: false,
|
|
@@ -1760,11 +1741,6 @@ var schema14 = new MongooseSchema14(
|
|
|
1760
1741
|
downgradeSnapshot: { required: false, type: downgradeSnapshotSchema },
|
|
1761
1742
|
foodTruck: { required: true, type: Boolean },
|
|
1762
1743
|
products: { required: false, type: productWrapperSchema },
|
|
1763
|
-
relations: {
|
|
1764
|
-
default: [],
|
|
1765
|
-
required: false,
|
|
1766
|
-
type: [resourceRelationsSchema]
|
|
1767
|
-
},
|
|
1768
1744
|
shareRelation: { required: false, type: socialShareResourceSchema },
|
|
1769
1745
|
unregisteredVendorId: {
|
|
1770
1746
|
ref: "UnregisteredVendor",
|
|
@@ -1857,7 +1833,7 @@ var import_mongoose20 = __toESM(require("mongoose"));
|
|
|
1857
1833
|
var MongooseSchema16 = import_mongoose20.default.Schema;
|
|
1858
1834
|
var invitationSchema = new MongooseSchema16(
|
|
1859
1835
|
{
|
|
1860
|
-
dateTime: { required: true, type: [
|
|
1836
|
+
dateTime: { required: true, type: [dateTimeSchema] },
|
|
1861
1837
|
inviterId: {
|
|
1862
1838
|
ref: "Event",
|
|
1863
1839
|
required: true,
|
|
@@ -1901,7 +1877,7 @@ var schema17 = new MongooseSchema17(
|
|
|
1901
1877
|
...baseResourceFields,
|
|
1902
1878
|
// Importing base resource fields from global.ts
|
|
1903
1879
|
claimed: { default: true, required: false, type: Boolean },
|
|
1904
|
-
dateTime: { required: true, type: [
|
|
1880
|
+
dateTime: { required: true, type: [dateTimeSchema] },
|
|
1905
1881
|
eventInfoId: {
|
|
1906
1882
|
ref: "EventInfo",
|
|
1907
1883
|
required: false,
|
|
@@ -1924,11 +1900,6 @@ var schema17 = new MongooseSchema17(
|
|
|
1924
1900
|
nzbn: { required: true, type: String },
|
|
1925
1901
|
provider: { required: false, type: String },
|
|
1926
1902
|
rainOrShine: { required: true, type: Boolean },
|
|
1927
|
-
relations: {
|
|
1928
|
-
default: [],
|
|
1929
|
-
required: false,
|
|
1930
|
-
type: [resourceRelationsSchema]
|
|
1931
|
-
},
|
|
1932
1903
|
shareRelation: { required: false, type: socialShareResourceSchema },
|
|
1933
1904
|
tags: { required: true, type: [String] }
|
|
1934
1905
|
},
|
|
@@ -1942,16 +1913,32 @@ schema17.index({ tags: 1 });
|
|
|
1942
1913
|
schema17.index({ deletedAt: 1 });
|
|
1943
1914
|
schema17.index({ "dateTime.dateStatus": 1 });
|
|
1944
1915
|
schema17.index({ slug: 1 });
|
|
1945
|
-
schema17.index({
|
|
1946
|
-
schema17.index({ "owner.userId": 1
|
|
1916
|
+
schema17.index({ description: "text", name: "text", tags: "text" });
|
|
1917
|
+
schema17.index({ deletedAt: 1, "owner.userId": 1 });
|
|
1947
1918
|
schema17.plugin(searchNamePlugin);
|
|
1948
1919
|
var EventModel = import_mongoose21.default.models.Event || import_mongoose21.default.model("Event", schema17);
|
|
1949
1920
|
|
|
1921
|
+
// src/mongoose/event/EventDateArchive.ts
|
|
1922
|
+
var import_mongoose22 = __toESM(require("mongoose"));
|
|
1923
|
+
var schema18 = new import_mongoose22.default.Schema(
|
|
1924
|
+
{
|
|
1925
|
+
dateTime: { required: true, type: [dateTimeSchema] },
|
|
1926
|
+
eventId: {
|
|
1927
|
+
ref: "Event",
|
|
1928
|
+
required: true,
|
|
1929
|
+
type: import_mongoose22.default.Schema.Types.ObjectId
|
|
1930
|
+
}
|
|
1931
|
+
},
|
|
1932
|
+
{ timestamps: true }
|
|
1933
|
+
);
|
|
1934
|
+
schema18.index({ eventId: 1 }, { unique: true });
|
|
1935
|
+
var EventDateArchiveModel = import_mongoose22.default.models.EventDateArchive || import_mongoose22.default.model("EventDateArchive", schema18);
|
|
1936
|
+
|
|
1950
1937
|
// src/mongoose/Partner.ts
|
|
1951
1938
|
var import_cluemart_shared17 = require("@timardex/cluemart-shared");
|
|
1952
|
-
var
|
|
1953
|
-
var MongooseSchema18 =
|
|
1954
|
-
var
|
|
1939
|
+
var import_mongoose23 = __toESM(require("mongoose"));
|
|
1940
|
+
var MongooseSchema18 = import_mongoose23.default.Schema;
|
|
1941
|
+
var schema19 = new MongooseSchema18(
|
|
1955
1942
|
{
|
|
1956
1943
|
...baseResourceFields,
|
|
1957
1944
|
location: {
|
|
@@ -1967,23 +1954,23 @@ var schema18 = new MongooseSchema18(
|
|
|
1967
1954
|
},
|
|
1968
1955
|
{ timestamps: true }
|
|
1969
1956
|
);
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
var PartnerModel =
|
|
1957
|
+
schema19.index({ name: 1 });
|
|
1958
|
+
schema19.index({ description: 1 });
|
|
1959
|
+
schema19.index({ region: 1 });
|
|
1960
|
+
schema19.index({ "location.geo": "2dsphere" });
|
|
1961
|
+
schema19.index({ slug: 1 });
|
|
1962
|
+
schema19.index({ name: "text", description: "text" });
|
|
1963
|
+
schema19.index({ "owner.userId": 1, deletedAt: 1 });
|
|
1964
|
+
schema19.plugin(searchNamePlugin);
|
|
1965
|
+
var PartnerModel = import_mongoose23.default.models.Partner || import_mongoose23.default.model("Partner", schema19);
|
|
1979
1966
|
|
|
1980
1967
|
// src/mongoose/Post.ts
|
|
1981
1968
|
var import_cluemart_shared18 = require("@timardex/cluemart-shared");
|
|
1982
|
-
var
|
|
1983
|
-
var MongooseSchema19 =
|
|
1969
|
+
var import_mongoose24 = __toESM(require("mongoose"));
|
|
1970
|
+
var MongooseSchema19 = import_mongoose24.default.Schema;
|
|
1984
1971
|
var contentSchema = new MongooseSchema19(
|
|
1985
1972
|
{
|
|
1986
|
-
contentData:
|
|
1973
|
+
contentData: import_mongoose24.Schema.Types.Mixed,
|
|
1987
1974
|
contentOrder: { required: true, type: Number },
|
|
1988
1975
|
contentType: {
|
|
1989
1976
|
enum: Object.values(import_cluemart_shared18.EnumPostContentType),
|
|
@@ -2006,7 +1993,7 @@ var resourceSchema = new MongooseSchema19(
|
|
|
2006
1993
|
},
|
|
2007
1994
|
{ _id: false }
|
|
2008
1995
|
);
|
|
2009
|
-
var
|
|
1996
|
+
var schema20 = new MongooseSchema19(
|
|
2010
1997
|
{
|
|
2011
1998
|
active: { default: false, required: true, type: Boolean },
|
|
2012
1999
|
approvedAt: { default: null, required: false, type: Date },
|
|
@@ -2037,14 +2024,14 @@ var schema19 = new MongooseSchema19(
|
|
|
2037
2024
|
},
|
|
2038
2025
|
{ timestamps: true }
|
|
2039
2026
|
);
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
var PostModel =
|
|
2027
|
+
schema20.index({ title: 1 });
|
|
2028
|
+
schema20.index({ tags: 1 });
|
|
2029
|
+
schema20.index({ postType: 1, slug: 1 }, { unique: true });
|
|
2030
|
+
var PostModel = import_mongoose24.default.models.Post || import_mongoose24.default.model("Post", schema20);
|
|
2044
2031
|
|
|
2045
2032
|
// src/mongoose/AppSetting.ts
|
|
2046
|
-
var
|
|
2047
|
-
var MongooseSchema20 =
|
|
2033
|
+
var import_mongoose25 = __toESM(require("mongoose"));
|
|
2034
|
+
var MongooseSchema20 = import_mongoose25.default.Schema;
|
|
2048
2035
|
var APP_SETTINGS_ID = "APP_SETTINGS_DOCUMENT_ID";
|
|
2049
2036
|
var AppSettingSchema = new MongooseSchema20(
|
|
2050
2037
|
{
|
|
@@ -2081,18 +2068,18 @@ var AppSettingSchema = new MongooseSchema20(
|
|
|
2081
2068
|
},
|
|
2082
2069
|
{ timestamps: true }
|
|
2083
2070
|
);
|
|
2084
|
-
var AppSettingModel =
|
|
2071
|
+
var AppSettingModel = import_mongoose25.default.models.AppSetting || import_mongoose25.default.model("AppSetting", AppSettingSchema);
|
|
2085
2072
|
|
|
2086
2073
|
// src/mongoose/game/Game.ts
|
|
2087
2074
|
var import_cluemart_shared19 = require("@timardex/cluemart-shared");
|
|
2088
|
-
var
|
|
2075
|
+
var import_mongoose29 = __toESM(require("mongoose"));
|
|
2089
2076
|
|
|
2090
2077
|
// src/mongoose/game/DailyClue.ts
|
|
2091
|
-
var
|
|
2078
|
+
var import_mongoose27 = __toESM(require("mongoose"));
|
|
2092
2079
|
|
|
2093
2080
|
// src/mongoose/game/utils.ts
|
|
2094
|
-
var
|
|
2095
|
-
var MongooseSchema21 =
|
|
2081
|
+
var import_mongoose26 = __toESM(require("mongoose"));
|
|
2082
|
+
var MongooseSchema21 = import_mongoose26.default.Schema;
|
|
2096
2083
|
var schemaGameDate = new MongooseSchema21(
|
|
2097
2084
|
{
|
|
2098
2085
|
endDate: { required: true, type: Date },
|
|
@@ -2102,7 +2089,7 @@ var schemaGameDate = new MongooseSchema21(
|
|
|
2102
2089
|
);
|
|
2103
2090
|
|
|
2104
2091
|
// src/mongoose/game/DailyClue.ts
|
|
2105
|
-
var MongooseSchema22 =
|
|
2092
|
+
var MongooseSchema22 = import_mongoose27.default.Schema;
|
|
2106
2093
|
var schemaLetters = new MongooseSchema22(
|
|
2107
2094
|
{
|
|
2108
2095
|
collected: { required: false, type: [String] },
|
|
@@ -2133,8 +2120,8 @@ var schemaDailyClueGameData = new MongooseSchema22(
|
|
|
2133
2120
|
);
|
|
2134
2121
|
|
|
2135
2122
|
// src/mongoose/game/PuzzleGame.ts
|
|
2136
|
-
var
|
|
2137
|
-
var MongooseSchema23 =
|
|
2123
|
+
var import_mongoose28 = __toESM(require("mongoose"));
|
|
2124
|
+
var MongooseSchema23 = import_mongoose28.default.Schema;
|
|
2138
2125
|
var schemaPuzzleAnswer = new MongooseSchema23(
|
|
2139
2126
|
{
|
|
2140
2127
|
answer: { required: true, type: String },
|
|
@@ -2179,16 +2166,16 @@ var schemaPuzzleGameData = new MongooseSchema23(
|
|
|
2179
2166
|
);
|
|
2180
2167
|
|
|
2181
2168
|
// src/mongoose/game/Game.ts
|
|
2182
|
-
var MongooseSchema24 =
|
|
2169
|
+
var MongooseSchema24 = import_mongoose29.default.Schema;
|
|
2183
2170
|
var gameDataSchemas = {
|
|
2184
2171
|
[import_cluemart_shared19.EnumGameType.DAILY_CLUE]: schemaDailyClueGameData,
|
|
2185
2172
|
[import_cluemart_shared19.EnumGameType.MINI_QUIZ]: schemaPuzzleGameData,
|
|
2186
2173
|
[import_cluemart_shared19.EnumGameType.ODD_ONE_OUT]: schemaPuzzleGameData
|
|
2187
2174
|
};
|
|
2188
2175
|
var gameDataDefinition = Object.fromEntries(
|
|
2189
|
-
Object.entries(gameDataSchemas).map(([key,
|
|
2176
|
+
Object.entries(gameDataSchemas).map(([key, schema25]) => [
|
|
2190
2177
|
key,
|
|
2191
|
-
{ default: null, required: false, type:
|
|
2178
|
+
{ default: null, required: false, type: schema25 }
|
|
2192
2179
|
])
|
|
2193
2180
|
);
|
|
2194
2181
|
var gameHistorySchema = new MongooseSchema24(
|
|
@@ -2226,7 +2213,7 @@ var gameTypeSchema = new MongooseSchema24(
|
|
|
2226
2213
|
},
|
|
2227
2214
|
{ timestamps: true }
|
|
2228
2215
|
);
|
|
2229
|
-
var
|
|
2216
|
+
var schema21 = new MongooseSchema24(
|
|
2230
2217
|
{
|
|
2231
2218
|
active: { default: false, required: true, type: Boolean },
|
|
2232
2219
|
deletedAt: { default: null, required: false, type: Date },
|
|
@@ -2239,11 +2226,11 @@ var schema20 = new MongooseSchema24(
|
|
|
2239
2226
|
},
|
|
2240
2227
|
{ timestamps: true }
|
|
2241
2228
|
);
|
|
2242
|
-
var GameModel =
|
|
2229
|
+
var GameModel = import_mongoose29.default.models.Game || import_mongoose29.default.model("Game", schema21);
|
|
2243
2230
|
|
|
2244
2231
|
// src/mongoose/School.ts
|
|
2245
|
-
var
|
|
2246
|
-
var MongooseSchema25 =
|
|
2232
|
+
var import_mongoose30 = __toESM(require("mongoose"));
|
|
2233
|
+
var MongooseSchema25 = import_mongoose30.default.Schema;
|
|
2247
2234
|
var campaignsSchema = new MongooseSchema25(
|
|
2248
2235
|
{
|
|
2249
2236
|
endDate: { required: true, type: Date },
|
|
@@ -2252,7 +2239,7 @@ var campaignsSchema = new MongooseSchema25(
|
|
|
2252
2239
|
},
|
|
2253
2240
|
{ _id: false }
|
|
2254
2241
|
);
|
|
2255
|
-
var
|
|
2242
|
+
var schema22 = new MongooseSchema25(
|
|
2256
2243
|
{
|
|
2257
2244
|
// New schools are active by default
|
|
2258
2245
|
active: { default: false, required: true, type: Boolean },
|
|
@@ -2279,19 +2266,19 @@ var schema21 = new MongooseSchema25(
|
|
|
2279
2266
|
},
|
|
2280
2267
|
{ timestamps: true }
|
|
2281
2268
|
);
|
|
2282
|
-
|
|
2269
|
+
schema22.index(
|
|
2283
2270
|
{ schoolCode: 1 },
|
|
2284
2271
|
{
|
|
2285
2272
|
partialFilterExpression: { active: true, deletedAt: null },
|
|
2286
2273
|
unique: true
|
|
2287
2274
|
}
|
|
2288
2275
|
);
|
|
2289
|
-
var SchoolModel =
|
|
2276
|
+
var SchoolModel = import_mongoose30.default.models.School || import_mongoose30.default.model("School", schema22);
|
|
2290
2277
|
|
|
2291
2278
|
// src/mongoose/Affiliate.ts
|
|
2292
2279
|
var import_cluemart_shared20 = require("@timardex/cluemart-shared");
|
|
2293
|
-
var
|
|
2294
|
-
var MongooseSchema26 =
|
|
2280
|
+
var import_mongoose31 = __toESM(require("mongoose"));
|
|
2281
|
+
var MongooseSchema26 = import_mongoose31.default.Schema;
|
|
2295
2282
|
var affiliateRewardSchema = new MongooseSchema26(
|
|
2296
2283
|
{
|
|
2297
2284
|
createdAt: { required: true, type: Date },
|
|
@@ -2312,7 +2299,7 @@ var affiliateResourceSchema = new MongooseSchema26(
|
|
|
2312
2299
|
resourceDeletedAt: { default: null, required: false, type: Date },
|
|
2313
2300
|
resourceId: {
|
|
2314
2301
|
required: true,
|
|
2315
|
-
type:
|
|
2302
|
+
type: import_mongoose31.default.Schema.Types.ObjectId
|
|
2316
2303
|
},
|
|
2317
2304
|
resourceName: { required: true, type: String },
|
|
2318
2305
|
resourceOwner: {
|
|
@@ -2375,7 +2362,7 @@ var redeemHistorySchema = new MongooseSchema26(
|
|
|
2375
2362
|
},
|
|
2376
2363
|
{ _id: false }
|
|
2377
2364
|
);
|
|
2378
|
-
var
|
|
2365
|
+
var schema23 = new MongooseSchema26(
|
|
2379
2366
|
{
|
|
2380
2367
|
active: { default: false, required: true, type: Boolean },
|
|
2381
2368
|
affiliateBonusRewards: {
|
|
@@ -2405,19 +2392,19 @@ var schema22 = new MongooseSchema26(
|
|
|
2405
2392
|
},
|
|
2406
2393
|
{ timestamps: true }
|
|
2407
2394
|
);
|
|
2408
|
-
|
|
2395
|
+
schema23.index(
|
|
2409
2396
|
{ affiliateCode: 1 },
|
|
2410
2397
|
{
|
|
2411
2398
|
partialFilterExpression: { active: true, deletedAt: null },
|
|
2412
2399
|
unique: true
|
|
2413
2400
|
}
|
|
2414
2401
|
);
|
|
2415
|
-
var AffiliateModel =
|
|
2402
|
+
var AffiliateModel = import_mongoose31.default.models.Affiliate || import_mongoose31.default.model("Affiliate", schema23);
|
|
2416
2403
|
|
|
2417
2404
|
// src/mongoose/Coupon.ts
|
|
2418
2405
|
var import_cluemart_shared21 = require("@timardex/cluemart-shared");
|
|
2419
|
-
var
|
|
2420
|
-
var MongooseSchema27 =
|
|
2406
|
+
var import_mongoose32 = __toESM(require("mongoose"));
|
|
2407
|
+
var MongooseSchema27 = import_mongoose32.default.Schema;
|
|
2421
2408
|
var couponOptionSchema = new MongooseSchema27(
|
|
2422
2409
|
{
|
|
2423
2410
|
buy: { required: false, type: Number },
|
|
@@ -2437,20 +2424,20 @@ var couponVendorProductSchema = new MongooseSchema27(
|
|
|
2437
2424
|
{
|
|
2438
2425
|
couponId: {
|
|
2439
2426
|
required: true,
|
|
2440
|
-
type:
|
|
2427
|
+
type: import_mongoose32.default.Schema.Types.ObjectId
|
|
2441
2428
|
},
|
|
2442
2429
|
productId: {
|
|
2443
2430
|
required: true,
|
|
2444
|
-
type:
|
|
2431
|
+
type: import_mongoose32.default.Schema.Types.ObjectId
|
|
2445
2432
|
},
|
|
2446
2433
|
vendorCouponId: {
|
|
2447
2434
|
required: false,
|
|
2448
|
-
type:
|
|
2435
|
+
type: import_mongoose32.default.Schema.Types.ObjectId
|
|
2449
2436
|
},
|
|
2450
2437
|
vendorId: {
|
|
2451
2438
|
ref: "Vendor",
|
|
2452
2439
|
required: true,
|
|
2453
|
-
type:
|
|
2440
|
+
type: import_mongoose32.default.Schema.Types.ObjectId
|
|
2454
2441
|
}
|
|
2455
2442
|
},
|
|
2456
2443
|
{ _id: false }
|
|
@@ -2472,7 +2459,7 @@ var couponParticipantUserSchema = new MongooseSchema27(
|
|
|
2472
2459
|
userId: {
|
|
2473
2460
|
ref: "User",
|
|
2474
2461
|
required: true,
|
|
2475
|
-
type:
|
|
2462
|
+
type: import_mongoose32.default.Schema.Types.ObjectId
|
|
2476
2463
|
}
|
|
2477
2464
|
},
|
|
2478
2465
|
{ timestamps: true }
|
|
@@ -2504,7 +2491,7 @@ var couponDataSchema = new MongooseSchema27(
|
|
|
2504
2491
|
},
|
|
2505
2492
|
{ timestamps: true }
|
|
2506
2493
|
);
|
|
2507
|
-
var
|
|
2494
|
+
var schema24 = new MongooseSchema27(
|
|
2508
2495
|
{
|
|
2509
2496
|
active: { default: true, required: true, type: Boolean },
|
|
2510
2497
|
couponData: { default: [], required: false, type: [couponDataSchema] },
|
|
@@ -2516,9 +2503,9 @@ var schema23 = new MongooseSchema27(
|
|
|
2516
2503
|
},
|
|
2517
2504
|
{ timestamps: true }
|
|
2518
2505
|
);
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
var CouponModel =
|
|
2506
|
+
schema24.index({ active: 1, deletedAt: 1, "owner.userId": 1 });
|
|
2507
|
+
schema24.index({ "couponData.participantUsers.userId": 1 });
|
|
2508
|
+
var CouponModel = import_mongoose32.default.models.Coupon || import_mongoose32.default.model("Coupon", schema24);
|
|
2522
2509
|
|
|
2523
2510
|
// src/service/promoCode/constants.ts
|
|
2524
2511
|
var ACTIVE_NOT_DELETED_FILTER = {
|
|
@@ -2947,7 +2934,7 @@ function normalizeAffiliatePromoCodes(promoCodes) {
|
|
|
2947
2934
|
}
|
|
2948
2935
|
|
|
2949
2936
|
// src/service/database.ts
|
|
2950
|
-
var
|
|
2937
|
+
var import_mongoose36 = __toESM(require("mongoose"));
|
|
2951
2938
|
var connectToDatabase = async ({
|
|
2952
2939
|
appName,
|
|
2953
2940
|
dbName,
|
|
@@ -2960,7 +2947,7 @@ var connectToDatabase = async ({
|
|
|
2960
2947
|
// Fallback to MongoDB Atlas connection string
|
|
2961
2948
|
`mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
|
|
2962
2949
|
);
|
|
2963
|
-
await
|
|
2950
|
+
await import_mongoose36.default.connect(mongoUri);
|
|
2964
2951
|
const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
|
|
2965
2952
|
console.log(
|
|
2966
2953
|
`${connectionType} connected from server/src/service/database.ts`
|
|
@@ -2973,7 +2960,7 @@ var connectToDatabase = async ({
|
|
|
2973
2960
|
|
|
2974
2961
|
// src/types/index.ts
|
|
2975
2962
|
var import_express = __toESM(require("express"));
|
|
2976
|
-
var
|
|
2963
|
+
var import_mongoose37 = __toESM(require("mongoose"));
|
|
2977
2964
|
|
|
2978
2965
|
// src/service/notifyUsers.ts
|
|
2979
2966
|
async function publishNotificationEvents(userId, pubsub) {
|
|
@@ -3082,15 +3069,15 @@ async function updateAdStatuses() {
|
|
|
3082
3069
|
}
|
|
3083
3070
|
|
|
3084
3071
|
// src/service/objectIdToString.ts
|
|
3085
|
-
var
|
|
3072
|
+
var import_mongoose39 = __toESM(require("mongoose"));
|
|
3086
3073
|
function isValidObjectId(value) {
|
|
3087
|
-
return
|
|
3074
|
+
return import_mongoose39.default.Types.ObjectId.isValid(value);
|
|
3088
3075
|
}
|
|
3089
3076
|
function convertObjectIdsToStrings(obj) {
|
|
3090
3077
|
if (obj === null || obj === void 0) {
|
|
3091
3078
|
return obj;
|
|
3092
3079
|
}
|
|
3093
|
-
if (obj instanceof
|
|
3080
|
+
if (obj instanceof import_mongoose39.default.Types.ObjectId) {
|
|
3094
3081
|
return obj.toString();
|
|
3095
3082
|
}
|
|
3096
3083
|
if (obj instanceof Date) {
|
|
@@ -3110,33 +3097,82 @@ function convertObjectIdsToStrings(obj) {
|
|
|
3110
3097
|
}
|
|
3111
3098
|
|
|
3112
3099
|
// src/service/event/updateAllEventDateTimeStatuses.ts
|
|
3113
|
-
var
|
|
3100
|
+
var import_cluemart_shared26 = require("@timardex/cluemart-shared");
|
|
3114
3101
|
var import_dayjs2 = __toESM(require("dayjs"));
|
|
3115
3102
|
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
3116
3103
|
var import_isoWeek = __toESM(require("dayjs/plugin/isoWeek"));
|
|
3104
|
+
|
|
3105
|
+
// src/service/event/archiveEndedEventDates.ts
|
|
3106
|
+
var import_cluemart_shared25 = require("@timardex/cluemart-shared");
|
|
3107
|
+
var ARCHIVED_STATUSES = /* @__PURE__ */ new Set([
|
|
3108
|
+
import_cluemart_shared25.EnumEventDateStatus.ENDED
|
|
3109
|
+
]);
|
|
3110
|
+
var DISCARDED_STATUSES = /* @__PURE__ */ new Set([
|
|
3111
|
+
import_cluemart_shared25.EnumEventDateStatus.INVALID
|
|
3112
|
+
]);
|
|
3113
|
+
function splitEventDatesForArchive(dateTime) {
|
|
3114
|
+
return {
|
|
3115
|
+
archive: dateTime.filter((slot) => ARCHIVED_STATUSES.has(slot.dateStatus)),
|
|
3116
|
+
discard: dateTime.filter((slot) => DISCARDED_STATUSES.has(slot.dateStatus)),
|
|
3117
|
+
keep: dateTime.filter(
|
|
3118
|
+
(slot) => !ARCHIVED_STATUSES.has(slot.dateStatus) && !DISCARDED_STATUSES.has(slot.dateStatus)
|
|
3119
|
+
)
|
|
3120
|
+
};
|
|
3121
|
+
}
|
|
3122
|
+
function dedupeArchivedSlotsByStartDateTime(slots) {
|
|
3123
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3124
|
+
return slots.filter((slot) => {
|
|
3125
|
+
const key = `${slot.startDate}_${slot.startTime}`;
|
|
3126
|
+
if (seen.has(key)) {
|
|
3127
|
+
return false;
|
|
3128
|
+
}
|
|
3129
|
+
seen.add(key);
|
|
3130
|
+
return true;
|
|
3131
|
+
});
|
|
3132
|
+
}
|
|
3133
|
+
async function persistArchivedEventDates(eventId, slots) {
|
|
3134
|
+
if (slots.length === 0) {
|
|
3135
|
+
return;
|
|
3136
|
+
}
|
|
3137
|
+
const uniqueSlots = dedupeArchivedSlotsByStartDateTime(slots);
|
|
3138
|
+
await EventDateArchiveModel.updateOne(
|
|
3139
|
+
{ eventId },
|
|
3140
|
+
{ $addToSet: { dateTime: { $each: uniqueSlots } } },
|
|
3141
|
+
{ upsert: true }
|
|
3142
|
+
);
|
|
3143
|
+
}
|
|
3144
|
+
|
|
3145
|
+
// src/service/event/updateAllEventDateTimeStatuses.ts
|
|
3117
3146
|
import_dayjs2.default.extend(import_customParseFormat.default);
|
|
3118
3147
|
import_dayjs2.default.extend(import_isoWeek.default);
|
|
3148
|
+
var MANUAL_DATE_STATUSES = /* @__PURE__ */ new Set([
|
|
3149
|
+
import_cluemart_shared26.EnumEventDateStatus.CANCELED,
|
|
3150
|
+
import_cluemart_shared26.EnumEventDateStatus.RE_SCHEDULED
|
|
3151
|
+
]);
|
|
3119
3152
|
function getFutureEventStatus(startDateTime, now) {
|
|
3120
3153
|
const hoursUntilStart = startDateTime.diff(now, "hour", true);
|
|
3121
3154
|
if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
|
|
3122
|
-
return
|
|
3155
|
+
return import_cluemart_shared26.EnumEventDateStatus.STARTING_SOON;
|
|
3123
3156
|
}
|
|
3124
3157
|
if (startDateTime.isSame(now, "day")) {
|
|
3125
|
-
return
|
|
3158
|
+
return import_cluemart_shared26.EnumEventDateStatus.TODAY;
|
|
3126
3159
|
}
|
|
3127
3160
|
if (startDateTime.isSame(now.add(1, "day"), "day")) {
|
|
3128
|
-
return
|
|
3161
|
+
return import_cluemart_shared26.EnumEventDateStatus.TOMORROW;
|
|
3129
3162
|
}
|
|
3130
3163
|
if (startDateTime.isSame(now, "isoWeek")) {
|
|
3131
|
-
return
|
|
3164
|
+
return import_cluemart_shared26.EnumEventDateStatus.THIS_WEEK;
|
|
3132
3165
|
}
|
|
3133
3166
|
if (startDateTime.isSame(now.add(1, "week"), "isoWeek")) {
|
|
3134
|
-
return
|
|
3167
|
+
return import_cluemart_shared26.EnumEventDateStatus.NEXT_WEEK;
|
|
3135
3168
|
}
|
|
3136
|
-
return
|
|
3169
|
+
return import_cluemart_shared26.EnumEventDateStatus.UPCOMING;
|
|
3137
3170
|
}
|
|
3138
3171
|
function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()) {
|
|
3139
|
-
|
|
3172
|
+
if (MANUAL_DATE_STATUSES.has(dateTime.dateStatus)) {
|
|
3173
|
+
return dateTime;
|
|
3174
|
+
}
|
|
3175
|
+
const dateTimeFormat = `${import_cluemart_shared26.dateFormat} ${import_cluemart_shared26.timeFormat}`;
|
|
3140
3176
|
const startDateTime = (0, import_dayjs2.default)(
|
|
3141
3177
|
`${dateTime.startDate} ${dateTime.startTime}`,
|
|
3142
3178
|
dateTimeFormat,
|
|
@@ -3150,13 +3186,13 @@ function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()
|
|
|
3150
3186
|
if (!startDateTime.isValid() || !endDateTime.isValid()) {
|
|
3151
3187
|
return {
|
|
3152
3188
|
...dateTime,
|
|
3153
|
-
dateStatus:
|
|
3189
|
+
dateStatus: import_cluemart_shared26.EnumEventDateStatus.INVALID
|
|
3154
3190
|
};
|
|
3155
3191
|
}
|
|
3156
3192
|
if (endDateTime.isBefore(startDateTime)) {
|
|
3157
3193
|
return {
|
|
3158
3194
|
...dateTime,
|
|
3159
|
-
dateStatus:
|
|
3195
|
+
dateStatus: import_cluemart_shared26.EnumEventDateStatus.INVALID
|
|
3160
3196
|
};
|
|
3161
3197
|
}
|
|
3162
3198
|
let dateStatus;
|
|
@@ -3164,10 +3200,10 @@ function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()
|
|
|
3164
3200
|
if (startDateTime.isAfter(now)) {
|
|
3165
3201
|
dateStatus = getFutureEventStatus(startDateTime, now);
|
|
3166
3202
|
} else {
|
|
3167
|
-
dateStatus =
|
|
3203
|
+
dateStatus = import_cluemart_shared26.EnumEventDateStatus.STARTED;
|
|
3168
3204
|
}
|
|
3169
3205
|
} else {
|
|
3170
|
-
dateStatus =
|
|
3206
|
+
dateStatus = import_cluemart_shared26.EnumEventDateStatus.ENDED;
|
|
3171
3207
|
}
|
|
3172
3208
|
return {
|
|
3173
3209
|
...dateTime,
|
|
@@ -3223,6 +3259,111 @@ async function updateModelDateTimeStatuses(model, now) {
|
|
|
3223
3259
|
}
|
|
3224
3260
|
return updated;
|
|
3225
3261
|
}
|
|
3262
|
+
var ARCHIVABLE_EVENT_FILTER = {
|
|
3263
|
+
"dateTime.dateStatus": {
|
|
3264
|
+
$in: [import_cluemart_shared26.EnumEventDateStatus.ENDED, import_cluemart_shared26.EnumEventDateStatus.INVALID]
|
|
3265
|
+
},
|
|
3266
|
+
deletedAt: null
|
|
3267
|
+
};
|
|
3268
|
+
async function archiveEndedAndDiscardInvalidEventDates(now) {
|
|
3269
|
+
const cursor = EventModel.find(ARCHIVABLE_EVENT_FILTER).select({ _id: 1, dateTime: 1 }).lean().cursor({ batchSize: CURSOR_BATCH_SIZE });
|
|
3270
|
+
let archivedCount = 0;
|
|
3271
|
+
let archiveOps = [];
|
|
3272
|
+
let eventOps = [];
|
|
3273
|
+
const flushBulkWrites = async () => {
|
|
3274
|
+
if (archiveOps.length) {
|
|
3275
|
+
await EventDateArchiveModel.bulkWrite(archiveOps);
|
|
3276
|
+
archiveOps = [];
|
|
3277
|
+
}
|
|
3278
|
+
if (eventOps.length) {
|
|
3279
|
+
await EventModel.bulkWrite(eventOps);
|
|
3280
|
+
eventOps = [];
|
|
3281
|
+
}
|
|
3282
|
+
};
|
|
3283
|
+
try {
|
|
3284
|
+
for await (const doc of cursor) {
|
|
3285
|
+
const updated = doc.dateTime.map(
|
|
3286
|
+
(slot) => updateSingleDateTimeStatus(slot, now)
|
|
3287
|
+
);
|
|
3288
|
+
const { archive, discard } = splitEventDatesForArchive(updated);
|
|
3289
|
+
if (archive.length === 0 && discard.length === 0) {
|
|
3290
|
+
continue;
|
|
3291
|
+
}
|
|
3292
|
+
if (archive.length > 0) {
|
|
3293
|
+
const uniqueArchive = dedupeArchivedSlotsByStartDateTime(archive);
|
|
3294
|
+
archiveOps.push({
|
|
3295
|
+
updateOne: {
|
|
3296
|
+
filter: { eventId: doc._id },
|
|
3297
|
+
update: { $addToSet: { dateTime: { $each: uniqueArchive } } },
|
|
3298
|
+
upsert: true
|
|
3299
|
+
}
|
|
3300
|
+
});
|
|
3301
|
+
archivedCount += uniqueArchive.length;
|
|
3302
|
+
}
|
|
3303
|
+
eventOps.push({
|
|
3304
|
+
updateOne: {
|
|
3305
|
+
filter: { _id: doc._id },
|
|
3306
|
+
update: {
|
|
3307
|
+
$pull: {
|
|
3308
|
+
dateTime: {
|
|
3309
|
+
dateStatus: {
|
|
3310
|
+
$in: [import_cluemart_shared26.EnumEventDateStatus.ENDED, import_cluemart_shared26.EnumEventDateStatus.INVALID]
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
});
|
|
3317
|
+
if (archiveOps.length >= CURSOR_BATCH_SIZE || eventOps.length >= CURSOR_BATCH_SIZE) {
|
|
3318
|
+
await flushBulkWrites();
|
|
3319
|
+
}
|
|
3320
|
+
}
|
|
3321
|
+
await flushBulkWrites();
|
|
3322
|
+
} finally {
|
|
3323
|
+
await cursor.close().catch(() => void 0);
|
|
3324
|
+
}
|
|
3325
|
+
return archivedCount;
|
|
3326
|
+
}
|
|
3327
|
+
var EVENT_INFO_DATE_FILTER = {
|
|
3328
|
+
dateTime: { $ne: [], $type: "array" }
|
|
3329
|
+
};
|
|
3330
|
+
async function cleanEventInfoDates(now) {
|
|
3331
|
+
const cursor = EventInfoModel.find(EVENT_INFO_DATE_FILTER).select({ _id: 1, dateTime: 1 }).lean().cursor({ batchSize: CURSOR_BATCH_SIZE });
|
|
3332
|
+
let removedCount = 0;
|
|
3333
|
+
let bulkOps = [];
|
|
3334
|
+
const flushBulkWrites = async () => {
|
|
3335
|
+
if (!bulkOps.length) {
|
|
3336
|
+
return;
|
|
3337
|
+
}
|
|
3338
|
+
await EventInfoModel.bulkWrite(bulkOps);
|
|
3339
|
+
bulkOps = [];
|
|
3340
|
+
};
|
|
3341
|
+
try {
|
|
3342
|
+
for await (const doc of cursor) {
|
|
3343
|
+
const updated = doc.dateTime.map(
|
|
3344
|
+
(slot) => updateSingleDateTimeStatus(slot, now)
|
|
3345
|
+
);
|
|
3346
|
+
const kept = (0, import_cluemart_shared26.filterDatesByFutureStatus)(updated);
|
|
3347
|
+
if (kept.length === updated.length) {
|
|
3348
|
+
continue;
|
|
3349
|
+
}
|
|
3350
|
+
bulkOps.push({
|
|
3351
|
+
updateOne: {
|
|
3352
|
+
filter: { _id: doc._id },
|
|
3353
|
+
update: { $set: { dateTime: kept } }
|
|
3354
|
+
}
|
|
3355
|
+
});
|
|
3356
|
+
removedCount += updated.length - kept.length;
|
|
3357
|
+
if (bulkOps.length >= CURSOR_BATCH_SIZE) {
|
|
3358
|
+
await flushBulkWrites();
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3361
|
+
await flushBulkWrites();
|
|
3362
|
+
} finally {
|
|
3363
|
+
await cursor.close().catch(() => void 0);
|
|
3364
|
+
}
|
|
3365
|
+
return removedCount;
|
|
3366
|
+
}
|
|
3226
3367
|
async function updateAllEventDateTimeStatuses() {
|
|
3227
3368
|
const now = (0, import_dayjs2.default)();
|
|
3228
3369
|
const [eventCount, marketCount] = await Promise.all([
|
|
@@ -3235,6 +3376,16 @@ async function updateAllEventDateTimeStatuses() {
|
|
|
3235
3376
|
console.log(
|
|
3236
3377
|
`\u2705 Event dateTime statuses updated: events=${eventCount} changed, google imported markets=${marketCount} changed`
|
|
3237
3378
|
);
|
|
3379
|
+
const archivedCount = await archiveEndedAndDiscardInvalidEventDates(now);
|
|
3380
|
+
if (archivedCount > 0) {
|
|
3381
|
+
console.log(`\u2705 Archived ${archivedCount} ended event date slot(s)`);
|
|
3382
|
+
}
|
|
3383
|
+
const removedEventInfoCount = await cleanEventInfoDates(now);
|
|
3384
|
+
if (removedEventInfoCount > 0) {
|
|
3385
|
+
console.log(
|
|
3386
|
+
`\u2705 Removed ${removedEventInfoCount} non-future event info date slot(s)`
|
|
3387
|
+
);
|
|
3388
|
+
}
|
|
3238
3389
|
}
|
|
3239
3390
|
|
|
3240
3391
|
// src/service/event/findEventOrImportedMarketById.ts
|
|
@@ -3251,7 +3402,7 @@ async function findEventOrImportedMarketById(resourceId) {
|
|
|
3251
3402
|
}
|
|
3252
3403
|
|
|
3253
3404
|
// src/service/relations.ts
|
|
3254
|
-
var
|
|
3405
|
+
var import_cluemart_shared27 = require("@timardex/cluemart-shared");
|
|
3255
3406
|
function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
|
|
3256
3407
|
if (!previousDateTime?.length) {
|
|
3257
3408
|
return false;
|
|
@@ -3269,7 +3420,7 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
3269
3420
|
) ?? false;
|
|
3270
3421
|
return {
|
|
3271
3422
|
...relationDate,
|
|
3272
|
-
status: existsInEvent ? relationDate.status :
|
|
3423
|
+
status: existsInEvent ? relationDate.status : import_cluemart_shared27.EnumInviteStatus.UNAVAILABLE
|
|
3273
3424
|
};
|
|
3274
3425
|
});
|
|
3275
3426
|
}
|
|
@@ -3278,15 +3429,15 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
3278
3429
|
var import_dayjs6 = __toESM(require("dayjs"));
|
|
3279
3430
|
|
|
3280
3431
|
// src/service/license/compliance/utils.ts
|
|
3281
|
-
var
|
|
3432
|
+
var import_cluemart_shared32 = require("@timardex/cluemart-shared");
|
|
3282
3433
|
var import_dayjs5 = __toESM(require("dayjs"));
|
|
3283
3434
|
|
|
3284
3435
|
// src/service/license/compliance/event.ts
|
|
3285
|
-
var
|
|
3436
|
+
var import_cluemart_shared28 = require("@timardex/cluemart-shared");
|
|
3286
3437
|
var eventLicences = [
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3438
|
+
import_cluemart_shared28.EnumUserLicence.STANDARD_EVENT,
|
|
3439
|
+
import_cluemart_shared28.EnumUserLicence.PRO_EVENT,
|
|
3440
|
+
import_cluemart_shared28.EnumUserLicence.PRO_PLUS_EVENT
|
|
3290
3441
|
];
|
|
3291
3442
|
async function handleEventLicenceCompliance(user, now) {
|
|
3292
3443
|
if (!user.licences || !user.events?.length) {
|
|
@@ -3498,9 +3649,9 @@ function buildLicenceExpiryPipeline(params) {
|
|
|
3498
3649
|
}
|
|
3499
3650
|
|
|
3500
3651
|
// src/service/license/compliance/partner.ts
|
|
3501
|
-
var
|
|
3652
|
+
var import_cluemart_shared29 = require("@timardex/cluemart-shared");
|
|
3502
3653
|
var partnerLicences = [
|
|
3503
|
-
|
|
3654
|
+
import_cluemart_shared29.EnumUserLicence.STANDARD_PARTNER
|
|
3504
3655
|
];
|
|
3505
3656
|
async function handlePartnerLicenceCompliance(user, now) {
|
|
3506
3657
|
if (!user.licences || !user.partner) {
|
|
@@ -3510,11 +3661,11 @@ async function handlePartnerLicenceCompliance(user, now) {
|
|
|
3510
3661
|
}
|
|
3511
3662
|
|
|
3512
3663
|
// src/service/license/compliance/vendor.ts
|
|
3513
|
-
var
|
|
3664
|
+
var import_cluemart_shared31 = require("@timardex/cluemart-shared");
|
|
3514
3665
|
var import_dayjs4 = __toESM(require("dayjs"));
|
|
3515
3666
|
|
|
3516
3667
|
// src/service/license/models.ts
|
|
3517
|
-
var
|
|
3668
|
+
var import_cluemart_shared30 = require("@timardex/cluemart-shared");
|
|
3518
3669
|
var import_dayjs3 = __toESM(require("dayjs"));
|
|
3519
3670
|
var import_graphql = require("graphql");
|
|
3520
3671
|
var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
|
|
@@ -3526,31 +3677,31 @@ var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
|
|
|
3526
3677
|
return LicenceCategory2;
|
|
3527
3678
|
})(LicenceCategory || {});
|
|
3528
3679
|
var licenceCategoryMapping = {
|
|
3529
|
-
[
|
|
3530
|
-
[
|
|
3531
|
-
[
|
|
3532
|
-
[
|
|
3533
|
-
[
|
|
3534
|
-
[
|
|
3535
|
-
[
|
|
3536
|
-
[
|
|
3537
|
-
[
|
|
3680
|
+
[import_cluemart_shared30.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
|
|
3681
|
+
[import_cluemart_shared30.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
|
|
3682
|
+
[import_cluemart_shared30.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
|
|
3683
|
+
[import_cluemart_shared30.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
|
|
3684
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
|
|
3685
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
|
|
3686
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
|
|
3687
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
|
|
3688
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_SCHOOL]: "school" /* SCHOOL */
|
|
3538
3689
|
};
|
|
3539
3690
|
var licencePriority = {
|
|
3540
|
-
[
|
|
3541
|
-
[
|
|
3542
|
-
[
|
|
3543
|
-
[
|
|
3544
|
-
[
|
|
3545
|
-
[
|
|
3546
|
-
[
|
|
3547
|
-
[
|
|
3548
|
-
[
|
|
3691
|
+
[import_cluemart_shared30.EnumUserLicence.PRO_PLUS_EVENT]: 3,
|
|
3692
|
+
[import_cluemart_shared30.EnumUserLicence.PRO_EVENT]: 2,
|
|
3693
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_EVENT]: 1,
|
|
3694
|
+
[import_cluemart_shared30.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
|
|
3695
|
+
[import_cluemart_shared30.EnumUserLicence.PRO_VENDOR]: 2,
|
|
3696
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR]: 1,
|
|
3697
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_PARTNER]: 1,
|
|
3698
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_AFFILIATE]: 1,
|
|
3699
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_SCHOOL]: 1
|
|
3549
3700
|
};
|
|
3550
3701
|
var standardLicences = [
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3702
|
+
import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR,
|
|
3703
|
+
import_cluemart_shared30.EnumUserLicence.STANDARD_EVENT,
|
|
3704
|
+
import_cluemart_shared30.EnumUserLicence.STANDARD_PARTNER
|
|
3554
3705
|
];
|
|
3555
3706
|
var standardLicenceSet = new Set(standardLicences);
|
|
3556
3707
|
function isStandardLicence(licence) {
|
|
@@ -3564,11 +3715,11 @@ var categoryRegexMapping = {
|
|
|
3564
3715
|
["school" /* SCHOOL */]: /_school$/
|
|
3565
3716
|
};
|
|
3566
3717
|
var categoryFallbackLicence = {
|
|
3567
|
-
["event" /* EVENT */]:
|
|
3568
|
-
["partner" /* PARTNER */]:
|
|
3569
|
-
["vendor" /* VENDOR */]:
|
|
3570
|
-
["affiliate" /* AFFILIATE */]:
|
|
3571
|
-
["school" /* SCHOOL */]:
|
|
3718
|
+
["event" /* EVENT */]: import_cluemart_shared30.EnumUserLicence.STANDARD_EVENT,
|
|
3719
|
+
["partner" /* PARTNER */]: import_cluemart_shared30.EnumUserLicence.STANDARD_PARTNER,
|
|
3720
|
+
["vendor" /* VENDOR */]: import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR,
|
|
3721
|
+
["affiliate" /* AFFILIATE */]: import_cluemart_shared30.EnumUserLicence.STANDARD_AFFILIATE,
|
|
3722
|
+
["school" /* SCHOOL */]: import_cluemart_shared30.EnumUserLicence.STANDARD_SCHOOL
|
|
3572
3723
|
};
|
|
3573
3724
|
var LicenceFilterInput = {
|
|
3574
3725
|
INPUT_USER_LICENCES: "$licences"
|
|
@@ -3598,11 +3749,11 @@ function getHighestLicenceForCategory(licences, category) {
|
|
|
3598
3749
|
function createLicenceObject(expiryDate, licenceType) {
|
|
3599
3750
|
const today = (0, import_dayjs3.default)();
|
|
3600
3751
|
const expiryDateMapping = {
|
|
3601
|
-
[
|
|
3602
|
-
[
|
|
3603
|
-
[
|
|
3604
|
-
[
|
|
3605
|
-
[
|
|
3752
|
+
[import_cluemart_shared30.LicenceExpiryDate.ONE_YEAR]: today.add(1, "year").endOf("day").toDate(),
|
|
3753
|
+
[import_cluemart_shared30.LicenceExpiryDate.ONE_MONTH]: today.add(1, "month").endOf("day").toDate(),
|
|
3754
|
+
[import_cluemart_shared30.LicenceExpiryDate.TWO_MONTHS]: today.add(2, "month").endOf("day").toDate(),
|
|
3755
|
+
[import_cluemart_shared30.LicenceExpiryDate.THREE_MONTHS]: today.add(3, "month").endOf("day").toDate(),
|
|
3756
|
+
[import_cluemart_shared30.LicenceExpiryDate.SIX_MONTHS]: today.add(6, "month").endOf("day").toDate()
|
|
3606
3757
|
};
|
|
3607
3758
|
const licenceObject = {
|
|
3608
3759
|
expiryDate: expiryDateMapping[expiryDate],
|
|
@@ -3706,13 +3857,13 @@ async function checkOwnerHasLicence({
|
|
|
3706
3857
|
const owner = await UserModel.findById(userId);
|
|
3707
3858
|
if (!owner) throw new import_graphql.GraphQLError("Owner not found");
|
|
3708
3859
|
const categoryByResource = {
|
|
3709
|
-
[
|
|
3710
|
-
[
|
|
3711
|
-
[
|
|
3712
|
-
[
|
|
3713
|
-
[
|
|
3860
|
+
[import_cluemart_shared30.EnumResourceType.EVENT]: "event" /* EVENT */,
|
|
3861
|
+
[import_cluemart_shared30.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
|
|
3862
|
+
[import_cluemart_shared30.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
|
|
3863
|
+
[import_cluemart_shared30.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
|
|
3864
|
+
[import_cluemart_shared30.EnumResourceType.SCHOOL]: "school" /* SCHOOL */
|
|
3714
3865
|
};
|
|
3715
|
-
if (!(0,
|
|
3866
|
+
if (!(0, import_cluemart_shared30.isNonVisitorResourceType)(resourceType)) {
|
|
3716
3867
|
throw new import_graphql.GraphQLError(`Invalid resource type: ${resourceType}.`);
|
|
3717
3868
|
}
|
|
3718
3869
|
const requiredCategory = categoryByResource[resourceType];
|
|
@@ -3792,7 +3943,7 @@ async function applyVendorDowngrade(vendor, ownerUserId) {
|
|
|
3792
3943
|
return (result?.matchedCount ?? 0) > 0;
|
|
3793
3944
|
}
|
|
3794
3945
|
async function downgradeVendorProFeatures(userId, licenceType) {
|
|
3795
|
-
const isStandardVendor = licenceType ===
|
|
3946
|
+
const isStandardVendor = licenceType === import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR;
|
|
3796
3947
|
if (!isStandardVendor) {
|
|
3797
3948
|
return;
|
|
3798
3949
|
}
|
|
@@ -3839,7 +3990,7 @@ async function applyVendorRestore(vendor, ownerUserId) {
|
|
|
3839
3990
|
return (result?.matchedCount ?? 0) > 0;
|
|
3840
3991
|
}
|
|
3841
3992
|
async function restoreVendorProFeatures(userId, licenceType) {
|
|
3842
|
-
const isProVendor = licenceType ===
|
|
3993
|
+
const isProVendor = licenceType === import_cluemart_shared31.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared31.EnumUserLicence.PRO_PLUS_VENDOR;
|
|
3843
3994
|
if (!isProVendor) {
|
|
3844
3995
|
return;
|
|
3845
3996
|
}
|
|
@@ -3860,14 +4011,14 @@ function isProtectedByCurrentStripeSubscription(user, licenceType, now) {
|
|
|
3860
4011
|
return false;
|
|
3861
4012
|
}
|
|
3862
4013
|
const gracePeriodEndsAt = stripe.paymentGracePeriodEndsAt ? (0, import_dayjs4.default)(stripe.paymentGracePeriodEndsAt) : null;
|
|
3863
|
-
const hasActivePaymentGracePeriod = (stripe.status ===
|
|
4014
|
+
const hasActivePaymentGracePeriod = (stripe.status === import_cluemart_shared31.EnumSubscriptionStatus.PAST_DUE || stripe.status === import_cluemart_shared31.EnumSubscriptionStatus.INACTIVE) && Boolean(stripe.paymentGraceSubscriptionId) && (!stripe.subscriptionId || stripe.subscriptionId === stripe.paymentGraceSubscriptionId) && gracePeriodEndsAt !== null && gracePeriodEndsAt.isValid() && gracePeriodEndsAt.isAfter(now);
|
|
3864
4015
|
if (hasActivePaymentGracePeriod) {
|
|
3865
4016
|
return true;
|
|
3866
4017
|
}
|
|
3867
4018
|
if (!stripe.subscriptionId) {
|
|
3868
4019
|
return false;
|
|
3869
4020
|
}
|
|
3870
|
-
if (stripe.status !==
|
|
4021
|
+
if (stripe.status !== import_cluemart_shared31.EnumSubscriptionStatus.ACTIVE) {
|
|
3871
4022
|
return false;
|
|
3872
4023
|
}
|
|
3873
4024
|
if (!stripe.endDate) {
|
|
@@ -3887,7 +4038,7 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
3887
4038
|
return;
|
|
3888
4039
|
}
|
|
3889
4040
|
const proLicences = vendorLicencesOfUser.filter(
|
|
3890
|
-
(licence) => licence.licenceType !==
|
|
4041
|
+
(licence) => licence.licenceType !== import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR
|
|
3891
4042
|
);
|
|
3892
4043
|
const expiredProLicences = proLicences.filter(
|
|
3893
4044
|
(licence) => !(0, import_dayjs4.default)(licence.expiryDate).isAfter(now)
|
|
@@ -3900,7 +4051,7 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
3900
4051
|
const expiredProLicence = expiredProLicences.some(
|
|
3901
4052
|
(licence) => !stripeProtectedLicenceTypes.has(licence.licenceType)
|
|
3902
4053
|
);
|
|
3903
|
-
const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences,
|
|
4054
|
+
const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences, import_cluemart_shared31.vendorLicences, now);
|
|
3904
4055
|
const hasExpiredVendorLicence = vendorLicencesOfUser.some(
|
|
3905
4056
|
(licence) => !(0, import_dayjs4.default)(licence.expiryDate).isAfter(now) && !stripeProtectedLicenceTypes.has(licence.licenceType)
|
|
3906
4057
|
);
|
|
@@ -3916,7 +4067,7 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
3916
4067
|
"owner.userId": user._id
|
|
3917
4068
|
}).lean().exec();
|
|
3918
4069
|
}
|
|
3919
|
-
const licencesToSync =
|
|
4070
|
+
const licencesToSync = import_cluemart_shared31.vendorLicences.filter(
|
|
3920
4071
|
(licenceType) => !stripeProtectedLicenceTypes.has(licenceType)
|
|
3921
4072
|
);
|
|
3922
4073
|
await syncUserLicencesAfterExpiry(user._id, licencesToSync, now, "downgrade");
|
|
@@ -3931,11 +4082,11 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
3931
4082
|
data: {
|
|
3932
4083
|
resourceId: String(vendor._id),
|
|
3933
4084
|
resourceName: vendor.name,
|
|
3934
|
-
resourceType:
|
|
4085
|
+
resourceType: import_cluemart_shared31.EnumNotificationResourceType.DOWNGRADED_VENDOR
|
|
3935
4086
|
},
|
|
3936
4087
|
message: `Your Vendor licence has been downgraded due to licence expiration.`,
|
|
3937
4088
|
title: `Vendor Licence Downgraded`,
|
|
3938
|
-
type:
|
|
4089
|
+
type: import_cluemart_shared31.EnumNotificationType.SYSTEM,
|
|
3939
4090
|
userIds: [user._id]
|
|
3940
4091
|
};
|
|
3941
4092
|
await sendDeactivationNotification(payload, user._id, vendor.name, "vendor");
|
|
@@ -3968,7 +4119,7 @@ async function vendorOwnerHasProLicence(vendorId) {
|
|
|
3968
4119
|
effectiveVendorLicences,
|
|
3969
4120
|
"vendor" /* VENDOR */
|
|
3970
4121
|
);
|
|
3971
|
-
return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[
|
|
4122
|
+
return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[import_cluemart_shared31.EnumUserLicence.PRO_VENDOR];
|
|
3972
4123
|
}
|
|
3973
4124
|
|
|
3974
4125
|
// src/service/license/compliance/utils.ts
|
|
@@ -3978,12 +4129,12 @@ async function syncUserLicencesAfterExpiry(userId, licenceTypes, now, mode = "do
|
|
|
3978
4129
|
const pipeline = buildLicenceExpiryPipeline({
|
|
3979
4130
|
downgradeBranches: [
|
|
3980
4131
|
{
|
|
3981
|
-
case:
|
|
3982
|
-
then:
|
|
4132
|
+
case: import_cluemart_shared32.EnumUserLicence.PRO_PLUS_VENDOR,
|
|
4133
|
+
then: import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR
|
|
3983
4134
|
},
|
|
3984
4135
|
{
|
|
3985
|
-
case:
|
|
3986
|
-
then:
|
|
4136
|
+
case: import_cluemart_shared32.EnumUserLicence.PRO_VENDOR,
|
|
4137
|
+
then: import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR
|
|
3987
4138
|
}
|
|
3988
4139
|
],
|
|
3989
4140
|
licenceTypes,
|
|
@@ -4112,7 +4263,7 @@ var REMINDER_WINDOW_MIN_HOURS = 6.5 * 24;
|
|
|
4112
4263
|
var REMINDER_WINDOW_MAX_HOURS = 7.5 * 24;
|
|
4113
4264
|
|
|
4114
4265
|
// src/service/license/reminder/utils.ts
|
|
4115
|
-
var
|
|
4266
|
+
var import_cluemart_shared33 = require("@timardex/cluemart-shared");
|
|
4116
4267
|
var import_utils8 = require("@timardex/cluemart-shared/utils");
|
|
4117
4268
|
var import_dayjs7 = __toESM(require("dayjs"));
|
|
4118
4269
|
|
|
@@ -4178,28 +4329,28 @@ function isLicenseExpiringIn7Days(expiryDate, now) {
|
|
|
4178
4329
|
return hoursUntilExpiry >= REMINDER_WINDOW_MIN_HOURS && hoursUntilExpiry <= REMINDER_WINDOW_MAX_HOURS;
|
|
4179
4330
|
}
|
|
4180
4331
|
function getLicenseName(licenceType) {
|
|
4181
|
-
return
|
|
4332
|
+
return import_cluemart_shared33.licenseNiceNames[licenceType] || licenceType;
|
|
4182
4333
|
}
|
|
4183
4334
|
function getNotificationTypes(isVendorLicense, isPartnerLicense) {
|
|
4184
4335
|
if (isVendorLicense) {
|
|
4185
4336
|
return {
|
|
4186
|
-
notificationType:
|
|
4187
|
-
resourceType:
|
|
4337
|
+
notificationType: import_cluemart_shared33.EnumNotificationType.SYSTEM,
|
|
4338
|
+
resourceType: import_cluemart_shared33.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
|
|
4188
4339
|
};
|
|
4189
4340
|
}
|
|
4190
4341
|
if (isPartnerLicense) {
|
|
4191
4342
|
return {
|
|
4192
|
-
notificationType:
|
|
4193
|
-
resourceType:
|
|
4343
|
+
notificationType: import_cluemart_shared33.EnumNotificationType.SYSTEM,
|
|
4344
|
+
resourceType: import_cluemart_shared33.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
|
|
4194
4345
|
};
|
|
4195
4346
|
}
|
|
4196
4347
|
return {
|
|
4197
|
-
notificationType:
|
|
4198
|
-
resourceType:
|
|
4348
|
+
notificationType: import_cluemart_shared33.EnumNotificationType.SYSTEM,
|
|
4349
|
+
resourceType: import_cluemart_shared33.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
|
|
4199
4350
|
};
|
|
4200
4351
|
}
|
|
4201
4352
|
async function getLicenseResourceInfo(user, licence) {
|
|
4202
|
-
const isVendorLicense =
|
|
4353
|
+
const isVendorLicense = import_cluemart_shared33.vendorLicences.includes(licence.licenceType);
|
|
4203
4354
|
const isPartnerLicense = partnerLicences.includes(licence.licenceType);
|
|
4204
4355
|
const licenceName = getLicenseName(licence.licenceType);
|
|
4205
4356
|
const { notificationType, resourceType } = getNotificationTypes(
|
|
@@ -4247,11 +4398,11 @@ async function getLicenseResourceInfo(user, licence) {
|
|
|
4247
4398
|
};
|
|
4248
4399
|
}
|
|
4249
4400
|
function getLicenceExpiryMode(licenceType) {
|
|
4250
|
-
return licenceType ===
|
|
4401
|
+
return licenceType === import_cluemart_shared33.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared33.EnumUserLicence.PRO_PLUS_VENDOR ? "downgrade" : "extend";
|
|
4251
4402
|
}
|
|
4252
4403
|
async function sendLicenseReminder(user, licence) {
|
|
4253
4404
|
const licenceName = getLicenseName(licence.licenceType);
|
|
4254
|
-
const expiryDate = (0, import_dayjs7.default)(licence.expiryDate).format(
|
|
4405
|
+
const expiryDate = (0, import_dayjs7.default)(licence.expiryDate).format(import_cluemart_shared33.dateFormat);
|
|
4255
4406
|
const userId = String(user._id);
|
|
4256
4407
|
const resourceInfo = await getLicenseResourceInfo(user, licence);
|
|
4257
4408
|
if (!resourceInfo) {
|
|
@@ -4388,6 +4539,7 @@ async function remindUsersAboutLicenseExpiration() {
|
|
|
4388
4539
|
connectToDatabase,
|
|
4389
4540
|
convertObjectIdsToStrings,
|
|
4390
4541
|
createLicenceObject,
|
|
4542
|
+
dedupeArchivedSlotsByStartDateTime,
|
|
4391
4543
|
didRemoveAnyEventDates,
|
|
4392
4544
|
downgradeVendorProFeatures,
|
|
4393
4545
|
ensureUserLicenseCompliance,
|
|
@@ -4418,6 +4570,7 @@ async function remindUsersAboutLicenseExpiration() {
|
|
|
4418
4570
|
normalizePromoCode,
|
|
4419
4571
|
notifyUsers,
|
|
4420
4572
|
partnerLicences,
|
|
4573
|
+
persistArchivedEventDates,
|
|
4421
4574
|
processLicenseReminder,
|
|
4422
4575
|
processUserCompliance,
|
|
4423
4576
|
processUserLicenseReminders,
|
|
@@ -4430,6 +4583,7 @@ async function remindUsersAboutLicenseExpiration() {
|
|
|
4430
4583
|
sendLicenseReminder,
|
|
4431
4584
|
sendPushNotifications,
|
|
4432
4585
|
sendReminderSafely,
|
|
4586
|
+
splitEventDatesForArchive,
|
|
4433
4587
|
syncUserLicencesAfterExpiry,
|
|
4434
4588
|
updateAdStatuses,
|
|
4435
4589
|
updateAllEventDateTimeStatuses,
|