@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/{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 +564 -417
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +41 -33
- package/dist/index.d.ts +41 -33
- package/dist/index.mjs +486 -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 +560 -413
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +31 -3
- package/dist/service/index.d.ts +31 -3
- package/dist/service/index.mjs +175 -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,75 @@ 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);
|
|
3119
3148
|
function getFutureEventStatus(startDateTime, now) {
|
|
3120
3149
|
const hoursUntilStart = startDateTime.diff(now, "hour", true);
|
|
3121
3150
|
if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
|
|
3122
|
-
return
|
|
3151
|
+
return import_cluemart_shared26.EnumEventDateStatus.STARTING_SOON;
|
|
3123
3152
|
}
|
|
3124
3153
|
if (startDateTime.isSame(now, "day")) {
|
|
3125
|
-
return
|
|
3154
|
+
return import_cluemart_shared26.EnumEventDateStatus.TODAY;
|
|
3126
3155
|
}
|
|
3127
3156
|
if (startDateTime.isSame(now.add(1, "day"), "day")) {
|
|
3128
|
-
return
|
|
3157
|
+
return import_cluemart_shared26.EnumEventDateStatus.TOMORROW;
|
|
3129
3158
|
}
|
|
3130
3159
|
if (startDateTime.isSame(now, "isoWeek")) {
|
|
3131
|
-
return
|
|
3160
|
+
return import_cluemart_shared26.EnumEventDateStatus.THIS_WEEK;
|
|
3132
3161
|
}
|
|
3133
3162
|
if (startDateTime.isSame(now.add(1, "week"), "isoWeek")) {
|
|
3134
|
-
return
|
|
3163
|
+
return import_cluemart_shared26.EnumEventDateStatus.NEXT_WEEK;
|
|
3135
3164
|
}
|
|
3136
|
-
return
|
|
3165
|
+
return import_cluemart_shared26.EnumEventDateStatus.UPCOMING;
|
|
3137
3166
|
}
|
|
3138
3167
|
function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()) {
|
|
3139
|
-
const dateTimeFormat = `${
|
|
3168
|
+
const dateTimeFormat = `${import_cluemart_shared26.dateFormat} ${import_cluemart_shared26.timeFormat}`;
|
|
3140
3169
|
const startDateTime = (0, import_dayjs2.default)(
|
|
3141
3170
|
`${dateTime.startDate} ${dateTime.startTime}`,
|
|
3142
3171
|
dateTimeFormat,
|
|
@@ -3150,13 +3179,13 @@ function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()
|
|
|
3150
3179
|
if (!startDateTime.isValid() || !endDateTime.isValid()) {
|
|
3151
3180
|
return {
|
|
3152
3181
|
...dateTime,
|
|
3153
|
-
dateStatus:
|
|
3182
|
+
dateStatus: import_cluemart_shared26.EnumEventDateStatus.INVALID
|
|
3154
3183
|
};
|
|
3155
3184
|
}
|
|
3156
3185
|
if (endDateTime.isBefore(startDateTime)) {
|
|
3157
3186
|
return {
|
|
3158
3187
|
...dateTime,
|
|
3159
|
-
dateStatus:
|
|
3188
|
+
dateStatus: import_cluemart_shared26.EnumEventDateStatus.INVALID
|
|
3160
3189
|
};
|
|
3161
3190
|
}
|
|
3162
3191
|
let dateStatus;
|
|
@@ -3164,10 +3193,10 @@ function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()
|
|
|
3164
3193
|
if (startDateTime.isAfter(now)) {
|
|
3165
3194
|
dateStatus = getFutureEventStatus(startDateTime, now);
|
|
3166
3195
|
} else {
|
|
3167
|
-
dateStatus =
|
|
3196
|
+
dateStatus = import_cluemart_shared26.EnumEventDateStatus.STARTED;
|
|
3168
3197
|
}
|
|
3169
3198
|
} else {
|
|
3170
|
-
dateStatus =
|
|
3199
|
+
dateStatus = import_cluemart_shared26.EnumEventDateStatus.ENDED;
|
|
3171
3200
|
}
|
|
3172
3201
|
return {
|
|
3173
3202
|
...dateTime,
|
|
@@ -3223,6 +3252,111 @@ async function updateModelDateTimeStatuses(model, now) {
|
|
|
3223
3252
|
}
|
|
3224
3253
|
return updated;
|
|
3225
3254
|
}
|
|
3255
|
+
var ARCHIVABLE_EVENT_FILTER = {
|
|
3256
|
+
"dateTime.dateStatus": {
|
|
3257
|
+
$in: [import_cluemart_shared26.EnumEventDateStatus.ENDED, import_cluemart_shared26.EnumEventDateStatus.INVALID]
|
|
3258
|
+
},
|
|
3259
|
+
deletedAt: null
|
|
3260
|
+
};
|
|
3261
|
+
async function archiveEndedAndDiscardInvalidEventDates(now) {
|
|
3262
|
+
const cursor = EventModel.find(ARCHIVABLE_EVENT_FILTER).select({ _id: 1, dateTime: 1 }).lean().cursor({ batchSize: CURSOR_BATCH_SIZE });
|
|
3263
|
+
let archivedCount = 0;
|
|
3264
|
+
let archiveOps = [];
|
|
3265
|
+
let eventOps = [];
|
|
3266
|
+
const flushBulkWrites = async () => {
|
|
3267
|
+
if (archiveOps.length) {
|
|
3268
|
+
await EventDateArchiveModel.bulkWrite(archiveOps);
|
|
3269
|
+
archiveOps = [];
|
|
3270
|
+
}
|
|
3271
|
+
if (eventOps.length) {
|
|
3272
|
+
await EventModel.bulkWrite(eventOps);
|
|
3273
|
+
eventOps = [];
|
|
3274
|
+
}
|
|
3275
|
+
};
|
|
3276
|
+
try {
|
|
3277
|
+
for await (const doc of cursor) {
|
|
3278
|
+
const updated = doc.dateTime.map(
|
|
3279
|
+
(slot) => updateSingleDateTimeStatus(slot, now)
|
|
3280
|
+
);
|
|
3281
|
+
const { archive, discard } = splitEventDatesForArchive(updated);
|
|
3282
|
+
if (archive.length === 0 && discard.length === 0) {
|
|
3283
|
+
continue;
|
|
3284
|
+
}
|
|
3285
|
+
if (archive.length > 0) {
|
|
3286
|
+
const uniqueArchive = dedupeArchivedSlotsByStartDateTime(archive);
|
|
3287
|
+
archiveOps.push({
|
|
3288
|
+
updateOne: {
|
|
3289
|
+
filter: { eventId: doc._id },
|
|
3290
|
+
update: { $addToSet: { dateTime: { $each: uniqueArchive } } },
|
|
3291
|
+
upsert: true
|
|
3292
|
+
}
|
|
3293
|
+
});
|
|
3294
|
+
archivedCount += uniqueArchive.length;
|
|
3295
|
+
}
|
|
3296
|
+
eventOps.push({
|
|
3297
|
+
updateOne: {
|
|
3298
|
+
filter: { _id: doc._id },
|
|
3299
|
+
update: {
|
|
3300
|
+
$pull: {
|
|
3301
|
+
dateTime: {
|
|
3302
|
+
dateStatus: {
|
|
3303
|
+
$in: [import_cluemart_shared26.EnumEventDateStatus.ENDED, import_cluemart_shared26.EnumEventDateStatus.INVALID]
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
});
|
|
3310
|
+
if (archiveOps.length >= CURSOR_BATCH_SIZE || eventOps.length >= CURSOR_BATCH_SIZE) {
|
|
3311
|
+
await flushBulkWrites();
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
await flushBulkWrites();
|
|
3315
|
+
} finally {
|
|
3316
|
+
await cursor.close().catch(() => void 0);
|
|
3317
|
+
}
|
|
3318
|
+
return archivedCount;
|
|
3319
|
+
}
|
|
3320
|
+
var EVENT_INFO_DATE_FILTER = {
|
|
3321
|
+
dateTime: { $ne: [], $type: "array" }
|
|
3322
|
+
};
|
|
3323
|
+
async function cleanEventInfoDates(now) {
|
|
3324
|
+
const cursor = EventInfoModel.find(EVENT_INFO_DATE_FILTER).select({ _id: 1, dateTime: 1 }).lean().cursor({ batchSize: CURSOR_BATCH_SIZE });
|
|
3325
|
+
let removedCount = 0;
|
|
3326
|
+
let bulkOps = [];
|
|
3327
|
+
const flushBulkWrites = async () => {
|
|
3328
|
+
if (!bulkOps.length) {
|
|
3329
|
+
return;
|
|
3330
|
+
}
|
|
3331
|
+
await EventInfoModel.bulkWrite(bulkOps);
|
|
3332
|
+
bulkOps = [];
|
|
3333
|
+
};
|
|
3334
|
+
try {
|
|
3335
|
+
for await (const doc of cursor) {
|
|
3336
|
+
const updated = doc.dateTime.map(
|
|
3337
|
+
(slot) => updateSingleDateTimeStatus(slot, now)
|
|
3338
|
+
);
|
|
3339
|
+
const kept = (0, import_cluemart_shared26.filterDatesByFutureStatus)(updated);
|
|
3340
|
+
if (kept.length === updated.length) {
|
|
3341
|
+
continue;
|
|
3342
|
+
}
|
|
3343
|
+
bulkOps.push({
|
|
3344
|
+
updateOne: {
|
|
3345
|
+
filter: { _id: doc._id },
|
|
3346
|
+
update: { $set: { dateTime: kept } }
|
|
3347
|
+
}
|
|
3348
|
+
});
|
|
3349
|
+
removedCount += updated.length - kept.length;
|
|
3350
|
+
if (bulkOps.length >= CURSOR_BATCH_SIZE) {
|
|
3351
|
+
await flushBulkWrites();
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3354
|
+
await flushBulkWrites();
|
|
3355
|
+
} finally {
|
|
3356
|
+
await cursor.close().catch(() => void 0);
|
|
3357
|
+
}
|
|
3358
|
+
return removedCount;
|
|
3359
|
+
}
|
|
3226
3360
|
async function updateAllEventDateTimeStatuses() {
|
|
3227
3361
|
const now = (0, import_dayjs2.default)();
|
|
3228
3362
|
const [eventCount, marketCount] = await Promise.all([
|
|
@@ -3235,6 +3369,16 @@ async function updateAllEventDateTimeStatuses() {
|
|
|
3235
3369
|
console.log(
|
|
3236
3370
|
`\u2705 Event dateTime statuses updated: events=${eventCount} changed, google imported markets=${marketCount} changed`
|
|
3237
3371
|
);
|
|
3372
|
+
const archivedCount = await archiveEndedAndDiscardInvalidEventDates(now);
|
|
3373
|
+
if (archivedCount > 0) {
|
|
3374
|
+
console.log(`\u2705 Archived ${archivedCount} ended event date slot(s)`);
|
|
3375
|
+
}
|
|
3376
|
+
const removedEventInfoCount = await cleanEventInfoDates(now);
|
|
3377
|
+
if (removedEventInfoCount > 0) {
|
|
3378
|
+
console.log(
|
|
3379
|
+
`\u2705 Removed ${removedEventInfoCount} non-future event info date slot(s)`
|
|
3380
|
+
);
|
|
3381
|
+
}
|
|
3238
3382
|
}
|
|
3239
3383
|
|
|
3240
3384
|
// src/service/event/findEventOrImportedMarketById.ts
|
|
@@ -3251,7 +3395,7 @@ async function findEventOrImportedMarketById(resourceId) {
|
|
|
3251
3395
|
}
|
|
3252
3396
|
|
|
3253
3397
|
// src/service/relations.ts
|
|
3254
|
-
var
|
|
3398
|
+
var import_cluemart_shared27 = require("@timardex/cluemart-shared");
|
|
3255
3399
|
function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
|
|
3256
3400
|
if (!previousDateTime?.length) {
|
|
3257
3401
|
return false;
|
|
@@ -3269,7 +3413,7 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
3269
3413
|
) ?? false;
|
|
3270
3414
|
return {
|
|
3271
3415
|
...relationDate,
|
|
3272
|
-
status: existsInEvent ? relationDate.status :
|
|
3416
|
+
status: existsInEvent ? relationDate.status : import_cluemart_shared27.EnumInviteStatus.UNAVAILABLE
|
|
3273
3417
|
};
|
|
3274
3418
|
});
|
|
3275
3419
|
}
|
|
@@ -3278,15 +3422,15 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
3278
3422
|
var import_dayjs6 = __toESM(require("dayjs"));
|
|
3279
3423
|
|
|
3280
3424
|
// src/service/license/compliance/utils.ts
|
|
3281
|
-
var
|
|
3425
|
+
var import_cluemart_shared32 = require("@timardex/cluemart-shared");
|
|
3282
3426
|
var import_dayjs5 = __toESM(require("dayjs"));
|
|
3283
3427
|
|
|
3284
3428
|
// src/service/license/compliance/event.ts
|
|
3285
|
-
var
|
|
3429
|
+
var import_cluemart_shared28 = require("@timardex/cluemart-shared");
|
|
3286
3430
|
var eventLicences = [
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3431
|
+
import_cluemart_shared28.EnumUserLicence.STANDARD_EVENT,
|
|
3432
|
+
import_cluemart_shared28.EnumUserLicence.PRO_EVENT,
|
|
3433
|
+
import_cluemart_shared28.EnumUserLicence.PRO_PLUS_EVENT
|
|
3290
3434
|
];
|
|
3291
3435
|
async function handleEventLicenceCompliance(user, now) {
|
|
3292
3436
|
if (!user.licences || !user.events?.length) {
|
|
@@ -3498,9 +3642,9 @@ function buildLicenceExpiryPipeline(params) {
|
|
|
3498
3642
|
}
|
|
3499
3643
|
|
|
3500
3644
|
// src/service/license/compliance/partner.ts
|
|
3501
|
-
var
|
|
3645
|
+
var import_cluemart_shared29 = require("@timardex/cluemart-shared");
|
|
3502
3646
|
var partnerLicences = [
|
|
3503
|
-
|
|
3647
|
+
import_cluemart_shared29.EnumUserLicence.STANDARD_PARTNER
|
|
3504
3648
|
];
|
|
3505
3649
|
async function handlePartnerLicenceCompliance(user, now) {
|
|
3506
3650
|
if (!user.licences || !user.partner) {
|
|
@@ -3510,11 +3654,11 @@ async function handlePartnerLicenceCompliance(user, now) {
|
|
|
3510
3654
|
}
|
|
3511
3655
|
|
|
3512
3656
|
// src/service/license/compliance/vendor.ts
|
|
3513
|
-
var
|
|
3657
|
+
var import_cluemart_shared31 = require("@timardex/cluemart-shared");
|
|
3514
3658
|
var import_dayjs4 = __toESM(require("dayjs"));
|
|
3515
3659
|
|
|
3516
3660
|
// src/service/license/models.ts
|
|
3517
|
-
var
|
|
3661
|
+
var import_cluemart_shared30 = require("@timardex/cluemart-shared");
|
|
3518
3662
|
var import_dayjs3 = __toESM(require("dayjs"));
|
|
3519
3663
|
var import_graphql = require("graphql");
|
|
3520
3664
|
var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
|
|
@@ -3526,31 +3670,31 @@ var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
|
|
|
3526
3670
|
return LicenceCategory2;
|
|
3527
3671
|
})(LicenceCategory || {});
|
|
3528
3672
|
var licenceCategoryMapping = {
|
|
3529
|
-
[
|
|
3530
|
-
[
|
|
3531
|
-
[
|
|
3532
|
-
[
|
|
3533
|
-
[
|
|
3534
|
-
[
|
|
3535
|
-
[
|
|
3536
|
-
[
|
|
3537
|
-
[
|
|
3673
|
+
[import_cluemart_shared30.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
|
|
3674
|
+
[import_cluemart_shared30.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
|
|
3675
|
+
[import_cluemart_shared30.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
|
|
3676
|
+
[import_cluemart_shared30.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
|
|
3677
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
|
|
3678
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
|
|
3679
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
|
|
3680
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
|
|
3681
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_SCHOOL]: "school" /* SCHOOL */
|
|
3538
3682
|
};
|
|
3539
3683
|
var licencePriority = {
|
|
3540
|
-
[
|
|
3541
|
-
[
|
|
3542
|
-
[
|
|
3543
|
-
[
|
|
3544
|
-
[
|
|
3545
|
-
[
|
|
3546
|
-
[
|
|
3547
|
-
[
|
|
3548
|
-
[
|
|
3684
|
+
[import_cluemart_shared30.EnumUserLicence.PRO_PLUS_EVENT]: 3,
|
|
3685
|
+
[import_cluemart_shared30.EnumUserLicence.PRO_EVENT]: 2,
|
|
3686
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_EVENT]: 1,
|
|
3687
|
+
[import_cluemart_shared30.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
|
|
3688
|
+
[import_cluemart_shared30.EnumUserLicence.PRO_VENDOR]: 2,
|
|
3689
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR]: 1,
|
|
3690
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_PARTNER]: 1,
|
|
3691
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_AFFILIATE]: 1,
|
|
3692
|
+
[import_cluemart_shared30.EnumUserLicence.STANDARD_SCHOOL]: 1
|
|
3549
3693
|
};
|
|
3550
3694
|
var standardLicences = [
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3695
|
+
import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR,
|
|
3696
|
+
import_cluemart_shared30.EnumUserLicence.STANDARD_EVENT,
|
|
3697
|
+
import_cluemart_shared30.EnumUserLicence.STANDARD_PARTNER
|
|
3554
3698
|
];
|
|
3555
3699
|
var standardLicenceSet = new Set(standardLicences);
|
|
3556
3700
|
function isStandardLicence(licence) {
|
|
@@ -3564,11 +3708,11 @@ var categoryRegexMapping = {
|
|
|
3564
3708
|
["school" /* SCHOOL */]: /_school$/
|
|
3565
3709
|
};
|
|
3566
3710
|
var categoryFallbackLicence = {
|
|
3567
|
-
["event" /* EVENT */]:
|
|
3568
|
-
["partner" /* PARTNER */]:
|
|
3569
|
-
["vendor" /* VENDOR */]:
|
|
3570
|
-
["affiliate" /* AFFILIATE */]:
|
|
3571
|
-
["school" /* SCHOOL */]:
|
|
3711
|
+
["event" /* EVENT */]: import_cluemart_shared30.EnumUserLicence.STANDARD_EVENT,
|
|
3712
|
+
["partner" /* PARTNER */]: import_cluemart_shared30.EnumUserLicence.STANDARD_PARTNER,
|
|
3713
|
+
["vendor" /* VENDOR */]: import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR,
|
|
3714
|
+
["affiliate" /* AFFILIATE */]: import_cluemart_shared30.EnumUserLicence.STANDARD_AFFILIATE,
|
|
3715
|
+
["school" /* SCHOOL */]: import_cluemart_shared30.EnumUserLicence.STANDARD_SCHOOL
|
|
3572
3716
|
};
|
|
3573
3717
|
var LicenceFilterInput = {
|
|
3574
3718
|
INPUT_USER_LICENCES: "$licences"
|
|
@@ -3598,11 +3742,11 @@ function getHighestLicenceForCategory(licences, category) {
|
|
|
3598
3742
|
function createLicenceObject(expiryDate, licenceType) {
|
|
3599
3743
|
const today = (0, import_dayjs3.default)();
|
|
3600
3744
|
const expiryDateMapping = {
|
|
3601
|
-
[
|
|
3602
|
-
[
|
|
3603
|
-
[
|
|
3604
|
-
[
|
|
3605
|
-
[
|
|
3745
|
+
[import_cluemart_shared30.LicenceExpiryDate.ONE_YEAR]: today.add(1, "year").endOf("day").toDate(),
|
|
3746
|
+
[import_cluemart_shared30.LicenceExpiryDate.ONE_MONTH]: today.add(1, "month").endOf("day").toDate(),
|
|
3747
|
+
[import_cluemart_shared30.LicenceExpiryDate.TWO_MONTHS]: today.add(2, "month").endOf("day").toDate(),
|
|
3748
|
+
[import_cluemart_shared30.LicenceExpiryDate.THREE_MONTHS]: today.add(3, "month").endOf("day").toDate(),
|
|
3749
|
+
[import_cluemart_shared30.LicenceExpiryDate.SIX_MONTHS]: today.add(6, "month").endOf("day").toDate()
|
|
3606
3750
|
};
|
|
3607
3751
|
const licenceObject = {
|
|
3608
3752
|
expiryDate: expiryDateMapping[expiryDate],
|
|
@@ -3706,13 +3850,13 @@ async function checkOwnerHasLicence({
|
|
|
3706
3850
|
const owner = await UserModel.findById(userId);
|
|
3707
3851
|
if (!owner) throw new import_graphql.GraphQLError("Owner not found");
|
|
3708
3852
|
const categoryByResource = {
|
|
3709
|
-
[
|
|
3710
|
-
[
|
|
3711
|
-
[
|
|
3712
|
-
[
|
|
3713
|
-
[
|
|
3853
|
+
[import_cluemart_shared30.EnumResourceType.EVENT]: "event" /* EVENT */,
|
|
3854
|
+
[import_cluemart_shared30.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
|
|
3855
|
+
[import_cluemart_shared30.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
|
|
3856
|
+
[import_cluemart_shared30.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
|
|
3857
|
+
[import_cluemart_shared30.EnumResourceType.SCHOOL]: "school" /* SCHOOL */
|
|
3714
3858
|
};
|
|
3715
|
-
if (!(0,
|
|
3859
|
+
if (!(0, import_cluemart_shared30.isNonVisitorResourceType)(resourceType)) {
|
|
3716
3860
|
throw new import_graphql.GraphQLError(`Invalid resource type: ${resourceType}.`);
|
|
3717
3861
|
}
|
|
3718
3862
|
const requiredCategory = categoryByResource[resourceType];
|
|
@@ -3792,7 +3936,7 @@ async function applyVendorDowngrade(vendor, ownerUserId) {
|
|
|
3792
3936
|
return (result?.matchedCount ?? 0) > 0;
|
|
3793
3937
|
}
|
|
3794
3938
|
async function downgradeVendorProFeatures(userId, licenceType) {
|
|
3795
|
-
const isStandardVendor = licenceType ===
|
|
3939
|
+
const isStandardVendor = licenceType === import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR;
|
|
3796
3940
|
if (!isStandardVendor) {
|
|
3797
3941
|
return;
|
|
3798
3942
|
}
|
|
@@ -3839,7 +3983,7 @@ async function applyVendorRestore(vendor, ownerUserId) {
|
|
|
3839
3983
|
return (result?.matchedCount ?? 0) > 0;
|
|
3840
3984
|
}
|
|
3841
3985
|
async function restoreVendorProFeatures(userId, licenceType) {
|
|
3842
|
-
const isProVendor = licenceType ===
|
|
3986
|
+
const isProVendor = licenceType === import_cluemart_shared31.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared31.EnumUserLicence.PRO_PLUS_VENDOR;
|
|
3843
3987
|
if (!isProVendor) {
|
|
3844
3988
|
return;
|
|
3845
3989
|
}
|
|
@@ -3860,14 +4004,14 @@ function isProtectedByCurrentStripeSubscription(user, licenceType, now) {
|
|
|
3860
4004
|
return false;
|
|
3861
4005
|
}
|
|
3862
4006
|
const gracePeriodEndsAt = stripe.paymentGracePeriodEndsAt ? (0, import_dayjs4.default)(stripe.paymentGracePeriodEndsAt) : null;
|
|
3863
|
-
const hasActivePaymentGracePeriod = (stripe.status ===
|
|
4007
|
+
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
4008
|
if (hasActivePaymentGracePeriod) {
|
|
3865
4009
|
return true;
|
|
3866
4010
|
}
|
|
3867
4011
|
if (!stripe.subscriptionId) {
|
|
3868
4012
|
return false;
|
|
3869
4013
|
}
|
|
3870
|
-
if (stripe.status !==
|
|
4014
|
+
if (stripe.status !== import_cluemart_shared31.EnumSubscriptionStatus.ACTIVE) {
|
|
3871
4015
|
return false;
|
|
3872
4016
|
}
|
|
3873
4017
|
if (!stripe.endDate) {
|
|
@@ -3887,7 +4031,7 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
3887
4031
|
return;
|
|
3888
4032
|
}
|
|
3889
4033
|
const proLicences = vendorLicencesOfUser.filter(
|
|
3890
|
-
(licence) => licence.licenceType !==
|
|
4034
|
+
(licence) => licence.licenceType !== import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR
|
|
3891
4035
|
);
|
|
3892
4036
|
const expiredProLicences = proLicences.filter(
|
|
3893
4037
|
(licence) => !(0, import_dayjs4.default)(licence.expiryDate).isAfter(now)
|
|
@@ -3900,7 +4044,7 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
3900
4044
|
const expiredProLicence = expiredProLicences.some(
|
|
3901
4045
|
(licence) => !stripeProtectedLicenceTypes.has(licence.licenceType)
|
|
3902
4046
|
);
|
|
3903
|
-
const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences,
|
|
4047
|
+
const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences, import_cluemart_shared31.vendorLicences, now);
|
|
3904
4048
|
const hasExpiredVendorLicence = vendorLicencesOfUser.some(
|
|
3905
4049
|
(licence) => !(0, import_dayjs4.default)(licence.expiryDate).isAfter(now) && !stripeProtectedLicenceTypes.has(licence.licenceType)
|
|
3906
4050
|
);
|
|
@@ -3916,7 +4060,7 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
3916
4060
|
"owner.userId": user._id
|
|
3917
4061
|
}).lean().exec();
|
|
3918
4062
|
}
|
|
3919
|
-
const licencesToSync =
|
|
4063
|
+
const licencesToSync = import_cluemart_shared31.vendorLicences.filter(
|
|
3920
4064
|
(licenceType) => !stripeProtectedLicenceTypes.has(licenceType)
|
|
3921
4065
|
);
|
|
3922
4066
|
await syncUserLicencesAfterExpiry(user._id, licencesToSync, now, "downgrade");
|
|
@@ -3931,11 +4075,11 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
3931
4075
|
data: {
|
|
3932
4076
|
resourceId: String(vendor._id),
|
|
3933
4077
|
resourceName: vendor.name,
|
|
3934
|
-
resourceType:
|
|
4078
|
+
resourceType: import_cluemart_shared31.EnumNotificationResourceType.DOWNGRADED_VENDOR
|
|
3935
4079
|
},
|
|
3936
4080
|
message: `Your Vendor licence has been downgraded due to licence expiration.`,
|
|
3937
4081
|
title: `Vendor Licence Downgraded`,
|
|
3938
|
-
type:
|
|
4082
|
+
type: import_cluemart_shared31.EnumNotificationType.SYSTEM,
|
|
3939
4083
|
userIds: [user._id]
|
|
3940
4084
|
};
|
|
3941
4085
|
await sendDeactivationNotification(payload, user._id, vendor.name, "vendor");
|
|
@@ -3968,7 +4112,7 @@ async function vendorOwnerHasProLicence(vendorId) {
|
|
|
3968
4112
|
effectiveVendorLicences,
|
|
3969
4113
|
"vendor" /* VENDOR */
|
|
3970
4114
|
);
|
|
3971
|
-
return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[
|
|
4115
|
+
return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[import_cluemart_shared31.EnumUserLicence.PRO_VENDOR];
|
|
3972
4116
|
}
|
|
3973
4117
|
|
|
3974
4118
|
// src/service/license/compliance/utils.ts
|
|
@@ -3978,12 +4122,12 @@ async function syncUserLicencesAfterExpiry(userId, licenceTypes, now, mode = "do
|
|
|
3978
4122
|
const pipeline = buildLicenceExpiryPipeline({
|
|
3979
4123
|
downgradeBranches: [
|
|
3980
4124
|
{
|
|
3981
|
-
case:
|
|
3982
|
-
then:
|
|
4125
|
+
case: import_cluemart_shared32.EnumUserLicence.PRO_PLUS_VENDOR,
|
|
4126
|
+
then: import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR
|
|
3983
4127
|
},
|
|
3984
4128
|
{
|
|
3985
|
-
case:
|
|
3986
|
-
then:
|
|
4129
|
+
case: import_cluemart_shared32.EnumUserLicence.PRO_VENDOR,
|
|
4130
|
+
then: import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR
|
|
3987
4131
|
}
|
|
3988
4132
|
],
|
|
3989
4133
|
licenceTypes,
|
|
@@ -4112,7 +4256,7 @@ var REMINDER_WINDOW_MIN_HOURS = 6.5 * 24;
|
|
|
4112
4256
|
var REMINDER_WINDOW_MAX_HOURS = 7.5 * 24;
|
|
4113
4257
|
|
|
4114
4258
|
// src/service/license/reminder/utils.ts
|
|
4115
|
-
var
|
|
4259
|
+
var import_cluemart_shared33 = require("@timardex/cluemart-shared");
|
|
4116
4260
|
var import_utils8 = require("@timardex/cluemart-shared/utils");
|
|
4117
4261
|
var import_dayjs7 = __toESM(require("dayjs"));
|
|
4118
4262
|
|
|
@@ -4178,28 +4322,28 @@ function isLicenseExpiringIn7Days(expiryDate, now) {
|
|
|
4178
4322
|
return hoursUntilExpiry >= REMINDER_WINDOW_MIN_HOURS && hoursUntilExpiry <= REMINDER_WINDOW_MAX_HOURS;
|
|
4179
4323
|
}
|
|
4180
4324
|
function getLicenseName(licenceType) {
|
|
4181
|
-
return
|
|
4325
|
+
return import_cluemart_shared33.licenseNiceNames[licenceType] || licenceType;
|
|
4182
4326
|
}
|
|
4183
4327
|
function getNotificationTypes(isVendorLicense, isPartnerLicense) {
|
|
4184
4328
|
if (isVendorLicense) {
|
|
4185
4329
|
return {
|
|
4186
|
-
notificationType:
|
|
4187
|
-
resourceType:
|
|
4330
|
+
notificationType: import_cluemart_shared33.EnumNotificationType.SYSTEM,
|
|
4331
|
+
resourceType: import_cluemart_shared33.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
|
|
4188
4332
|
};
|
|
4189
4333
|
}
|
|
4190
4334
|
if (isPartnerLicense) {
|
|
4191
4335
|
return {
|
|
4192
|
-
notificationType:
|
|
4193
|
-
resourceType:
|
|
4336
|
+
notificationType: import_cluemart_shared33.EnumNotificationType.SYSTEM,
|
|
4337
|
+
resourceType: import_cluemart_shared33.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
|
|
4194
4338
|
};
|
|
4195
4339
|
}
|
|
4196
4340
|
return {
|
|
4197
|
-
notificationType:
|
|
4198
|
-
resourceType:
|
|
4341
|
+
notificationType: import_cluemart_shared33.EnumNotificationType.SYSTEM,
|
|
4342
|
+
resourceType: import_cluemart_shared33.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
|
|
4199
4343
|
};
|
|
4200
4344
|
}
|
|
4201
4345
|
async function getLicenseResourceInfo(user, licence) {
|
|
4202
|
-
const isVendorLicense =
|
|
4346
|
+
const isVendorLicense = import_cluemart_shared33.vendorLicences.includes(licence.licenceType);
|
|
4203
4347
|
const isPartnerLicense = partnerLicences.includes(licence.licenceType);
|
|
4204
4348
|
const licenceName = getLicenseName(licence.licenceType);
|
|
4205
4349
|
const { notificationType, resourceType } = getNotificationTypes(
|
|
@@ -4247,11 +4391,11 @@ async function getLicenseResourceInfo(user, licence) {
|
|
|
4247
4391
|
};
|
|
4248
4392
|
}
|
|
4249
4393
|
function getLicenceExpiryMode(licenceType) {
|
|
4250
|
-
return licenceType ===
|
|
4394
|
+
return licenceType === import_cluemart_shared33.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared33.EnumUserLicence.PRO_PLUS_VENDOR ? "downgrade" : "extend";
|
|
4251
4395
|
}
|
|
4252
4396
|
async function sendLicenseReminder(user, licence) {
|
|
4253
4397
|
const licenceName = getLicenseName(licence.licenceType);
|
|
4254
|
-
const expiryDate = (0, import_dayjs7.default)(licence.expiryDate).format(
|
|
4398
|
+
const expiryDate = (0, import_dayjs7.default)(licence.expiryDate).format(import_cluemart_shared33.dateFormat);
|
|
4255
4399
|
const userId = String(user._id);
|
|
4256
4400
|
const resourceInfo = await getLicenseResourceInfo(user, licence);
|
|
4257
4401
|
if (!resourceInfo) {
|
|
@@ -4388,6 +4532,7 @@ async function remindUsersAboutLicenseExpiration() {
|
|
|
4388
4532
|
connectToDatabase,
|
|
4389
4533
|
convertObjectIdsToStrings,
|
|
4390
4534
|
createLicenceObject,
|
|
4535
|
+
dedupeArchivedSlotsByStartDateTime,
|
|
4391
4536
|
didRemoveAnyEventDates,
|
|
4392
4537
|
downgradeVendorProFeatures,
|
|
4393
4538
|
ensureUserLicenseCompliance,
|
|
@@ -4418,6 +4563,7 @@ async function remindUsersAboutLicenseExpiration() {
|
|
|
4418
4563
|
normalizePromoCode,
|
|
4419
4564
|
notifyUsers,
|
|
4420
4565
|
partnerLicences,
|
|
4566
|
+
persistArchivedEventDates,
|
|
4421
4567
|
processLicenseReminder,
|
|
4422
4568
|
processUserCompliance,
|
|
4423
4569
|
processUserLicenseReminders,
|
|
@@ -4430,6 +4576,7 @@ async function remindUsersAboutLicenseExpiration() {
|
|
|
4430
4576
|
sendLicenseReminder,
|
|
4431
4577
|
sendPushNotifications,
|
|
4432
4578
|
sendReminderSafely,
|
|
4579
|
+
splitEventDatesForArchive,
|
|
4433
4580
|
syncUserLicencesAfterExpiry,
|
|
4434
4581
|
updateAdStatuses,
|
|
4435
4582
|
updateAllEventDateTimeStatuses,
|